@react-scad/core 0.1.21 → 0.1.23
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/README.md +26 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,20 +24,28 @@ A lot of people already think in components and JSX from building UIs. **react-s
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
## [Try it out!](https://github.com/react-scad/example)
|
|
28
|
-
|
|
29
|
-
A minimal runnable example is available at **[react-scad/example](https://github.com/react-scad/example)**. Clone it, `npm install`, then `npm start` to generate the SCAD file.
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
27
|
## Getting Started
|
|
34
28
|
|
|
35
29
|
### Prerequisites
|
|
36
30
|
|
|
37
31
|
- **Node.js** 18+
|
|
38
|
-
- **React** 18 or later (peer dependency)
|
|
39
32
|
|
|
40
|
-
###
|
|
33
|
+
### Create a new project (recommended)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx create-react-scad my-project
|
|
37
|
+
cd my-project
|
|
38
|
+
npm run dev # watch mode
|
|
39
|
+
npm start # single run
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That’s it — open the generated `model.scad` in [OpenSCAD](https://openscad.org/) or your slicer.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### Add to an existing project
|
|
47
|
+
|
|
48
|
+
#### Install
|
|
41
49
|
|
|
42
50
|
```bash
|
|
43
51
|
npm install react @react-scad/core
|
|
@@ -54,7 +62,7 @@ yarn add react @react-scad/core
|
|
|
54
62
|
|
|
55
63
|
</details>
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
#### Minimal example
|
|
58
66
|
|
|
59
67
|
Create a file `main.tsx` (or `main.jsx`):
|
|
60
68
|
|
|
@@ -73,17 +81,7 @@ root.render(
|
|
|
73
81
|
);
|
|
74
82
|
```
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
| ----- | ------- |
|
|
78
|
-
| `createRoot("model.scad")` | Root that writes to `model.scad` |
|
|
79
|
-
| `Union` | CSG union of all children (like `union()` in SCAD) |
|
|
80
|
-
| `Cube` / `Sphere` | Props match SCAD: `size`, `center`, `r`, `$fn`, etc. |
|
|
81
|
-
|
|
82
|
-
### Run and write the `.scad` file
|
|
83
|
-
|
|
84
|
-
Run your entry file with [tsx](https://github.com/privatenumber/tsx) so Node can execute the `.tsx`. The `.scad` file is written to the **current working directory** when you call `root.render()`.
|
|
85
|
-
|
|
86
|
-
> **Note:** Node doesn’t run `.tsx` by itself. Use **tsx** or bundle with esbuild (see [Advanced](#advanced) for alternatives).
|
|
84
|
+
#### Run and write the `.scad` file
|
|
87
85
|
|
|
88
86
|
```bash
|
|
89
87
|
npx tsx main.tsx
|
|
@@ -95,16 +93,15 @@ Watch mode (re-run on save):
|
|
|
95
93
|
npx tsx watch main.tsx
|
|
96
94
|
```
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### View the result
|
|
96
|
+
#### View the result
|
|
101
97
|
|
|
102
98
|
- Open the generated `.scad` file in [OpenSCAD](https://openscad.org/) to preview, export STL, or tweak.
|
|
103
99
|
- Or import the `.scad` (or an exported STL) into your slicer for 3D printing.
|
|
104
100
|
|
|
105
101
|
---
|
|
106
102
|
|
|
107
|
-
|
|
103
|
+
<details>
|
|
104
|
+
<summary>Advanced</summary>
|
|
108
105
|
|
|
109
106
|
### Custom Behavior
|
|
110
107
|
|
|
@@ -130,10 +127,10 @@ writeFileSync("out/model.scad", scadCode);
|
|
|
130
127
|
|
|
131
128
|
Then run with `npx tsx main.tsx` or bundle with esbuild and run with Node.
|
|
132
129
|
|
|
130
|
+
</details>
|
|
133
131
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
### Interop with existing SCAD
|
|
132
|
+
<details>
|
|
133
|
+
<summary>Interop with existing SCAD</summary>
|
|
137
134
|
|
|
138
135
|
You can reuse existing `.scad` libraries and snippets in two ways:
|
|
139
136
|
|
|
@@ -161,6 +158,8 @@ You can reuse existing `.scad` libraries and snippets in two ways:
|
|
|
161
158
|
|
|
162
159
|
Typical pattern: **`Import`** the library file once (at top level or where needed), then use **`Raw`** to call its modules or paste any SCAD that fits your tree.
|
|
163
160
|
|
|
161
|
+
</details>
|
|
162
|
+
|
|
164
163
|
---
|
|
165
164
|
|
|
166
165
|
## Primitives (SCAD coverage)
|