@needle-tools/three-mesh-effects 0.2.0 → 0.2.2

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.2 - 2026-10-21
4
+
5
+ - 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.
6
+
7
+ ## 0.2.1 - 2026-10-21
8
+
9
+ - Put installation and features before the Quick start, and clarify that consumers configure compression decoders themselves when needed.
10
+
3
11
  ## 0.2.0 - 2026-10-21
4
12
 
5
13
  - 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.
package/README.md CHANGED
@@ -1,6 +1,23 @@
1
1
  Three.js loaders and TSL materials for GLBs exported by [Needle Mesh Baker](https://mesh-baker.needle.tools).
2
2
 
3
- ## Automatic glTF loading
3
+ ## Install
4
+
5
+ ```sh
6
+ npm install @needle-tools/three-mesh-effects three
7
+ ```
8
+
9
+ The package supports Three.js r185 and r186. Its Needle Engine adapter is an
10
+ optional import. The examples use ordinary Three.js and assume an existing
11
+ `renderer`, `scene`, and `camera`.
12
+
13
+ ## Features
14
+
15
+ - **Hull effects:** Restore the saved effect automatically, optionally binding its source model.
16
+ - **Octahedral impostors:** Load exported glTF extensions with a Three.js TSL material.
17
+ - **Deformation rigs:** Run IK and secondary motion alongside standard animation clips.
18
+ - **Pixel and voxel impostors:** Create the display mode selected in the workbench.
19
+
20
+ ## Quick start
4
21
 
5
22
  Register once, then load any Mesh Baker glTF without knowing its extensions:
6
23
 
@@ -34,28 +51,13 @@ asset's `extensionsRequired` rejects the load with an error. Calling `useLoader`
34
51
  again replaces the renderer and disable list for subsequent parses; omitting
35
52
  options enables everything again.
36
53
 
37
- Configure Draco, Meshopt and KTX2 decoders on the loader as usual when needed.
54
+ If a model uses Draco, Meshopt, or KTX2 compression, you must configure the
55
+ corresponding decoder or texture loader on your `GLTFLoader` yourself.
56
+ `useLoader` handles Needle extensions; it does not configure compression decoders.
38
57
  Rig animation still needs a per-frame update, pixel display modes remain available
39
58
  through `createPixelImpostorDisplay`. Hull effects load alone; optionally use
40
59
  `bindHull` to add an original model and animation syncing.
41
60
 
42
- ## Install
43
-
44
- ```sh
45
- npm install @needle-tools/three-mesh-effects three
46
- ```
47
-
48
- The package supports Three.js r185 and r186. Its Needle Engine adapter is an
49
- optional import. The examples use ordinary Three.js and assume an existing
50
- `renderer`, `scene`, and `camera`.
51
-
52
- ## Features
53
-
54
- - **Hull effects:** Restore the saved effect automatically, optionally binding its source model.
55
- - **Octahedral impostors:** Load exported glTF extensions with a Three.js TSL material.
56
- - **Deformation rigs:** Run IK and secondary motion alongside standard animation clips.
57
- - **Pixel and voxel impostors:** Create the display mode selected in the workbench.
58
-
59
61
  ## Hull effects
60
62
 
61
63
  When exporting with a hull effect selected, Mesh Baker saves its mode and
package/SKILL.md ADDED
@@ -0,0 +1,70 @@
1
+ ---
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.
4
+ ---
5
+
6
+ # Three Mesh Effects
7
+
8
+ Use the public runtime package to reproduce a Mesh Baker export in an existing
9
+ viewer. Read [README.md](README.md) for effect-specific examples and supported
10
+ Three.js versions. Read `package.json` for the installed version and exports.
11
+
12
+ ## Loader setup
13
+
14
+ Register `useLoader(loader, renderer)` from `@needle-tools/three-mesh-effects`
15
+ before loading or parsing an asset. Reuse the application's configured GLTFLoader
16
+ and renderer; preserve its Draco, Meshopt, KTX2, progressive-loading and other
17
+ plugins. Consumers configure compression decoders themselves.
18
+
19
+ The loader detects the asset's declared Needle extensions and dynamically
20
+ imports their handlers. Do not require callers to inspect extensions or invoke
21
+ separate registration functions. An optional typed third argument can disable
22
+ handlers, for example `{ disable: ['NEEDLE_hull_effect'] }`. Everything is enabled
23
+ by default. Disabled optional extensions retain their portable fallback;
24
+ disabled required extensions reject loading.
25
+
26
+ For Needle Engine, call `useLoader(loader, context.renderer)` in the engine's
27
+ custom extension `onImport` hook. Install the integration before creating viewers.
28
+ Use the existing render loop and model teardown hooks rather than starting an
29
+ independent animation loop.
30
+
31
+ ## Runtime updates and ownership
32
+
33
+ - Deformation rigs: obtain `getDeformationRig(scene)` from `/deformation-runtime`.
34
+ Advance the application's AnimationMixer first, then `rig.update(deltaSeconds)`.
35
+ Dispose the rig before releasing its model.
36
+ - Hulls: the versioned scene extension restores the saved effect automatically.
37
+ Obtain `getHullEffect(scene)` from `/hull-effects`. An original model is optional.
38
+ `bindHull(hull, original, { animate: true })` attaches a borrowed original and
39
+ replaces the effect; `bindHull(hull, null)` detaches it. Fetch the current effect
40
+ after rebinding, call `syncAnimation()` after mixers and rig updates, and dispose
41
+ the current effect before unloading. Never dispose the borrowed original's
42
+ geometry, materials or textures as part of binding cleanup.
43
+ - Pixel impostors: extension loading restores atlas bindings. Custom display
44
+ modes still use `createPixelImpostorDisplay` from `/pixel-impostor-runtime`;
45
+ update its viewport and dispose it as documented in the README.
46
+ - Octahedral impostors: pass the actual renderer to `useLoader` so the handler
47
+ can choose the supported material implementation.
48
+
49
+ Hull and other TSL effects require a renderer supporting node materials. Ordinary
50
+ Three.js applications use WebGPURenderer from `three/webgpu`, with its WebGPU or
51
+ WebGL2 backend. Some hosts provide their own TSL integration; inspect it before
52
+ changing their renderer or disabling existing rendering features.
53
+
54
+ When a scene is cleared while asynchronous initialization is pending, dispose
55
+ any runtimes that finish afterward. Track scenes separately per viewer/context,
56
+ including assets with multiple scenes. Avoid loading optional runtime modules
57
+ just to poll ordinary models that have no corresponding extension.
58
+
59
+ ## Verification
60
+
61
+ Exercise real GLTFLoader parsing and the host's update/clear lifecycle. Cover
62
+ ordinary assets, mixed extensions, opt-outs, disposal and asynchronous clear/load
63
+ races. Verify renderer compatibility when shader effects are involved; mocked
64
+ lifecycle tests alone do not establish visual correctness. Report checks that
65
+ were not run.
66
+
67
+ When extending this package, every new Needle glTF runtime extension must also
68
+ work through `useLoader`, including its typed disable key and lazy handler.
69
+ Preserve existing manual APIs. Use a versioned glTF extension for runtime data,
70
+ retain a portable fallback, and keep runtime contracts out of `extras`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/three-mesh-effects",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Three.js loaders and TSL effects for Needle Mesh Baker outputs.",
5
5
  "keywords": [
6
6
  "three.js",
@@ -78,7 +78,7 @@
78
78
  },
79
79
  "./package.json": "./package.json"
80
80
  },
81
- "files": ["build/", "src/", "README.md", "CHANGELOG.md", "LICENSE"],
81
+ "files": ["build/", "src/", "README.md", "CHANGELOG.md", "SKILL.md", "LICENSE"],
82
82
  "scripts": {
83
83
  "build": "node scripts/build.mjs",
84
84
  "test": "npm run build && node --test tests/use-loader.test.js",