@entro314labs/iso-engine 0.0.0-stage → 0.5.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -2
  3. package/THIRD_PARTY_NOTICES.md +39 -0
  4. package/dist/engine/anim.js +225 -0
  5. package/dist/engine/behaviors.js +105 -0
  6. package/dist/engine/diagram.js +80 -0
  7. package/dist/engine/draw.js +117 -0
  8. package/dist/engine/export.js +81 -0
  9. package/dist/engine/figure.js +35 -0
  10. package/dist/engine/global.js +4 -0
  11. package/dist/engine/index.d.ts +278 -0
  12. package/dist/engine/index.js +164 -0
  13. package/dist/engine/math.js +190 -0
  14. package/dist/engine/node.js +290 -0
  15. package/dist/engine/paths.js +76 -0
  16. package/dist/engine/prefabs/architecture.js +136 -0
  17. package/dist/engine/prefabs/basics.js +131 -0
  18. package/dist/engine/prefabs/devices.js +295 -0
  19. package/dist/engine/prefabs/icons.js +49 -0
  20. package/dist/engine/prefabs/index.js +12 -0
  21. package/dist/engine/prefabs/logistics.js +156 -0
  22. package/dist/engine/scene.js +466 -0
  23. package/dist/engine/shapes.js +781 -0
  24. package/dist/engine/sort.js +153 -0
  25. package/dist/engine/spec.js +81 -0
  26. package/dist/engine/style.js +87 -0
  27. package/dist/engine.css +1 -0
  28. package/dist/figure.css +93 -0
  29. package/dist/figure.d.ts +22 -0
  30. package/dist/figure.js +73 -0
  31. package/dist/filters.d.ts +9 -0
  32. package/dist/filters.js +22 -0
  33. package/dist/index.d.ts +9 -0
  34. package/dist/index.js +8 -0
  35. package/dist/iso.global.js +7990 -0
  36. package/dist/kernel.d.ts +102 -0
  37. package/dist/kernel.js +172 -0
  38. package/dist/loops.d.ts +49 -0
  39. package/dist/loops.js +64 -0
  40. package/dist/patterns.d.ts +44 -0
  41. package/dist/patterns.js +97 -0
  42. package/dist/theme.css +19 -0
  43. package/dist/types.d.ts +86 -0
  44. package/dist/types.js +1 -0
  45. package/package.json +50 -4
  46. package/skills/iso-engine/SKILL.md +143 -0
  47. package/skills/iso-engine/examples/engine.html +42 -0
  48. package/skills/iso-engine/examples/figure.html +51 -0
  49. package/skills/iso-engine/examples/loop.html +68 -0
  50. package/skills/iso-engine/examples/loop.js +36 -0
  51. package/skills/iso-engine/examples/matcher.js +134 -0
  52. package/skills/iso-engine/examples/spec.html +42 -0
  53. package/skills/iso-engine/references/animation.md +116 -0
  54. package/skills/iso-engine/references/api.md +207 -0
  55. package/skills/iso-engine/references/composition.md +66 -0
  56. package/skills/iso-engine/references/diagrams.md +68 -0
  57. package/skills/iso-engine/references/figures.md +359 -0
  58. package/skills/iso-engine/references/loops.md +126 -0
  59. package/skills/iso-engine/references/prefabs.md +103 -0
  60. package/skills/iso-engine/references/spec.md +66 -0
  61. package/skills/iso-engine/references/style.md +76 -0
  62. package/skills/iso-engine/references/troubleshooting.md +49 -0
  63. package/skills/iso-engine/scripts/build.mjs +35 -0
@@ -0,0 +1,76 @@
1
+ # Visual language
2
+
3
+ The look: technical line drawings in true isometric, quiet enough to breathe, with one thing that
4
+ glows. Think architectural axonometrics and product cutaways, not 3D-rendered blobs.
5
+
6
+ ## Line
7
+
8
+ - 1px hairlines, non-scaling, round joins. The engine handles this; never thicken lines to fix a weak
9
+ composition.
10
+ - Three weights, by role: `ln` for silhouettes and primary edges, `ln-soft` for drawn detail
11
+ (vents, slots, panel seams), `ln-faint` for texture (window mullions, floor grids, belts).
12
+ - Use `ln-strong` / `ln-bold` sparingly: an arrow, a selected path, a dotted wire to a lit object.
13
+
14
+ ## Fill
15
+
16
+ - Fills sit a hair off the page colour. Three tones imply light: top > left > right (dark themes),
17
+ so solids occlude without outlines doing all the work.
18
+ - No gradients, no drop shadows, no textures painted on surfaces. Depth comes from occlusion, tone
19
+ and line.
20
+ - `screen` (dark glass) for displays, `dark` for asphalt/panels/wheels, `glass` for panes you can see
21
+ through, `ghost`/`wire` for things that are planned, hidden or "not yet".
22
+
23
+ ## The lit moment
24
+
25
+ - At most one idea glows: a card, a screen, a selected node, the windows that are on, LEDs.
26
+ - The lit state must read at thumbnail size. Small lit things (a key, a card, LEDs, windows) are solid accent. A large
27
+ lit surface (a screen, a sheet, a band) stays glass — `material: 'glass'` or the accent at reduced strength with an
28
+ accent edge — with a bloom of light behind it, never a flat accent slab, or it turns into a blob. With `figure.css` and
29
+ the glow filters on the page, a flat shape with `class: 'glow-halo'` just before the lit object gives that bloom
30
+ (`halo()` from `@entro314labs/iso-engine/loops` adds one).
31
+ - Pair `material: 'lit'` with `glow: true` on small objects; leave glow off for many tiny lights
32
+ (lit windows, LEDs) — the contrast is enough.
33
+
34
+ ## Form
35
+
36
+ - Machined, rounded objects: `r` (plan radius ≥ the bevel) and a `chamfer` of 1–3 units on boxes that
37
+ are bigger than ~20 units. Tiny parts (keys, pins) keep `chamfer` ≤ 0.8.
38
+ - Details are drawn, not implied: vents, keys, screws, windows, cables. A face with nothing on it is
39
+ fine only if the object is genuinely plain.
40
+ - Proportions: real-world proportions read best. A phone is ~13×27, a laptop ~40×28, a door ~8×20,
41
+ a person-scale building floor ~10 units.
42
+
43
+ ## Composition
44
+
45
+ - One focal point. Put it slightly off-centre on the platform; let everything else support it.
46
+ - Empty space is material: leave 15–25% of the platform clear. Do not fill every corner.
47
+ - Diorama hierarchy: platform → large structures → medium objects → small scatter (trees, lamps).
48
+ - Repeated objects (trees, phones, windows) vary slightly (seeded scale, kind) — never randomly per load.
49
+ - Text belongs in the caption frame or on planes as engraved labels (`plane: 'top'`), mono, uppercase,
50
+ tracked. Use `label` callouts in diagrams. Keep in-figure text short (1–3 words).
51
+
52
+ ## Frame
53
+
54
+ `figure: { index, title, hint, status }` gives the caption grammar used by the references:
55
+ `Fig. 2` (top-left) · `DESK COMPUTER` (top-right) · `TYPE ON IT · CLICK IT TO SWITCH` (bottom-left) ·
56
+ `on · 4 chars · key k` (bottom-right, live state). Update the state with `s.status(text)`.
57
+
58
+ ## Colour and themes
59
+
60
+ - Default `dark`: near-black page, warm off-white ink. `light` and `paper` invert tone order so the top
61
+ stays closest to paper. `blueprint` and `terminal` are expressive variants — use when asked.
62
+ - A brand colour enters as `colors: { accent }` + `material: 'accent'` on the one lit object, or as
63
+ `color: '#hex'` tints on a few objects. Never more than one hue besides the neutrals.
64
+
65
+ ## Motion
66
+
67
+ - Physical and optional: ease-out entrances (`ease: 'out'`), 0.2–1s transitions, loops ≥ 2s.
68
+ - One entrance per figure (usually `assemble`, back to front). At most two ambient loops (e.g. travel
69
+ + blink). Motion should explain something: data flowing, a device responding, a process cycling.
70
+ - Interaction is a bonus, not a requirement: hover lifts, click toggles, typing. Always keyboard
71
+ operable (the engine makes clickable nodes focusable; give them a `label`).
72
+
73
+ ## Never
74
+
75
+ People at laptops, generic office stock, third-party logos, emoji, rainbow palettes, heavy glows,
76
+ 3D "blob" characters, perspective (keep it isometric), text paragraphs inside the drawing.
@@ -0,0 +1,49 @@
1
+ # Troubleshooting
2
+
3
+ ## Something is drawn in front of what should hide it (or behind)
4
+
5
+ The engine sorts by world bounding boxes: two objects are ordered by the axis that separates them.
6
+ It fails only when boxes genuinely interpenetrate or one shape wraps around another.
7
+
8
+ - **Enclosing shapes** (rings, U-shapes, courtyards): use `tube` for rings (already segmented); split
9
+ U/L shapes into separate boxes.
10
+ - **Concave prisms with things in the notch**: split the prism into convex boxes.
11
+ - **Objects sunk into a surface**: fine within a few units (resolved by least penetration); put them on
12
+ the surface (`z` = surface height) to be safe.
13
+ - **Long thin lines crossing tall objects**: lines on the floor are behind anything standing on the
14
+ floor. A line meant to pass *over* something must be higher than it.
15
+ - **A decal that must win**: `layer: 1` puts it above everything it overlaps (labels do this).
16
+ - **Parts inside a prefab** draw in the order added when the prefab uses `sort: 'none'`; reorder them.
17
+
18
+ ## An arrow or the end of a line is missing
19
+
20
+ It is hidden behind a tall node: a floor point within `h` behind a node's −x/−y faces is occluded.
21
+ Use the `diagram` builder (trims automatically), approach from the front, or end the line further out.
22
+
23
+ ## Text overflows a face or is unreadable
24
+
25
+ Shorten it (1–2 words), lower `size`, or move it off the face: a `label` callout, a `text` on the
26
+ floor (`plane: 'top'`), or the figure caption. Labels on lit objects use `tx-on-lit` automatically in
27
+ `block`; elsewhere pass `cls: 'tx tx-label tx-on-lit'`.
28
+
29
+ ## The figure is tiny / huge / off-centre
30
+
31
+ The viewBox fits everything that is drawn — including far-away decals or a stray object at the wrong
32
+ coordinates. Check positions; use `padding`, `zoom`, `aspect`, or an explicit `view`. Moving objects
33
+ leave the fitted area? Add `extend: [top, right, bottom, left]`.
34
+
35
+ ## Animation does nothing
36
+
37
+ - Targets: `'#id'`/`'id'` match ids, `'.name'` matches `class`, `'card*'` matches id prefixes.
38
+ - Two writers on one property: timelines run first, then loops (`travel`, custom `loop`), then reactive
39
+ tweens. A `travel` will override a timeline's `x/y/z` on the same node — animate a parent group instead.
40
+ - `float` and `pulse` are additive (they combine with other motion).
41
+ - Reduced motion: the scene shows its rest pose. Test in a real browser with motion allowed
42
+ (or emulate `prefers-reduced-motion` in the devtools to check the rest pose).
43
+
44
+ ## Performance
45
+
46
+ - ~1,500 nodes and dozens of movers run at 60 fps; per-frame JS cost is ~1–3 ms.
47
+ - Expensive: re-drawing geometry every frame (`spin`, animating `h`, `rot` on big groups). Prefer moving
48
+ (`x/y/z`), fading (`opacity`) or scaling — those are transforms.
49
+ - Thousands of trees: lower `count`, or use `kind: 'cone'` (fewer parts) for distant ones.
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ /* Make an engine page self-contained: inline every local classic <script src="…"> so the file works anywhere — an
3
+ artifact, an email attachment, a static host, file://. A script named iso.js or iso.global.js that isn't beside the
4
+ page is taken from this package's dist/iso.global.js. CDN scripts and ES modules are left as they are.
5
+
6
+ node build.mjs page.html → page.standalone.html
7
+ node build.mjs page.html --out out/figure.html */
8
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
9
+ import { dirname, resolve, basename, extname, join } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ const args = process.argv.slice(2);
13
+ const src = args.find((a) => !a.startsWith('--'));
14
+ if (!src) { console.error('usage: build.mjs <page.html> [--out file.html]'); process.exit(1); }
15
+ const outIdx = args.indexOf('--out');
16
+ const out = outIdx >= 0 ? args[outIdx + 1] : join(dirname(src), basename(src, extname(src)) + '.standalone.html');
17
+ const here = dirname(fileURLToPath(import.meta.url));
18
+ const engine = resolve(here, '../../../dist/iso.global.js');
19
+
20
+ let html = readFileSync(src, 'utf8');
21
+ let count = 0;
22
+ html = html.replace(/<script([^>]*)\ssrc=["']([^"']+)["']([^>]*)><\/script>/g, (m, a, href, b) => {
23
+ if (/^(https?:)?\/\//.test(href) || /type=["']module["']/.test(a + b)) return m;
24
+ let file = resolve(dirname(src), href);
25
+ if (!existsSync(file) && /(^|\/)iso(\.global)?\.js$/.test(href)) file = engine;
26
+ if (!existsSync(file)) {
27
+ console.error(`not found: ${href}` + (file === engine ? ` (nor ${engine}: build the package first)` : ''));
28
+ process.exit(1);
29
+ }
30
+ count++;
31
+ const code = readFileSync(file, 'utf8').replace(/<\/script/gi, '<\\/script');
32
+ return '<script' + a + b + '>\n' + code + '\n</script>';
33
+ });
34
+ writeFileSync(out, html);
35
+ console.log(`inlined ${count} script(s) → ${out} (${(Buffer.byteLength(html) / 1024).toFixed(1)} KB)`);