@needle-tools/three-mesh-effects 0.3.2 → 0.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/three-mesh-effects",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Three.js loaders and TSL effects for Needle Mesh Baker outputs.",
5
5
  "keywords": [
6
6
  "three.js",
@@ -925,14 +925,13 @@ export function createPbrImpostorNodeMaterial(descriptor, maps, inputFeatures =
925
925
  .add(cameraUpLocal.mul(positionGeometry.y));
926
926
  const planeLocal = samplingBillboardPosition.toVarying('vImpostorPlaneLocal');
927
927
  const createFrameSampler = (withReprojection) => {
928
- const buildFrameSample = ([frame, planePosition, rayDirection]) => {
928
+ const buildFrameSample = ([frame, planePosition, rayDirection, bounds]) => {
929
929
  const frameDirection = singleView
930
930
  ? singleCaptureDirection
931
931
  : gridToDirection(frame.div(frames.sub(1)));
932
932
  const basis = frameBasis(frameDirection);
933
933
  const right = basisMember(basis, 'right');
934
934
  const up = basisMember(basis, 'up');
935
- const bounds = viewBounds.element(int(frame.y.mul(frames).add(frame.x)));
936
935
  // Every atlas frame is an orthographic capture whose image plane passes
937
936
  // through the object center. Start from the intersection of the current
938
937
  // perspective camera ray and that frame plane. Projecting `planePosition`
@@ -1292,7 +1291,20 @@ export function createPbrImpostorNodeMaterial(descriptor, maps, inputFeatures =
1292
1291
  footprint,
1293
1292
  );
1294
1293
  };
1295
- return Fn(buildFrameSample);
1294
+ // Share the expensive frame search across the three selected captures.
1295
+ // Resolve uniform-array bounds at the call site for both TSL backends.
1296
+ const sampleFrame = Fn(buildFrameSample).setLayout({
1297
+ name: withReprojection ? 'sampleReprojectedImpostorFrame' : 'samplePlanarImpostorFrame',
1298
+ type: 'ImpostorFrameSample',
1299
+ inputs: [
1300
+ { name: 'frame', type: 'vec2' },
1301
+ { name: 'planePosition', type: 'vec3' },
1302
+ { name: 'rayDirection', type: 'vec3' },
1303
+ { name: 'bounds', type: 'vec4' },
1304
+ ],
1305
+ });
1306
+ return (frame, planePosition, rayDirection) => sampleFrame(frame, planePosition, rayDirection,
1307
+ viewBounds.element(int(frame.y.mul(frames).add(frame.x))));
1296
1308
  };
1297
1309
  const samplePlanarFrame = createFrameSampler(false);
1298
1310
  const sampleReprojectedFrame = features.reprojection ? createFrameSampler(true) : null;