@react-scad/core 0.1.14 → 0.1.16
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 +39 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,12 @@ 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
|
+
|
|
27
33
|
## Getting Started
|
|
28
34
|
|
|
29
35
|
### Prerequisites
|
|
@@ -100,6 +106,8 @@ The path you pass to `createRoot()` is relative to the current working directory
|
|
|
100
106
|
|
|
101
107
|
## Advanced
|
|
102
108
|
|
|
109
|
+
### Custom Behavior
|
|
110
|
+
|
|
103
111
|
To write to a custom path or get the SCAD string in memory instead of using `createRoot(path)`, use `createContainer()`, `render()`, and `toScad()`:
|
|
104
112
|
|
|
105
113
|
```jsx
|
|
@@ -122,6 +130,37 @@ writeFileSync("out/model.scad", scadCode);
|
|
|
122
130
|
|
|
123
131
|
Then run with `npx tsx main.tsx` or bundle with esbuild and run with Node.
|
|
124
132
|
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### Interop with existing SCAD
|
|
137
|
+
|
|
138
|
+
You can reuse existing `.scad` libraries and snippets in two ways:
|
|
139
|
+
|
|
140
|
+
- **`Import`** — Emit OpenSCAD’s `import("path")` so the generated file pulls in another SCAD file (e.g. STL/DXF or a file that defines modules). Use this when the library is a separate file and you just need to reference it.
|
|
141
|
+
|
|
142
|
+
```jsx
|
|
143
|
+
import { Import, Union } from "@react-scad/core";
|
|
144
|
+
|
|
145
|
+
<Union>
|
|
146
|
+
<Import file="lib/gears.scad" />
|
|
147
|
+
</Union>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- **`Raw`** — Emit arbitrary SCAD code inline. Use this to paste a snippet, call a module from an imported library, or wrap a block of SCAD you don’t have a dedicated component for. Children are ignored; only the `code` prop is emitted (with indentation applied).
|
|
151
|
+
|
|
152
|
+
```jsx
|
|
153
|
+
import { Raw, Union } from "@react-scad/core";
|
|
154
|
+
|
|
155
|
+
// After Import "lib/gears.scad", call a module from it:
|
|
156
|
+
<Raw code="gear(number_of_teeth=32, circular_pitch=200);" />
|
|
157
|
+
|
|
158
|
+
// Or inject a small SCAD block:
|
|
159
|
+
<Raw code={`include <BOSL2/std.scad>\nrounded_cube(20, 0.5);`} />
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
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
|
+
|
|
125
164
|
---
|
|
126
165
|
|
|
127
166
|
## Primitives (SCAD coverage)
|