@needle-tools/three-mesh-effects 0.2.3 → 0.3.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 (92) hide show
  1. package/CHANGELOG.md +25 -8
  2. package/README.md +68 -1
  3. package/SKILL.md +9 -1
  4. package/build/box-impostor-runtime.js +1298 -0
  5. package/build/box-impostor-runtime.js.map +7 -0
  6. package/build/deformation-runtime.js +30 -19
  7. package/build/deformation-runtime.js.map +3 -3
  8. package/build/hull-effects.js +60 -28
  9. package/build/hull-effects.js.map +3 -3
  10. package/build/impostor-runtime.js +152 -87
  11. package/build/impostor-runtime.js.map +3 -3
  12. package/build/index.js +4 -0
  13. package/build/index.js.map +2 -2
  14. package/build/internal/box-impostor/box-impostor-display-settings.js +50 -0
  15. package/build/internal/box-impostor/box-impostor-display-settings.js.map +7 -0
  16. package/build/internal/box-impostor/box-impostor-display.js +1005 -0
  17. package/build/internal/box-impostor/box-impostor-display.js.map +7 -0
  18. package/build/internal/box-impostor/box-impostor-face-axes.js +15 -0
  19. package/build/internal/box-impostor/box-impostor-face-axes.js.map +7 -0
  20. package/build/internal/box-impostor/box-impostor-faces.js +125 -0
  21. package/build/internal/box-impostor/box-impostor-faces.js.map +7 -0
  22. package/build/internal/box-impostor/box-impostor-geometry.js +230 -0
  23. package/build/internal/box-impostor/box-impostor-geometry.js.map +7 -0
  24. package/build/internal/box-impostor/box-impostor-material.js +964 -0
  25. package/build/internal/box-impostor/box-impostor-material.js.map +7 -0
  26. package/build/internal/box-impostor/box-impostor-metadata.js +108 -0
  27. package/build/internal/box-impostor/box-impostor-metadata.js.map +7 -0
  28. package/build/internal/box-impostor/box-impostor-projection.js +256 -0
  29. package/build/internal/box-impostor/box-impostor-projection.js.map +7 -0
  30. package/build/internal/box-impostor/box-impostor-runtime.js +1252 -0
  31. package/build/internal/box-impostor/box-impostor-runtime.js.map +7 -0
  32. package/build/internal/box-impostor/box-impostor-surface-search.js +21 -0
  33. package/build/internal/box-impostor/box-impostor-surface-search.js.map +7 -0
  34. package/build/internal/deformation/cloth-surface.js +23 -17
  35. package/build/internal/deformation/cloth-surface.js.map +3 -3
  36. package/build/internal/deformation/pin-cloth.js +7 -2
  37. package/build/internal/deformation/pin-cloth.js.map +2 -2
  38. package/build/internal/deformation/rig-runtime.js +30 -19
  39. package/build/internal/deformation/rig-runtime.js.map +3 -3
  40. package/build/internal/impostor/impostor-node-material.js +152 -87
  41. package/build/internal/impostor/impostor-node-material.js.map +3 -3
  42. package/build/internal/rendering/hull-effect-runtime.js +59 -27
  43. package/build/internal/rendering/hull-effect-runtime.js.map +3 -3
  44. package/build/internal/rendering/wireframe.js +41 -9
  45. package/build/internal/rendering/wireframe.js.map +2 -2
  46. package/build/internal/rendering/wrap-preview.js +59 -27
  47. package/build/internal/rendering/wrap-preview.js.map +3 -3
  48. package/build/types/box-impostor/box-impostor-display-settings.d.ts +30 -0
  49. package/build/types/box-impostor/box-impostor-display-settings.js +1 -0
  50. package/build/types/box-impostor/box-impostor-display.d.ts +5 -0
  51. package/build/types/box-impostor/box-impostor-display.js +1 -0
  52. package/build/types/box-impostor/box-impostor-face-axes.d.ts +5 -0
  53. package/build/types/box-impostor/box-impostor-face-axes.js +1 -0
  54. package/build/types/box-impostor/box-impostor-faces.d.ts +11 -0
  55. package/build/types/box-impostor/box-impostor-faces.js +1 -0
  56. package/build/types/box-impostor/box-impostor-geometry.d.ts +5 -0
  57. package/build/types/box-impostor/box-impostor-geometry.js +1 -0
  58. package/build/types/box-impostor/box-impostor-material.d.ts +10 -0
  59. package/build/types/box-impostor/box-impostor-material.js +1 -0
  60. package/build/types/box-impostor/box-impostor-metadata.d.ts +31 -0
  61. package/build/types/box-impostor/box-impostor-metadata.js +1 -0
  62. package/build/types/box-impostor/box-impostor-projection.d.ts +19 -0
  63. package/build/types/box-impostor/box-impostor-projection.js +1 -0
  64. package/build/types/box-impostor/box-impostor-runtime.d.ts +25 -0
  65. package/build/types/box-impostor/box-impostor-runtime.js +1 -0
  66. package/build/types/box-impostor/box-impostor-surface-search.d.ts +13 -0
  67. package/build/types/box-impostor/box-impostor-surface-search.js +1 -0
  68. package/build/types/deformation/cloth-surface.d.ts +1 -0
  69. package/build/types/deformation/pin-cloth.d.ts +1 -0
  70. package/build/types/public/box-impostor-runtime.d.ts +6 -0
  71. package/build/types/public/box-impostor-runtime.js +1 -0
  72. package/build/types/public/hull-effects.d.ts +1 -0
  73. package/build/types/public/index.d.ts +1 -1
  74. package/build/types/rendering/wireframe.d.ts +2 -2
  75. package/package.json +27 -6
  76. package/src/box-impostor/box-impostor-display-settings.js +54 -0
  77. package/src/box-impostor/box-impostor-display.js +38 -0
  78. package/src/box-impostor/box-impostor-face-axes.js +11 -0
  79. package/src/box-impostor/box-impostor-faces.js +118 -0
  80. package/src/box-impostor/box-impostor-geometry.js +140 -0
  81. package/src/box-impostor/box-impostor-material.js +721 -0
  82. package/src/box-impostor/box-impostor-metadata.js +122 -0
  83. package/src/box-impostor/box-impostor-projection.js +287 -0
  84. package/src/box-impostor/box-impostor-runtime.js +122 -0
  85. package/src/box-impostor/box-impostor-surface-search.js +11 -0
  86. package/src/deformation/cloth-surface.ts +28 -17
  87. package/src/deformation/pin-cloth.ts +9 -3
  88. package/src/impostor/impostor-node-material.js +177 -117
  89. package/src/public/box-impostor-runtime.js +14 -0
  90. package/src/public/hull-effects.js +1 -0
  91. package/src/public/index.js +5 -1
  92. package/src/rendering/wireframe.js +51 -13
package/CHANGELOG.md CHANGED
@@ -1,21 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 - 2026-11-11
4
+
5
+ - Show card and box carrier outlines without triangulation diagonals, including card overlays on WebGPU.
6
+ - Add High Contrast with black lines and a thin gray outline, plus Cyan, Lime and Magenta preview wireframe colors.
7
+
8
+ - Keep narrow captured surfaces visible in box impostors at oblique angles. The traced renderer now scales its search to the crossed texture pixels, improving detailed assets at increased GPU cost.
9
+
10
+ - Preserve steep surfaces between sparse octahedral captures, with bounded candidate validation that rejects false depth shells. This improves coverage at an increased GPU cost.
11
+
12
+ ## 0.3.0 - 2026-11-06
13
+
14
+ - Keep nearer surfaces visible when another card or box capture sees a farther layer.
15
+ - Add experimental basic cards, fitted cards and fitted-box impostors with automatic glTF loading and shared PBR atlases.
16
+ - Recover more silhouette detail in card and box impostors, with smoother edge lighting and voxel-based empty-space rejection.
17
+ - Reduce GPU rendering cost for depth-reconstructed card and box impostors without lowering image quality.
18
+ - Improve cloth stability and contact handling with overlapping colliders.
19
+
3
20
  ## 0.2.3 - 2026-10-30
4
21
 
5
- - Keep impostor shading and fur textures connected when progressive loading replaces a texture. Fur height preserves its UV channel and texture transforms; fur motion limits follow the loaded resolution.
6
- - Sample resized impostor color and shading atlases using their loaded dimensions, with frame boundaries and safe mip levels respected. Packed geometry/depth and sparse pixel records still require their authored resolution.
22
+ - Preserve impostor shading and fur detail as higher-quality textures arrive through progressive loading.
23
+ - Keep impostor views aligned and sharp when color and shading textures load at different resolutions.
7
24
 
8
25
  ## 0.2.2 - 2026-10-21
9
26
 
10
- - Include a package-root `SKILL.md` with integration guidance for extension loading, compression decoders, runtime updates, and cleanup in Three.js and Needle Engine applications.
27
+ - Help coding agents integrate Mesh Effects with bundled guidance for Three.js and Needle Engine, covering loading, animation and cleanup.
11
28
 
12
29
  ## 0.2.1 - 2026-10-21
13
30
 
14
- - Put installation and features before the Quick start, and clarify that consumers configure compression decoders themselves when needed.
31
+ - Get started more easily with a reorganized Quick start and guidance for compressed model loading.
15
32
 
16
33
  ## 0.2.0 - 2026-10-21
17
34
 
18
- - Register `useLoader(loader, renderer)` once to load any combination of Needle glTF runtime extensions without inspecting an asset beforehand. Extension handlers load dynamically as needed.
19
- - Opt out of specific extensions with the typed `{ disable: [extensionName] }` option. Optional extensions retain their portable fallback; disabled required extensions report an error.
20
- - Automatically restore saved hull effects and settings from the versioned `NEEDLE_hull_effect` extension. Hull effects work without an original model and can follow their own skin animation.
21
- - Use `bindHull(hull, original)` to attach an original model and animation syncing later, or pass `null` to detach it. Existing manual registration functions and `createHullEffect` remain supported.
35
+ - Register `useLoader(loader, renderer)` once to load any combination of supported Needle glTF extensions automatically.
36
+ - Choose which effects to enable with the typed `disable` option. Optional effects retain their portable fallback; required effects report when they cannot load.
37
+ - Restore exported hull effects with their saved appearance and settings, including animated models.
38
+ - Attach or detach an original model with `bindHull` for display and animation syncing, or use a hull effect on its own.
package/README.md CHANGED
@@ -13,6 +13,7 @@ optional import. The examples use ordinary Three.js and assume an existing
13
13
  ## Features
14
14
 
15
15
  - **Hull effects:** Restore the saved effect automatically, optionally binding its source model.
16
+ - **Card and box impostors (experimental):** Project or reconstruct six captures per part using shared PBR atlases.
16
17
  - **Octahedral impostors:** Load exported glTF extensions with a Three.js TSL material.
17
18
  - **Deformation rigs:** Run IK and secondary motion alongside standard animation clips.
18
19
  - **Pixel and voxel impostors:** Create the display mode selected in the workbench.
@@ -44,7 +45,7 @@ their glTF extension names in the optional third argument:
44
45
  useLoader(loader, renderer, { disable: ['NEEDLE_mesh_impostor'] });
45
46
  ```
46
47
 
47
- Supported keys are `NEEDLE_hull_effect`, `NEEDLE_mesh_impostor`, `NEEDLE_pixel_impostor`, and
48
+ Supported keys are `NEEDLE_box_impostor`, `NEEDLE_hull_effect`, `NEEDLE_mesh_impostor`, `NEEDLE_pixel_impostor`, and
48
49
  `NEEDLE_deformation_rig`. Disabled optional extensions keep their portable
49
50
  fallback without importing the handler. A disabled extension listed in the
50
51
  asset's `extensionsRequired` rejects the load with an error. Calling `useLoader`
@@ -66,6 +67,72 @@ across neighboring views. Compact shading alpha stores material data and needs
66
67
  independent channel filtering and lossless PNG encoding. Packed depth/geometry
67
68
  and sparse pixel-impostor records must retain their authored resolution.
68
69
 
70
+ ## Card and fitted-box impostors (experimental)
71
+
72
+ `NEEDLE_box_impostor` stores six orthographic PBR/depth views for each oriented
73
+ part, packed into four shared atlases. Basic mode draws one camera-facing card;
74
+ `cards` draws one per fitted region, and `fitted` draws twelve-triangle box proxies. Motion/opacity batches share atlas textures;
75
+ transparent boxes use separate draws for depth sorting. The runtime supports direct
76
+ plane projection, source-material transparency and standard rigid node
77
+ animation. Auto depth uses projection for flat captures and traces other captures.
78
+ Every display setting retains the same compact geometry: two triangles per card
79
+ or twelve per fitted box. Explicit projection trades curved silhouette/parallax
80
+ accuracy for lower shader cost. Fitted boxes with projection and no view blending
81
+ use ordinary fitted faces with no fragment depth search. Projected cards select
82
+ the nearest supported plane before blending. Captured depth bounds shorten traced
83
+ searches, and padded depth needs one texture read per step. Tracing checks the
84
+ supported captures in facing order and retains the nearest validated surface,
85
+ including surfaces hidden from the most directly facing capture.
86
+ Conservative voxel masks reject empty rays without reducing texture resolution.
87
+ Filtered normals preserve edge lighting. Geometric occupancy
88
+ in the material atlas rejects empty hits. Sampling rejects depth discontinuities
89
+ that would otherwise form extruded walls. Captures preserve surface opacity
90
+ independently of the display cutoff. `useLoader(loader, renderer)` enables it automatically.
91
+
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.
95
+ A nearest-surface depth field cannot represent all hidden layers; split complex
96
+ parts into more boxes when gaps or occluded surfaces disappear.
97
+
98
+ For manual integration, `@needle-tools/three-mesh-effects/box-impostor-runtime`
99
+ exports `registerNeedleBoxImpostorLoader(loader, { renderer })`,
100
+ `createBoxImpostorGeometry(descriptor)`, `createBoxImpostorMaterial(descriptor, maps)`
101
+ `parseBoxImpostorDescriptor`, and `setBoxImpostorDisplay(root, options)`. `maps` binds `baseColor`, `normalDepth`, `orm`
102
+ and `emissive` explicitly. The material owns its small rectangle lookup texture;
103
+ dispose the material and geometry on unload, and dispose shared atlas textures
104
+ once their last consumer is gone. No per-frame update is needed.
105
+
106
+ Change display settings after loading without rebuilding the geometry or atlases:
107
+
108
+ ```js
109
+ import { setBoxImpostorDisplay } from '@needle-tools/three-mesh-effects/box-impostor-runtime';
110
+ setBoxImpostorDisplay(gltf.scene, {
111
+ depthMode: 'auto', // auto, projection, depth
112
+ raySteps: 16,
113
+ interpolation: 'smooth', // none, linear, smooth
114
+ transparency: 'auto', // auto, cutout, dithered, blended
115
+ alphaCutoff: 0.5,
116
+ });
117
+ ```
118
+
119
+ Interpolation blends occupied captured planes, or depth-consistent samples on traced surfaces. Auto transparency follows each primitive’s source alpha mode. Blended
120
+ opacity uses sorted draws without depth writes. Dithered opacity uses
121
+ alpha hashing; captures do not represent layered glass or refraction. Cutout
122
+ uses the live alpha cutoff.
123
+ Depth quality, interpolation and transparency select cached compiled materials;
124
+ disposing the geometry releases the cached material variants without disposing shared atlases.
125
+ `DEFAULT_BOX_IMPOSTOR_DISPLAY` and `normalizeBoxImpostorDisplay` expose the same
126
+ defaults and validation used by loading and live updates.
127
+
128
+ Explicit depth reconstruction compiles Low, Medium or High adaptive sampling
129
+ (`raySteps: 8`, `16` or `32`). These set minimum interval budgets and respectively
130
+ 1, 2 or 4 samples per projected capture texel along the dominant texture axis;
131
+ they are not maximum counts. Oblique rays can require hundreds of samples.
132
+ Projection omits depth search entirely. Keep depth bytes lossless, atlas
133
+ resolution unchanged and mipmaps disabled: filtering packed 16-bit depth or
134
+ across neighboring views corrupts reconstruction.
135
+
69
136
  ## Hull effects
70
137
 
71
138
  When exporting with a hull effect selected, Mesh Baker saves its mode and
package/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: three-mesh-effects
3
- description: Integrate Mesh Baker glTF models into Three.js or Needle Engine applications, including extension loading, hull effects, deformation rigs, and pixel impostor displays.
3
+ description: Integrate Mesh Baker glTF models into Three.js or Needle Engine applications, including extension loading, hull effects, deformation rigs, and impostor displays.
4
4
  ---
5
5
 
6
6
  # Three Mesh Effects
@@ -43,6 +43,14 @@ independent animation loop.
43
43
  - Pixel impostors: extension loading restores atlas bindings. Custom display
44
44
  modes still use `createPixelImpostorDisplay` from `/pixel-impostor-runtime`;
45
45
  update its viewport and dispose it as documented in the README.
46
+ - Card and fitted-box impostors: `useLoader` restores `NEEDLE_box_impostor` with
47
+ WebGPURenderer (WebGPU or WebGL2 backend). Use `setBoxImpostorDisplay` from
48
+ `/box-impostor-runtime` for live depth, view blending, transparency and cutoff
49
+ changes. Rigid node animation uses the application's AnimationMixer. Dispose
50
+ geometry and materials on unload; geometry disposal also releases cached
51
+ display variants. Dispose shared atlas textures after their final consumer.
52
+ Captures contain one surface per direction, so hidden layers and refraction
53
+ are approximations; projection and traced modes have different quality costs.
46
54
  - Octahedral impostors: pass the actual renderer to `useLoader` so the handler
47
55
  can choose the supported material implementation.
48
56