@needle-tools/three-mesh-effects 0.3.3 → 0.3.5
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 +9 -0
- package/README.md +3 -2
- package/build/box-impostor-runtime.js +27 -2
- package/build/box-impostor-runtime.js.map +3 -3
- package/build/deformation-runtime.js +11 -9
- package/build/deformation-runtime.js.map +2 -2
- package/build/impostor-runtime.js +41 -19
- package/build/impostor-runtime.js.map +3 -3
- package/build/internal/box-impostor/box-impostor-display.js +10 -2
- package/build/internal/box-impostor/box-impostor-display.js.map +2 -2
- package/build/internal/box-impostor/box-impostor-faces.js.map +1 -1
- package/build/internal/box-impostor/box-impostor-geometry.js +4 -0
- package/build/internal/box-impostor/box-impostor-geometry.js.map +2 -2
- package/build/internal/box-impostor/box-impostor-material.js +10 -2
- package/build/internal/box-impostor/box-impostor-material.js.map +2 -2
- package/build/internal/box-impostor/box-impostor-metadata.js +4 -0
- package/build/internal/box-impostor/box-impostor-metadata.js.map +2 -2
- package/build/internal/box-impostor/box-impostor-projection.js.map +1 -1
- package/build/internal/box-impostor/box-impostor-runtime.js +27 -2
- package/build/internal/box-impostor/box-impostor-runtime.js.map +3 -3
- package/build/internal/deformation/pin-ik.js +11 -9
- package/build/internal/deformation/pin-ik.js.map +2 -2
- package/build/internal/deformation/pin-wiggle.js.map +1 -1
- package/build/internal/deformation/rig-extension.js.map +1 -1
- package/build/internal/deformation/rig-runtime.js +11 -9
- package/build/internal/deformation/rig-runtime.js.map +2 -2
- package/build/internal/impostor/impostor-node-material.js +41 -19
- package/build/internal/impostor/impostor-node-material.js.map +3 -3
- package/build/internal/pixel-impostor/pixel-impostor-display.js +9 -7
- package/build/internal/pixel-impostor/pixel-impostor-display.js.map +2 -2
- package/build/internal/rendering/classic-webgl-support.js +12 -0
- package/build/internal/rendering/classic-webgl-support.js.map +7 -0
- package/build/internal/rendering/renderer-support.js +13 -0
- package/build/internal/rendering/renderer-support.js.map +3 -3
- package/build/pixel-impostor-runtime.js +9 -7
- package/build/pixel-impostor-runtime.js.map +2 -2
- package/build/types/box-impostor/box-impostor-metadata.d.ts +3 -1
- package/build/types/rendering/classic-webgl-support.d.ts +9 -0
- package/build/types/rendering/classic-webgl-support.js +1 -0
- package/package.json +2 -2
- package/src/box-impostor/box-impostor-material.js +10 -2
- package/src/box-impostor/box-impostor-metadata.js +5 -1
- package/src/deformation/pin-ik.ts +13 -9
- package/src/impostor/impostor-node-material.js +31 -15
- package/src/pixel-impostor/pixel-impostor-display.js +18 -7
- package/src/rendering/classic-webgl-support.js +15 -0
- package/src/rendering/renderer-support.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.5 - 2026-11-22
|
|
4
|
+
|
|
5
|
+
- Give glass and lights their shine in box and card impostors, with edge reflections and HDR glow.
|
|
6
|
+
|
|
7
|
+
## 0.3.4 - 2026-11-22
|
|
8
|
+
|
|
9
|
+
- Use Mesh Effects with the latest Three.js, r187. WebGPURenderer is supported from r185 and WebGLRenderer from r187.
|
|
10
|
+
- Ground octahedral impostors in your scene with real-time shadows on WebGPU, shaped by the captured model.
|
|
11
|
+
|
|
3
12
|
## 0.3.3 - 2026-11-16
|
|
4
13
|
|
|
5
14
|
- Reduce first-use shader compilation stalls for octahedral impostors.
|
package/README.md
CHANGED
|
@@ -6,14 +6,15 @@ Three.js loaders and TSL materials for GLBs exported by [Needle Mesh Baker](http
|
|
|
6
6
|
npm install @needle-tools/three-mesh-effects three
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
The package supports Three.js r185 and
|
|
9
|
+
The package supports Three.js r185 and later with `WebGPURenderer`, and r187
|
|
10
|
+
and later with `WebGLRenderer`. Its Needle Engine adapter is an
|
|
10
11
|
optional import. The examples use ordinary Three.js and assume an existing
|
|
11
12
|
`renderer`, `scene`, and `camera`.
|
|
12
13
|
|
|
13
14
|
## Features
|
|
14
15
|
|
|
15
16
|
- **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.
|
|
17
|
+
- **Card and box impostors (experimental):** Project or reconstruct six captures per part using shared PBR atlases, with captured glass edge reflections and HDR emission.
|
|
17
18
|
- **Octahedral impostors:** Load exported glTF extensions with a Three.js TSL material.
|
|
18
19
|
- **Deformation rigs:** Run IK and secondary motion alongside standard animation clips.
|
|
19
20
|
- **Pixel and voxel impostors:** Create the display mode selected in the workbench.
|
|
@@ -69,6 +69,8 @@ function parseBoxImpostorDescriptor(raw) {
|
|
|
69
69
|
fail();
|
|
70
70
|
if (d.alphaMode !== void 0 && !["opaque", "mask", "blend"].includes(d.alphaMode))
|
|
71
71
|
fail();
|
|
72
|
+
if (d.fresnelOpacity !== void 0 && typeof d.fresnelOpacity !== "boolean") fail();
|
|
73
|
+
if (d.emissiveStrength !== void 0 && (!Number.isFinite(d.emissiveStrength) || d.emissiveStrength < 1)) fail();
|
|
72
74
|
if (d.mode === "basic" && d.boxes.length !== 1) fail();
|
|
73
75
|
for (const b of d.boxes) {
|
|
74
76
|
if (b.occupancy !== void 0 && (!Array.isArray(b.occupancy) || b.occupancy.length !== BOX_OCCUPANCY_WORDS || !b.occupancy.every(
|
|
@@ -103,6 +105,8 @@ function parseBoxImpostorDescriptor(raw) {
|
|
|
103
105
|
atlasResolution: d.atlasResolution,
|
|
104
106
|
padding: d.padding,
|
|
105
107
|
boxes: d.boxes,
|
|
108
|
+
...d.fresnelOpacity !== void 0 ? { fresnelOpacity: d.fresnelOpacity } : {},
|
|
109
|
+
...d.emissiveStrength !== void 0 ? { emissiveStrength: d.emissiveStrength } : {},
|
|
106
110
|
...d.alphaMode ? { alphaMode: d.alphaMode } : {},
|
|
107
111
|
...normalizeBoxImpostorDisplay(d)
|
|
108
112
|
};
|
|
@@ -284,6 +288,7 @@ import {
|
|
|
284
288
|
attribute as attribute3,
|
|
285
289
|
varying,
|
|
286
290
|
positionLocal as positionLocal2,
|
|
291
|
+
positionViewDirection,
|
|
287
292
|
modelWorldMatrixInverse,
|
|
288
293
|
cameraPosition,
|
|
289
294
|
cameraWorldMatrix,
|
|
@@ -1213,8 +1218,15 @@ function createBoxImpostorMaterialVariant(descriptor, maps, { filtering = false
|
|
|
1213
1218
|
material.roughnessNode = surfaceOrm.g;
|
|
1214
1219
|
material.metalnessNode = surfaceOrm.b;
|
|
1215
1220
|
material.aoNode = surfaceOrm.r;
|
|
1216
|
-
material.emissiveNode = emission;
|
|
1217
|
-
if (transparency !== "cutout")
|
|
1221
|
+
material.emissiveNode = emission.mul(descriptor.emissiveStrength ?? 1);
|
|
1222
|
+
if (transparency !== "cutout") {
|
|
1223
|
+
let opacity = color.a.clamp(0, 1);
|
|
1224
|
+
if (descriptor.fresnelOpacity) {
|
|
1225
|
+
const cosine = material.normalNode.dot(positionViewDirection).abs().clamp(0, 1);
|
|
1226
|
+
opacity = opacity.add(opacity.oneMinus().mul(cosine.oneMinus().pow(5)));
|
|
1227
|
+
}
|
|
1228
|
+
material.opacityNode = opacity;
|
|
1229
|
+
}
|
|
1218
1230
|
material.maskNode = hit.get("valid").greaterThan(0.5);
|
|
1219
1231
|
material.maskShadowNode = material.maskNode;
|
|
1220
1232
|
material.depthNode = capturedSurfaceDepth(hit.get("position"));
|
|
@@ -1235,7 +1247,17 @@ import {
|
|
|
1235
1247
|
} from "three";
|
|
1236
1248
|
|
|
1237
1249
|
// src/rendering/renderer-support.js
|
|
1250
|
+
import { REVISION } from "three";
|
|
1238
1251
|
import * as TSL from "three/tsl";
|
|
1252
|
+
|
|
1253
|
+
// src/rendering/classic-webgl-support.js
|
|
1254
|
+
function classicWebGLSupportsNodeMaterials(revision) {
|
|
1255
|
+
const fork = /^186\.2-alpha\.(\d+)$/.exec(revision);
|
|
1256
|
+
if (fork) return Number(fork[1]) >= 2;
|
|
1257
|
+
return Number.parseInt(revision, 10) >= 187;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
// src/rendering/renderer-support.js
|
|
1239
1261
|
function rendererSupportsImpostorNodeMaterials(renderer) {
|
|
1240
1262
|
if (typeof Reflect.get(TSL, "struct") !== "function") return false;
|
|
1241
1263
|
return renderer?.isWebGPURenderer === true || renderer?.capabilities?.supportsNodeMaterials === true;
|
|
@@ -1247,6 +1269,9 @@ async function enableRendererNodeMaterials(renderer) {
|
|
|
1247
1269
|
if (!setup) {
|
|
1248
1270
|
setup = import("three/addons/tsl/WebGLNodesHandler.js").then(({ WebGLNodesHandler }) => {
|
|
1249
1271
|
if (rendererSupportsImpostorNodeMaterials(renderer)) return;
|
|
1272
|
+
if (!classicWebGLSupportsNodeMaterials(REVISION)) {
|
|
1273
|
+
console.warn(`Mesh Effects: WebGLRenderer from three r${REVISION} stops drawing node materials after about a dozen are in use. Use three r187 or later, or WebGPURenderer.`);
|
|
1274
|
+
}
|
|
1250
1275
|
renderer.setNodesHandler?.(new WebGLNodesHandler());
|
|
1251
1276
|
renderer.capabilities ??= {};
|
|
1252
1277
|
renderer.capabilities.supportsNodeMaterials = true;
|