@react-scad/core 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/primitives/circle.d.ts +14 -0
- package/dist/primitives/circle.d.ts.map +1 -0
- package/dist/primitives/circle.js +12 -0
- package/dist/primitives/cube.d.ts +13 -0
- package/dist/primitives/cube.d.ts.map +1 -0
- package/dist/primitives/cube.js +13 -0
- package/dist/primitives/cylinder.d.ts +16 -0
- package/dist/primitives/cylinder.d.ts.map +1 -0
- package/dist/primitives/cylinder.js +10 -0
- package/dist/primitives/difference.d.ts +11 -0
- package/dist/primitives/difference.d.ts.map +1 -0
- package/dist/primitives/difference.js +9 -0
- package/dist/primitives/group.d.ts +11 -0
- package/dist/primitives/group.d.ts.map +1 -0
- package/dist/primitives/group.js +9 -0
- package/dist/primitives/import.d.ts +14 -0
- package/dist/primitives/import.d.ts.map +1 -0
- package/dist/primitives/import.js +15 -0
- package/dist/primitives/index.d.ts +41 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +20 -0
- package/dist/primitives/intersection.d.ts +11 -0
- package/dist/primitives/intersection.d.ts.map +1 -0
- package/dist/primitives/intersection.js +9 -0
- package/dist/primitives/linear-extrude.d.ts +18 -0
- package/dist/primitives/linear-extrude.d.ts.map +1 -0
- package/dist/primitives/linear-extrude.js +31 -0
- package/dist/primitives/polygon.d.ts +14 -0
- package/dist/primitives/polygon.d.ts.map +1 -0
- package/dist/primitives/polygon.js +14 -0
- package/dist/primitives/polyhedron.d.ts +14 -0
- package/dist/primitives/polyhedron.d.ts.map +1 -0
- package/dist/primitives/polyhedron.js +11 -0
- package/dist/primitives/primitive.d.ts +7 -0
- package/dist/primitives/primitive.d.ts.map +1 -0
- package/dist/primitives/primitive.js +5 -0
- package/dist/primitives/raw.d.ts +12 -0
- package/dist/primitives/raw.d.ts.map +1 -0
- package/dist/primitives/raw.js +12 -0
- package/dist/primitives/rotate-extrude.d.ts +14 -0
- package/dist/primitives/rotate-extrude.d.ts.map +1 -0
- package/dist/primitives/rotate-extrude.js +19 -0
- package/dist/primitives/rotate.d.ts +13 -0
- package/dist/primitives/rotate.d.ts.map +1 -0
- package/dist/primitives/rotate.js +11 -0
- package/dist/primitives/scale.d.ts +12 -0
- package/dist/primitives/scale.d.ts.map +1 -0
- package/dist/primitives/scale.js +10 -0
- package/dist/primitives/sphere.d.ts +14 -0
- package/dist/primitives/sphere.d.ts.map +1 -0
- package/dist/primitives/sphere.js +12 -0
- package/dist/primitives/square.d.ts +13 -0
- package/dist/primitives/square.d.ts.map +1 -0
- package/dist/primitives/square.js +13 -0
- package/dist/primitives/surface.d.ts +15 -0
- package/dist/primitives/surface.d.ts.map +1 -0
- package/dist/primitives/surface.js +17 -0
- package/dist/primitives/text.d.ts +20 -0
- package/dist/primitives/text.d.ts.map +1 -0
- package/dist/primitives/text.js +27 -0
- package/dist/primitives/translate.d.ts +12 -0
- package/dist/primitives/translate.d.ts.map +1 -0
- package/dist/primitives/translate.js +10 -0
- package/dist/primitives/union.d.ts +11 -0
- package/dist/primitives/union.d.ts.map +1 -0
- package/dist/primitives/union.js +9 -0
- package/dist/runtime/index.d.ts +62 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +147 -0
- package/dist/runtime/node-ops.d.ts +6 -0
- package/dist/runtime/node-ops.d.ts.map +1 -0
- package/dist/runtime/node-ops.js +517 -0
- package/dist/runtime/reconciler.d.ts +5 -0
- package/dist/runtime/reconciler.d.ts.map +1 -0
- package/dist/runtime/reconciler.js +10 -0
- package/dist/runtime/root.d.ts +13 -0
- package/dist/runtime/root.d.ts.map +1 -0
- package/dist/runtime/root.js +26 -0
- package/dist/serialize/index.d.ts +5 -0
- package/dist/serialize/index.d.ts.map +1 -0
- package/dist/serialize/index.js +81 -0
- package/dist/types.d.ts +149 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +19 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 react-scad contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# react-scad
|
|
2
|
+
|
|
3
|
+
Render JSX to **OpenSCAD** models using the [React reconciler](https://github.com/facebook/react/tree/main/packages/react-reconciler).
|
|
4
|
+
|
|
5
|
+
- Write declarative 3D with React components; no imperative OpenSCAD scripting
|
|
6
|
+
- Compose shapes with familiar JSX; get `.scad` source for OpenSCAD or 3D printing
|
|
7
|
+
- Use [@react-scad/cli](../cli) via npx to build and run
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
Install the library and React:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install react @react-scad/core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Minimal example
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
import { createRoot, Cube, Sphere, Union } from "react-scad";
|
|
21
|
+
|
|
22
|
+
const root = createRoot("model.scad");
|
|
23
|
+
|
|
24
|
+
root.render(
|
|
25
|
+
<Union>
|
|
26
|
+
<Cube size={[10, 10, 10]} center />
|
|
27
|
+
<Sphere r={6} />
|
|
28
|
+
</Union>
|
|
29
|
+
);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Save as `main.tsx`, then run it:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx @react-scad/cli run main.tsx
|
|
36
|
+
npx @react-scad/cli run main.tsx --watch
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Primitives (OpenSCAD coverage)
|
|
40
|
+
|
|
41
|
+
All listed OpenSCAD primitives and operations are implemented. Prop names follow OpenSCAD where it makes sense (`r`, `h`, `size`, `center`, `$fn`, etc.).
|
|
42
|
+
|
|
43
|
+
| OpenSCAD | react-scad | Implemented |
|
|
44
|
+
| -------- | ---------- | :---------: |
|
|
45
|
+
| **3D primitives** | | |
|
|
46
|
+
| `cube()` | `Cube` | ✓ |
|
|
47
|
+
| `sphere()` | `Sphere` | ✓ |
|
|
48
|
+
| `cylinder()` | `Cylinder` | ✓ |
|
|
49
|
+
| `polyhedron()` | `Polyhedron` | ✓ |
|
|
50
|
+
| **2D primitives** | | |
|
|
51
|
+
| `square()` | `Square` | ✓ |
|
|
52
|
+
| `circle()` | `Circle` | ✓ |
|
|
53
|
+
| `polygon()` | `Polygon` | ✓ |
|
|
54
|
+
| **CSG** | | |
|
|
55
|
+
| `union()` | `Union` | ✓ |
|
|
56
|
+
| `difference()` | `Difference` | ✓ |
|
|
57
|
+
| `intersection()` | `Intersection` | ✓ |
|
|
58
|
+
| **Transforms** | | |
|
|
59
|
+
| `translate()` | `Translate` | ✓ |
|
|
60
|
+
| `rotate()` | `Rotate` | ✓ |
|
|
61
|
+
| `scale()` | `Scale` | ✓ |
|
|
62
|
+
| **2D → 3D** | | |
|
|
63
|
+
| `linear_extrude()` | `LinearExtrude` | ✓ |
|
|
64
|
+
| `rotate_extrude()` | `RotateExtrude` | ✓ |
|
|
65
|
+
| **Text** | | |
|
|
66
|
+
| `text()` | `Text` | ✓ |
|
|
67
|
+
| **Other** | | |
|
|
68
|
+
| `{ }` (group) | `Group` | ✓ |
|
|
69
|
+
| inline code | `Raw` | ✓ |
|
|
70
|
+
| `surface()` | `Surface` | ✓ |
|
|
71
|
+
| `import()` | `Import` | ✓ |
|
|
72
|
+
|
|
73
|
+
## Why react-scad?
|
|
74
|
+
|
|
75
|
+
OpenSCAD is great for parametric 3D, but code is imperative and nesting gets messy. Composing modules and passing parameters can be tedious.
|
|
76
|
+
|
|
77
|
+
With react-scad you build a tree of SCAD primitives using React components. The reconciler runs with a custom host config that builds an internal SCAD tree (no DOM). Serialization turns that tree into OpenSCAD source.
|
|
78
|
+
|
|
79
|
+
**JSX → React tree → host config → SCAD tree → OpenSCAD source.**
|
|
80
|
+
|
|
81
|
+
You get declarative composition, reuse via components, and the same `.scad` output you’d use in OpenSCAD or slicers.
|
|
82
|
+
|
|
83
|
+
## Acknowledgements
|
|
84
|
+
|
|
85
|
+
- [React](https://react.dev/) and the [React reconciler](https://github.com/facebook/react/tree/main/packages/react-reconciler) for the rendering model that makes this approach possible.
|
|
86
|
+
- [OpenSCAD](https://openscad.org/) for the script-based CAD language and documentation.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
React SCAD is MIT-licensed open-source software by Leon Meka and
|
|
91
|
+
contributors.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createContainer, createRoot, render, toScad } from "./runtime/root.js";
|
|
2
|
+
export type { ScadContainer, ScadRoot, Path } from "./runtime/root.js";
|
|
3
|
+
export type { Vec2, Vec3, ScadExpr } from "./types.js";
|
|
4
|
+
export { Circle, Cube, Cylinder, Difference, Group, Import, Intersection, LinearExtrude, Polygon, Polyhedron, Raw, Rotate, RotateExtrude, Scale, Sphere, Square, Surface, Text, Translate, Union, } from "./primitives/index.js";
|
|
5
|
+
export type { CircleProps, CubeProps, CylinderProps, DifferenceProps, GroupProps, ImportProps, IntersectionProps, LinearExtrudeProps, PolygonProps, PolyhedronProps, RawProps, RotateProps, RotateExtrudeProps, ScaleProps, SphereProps, SquareProps, SurfaceProps, TextProps, TranslateProps, UnionProps, } from "./primitives/index.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChF,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EACN,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,KAAK,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,UAAU,EACV,GAAG,EACH,MAAM,EACN,aAAa,EACb,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAI,EACJ,SAAS,EACT,KAAK,GACL,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,GACV,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createContainer, createRoot, render, toScad } from "./runtime/root.js";
|
|
2
|
+
export { Circle, Cube, Cylinder, Difference, Group, Import, Intersection, LinearExtrude, Polygon, Polyhedron, Raw, Rotate, RotateExtrude, Scale, Sphere, Square, Surface, Text, Translate, Union, } from "./primitives/index.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { CircleNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface CircleProps extends PropsWithChildren {
|
|
5
|
+
r?: number;
|
|
6
|
+
d?: number;
|
|
7
|
+
$fn?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const Circle: {
|
|
10
|
+
(props: CircleProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function serialize(node: CircleNode, _indent: string, _ctx: SerializeContext): string;
|
|
14
|
+
//# sourceMappingURL=circle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle.d.ts","sourceRoot":"","sources":["../../src/primitives/circle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGhE,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACrD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,MAAM;YAAW,WAAW;;CACoB,CAAC;AAG9D,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAM3F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./primitive.js";
|
|
3
|
+
export const Circle = (props) => React.createElement(Primitive, { ...props, type: "circle" });
|
|
4
|
+
Circle.displayName = "Circle";
|
|
5
|
+
export function serialize(node, _indent, _ctx) {
|
|
6
|
+
const rVal = node.r ?? 1;
|
|
7
|
+
const dVal = node.d;
|
|
8
|
+
let args = dVal != null ? `d = ${String(dVal)}` : `r = ${String(rVal)}`;
|
|
9
|
+
if (node.$fn != null)
|
|
10
|
+
args += `, $fn = ${node.$fn}`;
|
|
11
|
+
return `circle(${args});`;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { CubeNode, SerializeContext, Vec3 } from "../types.js";
|
|
4
|
+
export interface CubeProps extends PropsWithChildren {
|
|
5
|
+
size?: Vec3;
|
|
6
|
+
center?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const Cube: {
|
|
9
|
+
(props: CubeProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function serialize(node: CubeNode, _indent: string, _ctx: SerializeContext): string;
|
|
13
|
+
//# sourceMappingURL=cube.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cube.d.ts","sourceRoot":"","sources":["../../src/primitives/cube.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAIpE,MAAM,WAAW,SAAU,SAAQ,iBAAiB;IACnD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,IAAI;YAAW,SAAS;;CACsB,CAAC;AAG5D,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAQzF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { formatVec3 } from "../utils.js";
|
|
3
|
+
import { Primitive } from "./primitive.js";
|
|
4
|
+
export const Cube = (props) => React.createElement(Primitive, { ...props, type: "cube" });
|
|
5
|
+
Cube.displayName = "Cube";
|
|
6
|
+
export function serialize(node, _indent, _ctx) {
|
|
7
|
+
const s = typeof node.size === "number"
|
|
8
|
+
? String(node.size)
|
|
9
|
+
: typeof node.size === "string"
|
|
10
|
+
? node.size
|
|
11
|
+
: formatVec3(node.size);
|
|
12
|
+
return `cube(size = ${s}, center = ${node.center});`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { CylinderNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface CylinderProps extends PropsWithChildren {
|
|
5
|
+
h?: number;
|
|
6
|
+
r1?: number;
|
|
7
|
+
r2?: number;
|
|
8
|
+
r?: number;
|
|
9
|
+
$fn?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const Cylinder: {
|
|
12
|
+
(props: CylinderProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function serialize(node: CylinderNode, _indent: string, _ctx: SerializeContext): string;
|
|
16
|
+
//# sourceMappingURL=cylinder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cylinder.d.ts","sourceRoot":"","sources":["../../src/primitives/cylinder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGlE,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACvD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,QAAQ;YAAW,aAAa;;CACkB,CAAC;AAGhE,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAI7F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./primitive.js";
|
|
3
|
+
export const Cylinder = (props) => React.createElement(Primitive, { ...props, type: "cylinder" });
|
|
4
|
+
Cylinder.displayName = "Cylinder";
|
|
5
|
+
export function serialize(node, _indent, _ctx) {
|
|
6
|
+
let args = `h = ${String(node.h)}, r1 = ${String(node.r1)}, r2 = ${String(node.r2)}`;
|
|
7
|
+
if (node.$fn != null)
|
|
8
|
+
args += `, $fn = ${node.$fn}`;
|
|
9
|
+
return `cylinder(${args});`;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { DifferenceNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface DifferenceProps extends PropsWithChildren {
|
|
5
|
+
}
|
|
6
|
+
export declare const Difference: {
|
|
7
|
+
(props: DifferenceProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function serialize(node: DifferenceNode, indent: string, ctx: SerializeContext): string;
|
|
11
|
+
//# sourceMappingURL=difference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"difference.d.ts","sourceRoot":"","sources":["../../src/primitives/difference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpE,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;CAAG;AAE7D,eAAO,MAAM,UAAU;YAAW,eAAe;;CACgB,CAAC;AAGlE,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAI7F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./primitive.js";
|
|
3
|
+
export const Difference = (props) => React.createElement(Primitive, { ...props, type: "difference" });
|
|
4
|
+
Difference.displayName = "Difference";
|
|
5
|
+
export function serialize(node, indent, ctx) {
|
|
6
|
+
const nextIndent = `${indent} `;
|
|
7
|
+
const inner = node.children.map((c) => nextIndent + ctx.serializeNode(c, nextIndent)).join("\n");
|
|
8
|
+
return inner ? `difference() {\n${inner}\n${indent}}` : "difference() {}";
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { GroupNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface GroupProps extends PropsWithChildren {
|
|
5
|
+
}
|
|
6
|
+
export declare const Group: {
|
|
7
|
+
(props: GroupProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function serialize(node: GroupNode, indent: string, ctx: SerializeContext): string;
|
|
11
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/primitives/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/D,MAAM,WAAW,UAAW,SAAQ,iBAAiB;CAAG;AAExD,eAAO,MAAM,KAAK;YAAW,UAAU;;CACqB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAIxF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./primitive.js";
|
|
3
|
+
export const Group = (props) => React.createElement(Primitive, { ...props, type: "group" });
|
|
4
|
+
Group.displayName = "Group";
|
|
5
|
+
export function serialize(node, indent, ctx) {
|
|
6
|
+
const nextIndent = `${indent} `;
|
|
7
|
+
const inner = node.children.map((c) => nextIndent + ctx.serializeNode(c, nextIndent)).join("\n");
|
|
8
|
+
return inner ? `{\n${inner}\n${indent}}` : "{}";
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { ImportNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface ImportProps extends PropsWithChildren {
|
|
5
|
+
file: string;
|
|
6
|
+
convexity?: number;
|
|
7
|
+
layer?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const Import: {
|
|
10
|
+
(props: ImportProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function serialize(node: ImportNode, _indent: string, _ctx: SerializeContext): string;
|
|
14
|
+
//# sourceMappingURL=import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/primitives/import.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGhE,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,MAAM;YAAW,WAAW;;CACoB,CAAC;AAO9D,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAK3F"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./primitive.js";
|
|
3
|
+
export const Import = (props) => React.createElement(Primitive, { ...props, type: "import" });
|
|
4
|
+
Import.displayName = "Import";
|
|
5
|
+
function escapePath(s) {
|
|
6
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
7
|
+
}
|
|
8
|
+
export function serialize(node, _indent, _ctx) {
|
|
9
|
+
const parts = [`"${escapePath(node.file)}"`];
|
|
10
|
+
if (node.convexity != null)
|
|
11
|
+
parts.push(`convexity = ${node.convexity}`);
|
|
12
|
+
if (node.layer != null)
|
|
13
|
+
parts.push(`layer = "${escapePath(node.layer)}"`);
|
|
14
|
+
return `import(${parts.join(", ")});`;
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export { Circle } from "./circle.js";
|
|
2
|
+
export { Cube } from "./cube.js";
|
|
3
|
+
export { Cylinder } from "./cylinder.js";
|
|
4
|
+
export { Difference } from "./difference.js";
|
|
5
|
+
export { Group } from "./group.js";
|
|
6
|
+
export { Import } from "./import.js";
|
|
7
|
+
export { Intersection } from "./intersection.js";
|
|
8
|
+
export { LinearExtrude } from "./linear-extrude.js";
|
|
9
|
+
export { Polygon } from "./polygon.js";
|
|
10
|
+
export { Polyhedron } from "./polyhedron.js";
|
|
11
|
+
export { Raw } from "./raw.js";
|
|
12
|
+
export { Rotate } from "./rotate.js";
|
|
13
|
+
export { RotateExtrude } from "./rotate-extrude.js";
|
|
14
|
+
export { Scale } from "./scale.js";
|
|
15
|
+
export { Sphere } from "./sphere.js";
|
|
16
|
+
export { Square } from "./square.js";
|
|
17
|
+
export { Surface } from "./surface.js";
|
|
18
|
+
export { Text } from "./text.js";
|
|
19
|
+
export { Translate } from "./translate.js";
|
|
20
|
+
export { Union } from "./union.js";
|
|
21
|
+
export type { CircleProps } from "./circle.js";
|
|
22
|
+
export type { CubeProps } from "./cube.js";
|
|
23
|
+
export type { CylinderProps } from "./cylinder.js";
|
|
24
|
+
export type { DifferenceProps } from "./difference.js";
|
|
25
|
+
export type { GroupProps } from "./group.js";
|
|
26
|
+
export type { ImportProps } from "./import.js";
|
|
27
|
+
export type { IntersectionProps } from "./intersection.js";
|
|
28
|
+
export type { LinearExtrudeProps } from "./linear-extrude.js";
|
|
29
|
+
export type { PolygonProps } from "./polygon.js";
|
|
30
|
+
export type { PolyhedronProps } from "./polyhedron.js";
|
|
31
|
+
export type { RawProps } from "./raw.js";
|
|
32
|
+
export type { RotateProps } from "./rotate.js";
|
|
33
|
+
export type { RotateExtrudeProps } from "./rotate-extrude.js";
|
|
34
|
+
export type { ScaleProps } from "./scale.js";
|
|
35
|
+
export type { SphereProps } from "./sphere.js";
|
|
36
|
+
export type { SquareProps } from "./square.js";
|
|
37
|
+
export type { SurfaceProps } from "./surface.js";
|
|
38
|
+
export type { TextProps } from "./text.js";
|
|
39
|
+
export type { TranslateProps } from "./translate.js";
|
|
40
|
+
export type { UnionProps } from "./union.js";
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { Circle } from "./circle.js";
|
|
2
|
+
export { Cube } from "./cube.js";
|
|
3
|
+
export { Cylinder } from "./cylinder.js";
|
|
4
|
+
export { Difference } from "./difference.js";
|
|
5
|
+
export { Group } from "./group.js";
|
|
6
|
+
export { Import } from "./import.js";
|
|
7
|
+
export { Intersection } from "./intersection.js";
|
|
8
|
+
export { LinearExtrude } from "./linear-extrude.js";
|
|
9
|
+
export { Polygon } from "./polygon.js";
|
|
10
|
+
export { Polyhedron } from "./polyhedron.js";
|
|
11
|
+
export { Raw } from "./raw.js";
|
|
12
|
+
export { Rotate } from "./rotate.js";
|
|
13
|
+
export { RotateExtrude } from "./rotate-extrude.js";
|
|
14
|
+
export { Scale } from "./scale.js";
|
|
15
|
+
export { Sphere } from "./sphere.js";
|
|
16
|
+
export { Square } from "./square.js";
|
|
17
|
+
export { Surface } from "./surface.js";
|
|
18
|
+
export { Text } from "./text.js";
|
|
19
|
+
export { Translate } from "./translate.js";
|
|
20
|
+
export { Union } from "./union.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { IntersectionNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface IntersectionProps extends PropsWithChildren {
|
|
5
|
+
}
|
|
6
|
+
export declare const Intersection: {
|
|
7
|
+
(props: IntersectionProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function serialize(node: IntersectionNode, indent: string, ctx: SerializeContext): string;
|
|
11
|
+
//# sourceMappingURL=intersection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../../src/primitives/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGtE,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;CAAG;AAE/D,eAAO,MAAM,YAAY;YAAW,iBAAiB;;CACc,CAAC;AAGpE,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAI/F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./primitive.js";
|
|
3
|
+
export const Intersection = (props) => React.createElement(Primitive, { ...props, type: "intersection" });
|
|
4
|
+
Intersection.displayName = "Intersection";
|
|
5
|
+
export function serialize(node, indent, ctx) {
|
|
6
|
+
const nextIndent = `${indent} `;
|
|
7
|
+
const inner = node.children.map((c) => nextIndent + ctx.serializeNode(c, nextIndent)).join("\n");
|
|
8
|
+
return inner ? `intersection() {\n${inner}\n${indent}}` : "intersection() {}";
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { LinearExtrudeNode, SerializeContext, Vec2 } from "../types.js";
|
|
4
|
+
export interface LinearExtrudeProps extends PropsWithChildren {
|
|
5
|
+
height: number;
|
|
6
|
+
center?: boolean;
|
|
7
|
+
twist?: number;
|
|
8
|
+
scale?: Vec2 | number;
|
|
9
|
+
convexity?: number;
|
|
10
|
+
slices?: number;
|
|
11
|
+
$fn?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const LinearExtrude: {
|
|
14
|
+
(props: LinearExtrudeProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function serialize(node: LinearExtrudeNode, indent: string, ctx: SerializeContext): string;
|
|
18
|
+
//# sourceMappingURL=linear-extrude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linear-extrude.d.ts","sourceRoot":"","sources":["../../src/primitives/linear-extrude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAI7E,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,aAAa;YAAW,kBAAkB;;CACc,CAAC;AAStE,wBAAgB,SAAS,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAahG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { formatVec2 } from "../utils.js";
|
|
3
|
+
import { Primitive } from "./primitive.js";
|
|
4
|
+
export const LinearExtrude = (props) => React.createElement(Primitive, { ...props, type: "linear_extrude" });
|
|
5
|
+
LinearExtrude.displayName = "LinearExtrude";
|
|
6
|
+
function formatScale(scale) {
|
|
7
|
+
if (scale == null)
|
|
8
|
+
return undefined;
|
|
9
|
+
if (typeof scale === "number" || typeof scale === "string")
|
|
10
|
+
return String(scale);
|
|
11
|
+
return formatVec2(scale);
|
|
12
|
+
}
|
|
13
|
+
export function serialize(node, indent, ctx) {
|
|
14
|
+
const parts = [`height = ${String(node.height)}`];
|
|
15
|
+
if (node.center === true)
|
|
16
|
+
parts.push("center = true");
|
|
17
|
+
if (node.twist != null)
|
|
18
|
+
parts.push(`twist = ${String(node.twist)}`);
|
|
19
|
+
const scaleStr = formatScale(node.scale);
|
|
20
|
+
if (scaleStr != null)
|
|
21
|
+
parts.push(`scale = ${scaleStr}`);
|
|
22
|
+
if (node.convexity != null)
|
|
23
|
+
parts.push(`convexity = ${node.convexity}`);
|
|
24
|
+
if (node.slices != null)
|
|
25
|
+
parts.push(`slices = ${node.slices}`);
|
|
26
|
+
if (node.$fn != null)
|
|
27
|
+
parts.push(`$fn = ${node.$fn}`);
|
|
28
|
+
const nextIndent = `${indent} `;
|
|
29
|
+
const inner = node.children.map((c) => nextIndent + ctx.serializeNode(c, nextIndent)).join("\n");
|
|
30
|
+
return `linear_extrude(${parts.join(", ")}) {\n${inner}\n${indent}}`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { PolygonNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface PolygonProps extends PropsWithChildren {
|
|
5
|
+
points: [number, number][];
|
|
6
|
+
paths?: number[][];
|
|
7
|
+
convexity?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const Polygon: {
|
|
10
|
+
(props: PolygonProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function serialize(node: PolygonNode, _indent: string, _ctx: SerializeContext): string;
|
|
14
|
+
//# sourceMappingURL=polygon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../src/primitives/polygon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIjE,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACtD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,OAAO;YAAW,YAAY;;CACmB,CAAC;AAG/D,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAO5F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { formatFaces, formatPoints2D } from "../utils.js";
|
|
3
|
+
import { Primitive } from "./primitive.js";
|
|
4
|
+
export const Polygon = (props) => React.createElement(Primitive, { ...props, type: "polygon" });
|
|
5
|
+
Polygon.displayName = "Polygon";
|
|
6
|
+
export function serialize(node, _indent, _ctx) {
|
|
7
|
+
let args = `points = ${formatPoints2D(node.points)}`;
|
|
8
|
+
if (node.paths != null && node.paths.length > 0) {
|
|
9
|
+
args += `, paths = ${formatFaces(node.paths)}`;
|
|
10
|
+
}
|
|
11
|
+
if (node.convexity != null)
|
|
12
|
+
args += `, convexity = ${node.convexity}`;
|
|
13
|
+
return `polygon(${args});`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { PolyhedronNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface PolyhedronProps extends PropsWithChildren {
|
|
5
|
+
points: [number, number, number][];
|
|
6
|
+
faces: number[][];
|
|
7
|
+
convexity?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const Polyhedron: {
|
|
10
|
+
(props: PolyhedronProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function serialize(node: PolyhedronNode, _indent: string, _ctx: SerializeContext): string;
|
|
14
|
+
//# sourceMappingURL=polyhedron.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyhedron.d.ts","sourceRoot":"","sources":["../../src/primitives/polyhedron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpE,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACzD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IACnC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU;YAAW,eAAe;;CACgB,CAAC;AAGlE,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAI/F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { formatFaces, formatPoints3D } from "../utils.js";
|
|
3
|
+
import { Primitive } from "./primitive.js";
|
|
4
|
+
export const Polyhedron = (props) => React.createElement(Primitive, { ...props, type: "polyhedron" });
|
|
5
|
+
Polyhedron.displayName = "Polyhedron";
|
|
6
|
+
export function serialize(node, _indent, _ctx) {
|
|
7
|
+
let args = `points = ${formatPoints3D(node.points)}, faces = ${formatFaces(node.faces)}`;
|
|
8
|
+
if (node.convexity != null)
|
|
9
|
+
args += `, convexity = ${node.convexity}`;
|
|
10
|
+
return `polyhedron(${args});`;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
export interface PrimitivePropsBase extends PropsWithChildren {
|
|
4
|
+
type: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function Primitive<Props extends PrimitivePropsBase>(props: Props): React.DOMElement<Omit<Props, "type" | "children">, Element>;
|
|
7
|
+
//# sourceMappingURL=primitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../src/primitives/primitive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC5D,IAAI,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,SAAS,CAAC,KAAK,SAAS,kBAAkB,EAAE,KAAK,EAAE,KAAK,+DAGvE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { RawNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface RawProps extends PropsWithChildren {
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const Raw: {
|
|
8
|
+
(props: RawProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function serialize(node: RawNode, indent: string, _ctx: SerializeContext): string;
|
|
12
|
+
//# sourceMappingURL=raw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../src/primitives/raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,WAAW,QAAS,SAAQ,iBAAiB;IAClD,IAAI,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,GAAG;YAAW,QAAQ;;CAA8D,CAAC;AAGlG,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAMvF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./primitive.js";
|
|
3
|
+
export const Raw = (props) => React.createElement(Primitive, { ...props, type: "raw" });
|
|
4
|
+
Raw.displayName = "Raw";
|
|
5
|
+
export function serialize(node, indent, _ctx) {
|
|
6
|
+
if (!node.code.trim())
|
|
7
|
+
return "";
|
|
8
|
+
return node.code
|
|
9
|
+
.split("\n")
|
|
10
|
+
.map((line) => indent + line)
|
|
11
|
+
.join("\n");
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import type { RotateExtrudeNode, SerializeContext } from "../types.js";
|
|
4
|
+
export interface RotateExtrudeProps extends PropsWithChildren {
|
|
5
|
+
angle?: number;
|
|
6
|
+
convexity?: number;
|
|
7
|
+
$fn?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const RotateExtrude: {
|
|
10
|
+
(props: RotateExtrudeProps): React.FunctionComponentElement<import("./primitive.js").PrimitivePropsBase>;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function serialize(node: RotateExtrudeNode, indent: string, ctx: SerializeContext): string;
|
|
14
|
+
//# sourceMappingURL=rotate-extrude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotate-extrude.d.ts","sourceRoot":"","sources":["../../src/primitives/rotate-extrude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGvE,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,aAAa;YAAW,kBAAkB;;CACc,CAAC;AAGtE,wBAAgB,SAAS,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAYhG"}
|