@needle-tools/three-mesh-effects 0.3.1 → 0.3.3

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 (50) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +22 -6
  3. package/SKILL.md +7 -5
  4. package/build/box-impostor-runtime.js +212 -87
  5. package/build/box-impostor-runtime.js.map +4 -4
  6. package/build/impostor-runtime.js +128 -48
  7. package/build/impostor-runtime.js.map +4 -4
  8. package/build/index.js +4 -0
  9. package/build/index.js.map +2 -2
  10. package/build/internal/box-impostor/box-impostor-display.js +178 -81
  11. package/build/internal/box-impostor/box-impostor-display.js.map +4 -4
  12. package/build/internal/box-impostor/box-impostor-material.js +163 -71
  13. package/build/internal/box-impostor/box-impostor-material.js.map +4 -4
  14. package/build/internal/box-impostor/box-impostor-projection.js +38 -18
  15. package/build/internal/box-impostor/box-impostor-projection.js.map +4 -4
  16. package/build/internal/box-impostor/box-impostor-runtime.js +193 -76
  17. package/build/internal/box-impostor/box-impostor-runtime.js.map +4 -4
  18. package/build/internal/impostor/impostor-node-material.js +128 -48
  19. package/build/internal/impostor/impostor-node-material.js.map +4 -4
  20. package/build/internal/pixel-impostor/pixel-impostor-display.js +84 -38
  21. package/build/internal/pixel-impostor/pixel-impostor-display.js.map +4 -4
  22. package/build/internal/rendering/captured-surface-depth.js +35 -0
  23. package/build/internal/rendering/captured-surface-depth.js.map +7 -0
  24. package/build/internal/rendering/captured-surface-material.js +28 -0
  25. package/build/internal/rendering/captured-surface-material.js.map +7 -0
  26. package/build/internal/rendering/renderer-support.js +31 -0
  27. package/build/internal/rendering/renderer-support.js.map +7 -0
  28. package/build/pixel-impostor-runtime.js +84 -38
  29. package/build/pixel-impostor-runtime.js.map +4 -4
  30. package/build/types/box-impostor/box-impostor-display.d.ts +9 -1
  31. package/build/types/box-impostor/box-impostor-material.d.ts +4 -0
  32. package/build/types/box-impostor/box-impostor-runtime.d.ts +5 -11
  33. package/build/types/impostor/impostor-node-material.d.ts +2 -15
  34. package/build/types/rendering/captured-surface-depth.d.ts +5 -0
  35. package/build/types/rendering/captured-surface-depth.js +1 -0
  36. package/build/types/rendering/captured-surface-material.d.ts +8 -0
  37. package/build/types/rendering/captured-surface-material.js +1 -0
  38. package/build/types/rendering/renderer-support.d.ts +27 -0
  39. package/build/types/rendering/renderer-support.js +1 -0
  40. package/package.json +3 -3
  41. package/src/box-impostor/box-impostor-display.js +23 -11
  42. package/src/box-impostor/box-impostor-material.js +94 -44
  43. package/src/box-impostor/box-impostor-projection.js +3 -14
  44. package/src/box-impostor/box-impostor-runtime.js +6 -4
  45. package/src/impostor/impostor-node-material.js +26 -43
  46. package/src/pixel-impostor/pixel-impostor-display.js +5 -13
  47. package/src/public/index.js +5 -0
  48. package/src/rendering/captured-surface-depth.js +55 -0
  49. package/src/rendering/captured-surface-material.js +27 -0
  50. package/src/rendering/renderer-support.js +50 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.3 - 2026-11-16
4
+
5
+ - Reduce first-use shader compilation stalls for octahedral impostors.
6
+
7
+ ## 0.3.2 - 2026-11-13
8
+
9
+ - Support Three.js r186 and load box and card impostors automatically with WebGLRenderer.
10
+ - Smooth box-impostor shading and view transitions, including capture edges.
11
+ - Correct point and spot lighting on reconstructed impostor surfaces.
12
+ - Keep traced boxes and fitted cards visible when the camera enters their bounds.
13
+ - Preserve scene intersections with standard, reversed and logarithmic depth buffers.
14
+ - Avoid repeated shader compilation when rendering box and card impostors on WebGL.
15
+
3
16
  ## 0.3.1 - 2026-11-11
4
17
 
5
18
  - Show card and box carrier outlines without triangulation diagonals, including card overlays on WebGPU.
package/README.md CHANGED
@@ -31,13 +31,19 @@ const { scene: model } = await loader.loadAsync('/model.glb');
31
31
  scene.add(model);
32
32
  ```
33
33
 
34
- This handles hull effects, deformation rigs, octahedral impostors, and pixel impostor atlas
34
+ This handles hull effects, deformation rigs, box and card impostors, octahedral impostors, and pixel impostor atlas
35
35
  bindings, including assets combining extensions. It also works with `load`,
36
36
  `parse`, and `parseAsync`. Each handler is dynamically imported only for assets
37
37
  declaring that extension; bundlers can keep those imports in separate chunks.
38
38
  Dynamic imports defer downloads, rather than removing handlers that an asset
39
39
  might need. The existing individual registration functions remain available.
40
40
 
41
+ On `WebGLRenderer`, loading an enabled Mesh Effects extension installs Three's
42
+ `WebGLNodesHandler` once per renderer, so the same TSL materials render on WebGL.
43
+ Ordinary glTF files and disabled extensions leave the renderer untouched. Hosts
44
+ with their own compatible handler can advertise
45
+ `renderer.capabilities.supportsNodeMaterials = true` to retain it.
46
+
41
47
  All extensions are enabled by default. To opt out of specific handlers, pass
42
48
  their glTF extension names in the optional third argument:
43
49
 
@@ -89,12 +95,19 @@ in the material atlas rejects empty hits. Sampling rejects depth discontinuities
89
95
  that would otherwise form extruded walls. Captures preserve surface opacity
90
96
  independently of the display cutoff. `useLoader(loader, renderer)` enables it automatically.
91
97
 
92
- Use `WebGPURenderer` from `three/webgpu`, with either its native WebGPU or WebGL2
93
- backend. Classic `WebGLRenderer` keeps the portable textured fallback when the
94
- extension is optional and rejects a required box extension. Captures remain fixed in their animated node frame.
98
+ Use `WebGLRenderer` or `WebGPURenderer` from `three/webgpu`. `useLoader` and the
99
+ manual box registration enable Three's WebGL TSL handler when needed. Renderers
100
+ without node-material support retain the portable fallback for optional box
101
+ extensions and reject required ones. Captures remain fixed in their animated node frame.
95
102
  A nearest-surface depth field cannot represent all hidden layers; split complex
96
103
  parts into more boxes when gaps or occluded surfaces disappear.
97
104
 
105
+ Depth-writing variants use the reconstructed surface for depth, point/spot lighting
106
+ and received shadows. Enable Three's shadow map and the usual light/mesh
107
+ `castShadow` and mesh `receiveShadow` flags. Raster reflection probes use
108
+ `CubeRenderTarget` with `WebGPURenderer`; geometry raycasts still see the compact
109
+ carrier. Alpha-blended variants retain sorting and do not write depth.
110
+
98
111
  For manual integration, `@needle-tools/three-mesh-effects/box-impostor-runtime`
99
112
  exports `registerNeedleBoxImpostorLoader(loader, { renderer })`,
100
113
  `createBoxImpostorGeometry(descriptor)`, `createBoxImpostorMaterial(descriptor, maps)`
@@ -121,7 +134,9 @@ opacity uses sorted draws without depth writes. Dithered opacity uses
121
134
  alpha hashing; captures do not represent layered glass or refraction. Cutout
122
135
  uses the live alpha cutoff.
123
136
  Depth quality, interpolation and transparency select cached compiled materials;
124
- disposing the geometry releases the cached material variants without disposing shared atlases.
137
+ disposing the current material releases its cached variants without disposing
138
+ shared atlases. Dispose geometry separately; a renderer may refresh its buffers
139
+ without unloading the material.
125
140
  `DEFAULT_BOX_IMPOSTOR_DISPLAY` and `normalizeBoxImpostorDisplay` expose the same
126
141
  defaults and validation used by loading and live updates.
127
142
 
@@ -162,7 +177,8 @@ Get the current effect again after rebinding; old bindings no longer control it.
162
177
  `getHullEffect(hull)` returns `undefined` for an ordinary or disposed hull.
163
178
  Standalone animated hulls can follow their own animation; call `syncAnimation()`
164
179
  after updating their mixers or deformation rig. TSL effects require
165
- `WebGPURenderer` from `three/webgpu`, using either its WebGPU or WebGL2 backend.
180
+ `WebGPURenderer` from `three/webgpu` or `WebGLRenderer` with Three's
181
+ `WebGLNodesHandler`, which `useLoader` enables when loading an effect.
166
182
 
167
183
  The existing manual API remains available for models without the extension.
168
184
  Here the hull supplies the effect's surface and the original stays visible inside:
package/SKILL.md CHANGED
@@ -44,10 +44,10 @@ independent animation loop.
44
44
  modes still use `createPixelImpostorDisplay` from `/pixel-impostor-runtime`;
45
45
  update its viewport and dispose it as documented in the README.
46
46
  - Card and fitted-box impostors: `useLoader` restores `NEEDLE_box_impostor` with
47
- WebGPURenderer (WebGPU or WebGL2 backend). Use `setBoxImpostorDisplay` from
47
+ WebGPURenderer or WebGLRenderer, enabling Three's WebGLNodesHandler as needed. Use `setBoxImpostorDisplay` from
48
48
  `/box-impostor-runtime` for live depth, view blending, transparency and cutoff
49
49
  changes. Rigid node animation uses the application's AnimationMixer. Dispose
50
- geometry and materials on unload; geometry disposal also releases cached
50
+ geometry and materials on unload; material disposal also releases cached
51
51
  display variants. Dispose shared atlas textures after their final consumer.
52
52
  Captures contain one surface per direction, so hidden layers and refraction
53
53
  are approximations; projection and traced modes have different quality costs.
@@ -55,9 +55,11 @@ independent animation loop.
55
55
  can choose the supported material implementation.
56
56
 
57
57
  Hull and other TSL effects require a renderer supporting node materials. Ordinary
58
- Three.js applications use WebGPURenderer from `three/webgpu`, with its WebGPU or
59
- WebGL2 backend. Some hosts provide their own TSL integration; inspect it before
60
- changing their renderer or disabling existing rendering features.
58
+ Three.js applications use WebGPURenderer from `three/webgpu` or WebGLRenderer
59
+ with Three's WebGLNodesHandler. `useLoader` enables the latter lazily for an
60
+ enabled extension. Hosts with an existing compiler advertise
61
+ `renderer.capabilities.supportsNodeMaterials = true` to preserve it. Reuse the
62
+ host's renderer and render loop.
61
63
 
62
64
  When a scene is cleared while asynchronous initialization is pending, dispose
63
65
  any runtimes that finish afterward. Track scenes separately per viewer/context,