@opsydyn/effect-three 0.3.0 → 0.4.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +12 -0
  3. package/dist/{index-8cf8t6by.js → index-h3vf50fn.js} +2113 -83
  4. package/dist/index-h3vf50fn.js.map +53 -0
  5. package/dist/index-ttwy0znv.js +145 -0
  6. package/dist/index-ttwy0znv.js.map +12 -0
  7. package/dist/index.js +488 -147
  8. package/dist/index.js.map +8 -6
  9. package/dist/kernel/boxSelect.d.ts +22 -0
  10. package/dist/kernel/boxSelect.d.ts.map +1 -0
  11. package/dist/kernel/build.d.ts +142 -6
  12. package/dist/kernel/build.d.ts.map +1 -1
  13. package/dist/kernel/cameraShake.d.ts.map +1 -1
  14. package/dist/kernel/describeScene.d.ts +50 -0
  15. package/dist/kernel/describeScene.d.ts.map +1 -0
  16. package/dist/kernel/description.d.ts +155 -1
  17. package/dist/kernel/description.d.ts.map +1 -1
  18. package/dist/kernel/diff.d.ts +15 -0
  19. package/dist/kernel/diff.d.ts.map +1 -1
  20. package/dist/kernel/equality.d.ts +9 -1
  21. package/dist/kernel/equality.d.ts.map +1 -1
  22. package/dist/kernel/gizmo.d.ts +69 -0
  23. package/dist/kernel/gizmo.d.ts.map +1 -0
  24. package/dist/kernel/history.d.ts +61 -0
  25. package/dist/kernel/history.d.ts.map +1 -0
  26. package/dist/kernel/index.d.ts +13 -2
  27. package/dist/kernel/index.d.ts.map +1 -1
  28. package/dist/kernel/index.js +106 -3
  29. package/dist/kernel/index.js.map +1 -1
  30. package/dist/kernel/inspect.d.ts +85 -0
  31. package/dist/kernel/inspect.d.ts.map +1 -0
  32. package/dist/kernel/lineGeometry.d.ts +25 -0
  33. package/dist/kernel/lineGeometry.d.ts.map +1 -0
  34. package/dist/kernel/lockstep.d.ts +114 -0
  35. package/dist/kernel/lockstep.d.ts.map +1 -0
  36. package/dist/kernel/loop.d.ts.map +1 -1
  37. package/dist/kernel/materials.d.ts.map +1 -1
  38. package/dist/kernel/pivot.d.ts +54 -0
  39. package/dist/kernel/pivot.d.ts.map +1 -0
  40. package/dist/kernel/pointBuffers.d.ts +17 -0
  41. package/dist/kernel/pointBuffers.d.ts.map +1 -0
  42. package/dist/kernel/pointer.d.ts +12 -0
  43. package/dist/kernel/pointer.d.ts.map +1 -1
  44. package/dist/kernel/renderKit.d.ts +21 -1
  45. package/dist/kernel/renderKit.d.ts.map +1 -1
  46. package/dist/kernel/renderer.d.ts +6 -0
  47. package/dist/kernel/renderer.d.ts.map +1 -1
  48. package/dist/kernel/sceneChanges.d.ts +87 -0
  49. package/dist/kernel/sceneChanges.d.ts.map +1 -0
  50. package/dist/kernel/sceneGraph.d.ts +6 -0
  51. package/dist/kernel/sceneGraph.d.ts.map +1 -1
  52. package/dist/kernel/seeded.d.ts +9 -0
  53. package/dist/kernel/seeded.d.ts.map +1 -0
  54. package/dist/kernel/shots.d.ts +26 -0
  55. package/dist/kernel/shots.d.ts.map +1 -0
  56. package/dist/kernel/tape.d.ts +38 -0
  57. package/dist/kernel/tape.d.ts.map +1 -0
  58. package/dist/kernel/trail.d.ts +31 -0
  59. package/dist/kernel/trail.d.ts.map +1 -0
  60. package/dist/kernel/viewportGizmo.d.ts +25 -0
  61. package/dist/kernel/viewportGizmo.d.ts.map +1 -0
  62. package/dist/runtime/Inspector.d.ts +20 -0
  63. package/dist/runtime/Inspector.d.ts.map +1 -0
  64. package/dist/runtime/SceneFile.d.ts +448 -0
  65. package/dist/runtime/SceneFile.d.ts.map +1 -0
  66. package/dist/runtime/SceneSchema.d.ts +318 -0
  67. package/dist/runtime/SceneSchema.d.ts.map +1 -1
  68. package/dist/runtime/errors.d.ts +9 -0
  69. package/dist/runtime/errors.d.ts.map +1 -1
  70. package/dist/runtime/index.d.ts +3 -1
  71. package/dist/runtime/index.d.ts.map +1 -1
  72. package/dist/webgl/index.d.ts.map +1 -1
  73. package/dist/webgl/index.js +228 -3
  74. package/dist/webgl/index.js.map +6 -4
  75. package/dist/webgl/line.d.ts +4 -0
  76. package/dist/webgl/line.d.ts.map +1 -0
  77. package/dist/webgl/points.d.ts +4 -0
  78. package/dist/webgl/points.d.ts.map +1 -0
  79. package/dist/webgpu/index.d.ts.map +1 -1
  80. package/dist/webgpu/index.js +206 -26
  81. package/dist/webgpu/index.js.map +6 -4
  82. package/dist/webgpu/line.d.ts +4 -0
  83. package/dist/webgpu/line.d.ts.map +1 -0
  84. package/dist/webgpu/points.d.ts +4 -0
  85. package/dist/webgpu/points.d.ts.map +1 -0
  86. package/package.json +2 -1
  87. package/src/kernel/boxSelect.ts +73 -0
  88. package/src/kernel/build.ts +332 -0
  89. package/src/kernel/cameraShake.ts +3 -13
  90. package/src/kernel/describeScene.ts +224 -0
  91. package/src/kernel/description.ts +175 -0
  92. package/src/kernel/diff.ts +39 -0
  93. package/src/kernel/equality.ts +101 -0
  94. package/src/kernel/gizmo.ts +478 -0
  95. package/src/kernel/history.ts +118 -0
  96. package/src/kernel/index.ts +97 -0
  97. package/src/kernel/inspect.ts +214 -0
  98. package/src/kernel/lineGeometry.ts +75 -0
  99. package/src/kernel/lockstep.ts +237 -0
  100. package/src/kernel/loop.ts +5 -0
  101. package/src/kernel/materials.ts +3 -0
  102. package/src/kernel/pivot.ts +418 -0
  103. package/src/kernel/pointBuffers.ts +115 -0
  104. package/src/kernel/pointer.ts +55 -12
  105. package/src/kernel/renderKit.ts +23 -1
  106. package/src/kernel/renderer.ts +6 -0
  107. package/src/kernel/sceneChanges.ts +265 -0
  108. package/src/kernel/sceneGraph.ts +319 -8
  109. package/src/kernel/seeded.ts +18 -0
  110. package/src/kernel/shots.ts +167 -0
  111. package/src/kernel/tape.ts +124 -0
  112. package/src/kernel/trail.ts +170 -0
  113. package/src/kernel/viewportGizmo.ts +194 -0
  114. package/src/runtime/Inspector.ts +43 -0
  115. package/src/runtime/SceneFile.ts +46 -0
  116. package/src/runtime/SceneSchema.ts +247 -0
  117. package/src/runtime/errors.ts +6 -0
  118. package/src/runtime/index.ts +3 -1
  119. package/src/webgl/index.ts +4 -0
  120. package/src/webgl/line.ts +66 -0
  121. package/src/webgl/points.ts +205 -0
  122. package/src/webgpu/index.ts +4 -0
  123. package/src/webgpu/line.ts +67 -0
  124. package/src/webgpu/points.ts +193 -0
  125. package/dist/index-8cf8t6by.js.map +0 -41
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0](https://github.com/opsydyn/fold-kit-experiments/compare/effect-three-v0.3.0...effect-three-v0.4.0) (2026-10-20)
4
+
5
+ ### Features
6
+
7
+ - **effect-three:** a HUD, and the viewport gizmo in it ([a1d99d4](https://github.com/opsydyn/fold-kit-experiments/commit/a1d99d477d80744652237c0718fe0f2418490ea8))
8
+ - **effect-three:** a measuring tape, the last widget of Beyond parity 5 ([0a05ae0](https://github.com/opsydyn/fold-kit-experiments/commit/0a05ae04b0ccfd616f945f26429b27acbe79f108))
9
+ - **effect-three:** a scene vocabulary for assistants ([a138ccb](https://github.com/opsydyn/fold-kit-experiments/commit/a138ccb3c38226149b44d7b56ce488be8ebbcd89))
10
+ - **effect-three:** a transform gizmo as data, and as a Foldkit submodel ([3b1e585](https://github.com/opsydyn/fold-kit-experiments/commit/3b1e58535b35669917c3325214199f9264fb314c))
11
+ - **effect-three:** an inspector generated from schemas ([64d1d3b](https://github.com/opsydyn/fold-kit-experiments/commit/64d1d3b8bf9991c57c1cf56b94a8b3f1c773b17d))
12
+ - **effect-three:** box select as data, and as a Foldkit submodel ([498a2ec](https://github.com/opsydyn/fold-kit-experiments/commit/498a2ecd7763208c17b54b85f5cc8af294c7ce9b))
13
+ - **effect-three:** edges, trails, points, sparkles and stars ([f976907](https://github.com/opsydyn/fold-kit-experiments/commit/f9769078724c7ef405728581574d50001f338e81))
14
+ - **effect-three:** lockstep, and the editor edited together across tabs ([b416557](https://github.com/opsydyn/fold-kit-experiments/commit/b416557da1e5b5c0d2669891c41e365f48ca818c))
15
+ - **effect-three:** pivot controls as data, and as a Foldkit submodel ([4284921](https://github.com/opsydyn/fold-kit-experiments/commit/42849211eed2b745c4a43ad42682e2508829901b))
16
+ - **effect-three:** scene files, branching history and review diffs ([ce2c54e](https://github.com/opsydyn/fold-kit-experiments/commit/ce2c54ef7cefa77ab07ee7126782b9abccb15adc))
17
+
3
18
  ## [0.3.0](https://github.com/opsydyn/fold-kit-experiments/compare/effect-three-v0.2.0...effect-three-v0.3.0) (2026-10-19)
4
19
 
5
20
  ### Features
package/README.md CHANGED
@@ -47,12 +47,24 @@ const description = scene({
47
47
  - **Keys are unique across the whole scene.** A node keeps its three.js object while its key and kind stay the same, including when it moves to another group. A different kind under the same key replaces the object in place.
48
48
  - **Descriptions are fully specified data.** The constructors fill in defaults, and nothing in a description is a closure or a three.js object.
49
49
  - **Shapes:** `box`, `sphere`, `plane`, `cylinder`, `torus`, `cone`, `capsule`, `ring` and `circle`, owned by one mesh or shared through `resources`. Parameter names and defaults are three.js's own. `roundedBox` and `backdrop` are Drei's `RoundedBox` and `Backdrop`, with Drei's defaults.
50
+ - **Lines:** `line({ key, points, width: 3, dashed: true })` is Drei's `Line` (three's fat lines, drawn by the render kit): pixels wide, or scene units with `worldUnits`; one colour or `vertexColors`; `segments: true` for pairs of points (Drei's `Segments`). `catmullRomPoints`, `cubicBezierPoints` and `quadraticBezierPoints` give the points of Drei's curve lines. `mesh({ edges: edges() })` outlines a mesh's hard edges (Drei's `Edges`), and `trail()` on a group or mesh leaves a ribbon behind it (Drei's `Trail`).
51
+ - **Points:** `points({ key, positions, size: 6 })` draws round dots (Drei's `Points` and `PointMaterial`), with a colour and size factor a point if you like; `sparkles()` and `stars()` are Drei's `Sparkles` and `Stars`, seeded so they are the same on every load, moving in scene time. The render kit draws them.
52
+ - **Transform gizmo:** `gizmoNodes(key, gizmo, placement, camera)` draws three's `TransformControls` handles (move, turn, scale; world or local; snaps) as scene nodes, and `pressGizmo` and `dragGizmo` turn the press and drag rays into the next placement, as three's controls would; the Foldkit adapter's `TransformGizmo` is it as a submodel. `basic({ depthTest: false })` draws over everything. `movedAlike(from, to, other)` moves the rest of a selection as the gizmo moved the first. `pivotNodes`, `pressPivot` and `dragPivot` are Drei's `PivotControls` the same way (every handle at once, sized in scene units); the adapter's `PivotControls` is the submodel.
53
+ - **Measuring tape:** `placeTapeEnd(tape(), point)` places a tape's ends where clicks hit the scene, `pointTape` runs it to the pointer while the second is placed, `tapeLength` measures it and `tapeNodes` draws it; the Foldkit adapter's `MeasuringTape` is it as a submodel, its length an overlay at the middle.
54
+ - **Lockstep:** `Lockstep.make`, `submit`, `send`, `receive` and `advance` keep peers that run the same `update` in step: each sends one packet a turn, a turn applies when all are in, inputs in peer order; `admit`, `welcomeDue`, `leave` and `remove` change who is in. The transport is yours (a `BroadcastChannel`, a socket); `SceneSchema.Lockstep(schema)` puts a session in a Model. The editor sample edits together across tabs with it (ADR-013).
55
+ - **Scene files:** `SceneFile.save(scene)` writes a description as indented JSON in a versioned envelope; `SceneFile.read(text)` reads one back as a `Result`, failing with `UnreadableScene` and where. Fields added since a file was written read at their defaults.
56
+ - **History:** `History.make(value)`, `History.record(history, next, label)`, `undo`, `redo`, `branches`, `chooseBranch` and `jumpTo` keep every Model value as a tree, so a change after an undo starts a branch instead of losing the old future; `SceneSchema.History(schema)` puts one in a Model.
57
+ - **Describing and staging, for assistants:** `describeScene(scene)` lists what a scene contains (camera, things with kind, size, colour and place, lights, bounds, staging) and `formatSummary` writes it as a few lines to read before acting; `shotCamera(camera, box, 'three-quarter')` frames a box from a named angle, and `moodStaging('sunset')` gives a mood's lights, environment and sky.
58
+ - **Inspector:** `Inspector.fields(schema, value)` lists any value's fields from its schema (numbers, text, switches, choices, colours, vectors; kinds and lists read-only), and `Inspector.edit(schema, value, path, next)` sets one and checks the result with the schema, as a `Result`. The Foldkit adapter's `inspectorView` draws them as a form.
59
+ - **Review diffs:** `sceneChanges(before, after)` lists what changed (the kernel's own operations, the scene's settings, its HUD and render textures) and `formatChanges` writes a line for each; `bun run scene:diff a.json b.json` prints them for two scene files.
60
+ - **Box select:** `boxSelect(camera, size, from, to, selectable)` returns the keys whose points fall in a box on the canvas, as three's `SelectionBox` (which Drei's `Select` wraps) would select them; the `GestureEnd` event ends a drag that began on nothing. The Foldkit adapter's `BoxSelect` is it as a submodel.
50
61
  - **Facing, detail and shake:** `rotation: billboard()` turns a node to face the camera every frame (Drei's `Billboard`, with `lockX`/`lockY`/`lockZ`); `group({ detail: detailed({ distances: [0, 10, 20] }) })` shows one child at a time by the camera's distance (Drei's `Detailed`); and a camera's `shake: cameraShake({ decay: true })` shakes it (Drei's `CameraShake`), a pure function of scene time that reduced motion holds still. A `borrowed` model shown under several keys is cloned, skinned models included (Drei's `Clone`).
51
62
  - **Materials:** `basic`, `lambert`, `phong`, `standard`, `physical` and `normalMaterial`, each with opacity, transparency, `side`, wireframe and (lit kinds) flat shading and emission. Defaults are three.js's own. Changing a material within its kind updates it in place; changing its kind replaces it.
52
63
  - **Shadows and render settings:** `scene({ render: renderSettings({ shadows: 'soft', toneMapping: 'aces' }) })`, then `castShadow`/`receiveShadow` on meshes and `castShadow` on directional, point and spot lights. Tone mapping defaults to `none` (React Three Fiber defaults to ACES) so colours render exactly as given.
53
64
  - **Instancing:** `instances({ key, geometry, material, instances: [instance({ key, position, color })] })` draws many copies in one call. Updates rewrite only the instances that changed, and hits name the instance (`instance` on the event).
54
65
  - **Views:** `scene({ views: [view({ key: 'front', camera, rect: { width: 0.5 } }), ...] })` draws several cameras into parts of one canvas; picks use the view under the pointer and report it as `view`.
55
66
  - **Post-processing:** `renderSettings({ effects: [bloom({ strength: 1.5 }), vignette()] })` applies three.js's composer passes in order (`bloom`, `vignette`, `film`); with no effects the scene renders straight to the screen.
67
+ - **HUD:** `scene({ hud: hud({ alignment: 'bottom-right', margin: [80, 80], children }) })` draws nodes over the scene (Drei's `Hud`), through a camera measured in CSS pixels whose origin sits `margin` in from the aligned edges; its interactive meshes are picked before the scene. `viewportGizmoNodes(key, camera)` is Drei's `GizmoViewport` for it, and `cameraAlong(camera, axis)` turns a camera to look from an axis; the Foldkit adapter's `ViewportGizmo` is both as a submodel.
56
68
  - **Render textures:** `scene({ renderTextures: [renderTexture({ id: 'screen', camera, children })] })` draws a little scene of its own into a texture that any material uses with `map: 'screen'`; it redraws only when its scene changes.
57
69
  - **Orbit controls:** `scene({ gestures: 'scene', camera: model.camera })` claims drags, wheel and pinches from the page and reports each as a `Gesture`; `orbit(model.camera, gesture)` returns the next camera, as three.js's `OrbitControls` would move it. A camera's `damping` eases the rendered camera there (a view's too), and `autoRotate` turns it round its target until a gesture, which an `AutoRotated` event precedes: keep it with `autoRotated(model.camera, detail)`. See [ADR-006](../../docs/effect-three/adr/006-controls-as-data.md).
58
70
  - **Fitting:** `scene({ measure: ['model'] })` reports the node's world box as a `Measured` event whenever it changes; `fitCamera(camera, box, area)` frames it as Drei's `Bounds` does, and `orbitKey` moves the camera for arrow keys.