lk3d 0.2.0 → 0.2.1
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/CHANGELOG.md +24 -0
- package/README.md +14 -6
- package/dist/lk3d-export.min.js +1 -1
- package/dist/lk3d.min.js +28 -22
- package/dist/lk3d.mjs +31 -25
- package/docs/api.md +31 -31
- package/docs/design.md +5 -3
- package/docs/handles-and-lines.md +27 -0
- package/docs/performance.md +2 -1
- package/docs/scene-format.md +1 -0
- package/index.d.ts +4 -0
- package/package.json +2 -1
- package/scene.d.ts +104 -0
- package/schema/scene.schema.json +164 -0
- package/skill/lk3d/SKILL.md +3 -0
- package/src/figure/api.js +7 -2
- package/src/figure/camera.js +11 -3
- package/src/figure/context.d.ts +16 -3
- package/src/figure/dimensions.js +140 -0
- package/src/figure/input.js +40 -16
- package/src/figure/labels.js +25 -10
- package/src/figure/loop.js +2 -0
- package/src/figure/pick.js +6 -4
- package/src/figure/steps.js +1 -0
- package/src/index.js +3 -0
- package/src/locales/en.js +1 -0
- package/src/locales/vi.js +1 -0
- package/src/renderer-gl.js +3 -1
- package/src/shaders.js +24 -16
- package/src/stylesheet.js +4 -2
- package/src/validate.js +39 -0
package/docs/api.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# API
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
|
-
// a page: one script tag, the global LK3D (https://unpkg.com/lk3d@0.2.
|
|
5
|
-
<script src="https://unpkg.com/lk3d@0.2.
|
|
4
|
+
// a page: one script tag, the global LK3D (https://unpkg.com/lk3d@0.2.1/dist/lk3d.min.js, or a copy of dist/lk3d.min.js)
|
|
5
|
+
<script src="https://unpkg.com/lk3d@0.2.1/dist/lk3d.min.js"></script>;
|
|
6
6
|
// or a module
|
|
7
7
|
import LK3D, { mount, build, defaults, locales } from 'lk3d';
|
|
8
8
|
```
|
|
@@ -62,35 +62,35 @@ try {
|
|
|
62
62
|
|
|
63
63
|
## The figure
|
|
64
64
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
| `set({ spin, explode, cut, section, xray, labels, style, theme, transparent, timeScale, projection, camera, glow, hide, move, joints })` | the spin angle (degrees) of parts with `spin`; how far apart (0 to 1); the cut (`true`, or 0 to 1: how far the plane has swept in, from just outside the model to the section); `section: {normal, offset}` moves the cut's plane; see-through casings; labels (`'auto'`, `'all'`, `'none'` or `[ids or groups]`); the look; the theme (`null`: none); no page behind the model; how fast particles and flows run (1; 0.2 for slow motion); `'perspective'` or `'ortho'`; `camera: {yaw, pitch, dist or zoom, target}`, placed at once (a gliding view stops); `glow: {id: 0..1}`; `hide: [ids or groups]`; `move: {id: [x, y, z]}` (a part moved by that much); `joints: {id: value}` (joints' values over their drives; each call replaces the last, so a joint left out follows its drive again; [joints](handles-and-lines.md#joints-parts-posed-by-how-they-are-joined)) |
|
|
68
|
-
| `view(name or [yaw, pitch] or {yaw, pitch, dist, zoom, target}, {ms})`
|
|
69
|
-
| `zoom(factor, x, y)`, `zoomLevel`
|
|
70
|
-
| `focus([ids or groups], {yaw, pitch, ms})`
|
|
71
|
-
| `step(index or id, {ms})`, `currentStep`, `steps`
|
|
72
|
-
| `explode(0 or 1)`
|
|
73
|
-
| `camera()`
|
|
74
|
-
| `select(id or null)`, `selected`
|
|
75
|
-
| `section`
|
|
76
|
-
| `labels`, `style`, `theme`, `timeScale`, `renderer`, `hifi`, `parts`
|
|
77
|
-
| `handle(id)`
|
|
78
|
-
| `motion(id)`
|
|
79
|
-
| `exportGLB({ animate, samples })`
|
|
80
|
-
| `liquid(id)`, `vessel(id)`, `gas(id)`
|
|
81
|
-
| `plume({at, height, radius})`
|
|
82
|
-
| `lines({ count, radius, color, studioColor, glow })`
|
|
83
|
-
| `flow({ path or paths, count, speed, amount, length, width, spread, ramp, part, closed })`
|
|
84
|
-
| `stream({ path, radius, speed, speeds, fade, density, turbulence, swirl, ramp })`
|
|
85
|
-
| `particles({ path, count, color, size, part, closed })`
|
|
86
|
-
| `particles({ count, radius, colors })`
|
|
87
|
-
| `tick(fn)`
|
|
88
|
-
| `ready`
|
|
89
|
-
| `redraw()`, `pick(x, y)`, `refreshMs`
|
|
90
|
-
| `drawNow()`
|
|
91
|
-
| `project([x, y, z], id)`
|
|
92
|
-
| `stats()`
|
|
93
|
-
| `destroy()`
|
|
65
|
+
| | |
|
|
66
|
+
| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
67
|
+
| `set({ spin, explode, cut, section, xray, labels, style, theme, transparent, timeScale, projection, camera, glow, hide, move, joints, dimensions })` | the spin angle (degrees) of parts with `spin`; how far apart (0 to 1); the cut (`true`, or 0 to 1: how far the plane has swept in, from just outside the model to the section); `section: {normal, offset, second}` moves the cut's plane (`second: {normal, offset}` a second plane for a quarter cut, only what lies beyond both cut away; `second: null` none); see-through casings; labels (`'auto'`, `'all'`, `'none'` or `[ids or groups]`); the look; the theme (`null`: none); no page behind the model; how fast particles and flows run (1; 0.2 for slow motion); `'perspective'` or `'ortho'`; `camera: {yaw, pitch, dist or zoom, target}`, placed at once (a gliding view stops); `glow: {id: 0..1}`; `hide: [ids or groups]`; `move: {id: [x, y, z]}` (a part moved by that much); `joints: {id: value}` (joints' values over their drives; each call replaces the last, so a joint left out follows its drive again; [joints](handles-and-lines.md#joints-parts-posed-by-how-they-are-joined)); `dimensions: [ids]` (the dimensions shown; `[]` none, `null` the scene's own: [dimensions](handles-and-lines.md#dimensions)) |
|
|
68
|
+
| `view(name or [yaw, pitch] or {yaw, pitch, dist, zoom, target}, {ms})` | glide the camera: `'front'`, `'side'`, `'top'`, `'iso'`, `'home'`; `zoom`: how close (2: twice as close as the whole model); `ms`: how long the glide takes (600; 0: at once) |
|
|
69
|
+
| `zoom(factor, x, y)`, `zoomLevel` | zoom by a factor towards a point of the stage (what is under it stays under it), as the wheel and a pinch do; how close the view is (the scene's `view.minZoom`, 0.02 by default, is the limit: 50 times closer) |
|
|
70
|
+
| `focus([ids or groups], {yaw, pitch, ms})` | frame those parts |
|
|
71
|
+
| `step(index or id, {ms})`, `currentStep`, `steps` | go to one of the scene's [guided steps](#guided-steps), gliding there (`ms: 0`: at once), without calling `onStep`; the step shown (from 0; `-1` for none); the scene's steps |
|
|
72
|
+
| `explode(0 or 1)` | take apart or put together, animated |
|
|
73
|
+
| `camera()` | `{yaw, pitch, dist, target}` (degrees, scene units) |
|
|
74
|
+
| `select(id or null)`, `selected` | choose a part (lit, its note shown) without calling `onPick`; the part chosen |
|
|
75
|
+
| `section` | the cut's plane now, `{normal, offset}`: the scene's, a step's, the page's, or where the reader moved it |
|
|
76
|
+
| `labels`, `style`, `theme`, `timeScale`, `renderer`, `hifi`, `parts` | the labels, look, theme and time scale in use; `'webgl2'`, `'webgl1'` or `'2d'`; the studio look's full lighting; the parts as built |
|
|
77
|
+
| `handle(id)` | `{ value, set(v) }` for a part with a handle ([handles](handles-and-lines.md)) |
|
|
78
|
+
| `motion(id)` | `{ value, playing, set(v), play(), stop() }` for a motion of the scene; `set({ motion: { id: value } })` sets several ([motions](handles-and-lines.md#motions-parts-that-move-together)) |
|
|
79
|
+
| `exportGLB({ animate, samples })` | the figure as glTF 2.0 binary (`Uint8Array`), posed as it is now; `animate`: each motion as an animation ([exporting](handles-and-lines.md#exporting-gltf)); needs the exporter, a script of its own |
|
|
80
|
+
| `liquid(id)`, `vessel(id)`, `gas(id)` | a liquid (`{ volume, level, set({volume}) }`), a vessel (`{ open, flow, set({open}) }`), a gas (`{ height, n, T, set({n, T, p, mass}) }`) ([liquids and gases](fluids.md)) |
|
|
81
|
+
| `plume({at, height, radius})` | warm air or smoke rising from `at` as a buoyant plume: a stream that widens and slows as one does |
|
|
82
|
+
| `lines({ count, radius, color, studioColor, glow })` | rods between points: `.set(k, a, b, r)` (segment k from a to b, its own radius r if given; `set(k, null)` hides it), `.clear()`, `.glow(v)`, `.remove()`; `.radius` and `.visible` (setting one draws again) |
|
|
83
|
+
| `flow({ path or paths, count, speed, amount, length, width, spread, ramp, part, closed })` | streaks of air, water or blood along paths, coloured by a ramp along them (also `opacity`): `.speed`, `.amount` (the share drawn), `.visible`, `.set({…})`, `.remove()` ([flow](handles-and-lines.md#flow)) |
|
|
84
|
+
| `stream({ path, radius, speed, speeds, fade, density, turbulence, swirl, ramp })` | air or gas as a moving volume along a path (a jet, an intake): `.speed`, `.density`, `.visible`, `.set({…})`, `.remove()` ([streams](handles-and-lines.md#streams)) |
|
|
85
|
+
| `particles({ path, count, color, size, part, closed })` | dots running along a path at `.speed` (negative: backwards); `part`: in that part's coordinates, so they move with it |
|
|
86
|
+
| `particles({ count, radius, colors })` | solid balls the page places: write `.positionsAndColors` (x, y, z, and 0..1 picking one of three colours), add 1 to `.version`, call `redraw()`; `.resize(n)` |
|
|
87
|
+
| `tick(fn)` | call `fn(now)` every frame while it returns true (`now`: the clock's milliseconds); returns a function that removes it |
|
|
88
|
+
| `ready` | a promise, resolved with the figure once it is complete: the first picture, the crease shading, every texture (for screenshots, print and tools) |
|
|
89
|
+
| `redraw()`, `pick(x, y)`, `refreshMs` | ask for a frame; the part under a point of the canvas; this screen's frame interval |
|
|
90
|
+
| `drawNow()` | draw the state as it is now, before returning (a tool that takes a picture right after setting it); `false` while the shaders are still compiling (await `ready` first) |
|
|
91
|
+
| `project([x, y, z], id)` | where a point of the scene is on the stage, `[x, y]` in CSS pixels from its top left, or `null` behind the eye; with a part's `id`, a point of that part as it is placed now (taken apart, moved, turned): for a page's own labels |
|
|
92
|
+
| `stats()` | what drawing costs here: setup, first picture, trees, crease shading (ms), triangles, resolution, textures still decoding, GPU |
|
|
93
|
+
| `destroy()` | take the figure down: timers, listeners and the GPU context released |
|
|
94
94
|
|
|
95
95
|
The figure draws only when something changes and pauses while it is off screen. A page's own simulation is better on
|
|
96
96
|
its own `requestAnimationFrame`, telling the figure the new state with `set` and `redraw`.
|
package/docs/design.md
CHANGED
|
@@ -45,6 +45,7 @@ lk3d is about 8 000 lines of plain JavaScript (ES modules, no dependencies). Thi
|
|
|
45
45
|
| `index.d.ts`, `scene.d.ts`, `scripts/types.mjs`, `tsconfig.json` | the TypeScript types: the page API by hand (`index.d.ts`), the scene's types generated from the schema (`scene.d.ts`, by `scripts/types.mjs`: `npm run types`); the sources are type-checked as JavaScript against them (`tsconfig.json`) |
|
|
46
46
|
| `build.mjs` | the bundle (esbuild), with the shaders' GLSL squeezed (comments and spaces out, line breaks kept) and the context's fields renamed short |
|
|
47
47
|
| `bin/lk3d.mjs` | the command line: `lk3d check`, `lk3d render` (the built engine in a headless browser) and `lk3d export` |
|
|
48
|
+
| `playground/` | the playground: an editor and the live figure (playground.js), the checks in a worker (check.js: lk3d/validate and lk3d/lint), each problem's place in the text (locate.js); published on GitHub Pages by `.github/workflows/pages.yml` |
|
|
48
49
|
|
|
49
50
|
## A mounted figure
|
|
50
51
|
|
|
@@ -181,9 +182,10 @@ schema makes.
|
|
|
181
182
|
a slider and a play button under the figure; liquids pouring and gases settling by their laws) or driven by the page
|
|
182
183
|
(spin, glow, particles, moved parts, a motion's value). There is no general physics engine; a page that simulates
|
|
183
184
|
writes its own model.
|
|
184
|
-
- The cut is one plane
|
|
185
|
-
face, or its slider) and a page can move, turn or sweep through the model (`set({ section, cut })`)
|
|
186
|
-
|
|
185
|
+
- The cut is one plane, or two for a quarter cut: the scene's (`section`), which the reader moves along its normal (dragging the cut
|
|
186
|
+
face, or its slider) and a page can move, turn or sweep through the model (`set({ section, cut })`). A second plane
|
|
187
|
+
(`section.second`) makes a quarter cut: only what lies beyond both is cut away; the reader drags either face. The
|
|
188
|
+
reader cannot turn a plane.
|
|
187
189
|
- Ambient occlusion is computed per part (a part's own creases and hollows), not between parts.
|
|
188
190
|
- The 2D fallback has no section view (its button is not offered) and no shadows, and draws balls without sorting them
|
|
189
191
|
by depth; WebGL 1 has no cast shadows, no glow halo, no surface detail, refraction or textures.
|
|
@@ -245,3 +245,30 @@ fig.drawNow();
|
|
|
245
245
|
Their time starts at 0, or where the clock last ran. When a speed changes, the thing goes on from where it was last
|
|
246
246
|
drawn at its new speed; a timeline that changes speeds as it goes seeks in order, as an export does, to draw the same
|
|
247
247
|
picture each time. No re-simulation is needed: their places follow from their seeds and the distance travelled.
|
|
248
|
+
|
|
249
|
+
## Dimensions
|
|
250
|
+
|
|
251
|
+
A scene's `dimensions` are drawn on the figure as on a technical drawing: a **length** between two points, with
|
|
252
|
+
extension lines out to a dimension line, arrows at its ends and its value; an **angle** at a vertex, an arc with arrows
|
|
253
|
+
and its value in degrees.
|
|
254
|
+
|
|
255
|
+
```json
|
|
256
|
+
"unit": "dm",
|
|
257
|
+
"dimensions": [
|
|
258
|
+
{ "id": "d", "name": "the object's distance", "from": { "part": "object", "at": [-4.5, 0, 0] }, "to": [0, 0, 0],
|
|
259
|
+
"offset": [0, -0.3, 0.5], "unit": "cm", "digits": 0 },
|
|
260
|
+
{ "id": "tilt", "angle": [[1, 0, 0], [0, 0, 0], [0.8, 0.6, 0]], "radius": 0.4 }
|
|
261
|
+
]
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
- **The value** is worked out from the points as they are shown, three significant figures by default (`digits` for a
|
|
265
|
+
fixed number of decimals), in the scene's `unit`, or converted to the dimension's own (`unit: "cm"` in a scene in
|
|
266
|
+
decimetres); an angle in degrees. `text` gives words of its own instead (`"Ø 40"`).
|
|
267
|
+
- **A point on a part**, `{part, at}` (`at` where it is with the part at rest), moves with the part: taken apart, moved
|
|
268
|
+
by a motion or a joint, or by the reader's handle. A length to it changes as it moves: the lens bench's distance from
|
|
269
|
+
the object to the lens follows the object as the reader slides it ([example](../examples/lens.html)).
|
|
270
|
+
- **Where the line goes**: `offset` moves the dimension line off the points, extension lines reaching out to it. An
|
|
271
|
+
angle's arc is a third of its shorter arm from the vertex unless `radius` says; `arms: true` draws the arms too.
|
|
272
|
+
- **Which show**: every dimension the scene does not mark `hidden`; a step shows exactly the ones it names
|
|
273
|
+
(`dimensions: ["d"]`, or `[]` for none), and a page sets them (`fig.set({ dimensions: ["d"] })`, `null` for the
|
|
274
|
+
scene's own). Screen readers find them listed with their values, each called by its `name`.
|
package/docs/performance.md
CHANGED
|
@@ -13,12 +13,13 @@ gzipped), outside the budget: a page loads it only to export.
|
|
|
13
13
|
|
|
14
14
|
| | Minified | Gzipped |
|
|
15
15
|
| --------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
|
|
16
|
+
| lk3d 0.2.1 | 170.5 KB | 66.6 KB |
|
|
16
17
|
| lk3d 0.2.0 | 166.0 KB | 64.9 KB |
|
|
17
18
|
| lk3d 0.1.0 | 148.0 KB | 59.2 KB |
|
|
18
19
|
| three.js r187, the smallest page (renderer, camera, box, basic material) | 522 KB | 131 KB |
|
|
19
20
|
| three.js r187 with what lk3d does (PBR and glass, shadows, environment, orbit controls, picking, glTF, labels, bloom, shape generators) | 708 KB | 181 KB |
|
|
20
21
|
|
|
21
|
-
Measured with esbuild (minify, ES2020) and gzip level 9 (lk3d by `npm run size`, 11 November 2026:
|
|
22
|
+
Measured with esbuild (minify, ES2020) and gzip level 9 (lk3d by `npm run size`, 11 November 2026: 68 157 bytes, 451 under the budget; three.js, 2 November 2026).
|
|
22
23
|
|
|
23
24
|
## Frames
|
|
24
25
|
|
package/docs/scene-format.md
CHANGED
|
@@ -33,6 +33,7 @@ A 3D figure as data: parts made of shapes, each with a name and a note, that the
|
|
|
33
33
|
| `motions` | list of object | Parts that move together as one value goes along a range: a piston's stroke as the crank turns, a sleeve sliding back, a valve opening. Set or played by the page (fig.motion(id)) and, when named, by the reader (a slider and a play button); run through its range by the geometry check. |
|
|
34
34
|
| `joints` | list of object | Parts posed by how they are joined, not by keys for each: a crank driven by a motion, a piston held by its rod, a rod aimed at the crank pin, a cam that follows at half speed. A joint's value comes from a motion, another joint, a rod, an aim, or the page (set({ joints })). |
|
|
35
35
|
| `scale` | object | Honest scale: a bar that keeps its true length as the view zooms, and/or a note saying what is not to scale. |
|
|
36
|
+
| `dimensions` | list of object | Dimensions drawn on the figure: lengths between points and angles at vertices, with their values, as on a technical drawing; worked out from the points as shown, so a length to a moving part changes as it moves. |
|
|
36
37
|
| `models` | map of name → object | glTF 2.0 models (.glb) by name, for {model: name} shapes. |
|
|
37
38
|
| `unit` | `"mm"` \| `"cm"` \| `"dm"` \| `"m"` \| `"km"` | What one scene unit is (m): the laws of liquids and gases (g, R) are worked out in it. |
|
|
38
39
|
| `vessels` | list of object | Parts that hold liquids or a gas: the radius of their inside at each height, and an outlet they pour through. |
|
package/index.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export interface Strings {
|
|
|
71
71
|
/** the slider that moves the cut, while it is on, and what a screen reader calls it */
|
|
72
72
|
cutAt: string;
|
|
73
73
|
cutAtLabel: string;
|
|
74
|
+
/** what screen readers call the list of the figure's dimensions */
|
|
75
|
+
dimensions: string;
|
|
74
76
|
/** the guided steps' panel, its buttons, and where the reader is ("{n}" and "{count}" are filled in) */
|
|
75
77
|
steps: string;
|
|
76
78
|
back: string;
|
|
@@ -283,6 +285,8 @@ export interface Figure {
|
|
|
283
285
|
motion?: Record<string, number>;
|
|
284
286
|
/** joints' values, by id, over their drives (a joint held by a rod or an aim keeps to it); each call replaces the last */
|
|
285
287
|
joints?: Record<string, number>;
|
|
288
|
+
/** the dimensions shown, by id ([]: none), or null: the scene's own (those not hidden) */
|
|
289
|
+
dimensions?: string[] | null;
|
|
286
290
|
}): void;
|
|
287
291
|
/** a motion of the scene, to set or play */
|
|
288
292
|
/** the figure as glTF 2.0 binary (.glb), posed as it is now; animate: each motion as an animation. Needs the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lk3d",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A small engine for explorable, accessible 3D diagrams built from data: take apart, cut open, label, move parts by hand",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"lint": "eslint . && prettier --check .",
|
|
89
89
|
"format": "prettier --write .",
|
|
90
90
|
"examples": "node build.mjs && node test/visual/serve.mjs",
|
|
91
|
+
"playground": "node build.mjs && node test/visual/serve.mjs",
|
|
91
92
|
"docs": "node docs/scene-format.mjs && node docs/shapes/render.mjs",
|
|
92
93
|
"prepublishOnly": "npm run lint && npm test && npm run typecheck && npm run size",
|
|
93
94
|
"prepack": "node build.mjs"
|
package/scene.d.ts
CHANGED
|
@@ -122,6 +122,16 @@ export interface Scene {
|
|
|
122
122
|
* while the model is cut open, the reader moves the plane along its normal.
|
|
123
123
|
*/
|
|
124
124
|
fixed?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* A second plane, for a quarter cut: then only what lies beyond both planes is cut away (two planes at right
|
|
127
|
+
* angles take out a quarter). false: none (a step's, over the scene's).
|
|
128
|
+
*/
|
|
129
|
+
second?:
|
|
130
|
+
| false
|
|
131
|
+
| {
|
|
132
|
+
normal?: Vec3;
|
|
133
|
+
offset?: number;
|
|
134
|
+
};
|
|
125
135
|
};
|
|
126
136
|
/**
|
|
127
137
|
* Parts that move together as one value goes along a range: a piston's stroke as the crank turns, a sleeve
|
|
@@ -139,6 +149,11 @@ export interface Scene {
|
|
|
139
149
|
* Honest scale: a bar that keeps its true length as the view zooms, and/or a note saying what is not to scale.
|
|
140
150
|
*/
|
|
141
151
|
scale?: SceneScale;
|
|
152
|
+
/**
|
|
153
|
+
* Dimensions drawn on the figure: lengths between points and angles at vertices, with their values, as on a
|
|
154
|
+
* technical drawing; worked out from the points as shown, so a length to a moving part changes as it moves.
|
|
155
|
+
*/
|
|
156
|
+
dimensions?: Dimension[];
|
|
142
157
|
/** glTF 2.0 models (.glb) by name, for {model: name} shapes. */
|
|
143
158
|
models?: { [key: string]: Model };
|
|
144
159
|
/** What one scene unit is (m): the laws of liquids and gases (g, R) are worked out in it. */
|
|
@@ -293,6 +308,65 @@ export interface SceneScaleFields {
|
|
|
293
308
|
note?: string;
|
|
294
309
|
}
|
|
295
310
|
|
|
311
|
+
/**
|
|
312
|
+
* A dimension drawn on the figure, as on a technical drawing: a length between two points (extension lines, a
|
|
313
|
+
* dimension line with arrows, its value), or an angle at a vertex (an arc with arrows, its value in degrees).
|
|
314
|
+
* Its value is worked out from the points as they are shown (in the scene's unit, when it has one), unless
|
|
315
|
+
* text says otherwise.
|
|
316
|
+
*/
|
|
317
|
+
export type Dimension = Form<DimensionFields, 'from' | 'to'> | Form<DimensionFields, 'angle'>;
|
|
318
|
+
|
|
319
|
+
/** the fields of Dimension, each optional (Dimension says which are required, together) */
|
|
320
|
+
export interface DimensionFields {
|
|
321
|
+
/**
|
|
322
|
+
* Unique among the dimensions: what steps and the page name it by.
|
|
323
|
+
* @minLength 1
|
|
324
|
+
*/
|
|
325
|
+
id?: string;
|
|
326
|
+
/**
|
|
327
|
+
* What is measured, for screen readers ("the piston's stroke").
|
|
328
|
+
* @minLength 1
|
|
329
|
+
*/
|
|
330
|
+
name?: string;
|
|
331
|
+
/** A length's first end. */
|
|
332
|
+
from?: Point;
|
|
333
|
+
/** A length's other end. */
|
|
334
|
+
to?: Point;
|
|
335
|
+
/**
|
|
336
|
+
* Where the dimension line is drawn: the two ends moved by this much (default: on the points themselves), with
|
|
337
|
+
* extension lines out to it.
|
|
338
|
+
*/
|
|
339
|
+
offset?: Vec3;
|
|
340
|
+
/** An angle: a point on one arm, the vertex, a point on the other arm. */
|
|
341
|
+
angle?: [Point, Point, Point];
|
|
342
|
+
/**
|
|
343
|
+
* An angle's arc radius (default: a third of the shorter arm).
|
|
344
|
+
* @exclusiveMinimum 0
|
|
345
|
+
*/
|
|
346
|
+
radius?: number;
|
|
347
|
+
/** Draw an angle's arms from the vertex (false by default: they are usually edges of the model). */
|
|
348
|
+
arms?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* The value shown, in place of the one worked out ("Ø 40", "stroke").
|
|
351
|
+
* @minLength 1
|
|
352
|
+
*/
|
|
353
|
+
text?: string;
|
|
354
|
+
/**
|
|
355
|
+
* Decimals in the value worked out (default: three significant figures).
|
|
356
|
+
* @minimum 0
|
|
357
|
+
* @maximum 6
|
|
358
|
+
* @integer
|
|
359
|
+
*/
|
|
360
|
+
digits?: number;
|
|
361
|
+
/** Not shown unless a step or the page names it. */
|
|
362
|
+
hidden?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* The unit a length's value is given in (the scene's unit by default); converted from the scene's unit, which
|
|
365
|
+
* it needs.
|
|
366
|
+
*/
|
|
367
|
+
unit?: 'mm' | 'cm' | 'dm' | 'm' | 'km';
|
|
368
|
+
}
|
|
369
|
+
|
|
296
370
|
/** a model needs its .glb: data (base64) or file (a path) */
|
|
297
371
|
export type Model = Form<ModelFields, 'data'> | Form<ModelFields, 'file'>;
|
|
298
372
|
|
|
@@ -553,6 +627,16 @@ export interface StepFields {
|
|
|
553
627
|
section?: {
|
|
554
628
|
normal?: Vec3;
|
|
555
629
|
offset?: number;
|
|
630
|
+
/**
|
|
631
|
+
* A second plane, for a quarter cut: then only what lies beyond both planes is cut away (two planes at right
|
|
632
|
+
* angles take out a quarter). false: none (a step's, over the scene's).
|
|
633
|
+
*/
|
|
634
|
+
second?:
|
|
635
|
+
| false
|
|
636
|
+
| {
|
|
637
|
+
normal?: Vec3;
|
|
638
|
+
offset?: number;
|
|
639
|
+
};
|
|
556
640
|
};
|
|
557
641
|
/** Casings see-through. */
|
|
558
642
|
xray?: boolean;
|
|
@@ -572,6 +656,10 @@ export interface StepFields {
|
|
|
572
656
|
motion?: { [key: string]: number };
|
|
573
657
|
/** Motions played as the step comes, from the value it gives them. */
|
|
574
658
|
play?: string[];
|
|
659
|
+
/**
|
|
660
|
+
* The dimensions shown in this step, by id (none: [ ]); without it, the scene's own (those not hidden).
|
|
661
|
+
*/
|
|
662
|
+
dimensions?: string[];
|
|
575
663
|
}
|
|
576
664
|
|
|
577
665
|
/** Parts that move one way: moved, turned, or both (moved, then turned). */
|
|
@@ -593,6 +681,22 @@ export interface MotionTrackFields {
|
|
|
593
681
|
ease?: boolean;
|
|
594
682
|
}
|
|
595
683
|
|
|
684
|
+
/**
|
|
685
|
+
* A point of the scene, [x, y, z], or one carried by a part, {part, at}: it moves as the part does (taken
|
|
686
|
+
* apart, moved by a motion or a handle), so what is measured to it is measured as shown.
|
|
687
|
+
*/
|
|
688
|
+
export type Point =
|
|
689
|
+
| Vec3
|
|
690
|
+
| {
|
|
691
|
+
/**
|
|
692
|
+
* The part that carries it.
|
|
693
|
+
* @minLength 1
|
|
694
|
+
*/
|
|
695
|
+
part: string;
|
|
696
|
+
/** The point, in the part's own place at rest. */
|
|
697
|
+
at: Vec3;
|
|
698
|
+
};
|
|
699
|
+
|
|
596
700
|
/**
|
|
597
701
|
* How it reflects light in the studio look (and how much light wraps round into it, for soft materials).
|
|
598
702
|
*/
|