@es3d/es3d 1.0.1 → 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 CHANGED
@@ -1,11 +1,20 @@
1
1
  # ES3D
2
2
 
3
+ <p align="center">
4
+ <a href="https://www.jsdelivr.com/package/npm/@es3d/es3d"><img src="https://img.shields.io/jsdelivr/npm/hm/@es3d/es3d?label=jsDelivr" alt="jsDelivr"></a>
5
+ <a href="https://www.npmjs.com/package/@es3d/es3d"><img src="https://img.shields.io/npm/v/@es3d/es3d" alt="npm version"></a>
6
+ <a href="https://www.npmjs.com/package/@es3d/es3d"><img src="https://img.shields.io/npm/dm/@es3d/es3d" alt="npm downloads"></a>
7
+ <a href="https://github.com/bitilia/es3d/stargazers"><img src="https://img.shields.io/github/stars/bitilia/es3d" alt="GitHub stars"></a>
8
+ <a href="https://github.com/bitilia/es3d/blob/main/LICENSE"><img src="https://img.shields.io/github/license/bitilia/es3d" alt="License"></a>
9
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/@es3d/es3d" alt="Node.js"></a>
10
+ </p>
11
+
3
12
  **A file format for 3D scenes you can write by hand, the way people write SVG.** The file describes objects, not triangles: a rounded box, an outline extruded into a solid, two thousand trees placed by a rule. The viewer builds the triangles, at the detail the screen needs.
4
13
 
5
14
  This package is the reference implementation:
6
15
  - a strict parser and validator;
7
16
  - a WebGPU renderer with a WebGL2 fallback;
8
- - converters from SVG, OBJ, STL, STEP and glTF, and back;
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;
9
18
  - the `es3d` command.
10
19
 
11
20
  It has no dependencies.
@@ -47,6 +56,17 @@ stage.show(source); // ES3D markup, compact syntax or JSON
47
56
 
48
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.
49
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
+
50
70
  ## Compile, check and convert
51
71
 
52
72
  ```js
@@ -55,19 +75,19 @@ import { compile, importFiles, exportFormat } from '@es3d/es3d';
55
75
  const result = compile(source);
56
76
  if (!result.ok) console.error(result.diagnostics.map((d) => d.format()).join('\n\n'));
57
77
 
58
- const { text } = await importFiles([{ name: 'logo.svg', bytes }]); // SVG, OBJ, STL, STEP, glTF → ES3D
59
- 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
60
80
  ```
61
81
 
62
- Every error has a line, a column, a code and, where it can, a "did you mean" suggestion.
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.
63
83
 
64
84
  ## The command
65
85
 
66
86
  ```bash
67
- npx @es3d/es3d validate scene.es3d # every diagnostic; exit code 1 on errors
87
+ npx @es3d/es3d validate scene.es3d # diagnostics, repeated warnings grouped; exit code 1 on errors
68
88
  npx @es3d/es3d compact scene.es3d # convert to the compact syntax (also: markup, json, fmt, minify)
69
- npx @es3d/es3d glb scene.es3d -o scene.glb # export (also: obj, stl, step)
70
- npx @es3d/es3d import logo.svg -o logo.es3d # SVG, OBJ, STL, STEP or glTF to ES3D
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
71
91
  npx @es3d/es3d stats scene.es3d # sizes, counts and timings
72
92
  ```
73
93