@needle-tools/three-mesh-effects 0.1.0-alpha.1 → 0.1.0-alpha.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/README.md +42 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
# @needle-tools/three-mesh-effects
|
|
2
|
-
|
|
3
1
|
Three.js loaders and TSL materials for GLBs exported by [Needle Mesh Baker](https://mesh-baker.needle.tools).
|
|
4
|
-
Install this package in the app that displays the result; baking tools are in
|
|
5
|
-
`@needle-tools/baker`.
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
## Features
|
|
4
|
+
|
|
5
|
+
- **Hull effects:** Render effects using an exported hull and its source model.
|
|
6
|
+
- **Octahedral impostors:** Load exported glTF extensions with a Three.js TSL material.
|
|
7
|
+
- **Deformation rigs:** Run IK and secondary motion alongside standard animation clips.
|
|
8
|
+
- **Pixel and voxel impostors:** Create the display mode selected in the workbench.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
8
11
|
|
|
9
12
|
```sh
|
|
10
13
|
npm install @needle-tools/three-mesh-effects three
|
|
@@ -13,6 +16,30 @@ npm install @needle-tools/three-mesh-effects three
|
|
|
13
16
|
The package supports Three.js r185 and r186. Its Needle Engine adapter is an
|
|
14
17
|
optional import; the examples below use ordinary Three.js.
|
|
15
18
|
|
|
19
|
+
## Hull effects
|
|
20
|
+
|
|
21
|
+
Hull effects use the exported hull and its original source model. Available
|
|
22
|
+
modes and their defaults are in `WRAP_PREVIEW_MODES` and
|
|
23
|
+
`createWrapPreviewValues()`:
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { createWrapPreview, createWrapPreviewValues } from '@needle-tools/three-mesh-effects/wrap-effects';
|
|
29
|
+
|
|
30
|
+
const effect = createWrapPreview(hull, original, 'flames', createWrapPreviewValues().flames);
|
|
31
|
+
// For animated models, advance both mixers and call effect.syncAnimation() each frame.
|
|
32
|
+
// Call effect.dispose() at teardown.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Octahedral impostors
|
|
36
|
+
|
|
37
|
+
An 800,000-triangle source represented by a two-triangle impostor:
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
Register the extension loader before loading an exported impostor GLB:
|
|
42
|
+
|
|
16
43
|
```js
|
|
17
44
|
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
18
45
|
import { registerNeedleImpostorLoader } from '@needle-tools/three-mesh-effects/impostor-runtime';
|
|
@@ -22,16 +49,20 @@ const { scene: model } = await loader.loadAsync('/result_impostor.glb');
|
|
|
22
49
|
scene.add(model);
|
|
23
50
|
```
|
|
24
51
|
|
|
52
|
+
## Deformation rigs
|
|
53
|
+
|
|
25
54
|
For a rigged GLB, register the extension before loading and advance the rig
|
|
26
|
-
once per frame:
|
|
55
|
+
once per frame. Update the animation mixer first:
|
|
27
56
|
|
|
28
57
|
```js
|
|
29
|
-
import { AnimationMixer } from 'three';
|
|
58
|
+
import { AnimationMixer, Clock } from 'three';
|
|
59
|
+
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
30
60
|
import { registerNeedleDeformationRigLoader, getDeformationRig } from '@needle-tools/three-mesh-effects/deformation-runtime';
|
|
31
61
|
|
|
32
62
|
const rigLoader = registerNeedleDeformationRigLoader(new GLTFLoader());
|
|
33
63
|
const { scene: riggedModel, animations } = await rigLoader.loadAsync('/rigged.glb');
|
|
34
64
|
scene.add(riggedModel);
|
|
65
|
+
const clock = new Clock();
|
|
35
66
|
const mixer = new AnimationMixer(riggedModel);
|
|
36
67
|
if (animations[0]) mixer.clipAction(animations[0]).play();
|
|
37
68
|
const rig = getDeformationRig(riggedModel);
|
|
@@ -48,10 +79,13 @@ mixer before `rig.update(deltaSeconds)` when also using IK or secondary motion.
|
|
|
48
79
|
The runtime respects the animated bone frame; it does not play the clip itself.
|
|
49
80
|
Without procedural rig features, the mixer and standard GLTFLoader are sufficient.
|
|
50
81
|
|
|
82
|
+
## Pixel and voxel impostors
|
|
83
|
+
|
|
51
84
|
Pixel and voxel impostors have a portable glTF shell. Register the loader and
|
|
52
85
|
create the display that matches the chosen workbench mode:
|
|
53
86
|
|
|
54
87
|
```js
|
|
88
|
+
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
55
89
|
import { registerNeedlePixelImpostorLoader, createPixelImpostorDisplay } from '@needle-tools/three-mesh-effects/pixel-impostor-runtime';
|
|
56
90
|
|
|
57
91
|
const pixelLoader = registerNeedlePixelImpostorLoader(new GLTFLoader());
|
|
@@ -61,17 +95,7 @@ const display = createPixelImpostorDisplay(pixelModel, { renderer, mode: 'screen
|
|
|
61
95
|
// Call display.updateViewport() after a resize and display.dispose() at teardown.
|
|
62
96
|
```
|
|
63
97
|
|
|
64
|
-
|
|
65
|
-
modes and their defaults are in `WRAP_PREVIEW_MODES` and
|
|
66
|
-
`createWrapPreviewValues()`:
|
|
67
|
-
|
|
68
|
-
```js
|
|
69
|
-
import { createWrapPreview, createWrapPreviewValues } from '@needle-tools/three-mesh-effects/wrap-effects';
|
|
70
|
-
|
|
71
|
-
const effect = createWrapPreview(hull, original, 'flames', createWrapPreviewValues().flames);
|
|
72
|
-
// For animated models, advance both mixers and call effect.syncAnimation() each frame.
|
|
73
|
-
// Call effect.dispose() at teardown.
|
|
74
|
-
```
|
|
98
|
+
## Needle Engine and glTF fallbacks
|
|
75
99
|
|
|
76
100
|
`impostor-runtime/needle-engine` is a separate optional import that requires
|
|
77
101
|
`@needle-tools/engine`; ordinary Three.js applications never import it.
|