@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
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
3
|
// src/rendering/renderer-support.js
|
|
4
|
+
import { REVISION } from "three";
|
|
4
5
|
import * as TSL from "three/tsl";
|
|
6
|
+
|
|
7
|
+
// src/rendering/classic-webgl-support.js
|
|
8
|
+
function classicWebGLSupportsNodeMaterials(revision) {
|
|
9
|
+
const fork = /^186\.2-alpha\.(\d+)$/.exec(revision);
|
|
10
|
+
if (fork) return Number(fork[1]) >= 2;
|
|
11
|
+
return Number.parseInt(revision, 10) >= 187;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/rendering/renderer-support.js
|
|
5
15
|
function rendererSupportsImpostorNodeMaterials(renderer) {
|
|
6
16
|
if (typeof Reflect.get(TSL, "struct") !== "function") return false;
|
|
7
17
|
return renderer?.isWebGPURenderer === true || renderer?.capabilities?.supportsNodeMaterials === true;
|
|
@@ -13,6 +23,9 @@ async function enableRendererNodeMaterials(renderer) {
|
|
|
13
23
|
if (!setup) {
|
|
14
24
|
setup = import("three/addons/tsl/WebGLNodesHandler.js").then(({ WebGLNodesHandler }) => {
|
|
15
25
|
if (rendererSupportsImpostorNodeMaterials(renderer)) return;
|
|
26
|
+
if (!classicWebGLSupportsNodeMaterials(REVISION)) {
|
|
27
|
+
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.`);
|
|
28
|
+
}
|
|
16
29
|
renderer.setNodesHandler?.(new WebGLNodesHandler());
|
|
17
30
|
renderer.capabilities ??= {};
|
|
18
31
|
renderer.capabilities.supportsNodeMaterials = true;
|
|
@@ -766,7 +779,7 @@ function createPbrImpostorNodeMaterial(descriptor, maps, inputFeatures = {}, ren
|
|
|
766
779
|
const padding = float(descriptor.padding);
|
|
767
780
|
const radius = float(descriptor.radius);
|
|
768
781
|
const captureAlphaCutoff = float(descriptor.captureAlphaCutoff);
|
|
769
|
-
const reprojectionSurfaceCutoff = descriptor.coverageEncoding === "sdf-base-alpha" ? float(0.5) : min(captureAlphaCutoff,
|
|
782
|
+
const reprojectionSurfaceCutoff = descriptor.coverageEncoding === "sdf-base-alpha" ? float(0.5) : float(Math.min(Number(descriptor.captureAlphaCutoff), 0.25));
|
|
770
783
|
const blendCutoff = float((1 - profile.blendZone) * 0.5);
|
|
771
784
|
const coarseSearchSteps = profile.raySamples;
|
|
772
785
|
const fullSphere = descriptor.mapping === "full";
|
|
@@ -1254,26 +1267,35 @@ function createPbrImpostorNodeMaterial(descriptor, maps, inputFeatures = {}, ren
|
|
|
1254
1267
|
footprint
|
|
1255
1268
|
);
|
|
1256
1269
|
};
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1270
|
+
const functions = /* @__PURE__ */ new WeakMap();
|
|
1271
|
+
return (builder) => {
|
|
1272
|
+
let sampleFrame = functions.get(builder);
|
|
1273
|
+
if (!sampleFrame) {
|
|
1274
|
+
sampleFrame = Fn2(buildFrameSample).setLayout({
|
|
1275
|
+
name: withReprojection ? "sampleReprojectedImpostorFrame" : "samplePlanarImpostorFrame",
|
|
1276
|
+
type: "ImpostorFrameSample",
|
|
1277
|
+
inputs: [
|
|
1278
|
+
{ name: "frame", type: "vec2" },
|
|
1279
|
+
{ name: "planePosition", type: "vec3" },
|
|
1280
|
+
{ name: "rayDirection", type: "vec3" },
|
|
1281
|
+
{ name: "bounds", type: "vec4" }
|
|
1282
|
+
]
|
|
1283
|
+
});
|
|
1284
|
+
functions.set(builder, sampleFrame);
|
|
1285
|
+
}
|
|
1286
|
+
return (frame, planePosition, rayDirection) => sampleFrame(
|
|
1287
|
+
frame,
|
|
1288
|
+
planePosition,
|
|
1289
|
+
rayDirection,
|
|
1290
|
+
viewBounds.element(int(frame.y.mul(frames).add(frame.x)))
|
|
1291
|
+
);
|
|
1292
|
+
};
|
|
1273
1293
|
};
|
|
1274
|
-
const
|
|
1275
|
-
const
|
|
1294
|
+
const planarFrameSamplers = createFrameSampler(false);
|
|
1295
|
+
const reprojectedFrameSamplers = features.reprojection ? createFrameSampler(true) : null;
|
|
1276
1296
|
const buildBlendedSample = ([], builder) => {
|
|
1297
|
+
const samplePlanarFrame = planarFrameSamplers(builder);
|
|
1298
|
+
const sampleReprojectedFrame = reprojectedFrameSamplers ? reprojectedFrameSamplers(builder) : null;
|
|
1277
1299
|
const samplingCameraLocal = samplingCamera;
|
|
1278
1300
|
const centerViewDirection = samplingCameraLocal.normalize();
|
|
1279
1301
|
const usePerspectiveCorrection = features.perspectiveCorrection && builder.camera.isPerspectiveCamera;
|