@es3d/es3d 1.0.2 → 1.1.0
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 +16 -5
- package/browser/es3d-stage.min.js +10349 -0
- package/package.json +4 -2
- package/scripts/es3d-cli.mjs +28 -5
- package/src/index.js +10 -3
- package/src/io/convert.js +53 -5
- package/src/io/export-model.js +679 -0
- package/src/io/file-loader.js +3 -2
- package/src/io/openscad-import.js +1295 -0
- package/src/io/openscad.js +252 -0
- package/src/io/text-encode.js +87 -0
- package/src/io/threejs.js +397 -0
- package/src/io/usd.js +669 -0
- package/src/io/x3d.js +1183 -0
- package/src/render/stage.js +85 -10
- package/src/scene/flatten.js +208 -4
- package/src/scene/scene-graph.js +13 -2
- package/src/stage.js +8 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
This package is the reference implementation:
|
|
15
15
|
- a strict parser and validator;
|
|
16
16
|
- a WebGPU renderer with a WebGL2 fallback;
|
|
17
|
-
- converters from SVG, OBJ, STL, STEP and glTF, and
|
|
17
|
+
- converters from SVG, OBJ, STL, STEP, glTF, X3D, USDA and OpenSCAD, and to glTF, OBJ, STL, STEP, X3D, USDA, OpenSCAD and a three.js module;
|
|
18
18
|
- the `es3d` command.
|
|
19
19
|
|
|
20
20
|
It has no dependencies.
|
|
@@ -56,6 +56,17 @@ stage.show(source); // ES3D markup, compact syntax or JSON
|
|
|
56
56
|
|
|
57
57
|
The canvas is sized by its parent element. The stage draws only when something changes, plays animations, and follows the document's `<controls>`: orbit limits, collision with the scene, or a camera that follows page scroll.
|
|
58
58
|
|
|
59
|
+
A page that moves shapes itself can load the stage as one file:
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import { createStage, mulberry32, es3dSin, es3dCos } from '@es3d/es3d/stage';
|
|
63
|
+
|
|
64
|
+
const stage = await createStage(document.querySelector('canvas'), { background: true });
|
|
65
|
+
stage.show(source);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`background: true` runs the clock and leaves the camera still. `stage.setTransform(id, matrix)` replaces the local matrix of an element that is placed once (column-major, the same layout as `matrix()`). `stage.setTransforms([[id, matrix], ...])` stores every matrix, walks each affected part of the scene once, and returns a boolean for each entry. A shared definition or a `<repeat>` / `<scatter>` copy is left unchanged and that entry is false. `stage.reducedMotion` follows the visitor's reduced-motion preference, and the clock stays still while it matches. `clock: 'always'` runs the clock when the document has no `<animate>`. `mulberry32`, `es3dSin` and `es3dCos` are the reader's placement functions. The format stays version 1.
|
|
69
|
+
|
|
59
70
|
## Compile, check and convert
|
|
60
71
|
|
|
61
72
|
```js
|
|
@@ -64,8 +75,8 @@ import { compile, importFiles, exportFormat } from '@es3d/es3d';
|
|
|
64
75
|
const result = compile(source);
|
|
65
76
|
if (!result.ok) console.error(result.diagnostics.map((d) => d.format()).join('\n\n'));
|
|
66
77
|
|
|
67
|
-
const { text } = await importFiles([{ name: 'logo.svg', bytes }]); // SVG, OBJ, STL, STEP, glTF → ES3D
|
|
68
|
-
const { files } = exportFormat(text, 'glb'); // ES3D → glTF, OBJ, STL, STEP
|
|
78
|
+
const { text } = await importFiles([{ name: 'logo.svg', bytes }]); // SVG, OBJ, STL, STEP, glTF, X3D, USDA, OpenSCAD → ES3D
|
|
79
|
+
const { files } = exportFormat(text, 'glb'); // ES3D → glTF, OBJ, STL, STEP, X3D, USDA, OpenSCAD, three.js
|
|
69
80
|
```
|
|
70
81
|
|
|
71
82
|
Every error has a line, a column, a code and, where it can, a "did you mean" suggestion. Repeated warnings that share a code, an element name and a message are printed once, with a count. `validate --json` still lists every warning.
|
|
@@ -75,8 +86,8 @@ Every error has a line, a column, a code and, where it can, a "did you mean" sug
|
|
|
75
86
|
```bash
|
|
76
87
|
npx @es3d/es3d validate scene.es3d # diagnostics, repeated warnings grouped; exit code 1 on errors
|
|
77
88
|
npx @es3d/es3d compact scene.es3d # convert to the compact syntax (also: markup, json, fmt, minify)
|
|
78
|
-
npx @es3d/es3d glb scene.es3d -o scene.glb # export (also: obj, stl, step)
|
|
79
|
-
npx @es3d/es3d import logo.svg -o logo.es3d # SVG, OBJ, STL, STEP or
|
|
89
|
+
npx @es3d/es3d glb scene.es3d -o scene.glb # export (also: obj, stl, step, x3d, usd, scad, js)
|
|
90
|
+
npx @es3d/es3d import logo.svg -o logo.es3d # SVG, OBJ, STL, STEP, glTF, X3D, USDA or OpenSCAD to ES3D
|
|
80
91
|
npx @es3d/es3d stats scene.es3d # sizes, counts and timings
|
|
81
92
|
```
|
|
82
93
|
|