@needle-tools/three-mesh-effects 0.2.3 → 0.3.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.
Files changed (113) hide show
  1. package/CHANGELOG.md +34 -8
  2. package/README.md +86 -3
  3. package/SKILL.md +14 -4
  4. package/build/box-impostor-runtime.js +1423 -0
  5. package/build/box-impostor-runtime.js.map +7 -0
  6. package/build/deformation-runtime.js +30 -19
  7. package/build/deformation-runtime.js.map +3 -3
  8. package/build/hull-effects.js +60 -28
  9. package/build/hull-effects.js.map +3 -3
  10. package/build/impostor-runtime.js +264 -133
  11. package/build/impostor-runtime.js.map +4 -4
  12. package/build/index.js +8 -0
  13. package/build/index.js.map +2 -2
  14. package/build/internal/box-impostor/box-impostor-display-settings.js +50 -0
  15. package/build/internal/box-impostor/box-impostor-display-settings.js.map +7 -0
  16. package/build/internal/box-impostor/box-impostor-display.js +1102 -0
  17. package/build/internal/box-impostor/box-impostor-display.js.map +7 -0
  18. package/build/internal/box-impostor/box-impostor-face-axes.js +15 -0
  19. package/build/internal/box-impostor/box-impostor-face-axes.js.map +7 -0
  20. package/build/internal/box-impostor/box-impostor-faces.js +125 -0
  21. package/build/internal/box-impostor/box-impostor-faces.js.map +7 -0
  22. package/build/internal/box-impostor/box-impostor-geometry.js +230 -0
  23. package/build/internal/box-impostor/box-impostor-geometry.js.map +7 -0
  24. package/build/internal/box-impostor/box-impostor-material.js +1056 -0
  25. package/build/internal/box-impostor/box-impostor-material.js.map +7 -0
  26. package/build/internal/box-impostor/box-impostor-metadata.js +108 -0
  27. package/build/internal/box-impostor/box-impostor-metadata.js.map +7 -0
  28. package/build/internal/box-impostor/box-impostor-projection.js +276 -0
  29. package/build/internal/box-impostor/box-impostor-projection.js.map +7 -0
  30. package/build/internal/box-impostor/box-impostor-runtime.js +1369 -0
  31. package/build/internal/box-impostor/box-impostor-runtime.js.map +7 -0
  32. package/build/internal/box-impostor/box-impostor-surface-search.js +21 -0
  33. package/build/internal/box-impostor/box-impostor-surface-search.js.map +7 -0
  34. package/build/internal/deformation/cloth-surface.js +23 -17
  35. package/build/internal/deformation/cloth-surface.js.map +3 -3
  36. package/build/internal/deformation/pin-cloth.js +7 -2
  37. package/build/internal/deformation/pin-cloth.js.map +2 -2
  38. package/build/internal/deformation/rig-runtime.js +30 -19
  39. package/build/internal/deformation/rig-runtime.js.map +3 -3
  40. package/build/internal/impostor/impostor-node-material.js +264 -133
  41. package/build/internal/impostor/impostor-node-material.js.map +4 -4
  42. package/build/internal/pixel-impostor/pixel-impostor-display.js +84 -38
  43. package/build/internal/pixel-impostor/pixel-impostor-display.js.map +4 -4
  44. package/build/internal/rendering/captured-surface-depth.js +35 -0
  45. package/build/internal/rendering/captured-surface-depth.js.map +7 -0
  46. package/build/internal/rendering/captured-surface-material.js +28 -0
  47. package/build/internal/rendering/captured-surface-material.js.map +7 -0
  48. package/build/internal/rendering/hull-effect-runtime.js +59 -27
  49. package/build/internal/rendering/hull-effect-runtime.js.map +3 -3
  50. package/build/internal/rendering/renderer-support.js +31 -0
  51. package/build/internal/rendering/renderer-support.js.map +7 -0
  52. package/build/internal/rendering/wireframe.js +41 -9
  53. package/build/internal/rendering/wireframe.js.map +2 -2
  54. package/build/internal/rendering/wrap-preview.js +59 -27
  55. package/build/internal/rendering/wrap-preview.js.map +3 -3
  56. package/build/pixel-impostor-runtime.js +84 -38
  57. package/build/pixel-impostor-runtime.js.map +4 -4
  58. package/build/types/box-impostor/box-impostor-display-settings.d.ts +30 -0
  59. package/build/types/box-impostor/box-impostor-display-settings.js +1 -0
  60. package/build/types/box-impostor/box-impostor-display.d.ts +13 -0
  61. package/build/types/box-impostor/box-impostor-display.js +1 -0
  62. package/build/types/box-impostor/box-impostor-face-axes.d.ts +5 -0
  63. package/build/types/box-impostor/box-impostor-face-axes.js +1 -0
  64. package/build/types/box-impostor/box-impostor-faces.d.ts +11 -0
  65. package/build/types/box-impostor/box-impostor-faces.js +1 -0
  66. package/build/types/box-impostor/box-impostor-geometry.d.ts +5 -0
  67. package/build/types/box-impostor/box-impostor-geometry.js +1 -0
  68. package/build/types/box-impostor/box-impostor-material.d.ts +14 -0
  69. package/build/types/box-impostor/box-impostor-material.js +1 -0
  70. package/build/types/box-impostor/box-impostor-metadata.d.ts +31 -0
  71. package/build/types/box-impostor/box-impostor-metadata.js +1 -0
  72. package/build/types/box-impostor/box-impostor-projection.d.ts +19 -0
  73. package/build/types/box-impostor/box-impostor-projection.js +1 -0
  74. package/build/types/box-impostor/box-impostor-runtime.d.ts +19 -0
  75. package/build/types/box-impostor/box-impostor-runtime.js +1 -0
  76. package/build/types/box-impostor/box-impostor-surface-search.d.ts +13 -0
  77. package/build/types/box-impostor/box-impostor-surface-search.js +1 -0
  78. package/build/types/deformation/cloth-surface.d.ts +1 -0
  79. package/build/types/deformation/pin-cloth.d.ts +1 -0
  80. package/build/types/impostor/impostor-node-material.d.ts +2 -15
  81. package/build/types/public/box-impostor-runtime.d.ts +6 -0
  82. package/build/types/public/box-impostor-runtime.js +1 -0
  83. package/build/types/public/hull-effects.d.ts +1 -0
  84. package/build/types/public/index.d.ts +1 -1
  85. package/build/types/rendering/captured-surface-depth.d.ts +5 -0
  86. package/build/types/rendering/captured-surface-depth.js +1 -0
  87. package/build/types/rendering/captured-surface-material.d.ts +8 -0
  88. package/build/types/rendering/captured-surface-material.js +1 -0
  89. package/build/types/rendering/renderer-support.d.ts +27 -0
  90. package/build/types/rendering/renderer-support.js +1 -0
  91. package/build/types/rendering/wireframe.d.ts +2 -2
  92. package/package.json +29 -8
  93. package/src/box-impostor/box-impostor-display-settings.js +54 -0
  94. package/src/box-impostor/box-impostor-display.js +50 -0
  95. package/src/box-impostor/box-impostor-face-axes.js +11 -0
  96. package/src/box-impostor/box-impostor-faces.js +118 -0
  97. package/src/box-impostor/box-impostor-geometry.js +140 -0
  98. package/src/box-impostor/box-impostor-material.js +771 -0
  99. package/src/box-impostor/box-impostor-metadata.js +122 -0
  100. package/src/box-impostor/box-impostor-projection.js +276 -0
  101. package/src/box-impostor/box-impostor-runtime.js +124 -0
  102. package/src/box-impostor/box-impostor-surface-search.js +11 -0
  103. package/src/deformation/cloth-surface.ts +28 -17
  104. package/src/deformation/pin-cloth.ts +9 -3
  105. package/src/impostor/impostor-node-material.js +188 -157
  106. package/src/pixel-impostor/pixel-impostor-display.js +5 -13
  107. package/src/public/box-impostor-runtime.js +14 -0
  108. package/src/public/hull-effects.js +1 -0
  109. package/src/public/index.js +10 -1
  110. package/src/rendering/captured-surface-depth.js +55 -0
  111. package/src/rendering/captured-surface-material.js +27 -0
  112. package/src/rendering/renderer-support.js +50 -0
  113. package/src/rendering/wireframe.js +51 -13
@@ -144,20 +144,71 @@ function registerNeedlePixelImpostorLoader(loader) {
144
144
  return loader;
145
145
  }
146
146
 
147
+ // src/rendering/captured-surface-material.js
148
+ import { MeshStandardNodeMaterial } from "three/webgpu";
149
+ import { context, modelViewMatrix, modelWorldMatrix, vec4 } from "three/tsl";
150
+ var CapturedSurfaceMaterial = class extends MeshStandardNodeMaterial {
151
+ /** @type {import('three/webgpu').Node<'vec3'> | null} */
152
+ capturedPositionNode = null;
153
+ /**
154
+ * @override
155
+ * @param {import('three/webgpu').NodeBuilder} builder
156
+ */
157
+ setupLighting(builder) {
158
+ const lighting = super.setupLighting(builder);
159
+ if (!this.capturedPositionNode) return lighting;
160
+ const world = modelWorldMatrix.mul(vec4(this.capturedPositionNode, 1)).xyz;
161
+ const view = modelViewMatrix.mul(vec4(this.capturedPositionNode, 1)).xyz;
162
+ return context(lighting, {
163
+ positionView: view,
164
+ positionWorld: world,
165
+ shadowPositionWorld: world
166
+ });
167
+ }
168
+ };
169
+
170
+ // src/rendering/captured-surface-depth.js
171
+ import {
172
+ Fn,
173
+ cameraFar,
174
+ cameraNear,
175
+ cameraProjectionMatrix,
176
+ modelViewMatrix as modelViewMatrix2,
177
+ vec4 as vec42,
178
+ viewZToLogarithmicDepth,
179
+ viewZToOrthographicDepth,
180
+ viewZToPerspectiveDepth,
181
+ viewZToReversedOrthographicDepth,
182
+ viewZToReversedPerspectiveDepth
183
+ } from "three/tsl";
184
+ function capturedSurfaceDepth(position, shadowBias = 0) {
185
+ return Fn(
186
+ (_, builder) => {
187
+ const z = modelViewMatrix2.mul(vec42(position, 1)).z.toVar("capturedSurfaceViewZ");
188
+ const reversed = builder.renderer.reversedDepthBuffer === true;
189
+ const perspective = cameraProjectionMatrix.mul(vec42(0, 0, 0, 1)).w.equal(0);
190
+ const perspectiveDepth = builder.renderer.logarithmicDepthBuffer === true ? viewZToLogarithmicDepth(z, cameraNear, cameraFar) : (reversed ? viewZToReversedPerspectiveDepth : viewZToPerspectiveDepth)(z, cameraNear, cameraFar);
191
+ const result = perspective.select(
192
+ perspectiveDepth,
193
+ (reversed ? viewZToReversedOrthographicDepth : viewZToOrthographicDepth)(z, cameraNear, cameraFar)
194
+ );
195
+ return shadowBias && "isShadowPassMaterial" in builder.material && builder.material.isShadowPassMaterial ? result.add(reversed ? -shadowBias : shadowBias).clamp(0, 1) : result;
196
+ }
197
+ )();
198
+ }
199
+
147
200
  // src/pixel-impostor/pixel-impostor-display.js
148
201
  import * as THREE from "three";
149
- import { MeshBasicNodeMaterial, MeshStandardNodeMaterial } from "three/webgpu";
202
+ import { MeshBasicNodeMaterial, MeshStandardNodeMaterial as MeshStandardNodeMaterial2 } from "three/webgpu";
150
203
  import {
151
204
  Break,
152
- Fn,
205
+ Fn as Fn2,
153
206
  If,
154
207
  Loop,
155
208
  abs,
156
209
  attribute,
157
- cameraProjectionMatrix,
210
+ cameraProjectionMatrix as cameraProjectionMatrix2,
158
211
  cameraProjectionMatrixInverse,
159
- cameraFar,
160
- cameraNear,
161
212
  cameraPosition,
162
213
  cameraWorldMatrix,
163
214
  ceil,
@@ -169,8 +220,8 @@ import {
169
220
  max,
170
221
  min,
171
222
  mix,
172
- modelViewMatrix,
173
- modelWorldMatrix,
223
+ modelViewMatrix as modelViewMatrix3,
224
+ modelWorldMatrix as modelWorldMatrix2,
174
225
  modelWorldMatrixInverse,
175
226
  mod,
176
227
  normalMap as normalMapNode,
@@ -189,10 +240,8 @@ import {
189
240
  uv,
190
241
  vec2,
191
242
  vec3,
192
- vec4,
193
- vertexColor,
194
- viewZToOrthographicDepth,
195
- viewZToPerspectiveDepth
243
+ vec4 as vec43,
244
+ vertexColor
196
245
  } from "three/tsl";
197
246
  function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
198
247
  const binding = descriptor;
@@ -283,7 +332,7 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
283
332
  const bytes = uvec4(texture(indexAtlas, linearTextureUv(texel, indexAtlasSize)).mul(255).round());
284
333
  return bytes.x.bitOr(bytes.y.shiftLeft(8)).bitOr(bytes.z.shiftLeft(16)).bitOr(bytes.w.shiftLeft(24));
285
334
  };
286
- const traceVolumeNode = Fn(([sampleOffset]) => {
335
+ const traceVolumeNode = Fn2(([sampleOffset]) => {
287
336
  const rasterPixelSize = screenPixelSize.mul(dpr);
288
337
  const sampleCoordinate = screenCoordinate.div(rasterPixelSize).floor().mul(rasterPixelSize).add(
289
338
  rasterPixelSize.mul(vec2(0.5).add(sampleOffset))
@@ -291,8 +340,8 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
291
340
  const sampleUv = sampleCoordinate.div(screenSize);
292
341
  const nearView = getViewPosition(sampleUv, float(0), cameraProjectionMatrixInverse);
293
342
  const farView = getViewPosition(sampleUv, float(1), cameraProjectionMatrixInverse);
294
- const nearWorld = cameraWorldMatrix.mul(vec4(nearView, 1));
295
- const farWorld = cameraWorldMatrix.mul(vec4(farView, 1));
343
+ const nearWorld = cameraWorldMatrix.mul(vec43(nearView, 1));
344
+ const farWorld = cameraWorldMatrix.mul(vec43(farView, 1));
296
345
  const rayOrigin = modelWorldMatrixInverse.mul(nearWorld).xyz;
297
346
  const rayFar = modelWorldMatrixInverse.mul(farWorld).xyz;
298
347
  const rayDirection = rayFar.sub(rayOrigin).normalize();
@@ -317,7 +366,7 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
317
366
  const nextDistance = cellFraction.mul(vec3(1).sub(positiveAxis)).add(vec3(1).sub(cellFraction).mul(positiveAxis));
318
367
  const nextCrossing = nextDistance.div(absoluteVelocity).toVar();
319
368
  const crossingDelta = vec3(1).div(absoluteVelocity);
320
- const result = vec4(0, 0, 0, 0).toVar();
369
+ const result = vec43(0, 0, 0, 0).toVar();
321
370
  const travelled = nearestDistance.toVar();
322
371
  Loop(maximumSteps, () => {
323
372
  const outside = cell.x.lessThan(0).or(cell.y.lessThan(0)).or(cell.z.lessThan(0)).or(cell.x.greaterThanEqual(planar)).or(cell.y.greaterThanEqual(layers)).or(cell.z.greaterThanEqual(planar));
@@ -341,7 +390,7 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
341
390
  cellOccupied = texture(atlas, atlasUv).a.greaterThan(0.5);
342
391
  }
343
392
  If(cellOccupied, () => {
344
- result.assign(vec4(
393
+ result.assign(vec43(
345
394
  rayOrigin.add(rayDirection.mul(travelled)),
346
395
  linearCell.add(1)
347
396
  ));
@@ -369,10 +418,6 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
369
418
  /** @type {unknown} */
370
419
  traceVolumeNode
371
420
  );
372
- const reconstructedDepth = Fn(([localPosition], builder) => {
373
- const viewZ = modelViewMatrix.mul(vec4(localPosition, 1)).z;
374
- return builder.camera.isPerspectiveCamera ? viewZToPerspectiveDepth(viewZ, cameraNear, cameraFar) : viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);
375
- }, "float");
376
421
  const createRaycastMaterial = (antialias, pbr) => {
377
422
  const centerHit = traceVolume(vec2(0));
378
423
  const occupied = centerHit.w.greaterThan(0);
@@ -414,9 +459,9 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
414
459
  );
415
460
  }
416
461
  const baseSample = texture(atlas, hitAtlasUv);
417
- const ormSample = ormAtlas ? texture(ormAtlas, hitAtlasUv) : vec4(1, 1, 0, 1);
462
+ const ormSample = ormAtlas ? texture(ormAtlas, hitAtlasUv) : vec43(1, 1, 0, 1);
418
463
  const hitPosition = hit.xyz;
419
- const hitToCamera = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz.sub(hitPosition);
464
+ const hitToCamera = modelWorldMatrixInverse.mul(vec43(cameraPosition, 1)).xyz.sub(hitPosition);
420
465
  const faceSign = step(0, hitToCamera).mul(2).sub(1);
421
466
  const hitCellCenter = hitCell.add(0.5).div(volumeDimensions).sub(0.5).mul(sizeNode).sub(raycastOffsetNode);
422
467
  const cellDelta = hitPosition.sub(hitCellCenter).div(sizeNode).mul(volumeDimensions);
@@ -435,13 +480,13 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
435
480
  const projectedNormal = bakedNormal.dot(geometricNormal).lessThan(0).select(bakedNormal.negate(), bakedNormal);
436
481
  const shadingNormal = mix(geometricNormal, projectedNormal, projectedNormalMix).normalize();
437
482
  const materialName = `Pixel impostor \xB7 volume raycast \xB7 ${antialias ? "AA" : "fast"} \xB7 ${pbr ? "PBR maps" : "plain lit"}`;
438
- const material = new MeshStandardNodeMaterial({
483
+ const material = new CapturedSurfaceMaterial({
439
484
  name: materialName,
440
485
  side: THREE.FrontSide,
441
486
  depthTest: true,
442
487
  depthWrite: true
443
488
  });
444
- material.colorNode = vec4(
489
+ material.colorNode = vec43(
445
490
  baseSample.rgb.mul(float(1).sub(unlitMix)),
446
491
  antialias ? baseSample.a.mul(coverage) : baseSample.a
447
492
  );
@@ -452,13 +497,14 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
452
497
  material.roughnessNode = ormSample.g.max(0.04);
453
498
  material.metalnessNode = ormSample.b;
454
499
  }
455
- material.receivedShadowPositionNode = modelWorldMatrix.mul(vec4(hitPosition, 1)).xyz;
500
+ material.receivedShadowPositionNode = modelWorldMatrix2.mul(vec43(hitPosition, 1)).xyz;
456
501
  material.maskNode = occupied.and(
457
502
  baseSample.a.greaterThan(Number(descriptor.alphaCutoff) || 0.5)
458
503
  );
459
504
  material.maskShadowNode = antialias ? coverage.greaterThanEqual(0.5) : occupied;
460
505
  material.alphaToCoverage = antialias;
461
- material.depthNode = reconstructedDepth(hitPosition);
506
+ material.capturedPositionNode = hitPosition;
507
+ material.depthNode = capturedSurfaceDepth(hitPosition);
462
508
  material.toneMapped = true;
463
509
  material.userData.screenPixelSize = screenPixelSize;
464
510
  material.userData.pixelImpostorRaycastAntialias = antialias;
@@ -504,7 +550,7 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
504
550
  shell
505
551
  );
506
552
  const geometryBaseSample = texture(atlas, uv());
507
- const geometryOrmSample = ormAtlas ? texture(ormAtlas, uv()) : vec4(1, 1, 0, 1);
553
+ const geometryOrmSample = ormAtlas ? texture(ormAtlas, uv()) : vec43(1, 1, 0, 1);
508
554
  const geometryNormal = attribute(
509
555
  "normal",
510
556
  /** @type {const} */
@@ -513,13 +559,13 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
513
559
  const geometryProjectedNormal = normalAtlas ? texture(normalAtlas, uv()).xyz.mul(2).sub(1).normalize() : geometryNormal;
514
560
  const geometryAlignedNormal = geometryProjectedNormal.dot(geometryNormal).lessThan(0).select(geometryProjectedNormal.negate(), geometryProjectedNormal);
515
561
  const createGeometryMaterial = (pbr) => {
516
- const material = new MeshStandardNodeMaterial({
562
+ const material = new MeshStandardNodeMaterial2({
517
563
  name: `Pixel impostor \xB7 voxel geometry \xB7 ${pbr ? "mapped" : "plain"}`,
518
564
  side: THREE.FrontSide,
519
565
  depthTest: true,
520
566
  depthWrite: true
521
567
  });
522
- material.colorNode = vec4(
568
+ material.colorNode = vec43(
523
569
  geometryBaseSample.rgb.mul(float(1).sub(unlitMix)),
524
570
  geometryBaseSample.a
525
571
  );
@@ -599,13 +645,13 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
599
645
  /** @type {const} */
600
646
  "vec2"
601
647
  );
602
- const centerView = modelViewMatrix.mul(vec4(voxelCenter, 1));
603
- const centerClip = cameraProjectionMatrix.mul(centerView);
648
+ const centerView = modelViewMatrix3.mul(vec43(voxelCenter, 1));
649
+ const centerClip = cameraProjectionMatrix2.mul(centerView);
604
650
  const centerNdc = centerClip.xy.div(centerClip.w);
605
651
  const cssViewport = viewportSize;
606
652
  const centerCss = centerNdc.mul(0.5).add(0.5).mul(cssViewport);
607
653
  const projectVoxelPoint = (point) => {
608
- const projected = cameraProjectionMatrix.mul(modelViewMatrix.mul(vec4(point, 1)));
654
+ const projected = cameraProjectionMatrix2.mul(modelViewMatrix3.mul(vec43(point, 1)));
609
655
  return projected.xy.div(projected.w).mul(0.5).add(0.5).mul(cssViewport);
610
656
  };
611
657
  const projectedX = projectVoxelPoint(voxelCenter.add(vec3(voxelHalfExtents.x, 0, 0)));
@@ -626,10 +672,10 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
626
672
  const splatSize = cellSpan.mul(splatPixelSize).mul(splatScale);
627
673
  const quadCss = snappedCss.add(voxelCorner.mul(splatSize.mul(0.52)));
628
674
  const quadNdc = quadCss.div(cssViewport).mul(2).sub(1);
629
- const quadClip = vec4(quadNdc.mul(centerClip.w), centerClip.z, centerClip.w);
675
+ const quadClip = vec43(quadNdc.mul(centerClip.w), centerClip.z, centerClip.w);
630
676
  const quadViewHomogeneous = cameraProjectionMatrixInverse.mul(quadClip);
631
677
  const quadView = quadViewHomogeneous.xyz.div(quadViewHomogeneous.w);
632
- const quadWorld = cameraWorldMatrix.mul(vec4(quadView, 1));
678
+ const quadWorld = cameraWorldMatrix.mul(vec43(quadView, 1));
633
679
  const quadLocalHomogeneous = modelWorldMatrixInverse.mul(quadWorld);
634
680
  const quadLocal = quadLocalHomogeneous.xyz.div(quadLocalHomogeneous.w);
635
681
  const splatUv = useSurfacePoints ? linearTextureUv(attribute(
@@ -638,8 +684,8 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
638
684
  "float"
639
685
  ), surfaceAtlasSize) : uv();
640
686
  const splatColor = texture(atlas, splatUv);
641
- const splatOrm = ormAtlas ? texture(ormAtlas, splatUv) : vec4(1, 1, 0, 1);
642
- const cameraLocal = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz;
687
+ const splatOrm = ormAtlas ? texture(ormAtlas, splatUv) : vec43(1, 1, 0, 1);
688
+ const cameraLocal = modelWorldMatrixInverse.mul(vec43(cameraPosition, 1)).xyz;
643
689
  const viewDirection = cameraLocal.sub(voxelCenter).normalize();
644
690
  const splatBakedNormal = normalAtlas ? texture(normalAtlas, splatUv).xyz.mul(2).sub(1).normalize() : viewDirection;
645
691
  const splatProjectedNormal = splatBakedNormal.dot(viewDirection).lessThan(0).select(splatBakedNormal.negate(), splatBakedNormal);
@@ -681,14 +727,14 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
681
727
  splatMask = sourceFaceNormal.dot(viewDirection).greaterThanEqual(bestFaceScore.sub(1e-5)).and(splatColor.a.greaterThan(0.5));
682
728
  }
683
729
  const createSnappedMaterial = (pbr) => {
684
- const material = new MeshStandardNodeMaterial({
730
+ const material = new MeshStandardNodeMaterial2({
685
731
  name: `Pixel impostor \xB7 vertex-snapped shell \xB7 ${pbr ? "mapped" : "plain"}`,
686
732
  side: THREE.FrontSide,
687
733
  depthTest: true,
688
734
  depthWrite: true
689
735
  });
690
736
  material.positionNode = quadLocal;
691
- material.colorNode = vec4(splatColor.rgb.mul(float(1).sub(unlitMix)), splatColor.a);
737
+ material.colorNode = vec43(splatColor.rgb.mul(float(1).sub(unlitMix)), splatColor.a);
692
738
  material.emissiveNode = splatColor.rgb.mul(pbr ? splatOrm.r : 1).mul(unlitMix);
693
739
  material.normalNode = transformNormalToView(splatShadingNormal);
694
740
  if (pbr) {