@needle-tools/three-mesh-effects 0.3.4 → 0.3.6
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 +32 -27
- package/README.md +63 -231
- package/SKILL.md +11 -68
- package/build/box-impostor-runtime.js +14 -2
- package/build/box-impostor-runtime.js.map +2 -2
- package/build/deformation-runtime.js +1 -1
- package/build/deformation-runtime.js.map +1 -1
- package/build/hull-effects.js.map +1 -1
- package/build/impostor-runtime.js +2 -2
- package/build/impostor-runtime.js.map +2 -2
- package/build/index.js +2 -2
- package/build/index.js.map +2 -2
- 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 +14 -2
- package/build/internal/box-impostor/box-impostor-runtime.js.map +2 -2
- package/build/internal/deformation/rig-runtime.js +1 -1
- package/build/internal/deformation/rig-runtime.js.map +1 -1
- package/build/internal/impostor/impostor-node-material.js +2 -2
- package/build/internal/impostor/impostor-node-material.js.map +2 -2
- package/build/internal/impostor/octahedral.js.map +1 -1
- package/build/internal/pixel-impostor/pixel-impostor-display.js +39 -16
- package/build/internal/pixel-impostor/pixel-impostor-display.js.map +2 -2
- package/build/internal/pixel-impostor/pixel-impostor-metadata.js +61 -6
- package/build/internal/pixel-impostor/pixel-impostor-metadata.js.map +2 -2
- package/build/internal/pixel-impostor/pixel-impostor-runtime.js +980 -26
- package/build/internal/pixel-impostor/pixel-impostor-runtime.js.map +4 -4
- package/build/internal/rendering/hull-effect-runtime.js.map +1 -1
- package/build/internal/rendering/renderer-support.js.map +1 -1
- package/build/internal/rendering/skin-projection.js.map +1 -1
- package/build/internal/rendering/surface-query.js.map +1 -1
- package/build/internal/rendering/wrap-preview.js.map +1 -1
- package/build/internal/rendering/wrap-skin.js.map +1 -1
- package/build/pixel-impostor-runtime.js +362 -172
- package/build/pixel-impostor-runtime.js.map +4 -4
- package/build/types/box-impostor/box-impostor-metadata.d.ts +3 -1
- package/build/types/deformation/rig-runtime.d.ts +1 -1
- package/build/types/impostor/octahedral.d.ts +1 -1
- package/build/types/pixel-impostor/pixel-impostor-display.d.ts +3 -3
- package/build/types/pixel-impostor/pixel-impostor-metadata.d.ts +76 -5
- package/build/types/pixel-impostor/pixel-impostor-runtime.d.ts +19 -7
- package/build/types/public/pixel-impostor-runtime.d.ts +1 -1
- package/build/types/rendering/renderer-support.d.ts +1 -1
- package/build/types/rendering/surface-query.d.ts +2 -2
- 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/rig-runtime.ts +1 -1
- package/src/impostor/impostor-node-material.js +2 -2
- package/src/impostor/octahedral.js +1 -1
- package/src/pixel-impostor/pixel-impostor-display.js +32 -18
- package/src/pixel-impostor/pixel-impostor-metadata.js +69 -9
- package/src/pixel-impostor/pixel-impostor-runtime.js +32 -9
- package/src/public/index.js +2 -2
- package/src/public/pixel-impostor-runtime.js +1 -1
- package/src/rendering/renderer-support.js +1 -1
- package/src/rendering/surface-query.js +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/impostor/octahedral.js"],
|
|
4
|
-
"sourcesContent": ["// @ts-check\n\n// A billboard point samples the capture camera along point -> camera, so its\n// local plane offset is subtracted from the object-center camera vector.\nexport const PERSPECTIVE_RAY_PLANE_SIGN = -1;\n\n/**\n * Encodes a local-space point into the orthographic capture depth used by the\n * normal/depth atlas. Capture cameras sit at `direction * 2r` and cover the\n * interval from +r to -r along their forward axis.\n *\n * @param {[number, number, number]} point\n * @param {[number, number, number]} direction Unit capture direction.\n * @param {number} radius\n */\nexport function captureDepthFromPoint(point, direction, radius) {\n if (!(radius > 0) || !Number.isFinite(radius)) {\n throw new RangeError('Capture radius must be positive and finite.');\n }\n const normalizedDirection = normalize3(direction);\n return (radius - dot3(point, normalizedDirection)) / (2 * radius);\n}\n\n/**\n * Intersects a runtime point-to-camera ray with the capture-depth plane\n * `dot(P, captureDirection) = radius - 2 * radius * depth`.\n *\n * This is the fixed-point step solved by the runtime parallax shader. It is\n * deliberately expressed independently here so sign and scale regressions are\n * caught by browserless tests.\n *\n * @param {[number, number, number]} rayOrigin\n * @param {[number, number, number]} rayDirection Unit point-to-camera ray.\n * @param {[number, number, number]} captureDirection Unit capture direction.\n * @param {number} depth\n * @param {number} radius\n * @returns {[number, number, number]}\n */\nexport function intersectRayWithCaptureDepth(\n rayOrigin,\n rayDirection,\n captureDirection,\n depth,\n radius,\n) {\n if (!(radius > 0) || !Number.isFinite(radius) || !Number.isFinite(depth)) {\n throw new RangeError('Capture depth and radius must be finite, with a positive radius.');\n }\n const ray = normalize3(rayDirection);\n const capture = normalize3(captureDirection);\n const denominator = dot3(ray, capture);\n if (Math.abs(denominator) < 1e-8) {\n throw new RangeError('Runtime ray is parallel to the capture-depth plane.');\n }\n const planeDepth = radius - 2 * radius * depth;\n const distance = (planeDepth - dot3(rayOrigin, capture)) / denominator;\n return /** @type {[number, number, number]} */ (rayOrigin.map((value, index) => (\n value + ray[index] * distance\n )));\n}\n\n/**\n * Decodes a regular or upper-hemisphere octahedral grid coordinate.\n * Y is the up axis used throughout the baker and preview runtime.\n *\n * @param {[number, number]} coordinate normalized 0..1 grid coordinate\n * @param {'hemisphere' | 'full'} mapping\n * @returns {[number, number, number]}\n */\nexport function gridToDirection(coordinate, mapping) {\n const [u, v] = coordinate;\n let x;\n let y;\n let z;\n if (mapping === 'hemisphere') {\n x = u - v;\n z = -1 + u + v;\n y = 1 - Math.abs(x) - Math.abs(z);\n } else {\n x = u * 2 - 1;\n z = v * 2 - 1;\n y = 1 - Math.abs(x) - Math.abs(z);\n if (y < 0) {\n const oldX = x;\n x = nonZeroSign(x) * (1 - Math.abs(z));\n z = nonZeroSign(z) * (1 - Math.abs(oldX));\n }\n }\n return normalize3([x, y, z]);\n}\n\n/**\n * @param {[number, number, number]} input\n * @param {'hemisphere' | 'full'} mapping\n * @returns {[number, number]}\n */\nexport function directionToGrid(input, mapping) {\n let [x, y, z] = normalize3(input);\n if (mapping === 'hemisphere') y = Math.max(y, 1e-6);\n const inverseL1 = 1 / Math.max(1e-12, Math.abs(x) + Math.abs(y) + Math.abs(z));\n x *= inverseL1;\n y *= inverseL1;\n z *= inverseL1;\n if (mapping === 'hemisphere') {\n return clamp2([(x + z) * 0.5 + 0.5, (z - x) * 0.5 + 0.5]);\n }\n if (y < 0) {\n const oldX = x;\n x = nonZeroSign(x) * (1 - Math.abs(z));\n z = nonZeroSign(z) * (1 - Math.abs(oldX));\n }\n return clamp2([x * 0.5 + 0.5, z * 0.5 + 0.5]);\n}\n\n/**\n * Finds the authored grid direction with the smallest spherical angle to an\n * arbitrary view. Octahedral coordinates are not equal-area, so independently\n * rounding U/V is not guaranteed to choose the closest capture near folds.\n * The production grids contain at most 24\u00B2 views; an exact dot-product search\n * is both cheap and unambiguous for an interaction that runs on orbit release.\n *\n * @param {[number, number, number]} inputDirection\n * @param {'hemisphere' | 'full'} mapping\n * @param {number} frames\n */\nexport function nearestOctahedralCapture(inputDirection, mapping, frames) {\n if (mapping !== 'hemisphere' && mapping !== 'full') {\n throw new RangeError('Impostor mapping must be hemisphere or full.');\n }\n if (!Number.isInteger(frames) || frames < 2) {\n throw new RangeError('Impostor capture search requires at least two frames per axis.');\n }\n const direction = normalize3(inputDirection);\n let bestFrame = /** @type {[number, number]} */ ([0, 0]);\n let bestDirection = gridToDirection([0, 0], mapping);\n let bestDot = -Number.POSITIVE_INFINITY;\n for (let y = 0; y < frames; y++) {\n for (let x = 0; x < frames; x++) {\n const candidate = gridToDirection([x / (frames - 1), y / (frames - 1)], mapping);\n const similarity = dot3(direction, candidate);\n if (similarity <= bestDot) continue;\n bestDot = similarity;\n bestFrame = [x, y];\n bestDirection = candidate;\n }\n }\n return {\n frame: bestFrame,\n direction: bestDirection,\n dot: Math.max(-1, Math.min(1, bestDot)),\n angleDegrees: Math.acos(Math.max(-1, Math.min(1, bestDot))) * 180 / Math.PI,\n };\n}\n\n/**\n * Projects a spherical direction beyond the latest sample. OrbitControls'\n * residual release motion supplies the two samples; values above one look\n * ahead in the same direction, so a fast release cannot select the capture\n * behind its visible trajectory.\n *\n * @param {[number, number, number]} startDirection\n * @param {[number, number, number]} endDirection\n * @param {number} multiplier 1 returns the end sample, 1.5 projects half of\n * the sampled angular motion beyond it.\n * @returns {[number, number, number]}\n */\nexport function extrapolateSphericalDirection(startDirection, endDirection, multiplier) {\n if (!Number.isFinite(multiplier) || multiplier < 0) {\n throw new RangeError('Spherical extrapolation multiplier must be finite and non-negative.');\n }\n const start = normalize3(startDirection);\n const end = normalize3(endDirection);\n const similarity = Math.max(-1, Math.min(1, dot3(start, end)));\n const angle = Math.acos(similarity);\n const axis = cross3(start, end);\n const axisLength = Math.hypot(...axis);\n if (angle < 1e-8 || axisLength < 1e-8) return end;\n const unitAxis = /** @type {[number, number, number]} */ (\n axis.map((component) => component / axisLength)\n );\n const projectedAngle = angle * multiplier;\n const cosine = Math.cos(projectedAngle);\n const sine = Math.sin(projectedAngle);\n const axisCrossStart = cross3(unitAxis, start);\n const axisDotStart = dot3(unitAxis, start);\n return normalize3(/** @type {[number, number, number]} */ (start.map((component, index) => (\n component * cosine\n + axisCrossStart[index] * sine\n + unitAxis[index] * axisDotStart * (1 - cosine)\n ))));\n}\n\n/**\n * Returns the three vertices and barycentric weights of the grid triangle\n * containing a direction. The diagonal is chosen consistently on CPU and GPU.\n *\n * @param {[number, number, number]} direction\n * @param {'hemisphere' | 'full'} mapping\n * @param {number} frames\n */\nexport function selectOctahedralFrames(direction, mapping, frames) {\n const scale = frames - 1;\n const grid = directionToGrid(direction, mapping);\n const gx = grid[0] * scale;\n const gy = grid[1] * scale;\n const x = Math.min(scale - 1, Math.floor(gx));\n const y = Math.min(scale - 1, Math.floor(gy));\n const fx = gx - x;\n const fy = gy - y;\n const base = gridToDirection([x / scale, y / scale], mapping);\n const right = gridToDirection([(x + 1) / scale, y / scale], mapping);\n const up = gridToDirection([x / scale, (y + 1) / scale], mapping);\n const diagonal = gridToDirection([(x + 1) / scale, (y + 1) / scale], mapping);\n // Octahedral grid quads are strongly warped on the sphere, especially at\n // low view counts. Use the shorter of their two spherical diagonals instead\n // of always connecting base -> diagonal. Fold cells still necessarily use\n // the anti-diagonal because it is the captured z=0 view edge.\n const antiDiagonal = mapping === 'hemisphere' && x + y === scale - 1\n || dot3(right, up) > dot3(base, diagonal);\n if (antiDiagonal) {\n if (fx + fy <= 1) {\n return {\n frames: /** @type {[[number, number], [number, number], [number, number]]} */ ([\n [x, y], [x + 1, y], [x, y + 1],\n ]),\n weights: /** @type {[number, number, number]} */ ([1 - fx - fy, fx, fy]),\n };\n }\n return {\n frames: /** @type {[[number, number], [number, number], [number, number]]} */ ([\n [x + 1, y + 1], [x, y + 1], [x + 1, y],\n ]),\n weights: /** @type {[number, number, number]} */ ([fx + fy - 1, 1 - fx, 1 - fy]),\n };\n }\n const horizontal = fx > fy;\n return {\n frames: /** @type {[[number, number], [number, number], [number, number]]} */ ([\n [x, y],\n horizontal ? [x + 1, y] : [x, y + 1],\n [x + 1, y + 1],\n ]),\n weights: /** @type {[number, number, number]} */ ([\n Math.min(1 - fx, 1 - fy),\n Math.abs(fx - fy),\n Math.min(fx, fy),\n ]),\n };\n}\n\n/** @param {[number, number, number]} a @param {[number, number, number]} b */\nfunction dot3(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n\n/** @param {[number, number, number]} a @param {[number, number, number]} b */\nfunction cross3(a, b) {\n return /** @type {[number, number, number]} */ ([\n a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0],\n ]);\n}\n\n/** @param {[number, number, number]} value */\nfunction normalize3(value) {\n const length = Math.hypot(...value);\n if (length < 1e-12) return /** @type {[number, number, number]} */ ([0, 1, 0]);\n return /** @type {[number, number, number]} */ (value.map((component) => component / length));\n}\n\n/** @param {[number, number]} value */\nfunction clamp2(value) {\n return /** @type {[number, number]} */ (value.map((component) => Math.max(0, Math.min(1, component))));\n}\n\n/** @param {number} value */\nfunction nonZeroSign(value) {\n return value < 0 ? -1 : 1;\n}\n"],
|
|
4
|
+
"sourcesContent": ["// @ts-check\n\n// A billboard point samples the capture camera along point -> camera, so its\n// local plane offset is subtracted from the object-center camera vector.\nexport const PERSPECTIVE_RAY_PLANE_SIGN = -1;\n\n/**\n * Encodes a local-space point into the orthographic capture depth used by the\n * normal/depth atlas. Capture cameras sit at `direction * 2r` and cover the\n * interval from +r to -r along their forward axis.\n *\n * @param {[number, number, number]} point\n * @param {[number, number, number]} direction Unit capture direction.\n * @param {number} radius\n */\nexport function captureDepthFromPoint(point, direction, radius) {\n if (!(radius > 0) || !Number.isFinite(radius)) {\n throw new RangeError('Capture radius must be positive and finite.');\n }\n const normalizedDirection = normalize3(direction);\n return (radius - dot3(point, normalizedDirection)) / (2 * radius);\n}\n\n/**\n * Intersects a runtime point-to-camera ray with the capture-depth plane\n * `dot(P, captureDirection) = radius - 2 * radius * depth`.\n *\n * This is the fixed-point step solved by the runtime parallax shader. It is\n * deliberately expressed independently here so sign and scale regressions are\n * caught by browserless tests.\n *\n * @param {[number, number, number]} rayOrigin\n * @param {[number, number, number]} rayDirection Unit point-to-camera ray.\n * @param {[number, number, number]} captureDirection Unit capture direction.\n * @param {number} depth\n * @param {number} radius\n * @returns {[number, number, number]}\n */\nexport function intersectRayWithCaptureDepth(\n rayOrigin,\n rayDirection,\n captureDirection,\n depth,\n radius,\n) {\n if (!(radius > 0) || !Number.isFinite(radius) || !Number.isFinite(depth)) {\n throw new RangeError('Capture depth and radius must be finite, with a positive radius.');\n }\n const ray = normalize3(rayDirection);\n const capture = normalize3(captureDirection);\n const denominator = dot3(ray, capture);\n if (Math.abs(denominator) < 1e-8) {\n throw new RangeError('Runtime ray is parallel to the capture-depth plane.');\n }\n const planeDepth = radius - 2 * radius * depth;\n const distance = (planeDepth - dot3(rayOrigin, capture)) / denominator;\n return /** @type {[number, number, number]} */ (rayOrigin.map((value, index) => (\n value + ray[index] * distance\n )));\n}\n\n/**\n * Decodes a regular or upper-hemisphere octahedral grid coordinate.\n * Uses Y as the up axis.\n *\n * @param {[number, number]} coordinate normalized 0..1 grid coordinate\n * @param {'hemisphere' | 'full'} mapping\n * @returns {[number, number, number]}\n */\nexport function gridToDirection(coordinate, mapping) {\n const [u, v] = coordinate;\n let x;\n let y;\n let z;\n if (mapping === 'hemisphere') {\n x = u - v;\n z = -1 + u + v;\n y = 1 - Math.abs(x) - Math.abs(z);\n } else {\n x = u * 2 - 1;\n z = v * 2 - 1;\n y = 1 - Math.abs(x) - Math.abs(z);\n if (y < 0) {\n const oldX = x;\n x = nonZeroSign(x) * (1 - Math.abs(z));\n z = nonZeroSign(z) * (1 - Math.abs(oldX));\n }\n }\n return normalize3([x, y, z]);\n}\n\n/**\n * @param {[number, number, number]} input\n * @param {'hemisphere' | 'full'} mapping\n * @returns {[number, number]}\n */\nexport function directionToGrid(input, mapping) {\n let [x, y, z] = normalize3(input);\n if (mapping === 'hemisphere') y = Math.max(y, 1e-6);\n const inverseL1 = 1 / Math.max(1e-12, Math.abs(x) + Math.abs(y) + Math.abs(z));\n x *= inverseL1;\n y *= inverseL1;\n z *= inverseL1;\n if (mapping === 'hemisphere') {\n return clamp2([(x + z) * 0.5 + 0.5, (z - x) * 0.5 + 0.5]);\n }\n if (y < 0) {\n const oldX = x;\n x = nonZeroSign(x) * (1 - Math.abs(z));\n z = nonZeroSign(z) * (1 - Math.abs(oldX));\n }\n return clamp2([x * 0.5 + 0.5, z * 0.5 + 0.5]);\n}\n\n/**\n * Finds the authored grid direction with the smallest spherical angle to an\n * arbitrary view. Octahedral coordinates are not equal-area, so independently\n * rounding U/V is not guaranteed to choose the closest capture near folds.\n * The production grids contain at most 24\u00B2 views; an exact dot-product search\n * is both cheap and unambiguous for an interaction that runs on orbit release.\n *\n * @param {[number, number, number]} inputDirection\n * @param {'hemisphere' | 'full'} mapping\n * @param {number} frames\n */\nexport function nearestOctahedralCapture(inputDirection, mapping, frames) {\n if (mapping !== 'hemisphere' && mapping !== 'full') {\n throw new RangeError('Impostor mapping must be hemisphere or full.');\n }\n if (!Number.isInteger(frames) || frames < 2) {\n throw new RangeError('Impostor capture search requires at least two frames per axis.');\n }\n const direction = normalize3(inputDirection);\n let bestFrame = /** @type {[number, number]} */ ([0, 0]);\n let bestDirection = gridToDirection([0, 0], mapping);\n let bestDot = -Number.POSITIVE_INFINITY;\n for (let y = 0; y < frames; y++) {\n for (let x = 0; x < frames; x++) {\n const candidate = gridToDirection([x / (frames - 1), y / (frames - 1)], mapping);\n const similarity = dot3(direction, candidate);\n if (similarity <= bestDot) continue;\n bestDot = similarity;\n bestFrame = [x, y];\n bestDirection = candidate;\n }\n }\n return {\n frame: bestFrame,\n direction: bestDirection,\n dot: Math.max(-1, Math.min(1, bestDot)),\n angleDegrees: Math.acos(Math.max(-1, Math.min(1, bestDot))) * 180 / Math.PI,\n };\n}\n\n/**\n * Projects a spherical direction beyond the latest sample. OrbitControls'\n * residual release motion supplies the two samples; values above one look\n * ahead in the same direction, so a fast release cannot select the capture\n * behind its visible trajectory.\n *\n * @param {[number, number, number]} startDirection\n * @param {[number, number, number]} endDirection\n * @param {number} multiplier 1 returns the end sample, 1.5 projects half of\n * the sampled angular motion beyond it.\n * @returns {[number, number, number]}\n */\nexport function extrapolateSphericalDirection(startDirection, endDirection, multiplier) {\n if (!Number.isFinite(multiplier) || multiplier < 0) {\n throw new RangeError('Spherical extrapolation multiplier must be finite and non-negative.');\n }\n const start = normalize3(startDirection);\n const end = normalize3(endDirection);\n const similarity = Math.max(-1, Math.min(1, dot3(start, end)));\n const angle = Math.acos(similarity);\n const axis = cross3(start, end);\n const axisLength = Math.hypot(...axis);\n if (angle < 1e-8 || axisLength < 1e-8) return end;\n const unitAxis = /** @type {[number, number, number]} */ (\n axis.map((component) => component / axisLength)\n );\n const projectedAngle = angle * multiplier;\n const cosine = Math.cos(projectedAngle);\n const sine = Math.sin(projectedAngle);\n const axisCrossStart = cross3(unitAxis, start);\n const axisDotStart = dot3(unitAxis, start);\n return normalize3(/** @type {[number, number, number]} */ (start.map((component, index) => (\n component * cosine\n + axisCrossStart[index] * sine\n + unitAxis[index] * axisDotStart * (1 - cosine)\n ))));\n}\n\n/**\n * Returns the three vertices and barycentric weights of the grid triangle\n * containing a direction. The diagonal is chosen consistently on CPU and GPU.\n *\n * @param {[number, number, number]} direction\n * @param {'hemisphere' | 'full'} mapping\n * @param {number} frames\n */\nexport function selectOctahedralFrames(direction, mapping, frames) {\n const scale = frames - 1;\n const grid = directionToGrid(direction, mapping);\n const gx = grid[0] * scale;\n const gy = grid[1] * scale;\n const x = Math.min(scale - 1, Math.floor(gx));\n const y = Math.min(scale - 1, Math.floor(gy));\n const fx = gx - x;\n const fy = gy - y;\n const base = gridToDirection([x / scale, y / scale], mapping);\n const right = gridToDirection([(x + 1) / scale, y / scale], mapping);\n const up = gridToDirection([x / scale, (y + 1) / scale], mapping);\n const diagonal = gridToDirection([(x + 1) / scale, (y + 1) / scale], mapping);\n // Octahedral grid quads are strongly warped on the sphere, especially at\n // low view counts. Use the shorter of their two spherical diagonals instead\n // of always connecting base -> diagonal. Fold cells still necessarily use\n // the anti-diagonal because it is the captured z=0 view edge.\n const antiDiagonal = mapping === 'hemisphere' && x + y === scale - 1\n || dot3(right, up) > dot3(base, diagonal);\n if (antiDiagonal) {\n if (fx + fy <= 1) {\n return {\n frames: /** @type {[[number, number], [number, number], [number, number]]} */ ([\n [x, y], [x + 1, y], [x, y + 1],\n ]),\n weights: /** @type {[number, number, number]} */ ([1 - fx - fy, fx, fy]),\n };\n }\n return {\n frames: /** @type {[[number, number], [number, number], [number, number]]} */ ([\n [x + 1, y + 1], [x, y + 1], [x + 1, y],\n ]),\n weights: /** @type {[number, number, number]} */ ([fx + fy - 1, 1 - fx, 1 - fy]),\n };\n }\n const horizontal = fx > fy;\n return {\n frames: /** @type {[[number, number], [number, number], [number, number]]} */ ([\n [x, y],\n horizontal ? [x + 1, y] : [x, y + 1],\n [x + 1, y + 1],\n ]),\n weights: /** @type {[number, number, number]} */ ([\n Math.min(1 - fx, 1 - fy),\n Math.abs(fx - fy),\n Math.min(fx, fy),\n ]),\n };\n}\n\n/** @param {[number, number, number]} a @param {[number, number, number]} b */\nfunction dot3(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n\n/** @param {[number, number, number]} a @param {[number, number, number]} b */\nfunction cross3(a, b) {\n return /** @type {[number, number, number]} */ ([\n a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0],\n ]);\n}\n\n/** @param {[number, number, number]} value */\nfunction normalize3(value) {\n const length = Math.hypot(...value);\n if (length < 1e-12) return /** @type {[number, number, number]} */ ([0, 1, 0]);\n return /** @type {[number, number, number]} */ (value.map((component) => component / length));\n}\n\n/** @param {[number, number]} value */\nfunction clamp2(value) {\n return /** @type {[number, number]} */ (value.map((component) => Math.max(0, Math.min(1, component))));\n}\n\n/** @param {number} value */\nfunction nonZeroSign(value) {\n return value < 0 ? -1 : 1;\n}\n"],
|
|
5
5
|
"mappings": ";;;AAIO,IAAM,6BAA6B;AAWnC,SAAS,sBAAsB,OAAO,WAAW,QAAQ;AAC9D,MAAI,EAAE,SAAS,MAAM,CAAC,OAAO,SAAS,MAAM,GAAG;AAC7C,UAAM,IA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;AAAA;AAAA,IAAwC,MAAM,IAAI,CAAC,cAAc,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC,CAAC;AAAA;AACtG;AAGA,SAAS,YAAY,OAAO;AAC1B,SAAO,QAAQ,IAAI,KAAK;AAC1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -138,7 +138,7 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
|
|
|
138
138
|
const normalAtlas = binding.normalAtlas instanceof THREE.Texture ? binding.normalAtlas : null;
|
|
139
139
|
const ormAtlas = binding.ormAtlas instanceof THREE.Texture ? binding.ormAtlas : null;
|
|
140
140
|
const indexAtlas = binding.indexAtlas instanceof THREE.Texture ? binding.indexAtlas : null;
|
|
141
|
-
const sparse = descriptor.
|
|
141
|
+
const sparse = descriptor.storage === "sparse";
|
|
142
142
|
if (sparse && !indexAtlas) return null;
|
|
143
143
|
for (const map of [normalAtlas, ormAtlas, indexAtlas]) {
|
|
144
144
|
if (!map) continue;
|
|
@@ -396,15 +396,16 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
|
|
|
396
396
|
...Object.values(raycastMaterials.plain)
|
|
397
397
|
];
|
|
398
398
|
const surfacePoints = binding.surfacePoints instanceof THREE.BufferAttribute || binding.surfacePoints instanceof THREE.InterleavedBufferAttribute ? binding.surfacePoints : null;
|
|
399
|
+
const shellless = descriptor.voxelShell === false;
|
|
399
400
|
let shell = null;
|
|
400
|
-
asset.traverse((object) => {
|
|
401
|
+
if (!shellless) asset.traverse((object) => {
|
|
401
402
|
if (!shell && object instanceof THREE.Mesh && (object.geometry.getAttribute("_voxel_center") || surfacePoints)) {
|
|
402
403
|
shell = object;
|
|
403
404
|
}
|
|
404
405
|
});
|
|
405
|
-
if (!shell) return null;
|
|
406
|
+
if (!shell && !shellless) return null;
|
|
406
407
|
const voxelShell = (
|
|
407
|
-
/** @type {THREE.Mesh} */
|
|
408
|
+
/** @type {THREE.Mesh | null} */
|
|
408
409
|
shell
|
|
409
410
|
);
|
|
410
411
|
const geometryBaseSample = texture(atlas, uv());
|
|
@@ -447,14 +448,23 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
|
|
|
447
448
|
mapped: createGeometryMaterial(true),
|
|
448
449
|
plain: createGeometryMaterial(false)
|
|
449
450
|
};
|
|
450
|
-
const previousGeometryMaterial = voxelShell
|
|
451
|
-
voxelShell
|
|
452
|
-
|
|
451
|
+
const previousGeometryMaterial = voxelShell?.material ?? null;
|
|
452
|
+
if (voxelShell) {
|
|
453
|
+
voxelShell.material = geometryMaterials.mapped;
|
|
454
|
+
voxelShell.userData.pixelImpostorAlternateMaterials = Object.values(geometryMaterials);
|
|
455
|
+
}
|
|
453
456
|
const skinnedSplats = voxelShell instanceof THREE.SkinnedMesh;
|
|
454
457
|
const useSurfacePoints = surfacePoints && !skinnedSplats;
|
|
455
|
-
|
|
458
|
+
const splatsAvailable = Boolean(voxelShell || useSurfacePoints);
|
|
459
|
+
let splatGeometry = skinnedSplats ? (
|
|
460
|
+
/** @type {THREE.Mesh} */
|
|
461
|
+
voxelShell.geometry.clone()
|
|
462
|
+
) : voxelShell?.geometry ?? new THREE.BufferGeometry();
|
|
456
463
|
if (skinnedSplats) {
|
|
457
|
-
const centers =
|
|
464
|
+
const centers = (
|
|
465
|
+
/** @type {THREE.Mesh} */
|
|
466
|
+
voxelShell.geometry.getAttribute("_voxel_center")
|
|
467
|
+
);
|
|
458
468
|
if (!centers) throw new Error("Animated voxel splats require retained voxel centers.");
|
|
459
469
|
splatGeometry.setAttribute("position", centers.clone());
|
|
460
470
|
}
|
|
@@ -485,8 +495,8 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
|
|
|
485
495
|
splatGeometry.setAttribute("_voxel_coord", new THREE.InstancedBufferAttribute(coordinates, 3));
|
|
486
496
|
splatGeometry.setAttribute("_voxel_record", new THREE.InstancedBufferAttribute(records, 1));
|
|
487
497
|
splatGeometry.setIndex([0, 1, 2, 0, 2, 3]);
|
|
488
|
-
splatGeometry.boundingBox = voxelShell
|
|
489
|
-
splatGeometry.boundingSphere = voxelShell
|
|
498
|
+
splatGeometry.boundingBox = voxelShell?.geometry.boundingBox?.clone() ?? bounds.clone();
|
|
499
|
+
splatGeometry.boundingSphere = voxelShell?.geometry.boundingSphere?.clone() ?? splatGeometry.boundingBox.getBoundingSphere(new THREE.Sphere());
|
|
490
500
|
}
|
|
491
501
|
const voxelCoordinate = attribute(
|
|
492
502
|
"_voxel_coord",
|
|
@@ -616,8 +626,8 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
|
|
|
616
626
|
snappedShell.bindMatrixInverse.copy(voxelShell.bindMatrixInverse);
|
|
617
627
|
}
|
|
618
628
|
asset.updateWorldMatrix(true, true);
|
|
619
|
-
voxelShell
|
|
620
|
-
if (!useSurfacePoints) {
|
|
629
|
+
voxelShell?.updateWorldMatrix(true, false);
|
|
630
|
+
if (!useSurfacePoints && voxelShell) {
|
|
621
631
|
snappedShell.matrix.copy(asset.matrixWorld).invert().multiply(voxelShell.matrixWorld);
|
|
622
632
|
snappedShell.matrixAutoUpdate = false;
|
|
623
633
|
}
|
|
@@ -650,8 +660,14 @@ function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {
|
|
|
650
660
|
preview.userData.pixelSizeValue = 5;
|
|
651
661
|
preview.add(raycast, snappedShell);
|
|
652
662
|
const textureBytes = textureFootprintBytes(atlas) + (normalAtlas ? textureFootprintBytes(normalAtlas) : 0) + (ormAtlas ? textureFootprintBytes(ormAtlas) : 0) + (indexAtlas ? textureFootprintBytes(indexAtlas) : 0);
|
|
653
|
-
const shellStats = pixelDisplayMeshStats(voxelShell, textureBytes);
|
|
654
|
-
const splatStats = pixelDisplayMeshStats(snappedShell, textureFootprintBytes(atlas));
|
|
663
|
+
const shellStats = voxelShell ? pixelDisplayMeshStats(voxelShell, textureBytes) : null;
|
|
664
|
+
const splatStats = splatsAvailable ? pixelDisplayMeshStats(snappedShell, textureFootprintBytes(atlas)) : null;
|
|
665
|
+
preview.userData.availableModes = [
|
|
666
|
+
...voxelShell ? ["geometry"] : [],
|
|
667
|
+
...splatsAvailable ? ["vertex-snap"] : [],
|
|
668
|
+
"raycast",
|
|
669
|
+
"screen-pixels"
|
|
670
|
+
];
|
|
655
671
|
const raycastStats = pixelDisplayMeshStats(raycast, textureBytes);
|
|
656
672
|
preview.userData.displayStats = {
|
|
657
673
|
geometry: shellStats,
|
|
@@ -711,11 +727,18 @@ function createPixelImpostorDisplay(asset, options = {}) {
|
|
|
711
727
|
if (object instanceof THREE.Mesh) originals.set(object, object.visible);
|
|
712
728
|
});
|
|
713
729
|
if (options.attach !== false) asset.add(preview);
|
|
714
|
-
|
|
730
|
+
const stored = (
|
|
731
|
+
/** @type {Partial<import('./pixel-impostor-metadata.js').PixelImpostorDisplay>} */
|
|
732
|
+
/** @type {{display?: object}} */
|
|
733
|
+
(binding.descriptor ?? {}).display ?? {}
|
|
734
|
+
);
|
|
735
|
+
options = { ...stored, ...Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0)) };
|
|
736
|
+
let mode = options.mode ?? (preview.userData.availableModes.includes("geometry") ? "geometry" : "screen-pixels");
|
|
715
737
|
let pbr = options.pbr ?? true;
|
|
716
738
|
let antialias = options.antialias ?? true;
|
|
717
739
|
const setMode = (next) => {
|
|
718
740
|
if (!["geometry", "vertex-snap", "raycast", "screen-pixels"].includes(next)) throw new Error(`Unknown pixel display mode: ${next}`);
|
|
741
|
+
if (!preview.userData.availableModes.includes(next)) throw new Error(`This pixel impostor has no voxel shell, so it cannot use the ${next} display mode.`);
|
|
719
742
|
mode = next;
|
|
720
743
|
preview.userData.displayMode = next;
|
|
721
744
|
for (const [mesh, visible] of originals) mesh.visible = next === "geometry" && visible;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/rendering/captured-surface-material.js", "../../../src/rendering/captured-surface-depth.js", "../../../src/pixel-impostor/pixel-impostor-display.js"],
|
|
4
|
-
"sourcesContent": ["// @ts-check\nimport { MeshStandardNodeMaterial } from 'three/webgpu';\nimport { context, modelViewMatrix, modelWorldMatrix, vec4 } from 'three/tsl';\n\n/** Light reconstructed surfaces at their hit position, not the carrier face.\n * View directions stay on the same ray; local lights also need the hit distance.\n */\nexport class CapturedSurfaceMaterial extends MeshStandardNodeMaterial {\n /** @type {import('three/webgpu').Node<'vec3'> | null} */\n capturedPositionNode = null;\n\n /**\n * @override\n * @param {import('three/webgpu').NodeBuilder} builder\n */\n setupLighting(builder) {\n const lighting = super.setupLighting(builder);\n if (!this.capturedPositionNode) return lighting;\n const world = modelWorldMatrix.mul(vec4(this.capturedPositionNode, 1)).xyz;\n const view = modelViewMatrix.mul(vec4(this.capturedPositionNode, 1)).xyz;\n return context(lighting, {\n positionView: view,\n positionWorld: world,\n shadowPositionWorld: world,\n });\n }\n}\n", "// @ts-check\nimport {\n Fn,\n cameraFar,\n cameraNear,\n cameraProjectionMatrix,\n modelViewMatrix,\n vec4,\n viewZToLogarithmicDepth,\n viewZToOrthographicDepth,\n viewZToPerspectiveDepth,\n viewZToReversedOrthographicDepth,\n viewZToReversedPerspectiveDepth,\n} from 'three/tsl';\n\n/** Match the renderer's depth convention after reconstructing a local hit.\n * @param {import('three/webgpu').Node<'vec3'>} position\n * @param {number} [shadowBias]\n */\nexport function capturedSurfaceDepth(position, shadowBias = 0) {\n return Fn(\n (\n /** @type {unknown} */ _,\n /** @type {import('three/webgpu').NodeBuilder} */ builder,\n ) => {\n // Resolve the shared hit before either projection branch consumes it.\n const z = modelViewMatrix\n .mul(vec4(position, 1))\n .z.toVar('capturedSurfaceViewZ');\n const reversed = builder.renderer.reversedDepthBuffer === true;\n // One material can alternate between a perspective view and orthographic\n // shadow cameras without a new pipeline; select using the active projection.\n const perspective = cameraProjectionMatrix\n .mul(vec4(0, 0, 0, 1))\n .w.equal(0);\n const perspectiveDepth =\n builder.renderer.logarithmicDepthBuffer === true\n ? viewZToLogarithmicDepth(z, cameraNear, cameraFar)\n : (reversed\n ? viewZToReversedPerspectiveDepth\n : viewZToPerspectiveDepth)(z, cameraNear, cameraFar);\n const result = perspective.select(\n perspectiveDepth,\n (reversed\n ? viewZToReversedOrthographicDepth\n : viewZToOrthographicDepth)(z, cameraNear, cameraFar),\n );\n return shadowBias &&\n 'isShadowPassMaterial' in builder.material &&\n builder.material.isShadowPassMaterial\n ? result.add(reversed ? -shadowBias : shadowBias).clamp(0, 1)\n : result;\n },\n )();\n}\n", "// @ts-check\nimport { CapturedSurfaceMaterial } from '../rendering/captured-surface-material.js';\nimport { capturedSurfaceDepth } from '../rendering/captured-surface-depth.js';\nimport * as THREE from 'three';\nimport { MeshBasicNodeMaterial, MeshStandardNodeMaterial } from 'three/webgpu';\nimport {\n Break,\n Fn,\n If,\n Loop,\n abs,\n attribute,\n cameraProjectionMatrix,\n cameraProjectionMatrixInverse,\n cameraPosition,\n cameraWorldMatrix,\n ceil,\n clamp,\n countOneBits,\n float,\n fwidth,\n getViewPosition,\n max,\n min,\n mix,\n modelViewMatrix,\n modelWorldMatrix,\n modelWorldMatrixInverse,\n mod,\n normalMap as normalMapNode,\n normalView,\n smoothstep,\n step,\n sRGBTransferEOTF,\n positionLocal,\n screenCoordinate,\n screenSize,\n texture,\n transformNormalToView,\n uint,\n uniform,\n uvec2,\n uvec4,\n uv,\n vec2,\n vec3,\n vec4,\n vertexColor,\n} from 'three/tsl';\n\n/**\n * Builds the shader alternative to the exported voxel shell. The box supplies\n * interpolated ray-entry positions; the fragment node walks the packed solid\n * volume and returns the first occupied cell in a single draw/pass.\n *\n * @param {THREE.Object3D} asset\n * @param {THREE.Box3} bounds\n * @param {Record<string, unknown>} descriptor\n */\nexport function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {\n const binding = descriptor;\n descriptor = binding.descriptor && typeof binding.descriptor === 'object'\n ? /** @type {Record<string, unknown>} */ (binding.descriptor)\n : descriptor;\n const dimensions = Array.isArray(descriptor.dimensions)\n ? descriptor.dimensions.map(Number)\n : [];\n const planar = Math.round(dimensions[0] ?? 0);\n const layers = Math.round(dimensions[1] ?? 0);\n if (!(planar > 0) || !(layers > 0) || Math.round(dimensions[2] ?? 0) !== planar) return null;\n const atlasTextures = /** @type {THREE.Texture[]} */ ([]);\n if (binding.atlas instanceof THREE.Texture) atlasTextures.push(binding.atlas);\n asset.traverse((object) => {\n if (atlasTextures.length > 0 || !(object instanceof THREE.Mesh)) return;\n const materials = Array.isArray(object.material) ? object.material : [object.material];\n for (const material of materials) {\n const map = /** @type {THREE.MeshBasicMaterial} */ (material).map;\n if (map) { atlasTextures.push(map); break; }\n }\n });\n const atlas = atlasTextures[0];\n if (!atlas) return null;\n atlas.magFilter = THREE.NearestFilter;\n atlas.minFilter = THREE.NearestFilter;\n atlas.generateMipmaps = false;\n atlas.needsUpdate = true;\n const normalAtlas = binding.normalAtlas instanceof THREE.Texture ? binding.normalAtlas : null;\n const ormAtlas = binding.ormAtlas instanceof THREE.Texture ? binding.ormAtlas : null;\n const indexAtlas = binding.indexAtlas instanceof THREE.Texture ? binding.indexAtlas : null;\n const sparse = descriptor.version === 3 && descriptor.storage === 'sparse';\n if (sparse && !indexAtlas) return null;\n for (const map of [normalAtlas, ormAtlas, indexAtlas]) {\n if (!map) continue;\n map.colorSpace = THREE.NoColorSpace;\n map.magFilter = THREE.NearestFilter;\n map.minFilter = THREE.NearestFilter;\n map.generateMipmaps = false;\n map.needsUpdate = true;\n }\n\n const authoredMin = Array.isArray(descriptor.volumeMin) ? descriptor.volumeMin.map(Number) : null;\n const authoredSize = Array.isArray(descriptor.volumeSize) ? descriptor.volumeSize.map(Number) : null;\n const size = authoredSize?.length === 3 && authoredSize.every((value) => value > 0)\n ? new THREE.Vector3().fromArray(authoredSize)\n : bounds.getSize(new THREE.Vector3());\n const center = authoredMin?.length === 3\n ? new THREE.Vector3().fromArray(authoredMin).addScaledVector(size, 0.5)\n : bounds.getCenter(new THREE.Vector3());\n const authoredOccupiedMin = Array.isArray(descriptor.occupiedMin)\n ? descriptor.occupiedMin.map(Number) : null;\n const authoredOccupiedSize = Array.isArray(descriptor.occupiedSize)\n ? descriptor.occupiedSize.map(Number) : null;\n const raycastSize = authoredOccupiedSize?.length === 3\n && authoredOccupiedSize.every((value) => value > 0)\n ? new THREE.Vector3().fromArray(authoredOccupiedSize)\n : size.clone();\n const raycastCenter = authoredOccupiedMin?.length === 3\n ? new THREE.Vector3().fromArray(authoredOccupiedMin).addScaledVector(raycastSize, 0.5)\n : center.clone();\n const raycastOffset = raycastCenter.clone().sub(center);\n const atlasColumns = Math.max(1, Math.round(Number(descriptor.atlasColumns) || Math.ceil(Math.sqrt(layers))));\n const atlasRows = Math.max(1, Math.round(Number(descriptor.atlasRows) || Math.ceil(layers / atlasColumns)));\n const surfaceAtlasSize = Array.isArray(descriptor.surfaceAtlasSize)\n ? descriptor.surfaceAtlasSize.map(Number) : [atlas.image.width, atlas.image.height];\n const indexAtlasSize = Array.isArray(descriptor.indexAtlasSize)\n ? descriptor.indexAtlasSize.map(Number) : [1, 1];\n const sizeNode = uniform(size.clone());\n const raycastHalfSize = uniform(raycastSize.clone().multiplyScalar(0.5));\n const raycastOffsetNode = uniform(raycastOffset);\n const screenPixelSize = uniform(1);\n const splatPixelSize = uniform(5);\n const splatScale = uniform(1);\n const projectedNormalMix = uniform(1);\n const unlitMix = uniform(0);\n const snapMode = uniform(0);\n const viewportSize = uniform(new THREE.Vector2(1, 1));\n const dpr = uniform(1);\n const volumeDimensions = vec3(planar, layers, planar);\n const voxelHalfExtents = vec3(\n size.x / planar * 0.5,\n size.y / layers * 0.5,\n size.z / planar * 0.5,\n );\n const minimumCellSize = Math.min(size.x / planar, size.y / layers, size.z / planar);\n const maximumSteps = planar * 2 + layers + 3;\n const linearTextureUv = (/** @type {import('three/webgpu').Node<'float'>} */ index, /** @type {number[]} */ dimensions) => vec2(\n mod(index, dimensions[0]).add(0.5).div(dimensions[0]),\n index.div(dimensions[0]).floor().add(0.5).div(dimensions[1]),\n );\n // The ray march reads these atlases texel by texel. Explicit integer loads\n // avoid a nearest-filtered sample's shared size lookup: before r187, Three\n // computes it once inside the first trace loop, after the loop's early exit,\n // and later traces read it unassigned when that first ray leaves early.\n // Same texel a nearest sample selects: floor(uv * the texture's own size).\n const loadTexel = (/** @type {THREE.Texture} */ map, /** @type {import('three/webgpu').Node<'vec2'>} */ atlasUv) =>\n texture(map).load(uvec2(atlasUv.mul(vec2(Number(map.image.width), Number(map.image.height))).floor()));\n const sparseUint = (/** @type {import('three/webgpu').Node<'float'>} */ texel) => {\n if (!indexAtlas) throw new Error('Sparse pixel impostor requires an index atlas');\n const bytes = uvec4(loadTexel(indexAtlas, linearTextureUv(texel, indexAtlasSize)).mul(255).round());\n return bytes.x\n .bitOr(bytes.y.shiftLeft(8))\n .bitOr(bytes.z.shiftLeft(16))\n .bitOr(bytes.w.shiftLeft(24));\n };\n // @ts-ignore -- TSL's Fn declaration exposes NodeBuilder instead of its shader parameters.\n const traceVolumeNode = Fn(([sampleOffset]) => {\n // Reconstructing the ray from the snapped screen coordinate avoids the\n // derivative discontinuity along the two triangles of each box face.\n const rasterPixelSize = screenPixelSize.mul(dpr);\n const sampleCoordinate = screenCoordinate.div(rasterPixelSize).floor()\n .mul(rasterPixelSize).add(\n rasterPixelSize.mul(vec2(0.5).add(sampleOffset)),\n );\n const sampleUv = sampleCoordinate.div(screenSize);\n const nearView = getViewPosition(sampleUv, float(0), cameraProjectionMatrixInverse);\n const farView = getViewPosition(sampleUv, float(1), cameraProjectionMatrixInverse);\n const nearWorld = cameraWorldMatrix.mul(vec4(nearView, 1));\n const farWorld = cameraWorldMatrix.mul(vec4(farView, 1));\n const rayOrigin = modelWorldMatrixInverse.mul(nearWorld).xyz;\n const rayFar = modelWorldMatrixInverse.mul(farWorld).xyz;\n const rayDirection = rayFar.sub(rayOrigin).normalize();\n const distanceA = raycastHalfSize.negate().sub(rayOrigin).div(rayDirection);\n const distanceB = raycastHalfSize.sub(rayOrigin).div(rayDirection);\n const nearestDistance = max(\n max(min(distanceA.x, distanceB.x), min(distanceA.y, distanceB.y)),\n min(distanceA.z, distanceB.z),\n ).max(0);\n const exitDistance = min(\n min(max(distanceA.x, distanceB.x), max(distanceA.y, distanceB.y)),\n max(distanceA.z, distanceB.z),\n );\n const entry = rayOrigin.add(rayDirection.mul(nearestDistance));\n const gridVelocity = rayDirection.div(sizeNode).mul(volumeDimensions);\n const gridPoint = entry.add(raycastOffsetNode).div(sizeNode).add(0.5).mul(volumeDimensions)\n .add(gridVelocity.mul(minimumCellSize * 0.001));\n // Rasterization only guarantees that the center ray intersects the proxy.\n // An AA sub-sample can lie outside it; reject that ray instead of feeding\n // its invalid slab entry into the voxel traversal (which drew box lines).\n const cell = exitDistance.greaterThanEqual(nearestDistance)\n .select(gridPoint.floor(), vec3(-1)).toVar();\n // Declared before the loop: Three r186 caches a sub-expression shared by\n // the per-axis branches below into a variable assigned only inside the\n // first branch that uses it, so the z step read a stale value.\n const directionStep = step(0, gridVelocity).mul(2).sub(1).toVar();\n const absoluteVelocity = abs(gridVelocity).max(1e-6);\n const cellFraction = gridPoint.sub(cell);\n const positiveAxis = step(0, gridVelocity);\n const nextDistance = cellFraction.mul(vec3(1).sub(positiveAxis))\n .add(vec3(1).sub(cellFraction).mul(positiveAxis));\n const nextCrossing = nextDistance.div(absoluteVelocity).toVar();\n const crossingDelta = vec3(1).div(absoluteVelocity).toVar();\n // xyz is the reconstructed local hit; w is the linear cell index + 1.\n // Keeping both in one vec4 avoids rebuilding the camera ray after traversal.\n const result = vec4(0, 0, 0, 0).toVar();\n const travelled = nearestDistance.toVar();\n Loop(maximumSteps, () => {\n const outside = cell.x.lessThan(0).or(cell.y.lessThan(0)).or(cell.z.lessThan(0))\n .or(cell.x.greaterThanEqual(planar)).or(cell.y.greaterThanEqual(layers)).or(cell.z.greaterThanEqual(planar));\n If(outside, () => { Break(); });\n // Keep every operation in the TSL graph. JavaScript arithmetic coerces\n // node expressions to NaN, which then produces invalid WGSL (`NaN.0`).\n const linearCell = cell.x.add(cell.z.add(cell.y.mul(planar)).mul(planar));\n let cellOccupied;\n if (sparse) {\n const wordIndex = linearCell.div(32).floor();\n const word = sparseUint(wordIndex.mul(2));\n const bit = uint(mod(linearCell, 32));\n cellOccupied = word.shiftRight(bit).bitAnd(1).equal(1);\n } else {\n const atlasColumn = mod(cell.y, atlasColumns);\n const atlasRow = cell.y.div(atlasColumns).floor();\n const atlasUv = vec2(\n atlasColumn.mul(planar).add(cell.x).add(0.5).div(atlasColumns * planar),\n atlasRow.mul(planar).add(cell.z).add(0.5).div(atlasRows * planar),\n );\n cellOccupied = loadTexel(atlas, atlasUv).a.greaterThan(0.5);\n }\n If(cellOccupied, () => {\n result.assign(vec4(\n rayOrigin.add(rayDirection.mul(travelled)),\n linearCell.add(1),\n ));\n Break();\n });\n const nearestCrossing = min(nextCrossing.x, min(nextCrossing.y, nextCrossing.z));\n travelled.assign(nearestDistance.add(nearestCrossing));\n // Independent branches intentionally advance two or three axes for an\n // exact edge/corner crossing; that avoids revisiting zero-width cells.\n If(nextCrossing.x.lessThanEqual(nearestCrossing.add(1e-6)), () => {\n cell.x.addAssign(directionStep.x);\n nextCrossing.x.addAssign(crossingDelta.x);\n });\n If(nextCrossing.y.lessThanEqual(nearestCrossing.add(1e-6)), () => {\n cell.y.addAssign(directionStep.y);\n nextCrossing.y.addAssign(crossingDelta.y);\n });\n If(nextCrossing.z.lessThanEqual(nearestCrossing.add(1e-6)), () => {\n cell.z.addAssign(directionStep.z);\n nextCrossing.z.addAssign(crossingDelta.z);\n });\n });\n return result;\n });\n const traceVolume = /** @type {(sampleOffset: import('three/webgpu').Node<'vec2'>) => import('three/webgpu').Node<'vec4'>} */ (\n /** @type {unknown} */ (traceVolumeNode)\n );\n const createRaycastMaterial = (\n /** @type {boolean} */ antialias,\n /** @type {boolean} */ pbr,\n ) => {\n // Baked material maps are a cached graph variant, not a uniform branch:\n // the plain lit graph retains lighting and projected normals but contains\n // no voxel ORM sampling or AO/roughness/metalness nodes.\n const centerHit = traceVolume(vec2(0));\n const occupied = centerHit.w.greaterThan(0);\n /** @type {import('three/webgpu').Node<'float'>} */\n let coverage = float(1);\n if (antialias) {\n // This JavaScript branch specializes the TSL graph: the fast material\n // contains one DDA trace, while the AA material contains five. There is\n // no runtime AA branch or dormant extra tracing in the fast pipeline.\n const sampleHits = [\n traceVolume(vec2(-0.125, -0.375)),\n traceVolume(vec2(0.375, -0.125)),\n traceVolume(vec2(-0.375, 0.125)),\n traceVolume(vec2(0.125, 0.375)),\n ];\n const sampleOccupancy = sampleHits.map((sampleHit) => sampleHit.w.greaterThan(0));\n coverage = sampleOccupancy[0].select(1, 0)\n .add(sampleOccupancy[1].select(1, 0))\n .add(sampleOccupancy[2].select(1, 0))\n .add(sampleOccupancy[3].select(1, 0))\n .mul(0.25).mul(occupied.select(1, 0));\n }\n const hit = centerHit.toVar(antialias ? 'pixelImpostorAaHit' : 'pixelImpostorFastHit');\n const linearHitCell = hit.w.sub(1).max(0);\n const hitLayer = linearHitCell.div(planar * planar).floor();\n const hitSliceCell = mod(linearHitCell, planar * planar);\n const hitCell = vec3(mod(hitSliceCell, planar), hitLayer, hitSliceCell.div(planar).floor());\n let hitAtlasUv;\n if (sparse) {\n const wordIndex = linearHitCell.div(32).floor();\n const word = sparseUint(wordIndex.mul(2));\n const prefixRank = sparseUint(wordIndex.mul(2).add(1));\n const bit = uint(mod(linearHitCell, 32));\n const precedingMask = uint(1).shiftLeft(bit).sub(1);\n // Three's nodeProxyIntent returns a typed TSL node; @types/three\n // currently declares the bare BitcountNode class instead. A uint input\n // produces uint output (WGSL countOneBits preserves its input type).\n const precedingCount = /** @type {ReturnType<typeof countOneBits> & import('three/webgpu').Node<'uint'>} */ (countOneBits(word.bitAnd(precedingMask)));\n const record = prefixRank.add(precedingCount);\n hitAtlasUv = linearTextureUv(float(record), surfaceAtlasSize);\n } else {\n const hitAtlasColumn = mod(hitCell.y, atlasColumns);\n const hitAtlasRow = hitCell.y.div(atlasColumns).floor();\n hitAtlasUv = vec2(\n hitAtlasColumn.mul(planar).add(hitCell.x).add(0.5).div(atlasColumns * planar),\n hitAtlasRow.mul(planar).add(hitCell.z).add(0.5).div(atlasRows * planar),\n );\n }\n const baseSample = loadTexel(atlas, hitAtlasUv);\n const ormSample = ormAtlas ? loadTexel(ormAtlas, hitAtlasUv) : vec4(1, 1, 0, 1);\n const hitPosition = hit.xyz;\n const hitToCamera = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz.sub(hitPosition);\n const faceSign = step(0, hitToCamera).mul(2).sub(1);\n const hitCellCenter = hitCell.add(0.5).div(volumeDimensions).sub(0.5)\n .mul(sizeNode).sub(raycastOffsetNode);\n const cellDelta = hitPosition.sub(hitCellCenter).div(sizeNode).mul(volumeDimensions);\n const absoluteCellDelta = cellDelta.abs();\n const boundaryDistance = max(absoluteCellDelta.x,\n max(absoluteCellDelta.y, absoluteCellDelta.z));\n const faceDirection = hitToCamera.abs().normalize();\n // At an edge/corner more than one face is a valid entry face. Floating\n // error used to make the largest coordinate flicker between them. Treat\n // near-ties as the same boundary and choose the most camera-facing face.\n const xFaceScore = absoluteCellDelta.x.greaterThanEqual(boundaryDistance.sub(1e-4))\n .select(faceDirection.x, -1);\n const yFaceScore = absoluteCellDelta.y.greaterThanEqual(boundaryDistance.sub(1e-4))\n .select(faceDirection.y, -1);\n const zFaceScore = absoluteCellDelta.z.greaterThanEqual(boundaryDistance.sub(1e-4))\n .select(faceDirection.z, -1);\n const geometricNormal = xFaceScore.greaterThanEqual(yFaceScore)\n .and(xFaceScore.greaterThanEqual(zFaceScore))\n .select(vec3(faceSign.x, 0, 0), yFaceScore.greaterThanEqual(zFaceScore)\n .select(vec3(0, faceSign.y, 0), vec3(0, 0, faceSign.z)));\n const sampledNormal = normalAtlas\n ? loadTexel(normalAtlas, hitAtlasUv).xyz.mul(2).sub(1)\n : geometricNormal;\n const bakedNormal = sampledNormal.dot(sampledNormal).greaterThan(1e-8)\n .select(sampledNormal.normalize(), geometricNormal);\n const projectedNormal = bakedNormal.dot(geometricNormal).lessThan(0)\n .select(bakedNormal.negate(), bakedNormal);\n const shadingNormal = mix(geometricNormal, projectedNormal, projectedNormalMix).normalize();\n const materialName = `Pixel impostor \u00B7 volume raycast \u00B7 ${antialias ? 'AA' : 'fast'} \u00B7 ${pbr ? 'PBR maps' : 'plain lit'}`;\n const material = new CapturedSurfaceMaterial({\n name: materialName,\n side: THREE.FrontSide,\n depthTest: true,\n depthWrite: true,\n });\n material.colorNode = vec4(baseSample.rgb.mul(float(1).sub(unlitMix)),\n antialias ? baseSample.a.mul(coverage) : baseSample.a);\n material.emissiveNode = baseSample.rgb.mul(pbr ? ormSample.r : 1).mul(unlitMix);\n material.normalNode = transformNormalToView(shadingNormal);\n if (pbr) {\n material.aoNode = ormSample.r;\n material.roughnessNode = ormSample.g.max(0.04);\n material.metalnessNode = ormSample.b;\n }\n material.receivedShadowPositionNode = modelWorldMatrix.mul(vec4(hitPosition, 1)).xyz;\n material.maskNode = occupied.and(\n baseSample.a.greaterThan(Number(descriptor.alphaCutoff) || 0.5),\n );\n material.maskShadowNode = antialias ? coverage.greaterThanEqual(0.5) : occupied;\n material.alphaToCoverage = antialias;\n material.capturedPositionNode = hitPosition;\n material.depthNode = capturedSurfaceDepth(hitPosition);\n material.toneMapped = true;\n material.userData.screenPixelSize = screenPixelSize;\n material.userData.pixelImpostorRaycastAntialias = antialias;\n material.userData.pixelImpostorRaySamples = antialias ? 5 : 1;\n material.userData.pixelImpostorPbr = pbr;\n return material;\n };\n const raycastMaterials = {\n mapped: {\n fast: createRaycastMaterial(false, true),\n antialias: createRaycastMaterial(true, true),\n },\n plain: {\n fast: createRaycastMaterial(false, false),\n antialias: createRaycastMaterial(true, false),\n },\n };\n const raycast = new THREE.Mesh(new THREE.BoxGeometry(\n raycastSize.x,\n raycastSize.y,\n raycastSize.z,\n ), raycastMaterials.mapped.antialias);\n raycast.name = 'Pixel impostor \u00B7 volume raycast';\n raycast.position.copy(raycastCenter);\n raycast.castShadow = true;\n raycast.receiveShadow = true;\n raycast.userData.previewPixelImpostor = true;\n raycast.userData.pixelImpostorDisplayMode = 'raycast';\n raycast.userData.pixelImpostorAlternateMaterials = [\n ...Object.values(raycastMaterials.mapped),\n ...Object.values(raycastMaterials.plain),\n ];\n\n const surfacePoints = binding.surfacePoints instanceof THREE.BufferAttribute\n || binding.surfacePoints instanceof THREE.InterleavedBufferAttribute\n ? binding.surfacePoints : null;\n // Keep the portable face-culled shell as one ordinary draw. Each vertex is\n // marked with its source voxel center, so every corner from one voxel gets\n // exactly the same screen-space displacement and the cell remains coherent.\n /** @type {THREE.Mesh | null} */\n let shell = null;\n asset.traverse((object) => {\n if (!shell && object instanceof THREE.Mesh\n && (object.geometry.getAttribute('_voxel_center') || surfacePoints)) {\n shell = object;\n }\n });\n if (!shell) return null;\n const voxelShell = /** @type {THREE.Mesh} */ (shell);\n const geometryBaseSample = texture(atlas, uv());\n const geometryOrmSample = ormAtlas ? texture(ormAtlas, uv()) : vec4(1, 1, 0, 1);\n const geometryNormal = attribute('normal', /** @type {const} */ ('vec3')).normalize();\n const geometryProjectedNormal = normalAtlas\n ? texture(normalAtlas, uv()).xyz.mul(2).sub(1).normalize()\n : geometryNormal;\n const geometryAlignedNormal = geometryProjectedNormal.dot(geometryNormal).lessThan(0)\n .select(geometryProjectedNormal.negate(), geometryProjectedNormal);\n const createGeometryMaterial = (/** @type {boolean} */ pbr) => {\n const material = new MeshStandardNodeMaterial({\n name: `Pixel impostor \u00B7 voxel geometry \u00B7 ${pbr ? 'mapped' : 'plain'}`,\n side: THREE.FrontSide,\n depthTest: true,\n depthWrite: true,\n });\n material.colorNode = vec4(geometryBaseSample.rgb.mul(float(1).sub(unlitMix)),\n geometryBaseSample.a);\n material.emissiveNode = geometryBaseSample.rgb.mul(pbr ? geometryOrmSample.r : 1).mul(unlitMix);\n material.normalNode = transformNormalToView(\n mix(geometryNormal, geometryAlignedNormal, projectedNormalMix).normalize(),\n );\n if (pbr) {\n material.aoNode = geometryOrmSample.r;\n material.roughnessNode = geometryOrmSample.g.max(0.04);\n material.metalnessNode = geometryOrmSample.b;\n }\n material.maskNode = geometryBaseSample.a.greaterThan(\n Number(descriptor.alphaCutoff) || 0.5,\n );\n material.toneMapped = true;\n material.userData.pixelImpostorPbr = pbr;\n return material;\n };\n const geometryMaterials = {\n mapped: createGeometryMaterial(true),\n plain: createGeometryMaterial(false),\n };\n const previousGeometryMaterial = voxelShell.material;\n voxelShell.material = geometryMaterials.mapped;\n voxelShell.userData.pixelImpostorAlternateMaterials = Object.values(geometryMaterials);\n const skinnedSplats = voxelShell instanceof THREE.SkinnedMesh;\n // Sparse instancing deliberately omits the carrier mesh's per-vertex data.\n // Animated exports retain that data, so use their dense carriers and let\n // standard Three.js skinning deform each voxel center before screen-aligning\n // its quad. Static sparse files keep the smaller instanced path.\n const useSurfacePoints = surfacePoints && !skinnedSplats;\n let splatGeometry = skinnedSplats ? voxelShell.geometry.clone() : voxelShell.geometry;\n if (skinnedSplats) {\n const centers = voxelShell.geometry.getAttribute('_voxel_center');\n if (!centers) throw new Error('Animated voxel splats require retained voxel centers.');\n splatGeometry.setAttribute('position', centers.clone());\n }\n if (useSurfacePoints) {\n const count = surfacePoints.count;\n const coordinates = new Float32Array(count * 3);\n const records = new Float32Array(count);\n for (let index = 0; index < count; index++) {\n coordinates[index * 3] = surfacePoints.getX(index);\n coordinates[index * 3 + 1] = surfacePoints.getY(index);\n coordinates[index * 3 + 2] = surfacePoints.getZ(index);\n records[index] = index;\n }\n const instancedGeometry = new THREE.InstancedBufferGeometry();\n instancedGeometry.instanceCount = count;\n splatGeometry = instancedGeometry;\n splatGeometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(12), 3));\n splatGeometry.setAttribute('_voxel_corner', new THREE.BufferAttribute(new Float32Array([\n -1, -1, 1, -1, 1, 1, -1, 1,\n ]), 2));\n splatGeometry.setAttribute('_voxel_coord', new THREE.InstancedBufferAttribute(coordinates, 3));\n splatGeometry.setAttribute('_voxel_record', new THREE.InstancedBufferAttribute(records, 1));\n splatGeometry.setIndex([0, 1, 2, 0, 2, 3]);\n splatGeometry.boundingBox = voxelShell.geometry.boundingBox?.clone() ?? bounds.clone();\n splatGeometry.boundingSphere = voxelShell.geometry.boundingSphere?.clone()\n ?? splatGeometry.boundingBox.getBoundingSphere(new THREE.Sphere());\n }\n const voxelCoordinate = attribute('_voxel_coord', /** @type {const} */ ('vec3'));\n const voxelCenter = skinnedSplats\n ? positionLocal\n : useSurfacePoints\n ? voxelCoordinate.add(0.5).div(volumeDimensions)\n .sub(0.5).mul(sizeNode).add(uniform(center.clone()))\n : attribute('_voxel_center', /** @type {const} */ ('vec3'));\n const voxelCorner = attribute('_voxel_corner', /** @type {const} */ ('vec2'));\n const centerView = modelViewMatrix.mul(vec4(voxelCenter, 1));\n const centerClip = cameraProjectionMatrix.mul(centerView);\n const centerNdc = centerClip.xy.div(centerClip.w);\n const cssViewport = viewportSize;\n const centerCss = centerNdc.mul(0.5).add(0.5).mul(cssViewport);\n const projectVoxelPoint = (/** @type {import('three/webgpu').Node<'vec3'>} */ point) => {\n const projected = cameraProjectionMatrix.mul(modelViewMatrix.mul(vec4(point, 1)));\n return projected.xy.div(projected.w).mul(0.5).add(0.5).mul(cssViewport);\n };\n const projectedX = projectVoxelPoint(voxelCenter.add(vec3(voxelHalfExtents.x, 0, 0)));\n const projectedY = projectVoxelPoint(voxelCenter.add(vec3(0, voxelHalfExtents.y, 0)));\n const projectedZ = projectVoxelPoint(voxelCenter.add(vec3(0, 0, voxelHalfExtents.z)));\n const projectedHalfFootprint = projectedX.sub(centerCss).abs()\n .add(projectedY.sub(centerCss).abs())\n .add(projectedZ.sub(centerCss).abs());\n const projectedVoxelSize = max(projectedHalfFootprint.x, projectedHalfFootprint.y).mul(2);\n const projectedCellSpan = projectedVoxelSize.div(splatPixelSize);\n // `floor()` in this vertex-node graph causes pathological WebGPU pipeline\n // compilation on current Chrome/Metal. Inputs are positive, so this is the\n // same nearest-integer quantization with half values biased downward.\n const nearestCellSpan = ceil(projectedCellSpan.sub(0.5)).max(1);\n const singleCell = snapMode.equal(1);\n const centerOnly = snapMode.equal(2);\n const cellSpan = singleCell.select(1, nearestCellSpan);\n const cellCenter = centerCss.div(splatPixelSize).floor()\n .mul(splatPixelSize).add(splatPixelSize.mul(0.5));\n const gridIntersection = centerCss.div(splatPixelSize).add(0.5).floor().mul(splatPixelSize);\n const oddCellSpan = mod(cellSpan, 2);\n const parityAlignedCenter = oddCellSpan.greaterThan(0.5).select(cellCenter, gridIntersection);\n const snappedCss = centerOnly.select(cellCenter, parityAlignedCenter);\n const splatSize = cellSpan.mul(splatPixelSize).mul(splatScale);\n // The original exposed face is only a carrier. Replace its four positions\n // with a camera-facing square centered on the voxel. A small overlap avoids\n // pinholes between neighboring screen pixels under perspective projection.\n const quadCss = snappedCss.add(voxelCorner.mul(splatSize.mul(0.52)));\n const quadNdc = quadCss.div(cssViewport).mul(2).sub(1);\n const quadClip = vec4(quadNdc.mul(centerClip.w), centerClip.z, centerClip.w);\n const quadViewHomogeneous = cameraProjectionMatrixInverse.mul(quadClip);\n const quadView = quadViewHomogeneous.xyz.div(quadViewHomogeneous.w);\n const quadWorld = cameraWorldMatrix.mul(vec4(quadView, 1));\n const quadLocalHomogeneous = modelWorldMatrixInverse.mul(quadWorld);\n const quadLocal = quadLocalHomogeneous.xyz.div(quadLocalHomogeneous.w);\n\n const splatUv = useSurfacePoints\n ? linearTextureUv(attribute('_voxel_record', /** @type {const} */ ('float')), surfaceAtlasSize)\n : uv();\n const splatColor = texture(atlas, splatUv);\n const splatOrm = ormAtlas ? texture(ormAtlas, splatUv) : vec4(1, 1, 0, 1);\n const cameraLocal = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz;\n const viewDirection = cameraLocal.sub(voxelCenter).normalize();\n const splatBakedNormal = normalAtlas\n ? texture(normalAtlas, splatUv).xyz.mul(2).sub(1).normalize()\n : viewDirection;\n const splatProjectedNormal = splatBakedNormal.dot(viewDirection).lessThan(0)\n .select(splatBakedNormal.negate(), splatBakedNormal);\n const splatShadingNormal = mix(\n viewDirection,\n splatProjectedNormal,\n projectedNormalMix,\n ).normalize();\n let splatMask;\n if (useSurfacePoints) {\n splatMask = splatColor.a.greaterThan(0.5);\n } else {\n // Legacy v3 files duplicate a voxel once per exposed face. Select exactly\n // one carrier before rotating it into the screen-aligned square.\n const voxelFaceMask = float(attribute('_voxel_face_mask', /** @type {const} */ ('float')));\n const faceScores = [\n viewDirection.x.negate(), viewDirection.x,\n viewDirection.z.negate(), viewDirection.z,\n viewDirection.y.negate(), viewDirection.y,\n ];\n const exposedScore = (/** @type {number} */ face) => {\n const exposed = mod(voxelFaceMask.div(2 ** face).floor(), 2);\n return mix(-2, faceScores[face], exposed);\n };\n const bestFaceScore = max(\n max(max(exposedScore(0), exposedScore(1)), max(exposedScore(2), exposedScore(3))),\n max(exposedScore(4), exposedScore(5)),\n );\n const sourceFaceNormal = attribute('normal', /** @type {const} */ ('vec3'));\n splatMask = sourceFaceNormal.dot(viewDirection)\n .greaterThanEqual(bestFaceScore.sub(1e-5)).and(splatColor.a.greaterThan(0.5));\n }\n const createSnappedMaterial = (/** @type {boolean} */ pbr) => {\n const material = new MeshStandardNodeMaterial({\n name: `Pixel impostor \u00B7 vertex-snapped shell \u00B7 ${pbr ? 'mapped' : 'plain'}`,\n side: THREE.FrontSide,\n depthTest: true,\n depthWrite: true,\n });\n material.positionNode = quadLocal;\n material.colorNode = vec4(splatColor.rgb.mul(float(1).sub(unlitMix)), splatColor.a);\n material.emissiveNode = splatColor.rgb.mul(pbr ? splatOrm.r : 1).mul(unlitMix);\n material.normalNode = transformNormalToView(splatShadingNormal);\n if (pbr) {\n material.aoNode = splatOrm.r;\n material.roughnessNode = splatOrm.g.max(0.04);\n material.metalnessNode = splatOrm.b;\n }\n material.maskNode = splatMask;\n material.toneMapped = true;\n material.userData.pixelImpostorPbr = pbr;\n return material;\n };\n const snappedMaterials = {\n mapped: createSnappedMaterial(true),\n plain: createSnappedMaterial(false),\n };\n const snappedShell = skinnedSplats\n ? new THREE.SkinnedMesh(splatGeometry, snappedMaterials.mapped)\n : new THREE.Mesh(splatGeometry, snappedMaterials.mapped);\n if (snappedShell instanceof THREE.SkinnedMesh && voxelShell instanceof THREE.SkinnedMesh) {\n snappedShell.bindMode = voxelShell.bindMode;\n snappedShell.bind(voxelShell.skeleton, voxelShell.bindMatrix);\n snappedShell.bindMatrixInverse.copy(voxelShell.bindMatrixInverse);\n }\n asset.updateWorldMatrix(true, true);\n voxelShell.updateWorldMatrix(true, false);\n if (!useSurfacePoints) {\n snappedShell.matrix.copy(asset.matrixWorld).invert().multiply(voxelShell.matrixWorld);\n snappedShell.matrixAutoUpdate = false;\n }\n snappedShell.name = 'Pixel impostor \u00B7 vertex-snapped shell';\n snappedShell.castShadow = false;\n snappedShell.receiveShadow = false;\n snappedShell.userData.previewPixelImpostor = true;\n snappedShell.userData.pixelImpostorDisplayMode = 'vertex-snap';\n snappedShell.userData.pixelImpostorAlternateMaterials = Object.values(snappedMaterials);\n\n const preview = new THREE.Group();\n preview.name = 'Pixel impostor shader previews';\n preview.visible = false;\n preview.userData.screenPixelSize = screenPixelSize;\n preview.userData.splatPixelSize = splatPixelSize;\n preview.userData.splatScale = splatScale;\n preview.userData.projectedNormalMix = projectedNormalMix;\n preview.userData.projectedNormalMixValue = 1;\n preview.userData.unlitMix = unlitMix;\n preview.userData.raycastMesh = raycast;\n preview.userData.raycastMaterials = raycastMaterials;\n preview.userData.geometryMesh = voxelShell;\n preview.userData.previousGeometryMaterial = previousGeometryMaterial;\n preview.userData.geometryMaterials = geometryMaterials;\n preview.userData.snappedMesh = snappedShell;\n preview.userData.snappedMaterials = snappedMaterials;\n preview.userData.raycastAntialiasEnabled = true;\n preview.userData.snapMode = snapMode;\n preview.userData.viewportSize = viewportSize;\n preview.userData.dpr = dpr;\n preview.userData.pixelSizeValue = 5;\n preview.add(raycast, snappedShell);\n const textureBytes = textureFootprintBytes(atlas)\n + (normalAtlas ? textureFootprintBytes(normalAtlas) : 0)\n + (ormAtlas ? textureFootprintBytes(ormAtlas) : 0)\n + (indexAtlas ? textureFootprintBytes(indexAtlas) : 0);\n const shellStats = pixelDisplayMeshStats(voxelShell, textureBytes);\n const splatStats = pixelDisplayMeshStats(snappedShell, textureFootprintBytes(atlas));\n const raycastStats = pixelDisplayMeshStats(raycast, textureBytes);\n preview.userData.displayStats = {\n geometry: shellStats,\n 'vertex-snap': splatStats,\n raycast: raycastStats,\n 'screen-pixels': raycastStats,\n };\n return preview;\n}\n\n/** @param {THREE.Mesh} mesh @param {number} textureBytes */\nfunction pixelDisplayMeshStats(mesh, textureBytes) {\n const position = mesh.geometry.getAttribute('position');\n const geometryBytes = bufferGeometryFootprintBytes(mesh.geometry);\n const instances = mesh.geometry instanceof THREE.InstancedBufferGeometry\n ? mesh.geometry.instanceCount : 1;\n return {\n triangles: (mesh.geometry.getIndex()?.count ?? position?.count ?? 0) / 3 * instances,\n vertices: (position?.count ?? 0) * instances,\n drawCalls: 1,\n geometryBytes,\n textureBytes,\n gpuBytes: geometryBytes + textureBytes,\n };\n}\n\n/** @param {THREE.BufferGeometry} geometry */\nfunction bufferGeometryFootprintBytes(geometry) {\n const buffers = new Set();\n let bytes = 0;\n const add = (/** @type {THREE.BufferAttribute | THREE.InterleavedBufferAttribute | null | undefined} */ attribute) => {\n if (!attribute) return;\n const storage = attribute instanceof THREE.InterleavedBufferAttribute ? attribute.data : attribute;\n if (buffers.has(storage)) return;\n buffers.add(storage);\n bytes += storage.array?.byteLength ?? 0;\n };\n add(geometry.getIndex());\n for (const attribute of Object.values(geometry.attributes)) add(attribute);\n return bytes;\n}\n\n/** @param {THREE.Texture} atlas */\nfunction textureFootprintBytes(atlas) {\n const image = /** @type {{width?:number,height?:number,data?:{byteLength?:number}} | null} */ (atlas.image);\n if (image?.data?.byteLength !== undefined) return image.data.byteLength;\n const width = Number(image?.width ?? 0);\n const height = Number(image?.height ?? 0);\n return Number.isFinite(width) && Number.isFinite(height) ? width * height * 4 : 0;\n}\n\n/**\n * Install the same voxel, screen-snap, and raycast TSL display used by the\n * workbench. Register the pixel glTF loader before loading the GLB. Call\n * `updateViewport()` after a resize and `dispose()` before discarding the scene.\n *\n * @param {THREE.Object3D} asset Loaded glTF scene.\n * @param {{mode?: 'geometry'|'vertex-snap'|'raycast'|'screen-pixels',\n * binding?:Record<string,unknown>, attach?:boolean,\n * renderer?: {getPixelRatio?: () => number, domElement?: HTMLCanvasElement},\n * pixelSize?: number, snapMode?: 'nearest-grid'|'single-cell'|'center-only',\n * splatScale?: number, antialias?: boolean, pbr?: boolean,\n * projectedNormalMix?: number}=} options\n */\nexport function createPixelImpostorDisplay(asset, options = {}) {\n /** @type {Record<string, unknown> | null} */\n let binding = options.binding ?? null;\n asset.traverse(object => { if (!binding && object.userData.pixelImpostor) binding = object.userData.pixelImpostor; });\n if (!binding) throw new Error('Load a NEEDLE_pixel_impostor GLB with registerNeedlePixelImpostorLoader first.');\n const preview = createPixelImpostorRaycastPreview(asset, new THREE.Box3().setFromObject(asset), binding);\n if (!preview) throw new Error('The pixel impostor has no supported shader atlas.');\n const originals = new Map();\n asset.traverse(object => {\n if (object instanceof THREE.Mesh) originals.set(object, object.visible);\n });\n if (options.attach !== false) asset.add(preview);\n let mode = options.mode ?? 'geometry';\n let pbr = options.pbr ?? true;\n let antialias = options.antialias ?? true;\n const setMode = (/** @type {typeof mode} */ next) => {\n if (!['geometry', 'vertex-snap', 'raycast', 'screen-pixels'].includes(next)) throw new Error(`Unknown pixel display mode: ${next}`);\n mode = next;\n preview.userData.displayMode = next;\n for (const [mesh, visible] of originals) mesh.visible = next === 'geometry' && visible;\n preview.visible = next !== 'geometry';\n for (const child of preview.children) child.visible = child.userData.pixelImpostorDisplayMode === next\n || (next === 'screen-pixels' && child.userData.pixelImpostorDisplayMode === 'raycast');\n preview.userData.screenPixelSize.value = next === 'screen-pixels' ? (options.pixelSize ?? 5) : 1;\n const raycast = preview.userData.raycastMesh;\n const raycastMaterials = preview.userData.raycastMaterials;\n if (raycast instanceof THREE.Mesh) raycast.material = raycastMaterials[pbr ? 'mapped' : 'plain'][next === 'raycast' && antialias ? 'antialias' : 'fast'];\n const snapped = preview.userData.snappedMesh;\n if (snapped instanceof THREE.Mesh) snapped.material = preview.userData.snappedMaterials[pbr ? 'mapped' : 'plain'];\n const shell = preview.userData.geometryMesh;\n if (shell instanceof THREE.Mesh) shell.material = preview.userData.geometryMaterials[pbr ? 'mapped' : 'plain'];\n return preview.userData.displayStats?.[next] ?? null;\n };\n const updateViewport = () => {\n const canvas = options.renderer?.domElement;\n const viewport = preview.userData.viewportSize.value;\n if (viewport instanceof THREE.Vector2) viewport.set(Math.max(1, canvas?.clientWidth ?? 1), Math.max(1, canvas?.clientHeight ?? 1));\n preview.userData.dpr.value = options.renderer?.getPixelRatio?.() ?? 1;\n };\n preview.userData.splatPixelSize.value = options.pixelSize ?? 5;\n preview.userData.splatScale.value = options.splatScale ?? 1;\n preview.userData.projectedNormalMix.value = options.projectedNormalMix ?? 1;\n preview.userData.snapMode.value = options.snapMode === 'single-cell' ? 1 : options.snapMode === 'center-only' ? 2 : 0;\n setMode(mode);\n updateViewport();\n return {\n preview,\n setMode,\n updateViewport,\n /** @param {boolean} enabled */\n setPbr(enabled) { pbr = Boolean(enabled); setMode(mode); },\n /** @param {boolean} enabled */\n setAntialias(enabled) { antialias = Boolean(enabled); setMode(mode); },\n dispose() {\n preview.removeFromParent();\n for (const [mesh, visible] of originals) mesh.visible = visible;\n const shell = preview.userData.geometryMesh;\n if (shell instanceof THREE.Mesh) shell.material = preview.userData.previousGeometryMaterial;\n for (const child of preview.children) if (child instanceof THREE.Mesh && child.geometry !== preview.userData.geometryMesh?.geometry) child.geometry.dispose();\n for (const materials of [preview.userData.raycastMaterials?.mapped, preview.userData.raycastMaterials?.plain, preview.userData.snappedMaterials, preview.userData.geometryMaterials]) {\n if (materials) for (const material of Object.values(materials)) material.dispose();\n }\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;AACA,SAAS,gCAAgC;AACzC,SAAS,SAAS,iBAAiB,kBAAkB,YAAY;AAK1D,IAAM,0BAAN,cAAsC,yBAAyB;AAAA;AAAA,EAEpE,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,cAAc,SAAS;AACrB,UAAM,WAAW,MAAM,cAAc,OAAO;AAC5C,QAAI,CAAC,KAAK,qBAAsB,QAAO;AACvC,UAAM,QAAQ,iBAAiB,IAAI,KAAK,KAAK,sBAAsB,CAAC,CAAC,EAAE;AACvE,UAAM,OAAO,gBAAgB,IAAI,KAAK,KAAK,sBAAsB,CAAC,CAAC,EAAE;AACrE,WAAO,QAAQ,UAAU;AAAA,MACvB,cAAc;AAAA,MACd,eAAe;AAAA,MACf,qBAAqB;AAAA,IACvB,CAAC;AAAA,EACH;AACF;;;ACzBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAAA;AAAA,EACA,QAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMA,SAAS,qBAAqB,UAAU,aAAa,GAAG;AAC7D,SAAO;AAAA,IACL,CACyB,GAC2B,YAC/C;AAEH,YAAM,IAAID,iBACP,IAAIC,MAAK,UAAU,CAAC,CAAC,EACrB,EAAE,MAAM,sBAAsB;AACjC,YAAM,WAAW,QAAQ,SAAS,wBAAwB;AAG1D,YAAM,cAAc,uBACjB,IAAIA,MAAK,GAAG,GAAG,GAAG,CAAC,CAAC,EACpB,EAAE,MAAM,CAAC;AACZ,YAAM,mBACJ,QAAQ,SAAS,2BAA2B,OACxC,wBAAwB,GAAG,YAAY,SAAS,KAC/C,WACG,kCACA,yBAAyB,GAAG,YAAY,SAAS;AAC3D,YAAM,SAAS,YAAY;AAAA,QACzB;AAAA,SACC,WACG,mCACA,0BAA0B,GAAG,YAAY,SAA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AAS,kBAAkB,QAAQ,QAAQ,SAAS,kBAAkB,OAAO,QAAQ,SAAS,kBAAkB,QAAQ,SAAS,iBAAiB,GAAG;AACpL,YAAI,UAAW,YAAW,YAAY,OAAO,OAAO,SAAS,EAAG,UAAS,QAAQ;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["// @ts-check\nimport { MeshStandardNodeMaterial } from 'three/webgpu';\nimport { context, modelViewMatrix, modelWorldMatrix, vec4 } from 'three/tsl';\n\n/** Light reconstructed surfaces at their hit position, not the carrier face.\n * View directions stay on the same ray; local lights also need the hit distance.\n */\nexport class CapturedSurfaceMaterial extends MeshStandardNodeMaterial {\n /** @type {import('three/webgpu').Node<'vec3'> | null} */\n capturedPositionNode = null;\n\n /**\n * @override\n * @param {import('three/webgpu').NodeBuilder} builder\n */\n setupLighting(builder) {\n const lighting = super.setupLighting(builder);\n if (!this.capturedPositionNode) return lighting;\n const world = modelWorldMatrix.mul(vec4(this.capturedPositionNode, 1)).xyz;\n const view = modelViewMatrix.mul(vec4(this.capturedPositionNode, 1)).xyz;\n return context(lighting, {\n positionView: view,\n positionWorld: world,\n shadowPositionWorld: world,\n });\n }\n}\n", "// @ts-check\nimport {\n Fn,\n cameraFar,\n cameraNear,\n cameraProjectionMatrix,\n modelViewMatrix,\n vec4,\n viewZToLogarithmicDepth,\n viewZToOrthographicDepth,\n viewZToPerspectiveDepth,\n viewZToReversedOrthographicDepth,\n viewZToReversedPerspectiveDepth,\n} from 'three/tsl';\n\n/** Match the renderer's depth convention after reconstructing a local hit.\n * @param {import('three/webgpu').Node<'vec3'>} position\n * @param {number} [shadowBias]\n */\nexport function capturedSurfaceDepth(position, shadowBias = 0) {\n return Fn(\n (\n /** @type {unknown} */ _,\n /** @type {import('three/webgpu').NodeBuilder} */ builder,\n ) => {\n // Resolve the shared hit before either projection branch consumes it.\n const z = modelViewMatrix\n .mul(vec4(position, 1))\n .z.toVar('capturedSurfaceViewZ');\n const reversed = builder.renderer.reversedDepthBuffer === true;\n // One material can alternate between a perspective view and orthographic\n // shadow cameras without a new pipeline; select using the active projection.\n const perspective = cameraProjectionMatrix\n .mul(vec4(0, 0, 0, 1))\n .w.equal(0);\n const perspectiveDepth =\n builder.renderer.logarithmicDepthBuffer === true\n ? viewZToLogarithmicDepth(z, cameraNear, cameraFar)\n : (reversed\n ? viewZToReversedPerspectiveDepth\n : viewZToPerspectiveDepth)(z, cameraNear, cameraFar);\n const result = perspective.select(\n perspectiveDepth,\n (reversed\n ? viewZToReversedOrthographicDepth\n : viewZToOrthographicDepth)(z, cameraNear, cameraFar),\n );\n return shadowBias &&\n 'isShadowPassMaterial' in builder.material &&\n builder.material.isShadowPassMaterial\n ? result.add(reversed ? -shadowBias : shadowBias).clamp(0, 1)\n : result;\n },\n )();\n}\n", "// @ts-check\nimport { CapturedSurfaceMaterial } from '../rendering/captured-surface-material.js';\nimport { capturedSurfaceDepth } from '../rendering/captured-surface-depth.js';\nimport * as THREE from 'three';\nimport { MeshBasicNodeMaterial, MeshStandardNodeMaterial } from 'three/webgpu';\nimport {\n Break,\n Fn,\n If,\n Loop,\n abs,\n attribute,\n cameraProjectionMatrix,\n cameraProjectionMatrixInverse,\n cameraPosition,\n cameraWorldMatrix,\n ceil,\n clamp,\n countOneBits,\n float,\n fwidth,\n getViewPosition,\n max,\n min,\n mix,\n modelViewMatrix,\n modelWorldMatrix,\n modelWorldMatrixInverse,\n mod,\n normalMap as normalMapNode,\n normalView,\n smoothstep,\n step,\n sRGBTransferEOTF,\n positionLocal,\n screenCoordinate,\n screenSize,\n texture,\n transformNormalToView,\n uint,\n uniform,\n uvec2,\n uvec4,\n uv,\n vec2,\n vec3,\n vec4,\n vertexColor,\n} from 'three/tsl';\n\n/**\n * Builds the shader alternative to the exported voxel shell. The box supplies\n * interpolated ray-entry positions; the fragment node walks the packed solid\n * volume and returns the first occupied cell in a single draw/pass.\n *\n * @param {THREE.Object3D} asset\n * @param {THREE.Box3} bounds\n * @param {Record<string, unknown>} descriptor\n */\nexport function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {\n const binding = descriptor;\n descriptor = binding.descriptor && typeof binding.descriptor === 'object'\n ? /** @type {Record<string, unknown>} */ (binding.descriptor)\n : descriptor;\n const dimensions = Array.isArray(descriptor.dimensions)\n ? descriptor.dimensions.map(Number)\n : [];\n const planar = Math.round(dimensions[0] ?? 0);\n const layers = Math.round(dimensions[1] ?? 0);\n if (!(planar > 0) || !(layers > 0) || Math.round(dimensions[2] ?? 0) !== planar) return null;\n const atlasTextures = /** @type {THREE.Texture[]} */ ([]);\n if (binding.atlas instanceof THREE.Texture) atlasTextures.push(binding.atlas);\n asset.traverse((object) => {\n if (atlasTextures.length > 0 || !(object instanceof THREE.Mesh)) return;\n const materials = Array.isArray(object.material) ? object.material : [object.material];\n for (const material of materials) {\n const map = /** @type {THREE.MeshBasicMaterial} */ (material).map;\n if (map) { atlasTextures.push(map); break; }\n }\n });\n const atlas = atlasTextures[0];\n if (!atlas) return null;\n atlas.magFilter = THREE.NearestFilter;\n atlas.minFilter = THREE.NearestFilter;\n atlas.generateMipmaps = false;\n atlas.needsUpdate = true;\n const normalAtlas = binding.normalAtlas instanceof THREE.Texture ? binding.normalAtlas : null;\n const ormAtlas = binding.ormAtlas instanceof THREE.Texture ? binding.ormAtlas : null;\n const indexAtlas = binding.indexAtlas instanceof THREE.Texture ? binding.indexAtlas : null;\n const sparse = descriptor.storage === 'sparse';\n if (sparse && !indexAtlas) return null;\n for (const map of [normalAtlas, ormAtlas, indexAtlas]) {\n if (!map) continue;\n map.colorSpace = THREE.NoColorSpace;\n map.magFilter = THREE.NearestFilter;\n map.minFilter = THREE.NearestFilter;\n map.generateMipmaps = false;\n map.needsUpdate = true;\n }\n\n const authoredMin = Array.isArray(descriptor.volumeMin) ? descriptor.volumeMin.map(Number) : null;\n const authoredSize = Array.isArray(descriptor.volumeSize) ? descriptor.volumeSize.map(Number) : null;\n const size = authoredSize?.length === 3 && authoredSize.every((value) => value > 0)\n ? new THREE.Vector3().fromArray(authoredSize)\n : bounds.getSize(new THREE.Vector3());\n const center = authoredMin?.length === 3\n ? new THREE.Vector3().fromArray(authoredMin).addScaledVector(size, 0.5)\n : bounds.getCenter(new THREE.Vector3());\n const authoredOccupiedMin = Array.isArray(descriptor.occupiedMin)\n ? descriptor.occupiedMin.map(Number) : null;\n const authoredOccupiedSize = Array.isArray(descriptor.occupiedSize)\n ? descriptor.occupiedSize.map(Number) : null;\n const raycastSize = authoredOccupiedSize?.length === 3\n && authoredOccupiedSize.every((value) => value > 0)\n ? new THREE.Vector3().fromArray(authoredOccupiedSize)\n : size.clone();\n const raycastCenter = authoredOccupiedMin?.length === 3\n ? new THREE.Vector3().fromArray(authoredOccupiedMin).addScaledVector(raycastSize, 0.5)\n : center.clone();\n const raycastOffset = raycastCenter.clone().sub(center);\n const atlasColumns = Math.max(1, Math.round(Number(descriptor.atlasColumns) || Math.ceil(Math.sqrt(layers))));\n const atlasRows = Math.max(1, Math.round(Number(descriptor.atlasRows) || Math.ceil(layers / atlasColumns)));\n const surfaceAtlasSize = Array.isArray(descriptor.surfaceAtlasSize)\n ? descriptor.surfaceAtlasSize.map(Number) : [atlas.image.width, atlas.image.height];\n const indexAtlasSize = Array.isArray(descriptor.indexAtlasSize)\n ? descriptor.indexAtlasSize.map(Number) : [1, 1];\n const sizeNode = uniform(size.clone());\n const raycastHalfSize = uniform(raycastSize.clone().multiplyScalar(0.5));\n const raycastOffsetNode = uniform(raycastOffset);\n const screenPixelSize = uniform(1);\n const splatPixelSize = uniform(5);\n const splatScale = uniform(1);\n const projectedNormalMix = uniform(1);\n const unlitMix = uniform(0);\n const snapMode = uniform(0);\n const viewportSize = uniform(new THREE.Vector2(1, 1));\n const dpr = uniform(1);\n const volumeDimensions = vec3(planar, layers, planar);\n const voxelHalfExtents = vec3(\n size.x / planar * 0.5,\n size.y / layers * 0.5,\n size.z / planar * 0.5,\n );\n const minimumCellSize = Math.min(size.x / planar, size.y / layers, size.z / planar);\n const maximumSteps = planar * 2 + layers + 3;\n const linearTextureUv = (/** @type {import('three/webgpu').Node<'float'>} */ index, /** @type {number[]} */ dimensions) => vec2(\n mod(index, dimensions[0]).add(0.5).div(dimensions[0]),\n index.div(dimensions[0]).floor().add(0.5).div(dimensions[1]),\n );\n // The ray march reads these atlases texel by texel. Explicit integer loads\n // avoid a nearest-filtered sample's shared size lookup: before r187, Three\n // computes it once inside the first trace loop, after the loop's early exit,\n // and later traces read it unassigned when that first ray leaves early.\n // Same texel a nearest sample selects: floor(uv * the texture's own size).\n const loadTexel = (/** @type {THREE.Texture} */ map, /** @type {import('three/webgpu').Node<'vec2'>} */ atlasUv) =>\n texture(map).load(uvec2(atlasUv.mul(vec2(Number(map.image.width), Number(map.image.height))).floor()));\n const sparseUint = (/** @type {import('three/webgpu').Node<'float'>} */ texel) => {\n if (!indexAtlas) throw new Error('Sparse pixel impostor requires an index atlas');\n const bytes = uvec4(loadTexel(indexAtlas, linearTextureUv(texel, indexAtlasSize)).mul(255).round());\n return bytes.x\n .bitOr(bytes.y.shiftLeft(8))\n .bitOr(bytes.z.shiftLeft(16))\n .bitOr(bytes.w.shiftLeft(24));\n };\n // @ts-ignore -- TSL's Fn declaration exposes NodeBuilder instead of its shader parameters.\n const traceVolumeNode = Fn(([sampleOffset]) => {\n // Reconstructing the ray from the snapped screen coordinate avoids the\n // derivative discontinuity along the two triangles of each box face.\n const rasterPixelSize = screenPixelSize.mul(dpr);\n const sampleCoordinate = screenCoordinate.div(rasterPixelSize).floor()\n .mul(rasterPixelSize).add(\n rasterPixelSize.mul(vec2(0.5).add(sampleOffset)),\n );\n const sampleUv = sampleCoordinate.div(screenSize);\n const nearView = getViewPosition(sampleUv, float(0), cameraProjectionMatrixInverse);\n const farView = getViewPosition(sampleUv, float(1), cameraProjectionMatrixInverse);\n const nearWorld = cameraWorldMatrix.mul(vec4(nearView, 1));\n const farWorld = cameraWorldMatrix.mul(vec4(farView, 1));\n const rayOrigin = modelWorldMatrixInverse.mul(nearWorld).xyz;\n const rayFar = modelWorldMatrixInverse.mul(farWorld).xyz;\n const rayDirection = rayFar.sub(rayOrigin).normalize();\n const distanceA = raycastHalfSize.negate().sub(rayOrigin).div(rayDirection);\n const distanceB = raycastHalfSize.sub(rayOrigin).div(rayDirection);\n const nearestDistance = max(\n max(min(distanceA.x, distanceB.x), min(distanceA.y, distanceB.y)),\n min(distanceA.z, distanceB.z),\n ).max(0);\n const exitDistance = min(\n min(max(distanceA.x, distanceB.x), max(distanceA.y, distanceB.y)),\n max(distanceA.z, distanceB.z),\n );\n const entry = rayOrigin.add(rayDirection.mul(nearestDistance));\n const gridVelocity = rayDirection.div(sizeNode).mul(volumeDimensions);\n const gridPoint = entry.add(raycastOffsetNode).div(sizeNode).add(0.5).mul(volumeDimensions)\n .add(gridVelocity.mul(minimumCellSize * 0.001));\n // Rasterization only guarantees that the center ray intersects the proxy.\n // An AA sub-sample can lie outside it; reject that ray instead of feeding\n // its invalid slab entry into the voxel traversal (which drew box lines).\n const cell = exitDistance.greaterThanEqual(nearestDistance)\n .select(gridPoint.floor(), vec3(-1)).toVar();\n // Declared before the loop: Three r186 caches a sub-expression shared by\n // the per-axis branches below into a variable assigned only inside the\n // first branch that uses it, so the z step read a stale value.\n const directionStep = step(0, gridVelocity).mul(2).sub(1).toVar();\n const absoluteVelocity = abs(gridVelocity).max(1e-6);\n const cellFraction = gridPoint.sub(cell);\n const positiveAxis = step(0, gridVelocity);\n const nextDistance = cellFraction.mul(vec3(1).sub(positiveAxis))\n .add(vec3(1).sub(cellFraction).mul(positiveAxis));\n const nextCrossing = nextDistance.div(absoluteVelocity).toVar();\n const crossingDelta = vec3(1).div(absoluteVelocity).toVar();\n // xyz is the reconstructed local hit; w is the linear cell index + 1.\n // Keeping both in one vec4 avoids rebuilding the camera ray after traversal.\n const result = vec4(0, 0, 0, 0).toVar();\n const travelled = nearestDistance.toVar();\n Loop(maximumSteps, () => {\n const outside = cell.x.lessThan(0).or(cell.y.lessThan(0)).or(cell.z.lessThan(0))\n .or(cell.x.greaterThanEqual(planar)).or(cell.y.greaterThanEqual(layers)).or(cell.z.greaterThanEqual(planar));\n If(outside, () => { Break(); });\n // Keep every operation in the TSL graph. JavaScript arithmetic coerces\n // node expressions to NaN, which then produces invalid WGSL (`NaN.0`).\n const linearCell = cell.x.add(cell.z.add(cell.y.mul(planar)).mul(planar));\n let cellOccupied;\n if (sparse) {\n const wordIndex = linearCell.div(32).floor();\n const word = sparseUint(wordIndex.mul(2));\n const bit = uint(mod(linearCell, 32));\n cellOccupied = word.shiftRight(bit).bitAnd(1).equal(1);\n } else {\n const atlasColumn = mod(cell.y, atlasColumns);\n const atlasRow = cell.y.div(atlasColumns).floor();\n const atlasUv = vec2(\n atlasColumn.mul(planar).add(cell.x).add(0.5).div(atlasColumns * planar),\n atlasRow.mul(planar).add(cell.z).add(0.5).div(atlasRows * planar),\n );\n cellOccupied = loadTexel(atlas, atlasUv).a.greaterThan(0.5);\n }\n If(cellOccupied, () => {\n result.assign(vec4(\n rayOrigin.add(rayDirection.mul(travelled)),\n linearCell.add(1),\n ));\n Break();\n });\n const nearestCrossing = min(nextCrossing.x, min(nextCrossing.y, nextCrossing.z));\n travelled.assign(nearestDistance.add(nearestCrossing));\n // Independent branches intentionally advance two or three axes for an\n // exact edge/corner crossing; that avoids revisiting zero-width cells.\n If(nextCrossing.x.lessThanEqual(nearestCrossing.add(1e-6)), () => {\n cell.x.addAssign(directionStep.x);\n nextCrossing.x.addAssign(crossingDelta.x);\n });\n If(nextCrossing.y.lessThanEqual(nearestCrossing.add(1e-6)), () => {\n cell.y.addAssign(directionStep.y);\n nextCrossing.y.addAssign(crossingDelta.y);\n });\n If(nextCrossing.z.lessThanEqual(nearestCrossing.add(1e-6)), () => {\n cell.z.addAssign(directionStep.z);\n nextCrossing.z.addAssign(crossingDelta.z);\n });\n });\n return result;\n });\n const traceVolume = /** @type {(sampleOffset: import('three/webgpu').Node<'vec2'>) => import('three/webgpu').Node<'vec4'>} */ (\n /** @type {unknown} */ (traceVolumeNode)\n );\n const createRaycastMaterial = (\n /** @type {boolean} */ antialias,\n /** @type {boolean} */ pbr,\n ) => {\n // Baked material maps are a cached graph variant, not a uniform branch:\n // the plain lit graph retains lighting and projected normals but contains\n // no voxel ORM sampling or AO/roughness/metalness nodes.\n const centerHit = traceVolume(vec2(0));\n const occupied = centerHit.w.greaterThan(0);\n /** @type {import('three/webgpu').Node<'float'>} */\n let coverage = float(1);\n if (antialias) {\n // This JavaScript branch specializes the TSL graph: the fast material\n // contains one DDA trace, while the AA material contains five. There is\n // no runtime AA branch or dormant extra tracing in the fast pipeline.\n const sampleHits = [\n traceVolume(vec2(-0.125, -0.375)),\n traceVolume(vec2(0.375, -0.125)),\n traceVolume(vec2(-0.375, 0.125)),\n traceVolume(vec2(0.125, 0.375)),\n ];\n const sampleOccupancy = sampleHits.map((sampleHit) => sampleHit.w.greaterThan(0));\n coverage = sampleOccupancy[0].select(1, 0)\n .add(sampleOccupancy[1].select(1, 0))\n .add(sampleOccupancy[2].select(1, 0))\n .add(sampleOccupancy[3].select(1, 0))\n .mul(0.25).mul(occupied.select(1, 0));\n }\n const hit = centerHit.toVar(antialias ? 'pixelImpostorAaHit' : 'pixelImpostorFastHit');\n const linearHitCell = hit.w.sub(1).max(0);\n const hitLayer = linearHitCell.div(planar * planar).floor();\n const hitSliceCell = mod(linearHitCell, planar * planar);\n const hitCell = vec3(mod(hitSliceCell, planar), hitLayer, hitSliceCell.div(planar).floor());\n let hitAtlasUv;\n if (sparse) {\n const wordIndex = linearHitCell.div(32).floor();\n const word = sparseUint(wordIndex.mul(2));\n const prefixRank = sparseUint(wordIndex.mul(2).add(1));\n const bit = uint(mod(linearHitCell, 32));\n const precedingMask = uint(1).shiftLeft(bit).sub(1);\n // Three's nodeProxyIntent returns a typed TSL node; @types/three\n // currently declares the bare BitcountNode class instead. A uint input\n // produces uint output (WGSL countOneBits preserves its input type).\n const precedingCount = /** @type {ReturnType<typeof countOneBits> & import('three/webgpu').Node<'uint'>} */ (countOneBits(word.bitAnd(precedingMask)));\n const record = prefixRank.add(precedingCount);\n hitAtlasUv = linearTextureUv(float(record), surfaceAtlasSize);\n } else {\n const hitAtlasColumn = mod(hitCell.y, atlasColumns);\n const hitAtlasRow = hitCell.y.div(atlasColumns).floor();\n hitAtlasUv = vec2(\n hitAtlasColumn.mul(planar).add(hitCell.x).add(0.5).div(atlasColumns * planar),\n hitAtlasRow.mul(planar).add(hitCell.z).add(0.5).div(atlasRows * planar),\n );\n }\n const baseSample = loadTexel(atlas, hitAtlasUv);\n const ormSample = ormAtlas ? loadTexel(ormAtlas, hitAtlasUv) : vec4(1, 1, 0, 1);\n const hitPosition = hit.xyz;\n const hitToCamera = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz.sub(hitPosition);\n const faceSign = step(0, hitToCamera).mul(2).sub(1);\n const hitCellCenter = hitCell.add(0.5).div(volumeDimensions).sub(0.5)\n .mul(sizeNode).sub(raycastOffsetNode);\n const cellDelta = hitPosition.sub(hitCellCenter).div(sizeNode).mul(volumeDimensions);\n const absoluteCellDelta = cellDelta.abs();\n const boundaryDistance = max(absoluteCellDelta.x,\n max(absoluteCellDelta.y, absoluteCellDelta.z));\n const faceDirection = hitToCamera.abs().normalize();\n // At an edge/corner more than one face is a valid entry face. Floating\n // error used to make the largest coordinate flicker between them. Treat\n // near-ties as the same boundary and choose the most camera-facing face.\n const xFaceScore = absoluteCellDelta.x.greaterThanEqual(boundaryDistance.sub(1e-4))\n .select(faceDirection.x, -1);\n const yFaceScore = absoluteCellDelta.y.greaterThanEqual(boundaryDistance.sub(1e-4))\n .select(faceDirection.y, -1);\n const zFaceScore = absoluteCellDelta.z.greaterThanEqual(boundaryDistance.sub(1e-4))\n .select(faceDirection.z, -1);\n const geometricNormal = xFaceScore.greaterThanEqual(yFaceScore)\n .and(xFaceScore.greaterThanEqual(zFaceScore))\n .select(vec3(faceSign.x, 0, 0), yFaceScore.greaterThanEqual(zFaceScore)\n .select(vec3(0, faceSign.y, 0), vec3(0, 0, faceSign.z)));\n const sampledNormal = normalAtlas\n ? loadTexel(normalAtlas, hitAtlasUv).xyz.mul(2).sub(1)\n : geometricNormal;\n const bakedNormal = sampledNormal.dot(sampledNormal).greaterThan(1e-8)\n .select(sampledNormal.normalize(), geometricNormal);\n const projectedNormal = bakedNormal.dot(geometricNormal).lessThan(0)\n .select(bakedNormal.negate(), bakedNormal);\n const shadingNormal = mix(geometricNormal, projectedNormal, projectedNormalMix).normalize();\n const materialName = `Pixel impostor \u00B7 volume raycast \u00B7 ${antialias ? 'AA' : 'fast'} \u00B7 ${pbr ? 'PBR maps' : 'plain lit'}`;\n const material = new CapturedSurfaceMaterial({\n name: materialName,\n side: THREE.FrontSide,\n depthTest: true,\n depthWrite: true,\n });\n material.colorNode = vec4(baseSample.rgb.mul(float(1).sub(unlitMix)),\n antialias ? baseSample.a.mul(coverage) : baseSample.a);\n material.emissiveNode = baseSample.rgb.mul(pbr ? ormSample.r : 1).mul(unlitMix);\n material.normalNode = transformNormalToView(shadingNormal);\n if (pbr) {\n material.aoNode = ormSample.r;\n material.roughnessNode = ormSample.g.max(0.04);\n material.metalnessNode = ormSample.b;\n }\n material.receivedShadowPositionNode = modelWorldMatrix.mul(vec4(hitPosition, 1)).xyz;\n material.maskNode = occupied.and(\n baseSample.a.greaterThan(Number(descriptor.alphaCutoff) || 0.5),\n );\n material.maskShadowNode = antialias ? coverage.greaterThanEqual(0.5) : occupied;\n material.alphaToCoverage = antialias;\n material.capturedPositionNode = hitPosition;\n material.depthNode = capturedSurfaceDepth(hitPosition);\n material.toneMapped = true;\n material.userData.screenPixelSize = screenPixelSize;\n material.userData.pixelImpostorRaycastAntialias = antialias;\n material.userData.pixelImpostorRaySamples = antialias ? 5 : 1;\n material.userData.pixelImpostorPbr = pbr;\n return material;\n };\n const raycastMaterials = {\n mapped: {\n fast: createRaycastMaterial(false, true),\n antialias: createRaycastMaterial(true, true),\n },\n plain: {\n fast: createRaycastMaterial(false, false),\n antialias: createRaycastMaterial(true, false),\n },\n };\n const raycast = new THREE.Mesh(new THREE.BoxGeometry(\n raycastSize.x,\n raycastSize.y,\n raycastSize.z,\n ), raycastMaterials.mapped.antialias);\n raycast.name = 'Pixel impostor \u00B7 volume raycast';\n raycast.position.copy(raycastCenter);\n raycast.castShadow = true;\n raycast.receiveShadow = true;\n raycast.userData.previewPixelImpostor = true;\n raycast.userData.pixelImpostorDisplayMode = 'raycast';\n raycast.userData.pixelImpostorAlternateMaterials = [\n ...Object.values(raycastMaterials.mapped),\n ...Object.values(raycastMaterials.plain),\n ];\n\n const surfacePoints = binding.surfacePoints instanceof THREE.BufferAttribute\n || binding.surfacePoints instanceof THREE.InterleavedBufferAttribute\n ? binding.surfacePoints : null;\n // Keep the portable face-culled shell as one ordinary draw. Each vertex is\n // marked with its source voxel center, so every corner from one voxel gets\n // exactly the same screen-space displacement and the cell remains coherent.\n // An export for a volume display mode has no shell: its primitive is the volume's box (voxelShell: false).\n const shellless = descriptor.voxelShell === false;\n /** @type {THREE.Mesh | null} */\n let shell = null;\n if (!shellless) asset.traverse((object) => {\n if (!shell && object instanceof THREE.Mesh\n && (object.geometry.getAttribute('_voxel_center') || surfacePoints)) {\n shell = object;\n }\n });\n if (!shell && !shellless) return null;\n const voxelShell = /** @type {THREE.Mesh | null} */ (shell);\n const geometryBaseSample = texture(atlas, uv());\n const geometryOrmSample = ormAtlas ? texture(ormAtlas, uv()) : vec4(1, 1, 0, 1);\n const geometryNormal = attribute('normal', /** @type {const} */ ('vec3')).normalize();\n const geometryProjectedNormal = normalAtlas\n ? texture(normalAtlas, uv()).xyz.mul(2).sub(1).normalize()\n : geometryNormal;\n const geometryAlignedNormal = geometryProjectedNormal.dot(geometryNormal).lessThan(0)\n .select(geometryProjectedNormal.negate(), geometryProjectedNormal);\n const createGeometryMaterial = (/** @type {boolean} */ pbr) => {\n const material = new MeshStandardNodeMaterial({\n name: `Pixel impostor \u00B7 voxel geometry \u00B7 ${pbr ? 'mapped' : 'plain'}`,\n side: THREE.FrontSide,\n depthTest: true,\n depthWrite: true,\n });\n material.colorNode = vec4(geometryBaseSample.rgb.mul(float(1).sub(unlitMix)),\n geometryBaseSample.a);\n material.emissiveNode = geometryBaseSample.rgb.mul(pbr ? geometryOrmSample.r : 1).mul(unlitMix);\n material.normalNode = transformNormalToView(\n mix(geometryNormal, geometryAlignedNormal, projectedNormalMix).normalize(),\n );\n if (pbr) {\n material.aoNode = geometryOrmSample.r;\n material.roughnessNode = geometryOrmSample.g.max(0.04);\n material.metalnessNode = geometryOrmSample.b;\n }\n material.maskNode = geometryBaseSample.a.greaterThan(\n Number(descriptor.alphaCutoff) || 0.5,\n );\n material.toneMapped = true;\n material.userData.pixelImpostorPbr = pbr;\n return material;\n };\n const geometryMaterials = {\n mapped: createGeometryMaterial(true),\n plain: createGeometryMaterial(false),\n };\n const previousGeometryMaterial = voxelShell?.material ?? null;\n if (voxelShell) {\n voxelShell.material = geometryMaterials.mapped;\n voxelShell.userData.pixelImpostorAlternateMaterials = Object.values(geometryMaterials);\n }\n const skinnedSplats = voxelShell instanceof THREE.SkinnedMesh;\n // Sparse instancing deliberately omits the carrier mesh's per-vertex data.\n // Animated exports retain that data, so use their dense carriers and let\n // standard Three.js skinning deform each voxel center before screen-aligning\n // its quad. Static sparse files keep the smaller instanced path.\n const useSurfacePoints = surfacePoints && !skinnedSplats;\n // Without a shell, splats need the sparse surface points; otherwise the splat mode is unavailable.\n const splatsAvailable = Boolean(voxelShell || useSurfacePoints);\n let splatGeometry = skinnedSplats ? /** @type {THREE.Mesh} */ (voxelShell).geometry.clone() : voxelShell?.geometry ?? new THREE.BufferGeometry();\n if (skinnedSplats) {\n const centers = /** @type {THREE.Mesh} */ (voxelShell).geometry.getAttribute('_voxel_center');\n if (!centers) throw new Error('Animated voxel splats require retained voxel centers.');\n splatGeometry.setAttribute('position', centers.clone());\n }\n if (useSurfacePoints) {\n const count = surfacePoints.count;\n const coordinates = new Float32Array(count * 3);\n const records = new Float32Array(count);\n for (let index = 0; index < count; index++) {\n coordinates[index * 3] = surfacePoints.getX(index);\n coordinates[index * 3 + 1] = surfacePoints.getY(index);\n coordinates[index * 3 + 2] = surfacePoints.getZ(index);\n records[index] = index;\n }\n const instancedGeometry = new THREE.InstancedBufferGeometry();\n instancedGeometry.instanceCount = count;\n splatGeometry = instancedGeometry;\n splatGeometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(12), 3));\n splatGeometry.setAttribute('_voxel_corner', new THREE.BufferAttribute(new Float32Array([\n -1, -1, 1, -1, 1, 1, -1, 1,\n ]), 2));\n splatGeometry.setAttribute('_voxel_coord', new THREE.InstancedBufferAttribute(coordinates, 3));\n splatGeometry.setAttribute('_voxel_record', new THREE.InstancedBufferAttribute(records, 1));\n splatGeometry.setIndex([0, 1, 2, 0, 2, 3]);\n splatGeometry.boundingBox = voxelShell?.geometry.boundingBox?.clone() ?? bounds.clone();\n splatGeometry.boundingSphere = voxelShell?.geometry.boundingSphere?.clone()\n ?? splatGeometry.boundingBox.getBoundingSphere(new THREE.Sphere());\n }\n const voxelCoordinate = attribute('_voxel_coord', /** @type {const} */ ('vec3'));\n const voxelCenter = skinnedSplats\n ? positionLocal\n : useSurfacePoints\n ? voxelCoordinate.add(0.5).div(volumeDimensions)\n .sub(0.5).mul(sizeNode).add(uniform(center.clone()))\n : attribute('_voxel_center', /** @type {const} */ ('vec3'));\n const voxelCorner = attribute('_voxel_corner', /** @type {const} */ ('vec2'));\n const centerView = modelViewMatrix.mul(vec4(voxelCenter, 1));\n const centerClip = cameraProjectionMatrix.mul(centerView);\n const centerNdc = centerClip.xy.div(centerClip.w);\n const cssViewport = viewportSize;\n const centerCss = centerNdc.mul(0.5).add(0.5).mul(cssViewport);\n const projectVoxelPoint = (/** @type {import('three/webgpu').Node<'vec3'>} */ point) => {\n const projected = cameraProjectionMatrix.mul(modelViewMatrix.mul(vec4(point, 1)));\n return projected.xy.div(projected.w).mul(0.5).add(0.5).mul(cssViewport);\n };\n const projectedX = projectVoxelPoint(voxelCenter.add(vec3(voxelHalfExtents.x, 0, 0)));\n const projectedY = projectVoxelPoint(voxelCenter.add(vec3(0, voxelHalfExtents.y, 0)));\n const projectedZ = projectVoxelPoint(voxelCenter.add(vec3(0, 0, voxelHalfExtents.z)));\n const projectedHalfFootprint = projectedX.sub(centerCss).abs()\n .add(projectedY.sub(centerCss).abs())\n .add(projectedZ.sub(centerCss).abs());\n const projectedVoxelSize = max(projectedHalfFootprint.x, projectedHalfFootprint.y).mul(2);\n const projectedCellSpan = projectedVoxelSize.div(splatPixelSize);\n // `floor()` in this vertex-node graph causes pathological WebGPU pipeline\n // compilation on current Chrome/Metal. Inputs are positive, so this is the\n // same nearest-integer quantization with half values biased downward.\n const nearestCellSpan = ceil(projectedCellSpan.sub(0.5)).max(1);\n const singleCell = snapMode.equal(1);\n const centerOnly = snapMode.equal(2);\n const cellSpan = singleCell.select(1, nearestCellSpan);\n const cellCenter = centerCss.div(splatPixelSize).floor()\n .mul(splatPixelSize).add(splatPixelSize.mul(0.5));\n const gridIntersection = centerCss.div(splatPixelSize).add(0.5).floor().mul(splatPixelSize);\n const oddCellSpan = mod(cellSpan, 2);\n const parityAlignedCenter = oddCellSpan.greaterThan(0.5).select(cellCenter, gridIntersection);\n const snappedCss = centerOnly.select(cellCenter, parityAlignedCenter);\n const splatSize = cellSpan.mul(splatPixelSize).mul(splatScale);\n // The original exposed face is only a carrier. Replace its four positions\n // with a camera-facing square centered on the voxel. A small overlap avoids\n // pinholes between neighboring screen pixels under perspective projection.\n const quadCss = snappedCss.add(voxelCorner.mul(splatSize.mul(0.52)));\n const quadNdc = quadCss.div(cssViewport).mul(2).sub(1);\n const quadClip = vec4(quadNdc.mul(centerClip.w), centerClip.z, centerClip.w);\n const quadViewHomogeneous = cameraProjectionMatrixInverse.mul(quadClip);\n const quadView = quadViewHomogeneous.xyz.div(quadViewHomogeneous.w);\n const quadWorld = cameraWorldMatrix.mul(vec4(quadView, 1));\n const quadLocalHomogeneous = modelWorldMatrixInverse.mul(quadWorld);\n const quadLocal = quadLocalHomogeneous.xyz.div(quadLocalHomogeneous.w);\n\n const splatUv = useSurfacePoints\n ? linearTextureUv(attribute('_voxel_record', /** @type {const} */ ('float')), surfaceAtlasSize)\n : uv();\n const splatColor = texture(atlas, splatUv);\n const splatOrm = ormAtlas ? texture(ormAtlas, splatUv) : vec4(1, 1, 0, 1);\n const cameraLocal = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz;\n const viewDirection = cameraLocal.sub(voxelCenter).normalize();\n const splatBakedNormal = normalAtlas\n ? texture(normalAtlas, splatUv).xyz.mul(2).sub(1).normalize()\n : viewDirection;\n const splatProjectedNormal = splatBakedNormal.dot(viewDirection).lessThan(0)\n .select(splatBakedNormal.negate(), splatBakedNormal);\n const splatShadingNormal = mix(\n viewDirection,\n splatProjectedNormal,\n projectedNormalMix,\n ).normalize();\n let splatMask;\n if (useSurfacePoints) {\n splatMask = splatColor.a.greaterThan(0.5);\n } else {\n // Legacy v3 files duplicate a voxel once per exposed face. Select exactly\n // one carrier before rotating it into the screen-aligned square.\n const voxelFaceMask = float(attribute('_voxel_face_mask', /** @type {const} */ ('float')));\n const faceScores = [\n viewDirection.x.negate(), viewDirection.x,\n viewDirection.z.negate(), viewDirection.z,\n viewDirection.y.negate(), viewDirection.y,\n ];\n const exposedScore = (/** @type {number} */ face) => {\n const exposed = mod(voxelFaceMask.div(2 ** face).floor(), 2);\n return mix(-2, faceScores[face], exposed);\n };\n const bestFaceScore = max(\n max(max(exposedScore(0), exposedScore(1)), max(exposedScore(2), exposedScore(3))),\n max(exposedScore(4), exposedScore(5)),\n );\n const sourceFaceNormal = attribute('normal', /** @type {const} */ ('vec3'));\n splatMask = sourceFaceNormal.dot(viewDirection)\n .greaterThanEqual(bestFaceScore.sub(1e-5)).and(splatColor.a.greaterThan(0.5));\n }\n const createSnappedMaterial = (/** @type {boolean} */ pbr) => {\n const material = new MeshStandardNodeMaterial({\n name: `Pixel impostor \u00B7 vertex-snapped shell \u00B7 ${pbr ? 'mapped' : 'plain'}`,\n side: THREE.FrontSide,\n depthTest: true,\n depthWrite: true,\n });\n material.positionNode = quadLocal;\n material.colorNode = vec4(splatColor.rgb.mul(float(1).sub(unlitMix)), splatColor.a);\n material.emissiveNode = splatColor.rgb.mul(pbr ? splatOrm.r : 1).mul(unlitMix);\n material.normalNode = transformNormalToView(splatShadingNormal);\n if (pbr) {\n material.aoNode = splatOrm.r;\n material.roughnessNode = splatOrm.g.max(0.04);\n material.metalnessNode = splatOrm.b;\n }\n material.maskNode = splatMask;\n material.toneMapped = true;\n material.userData.pixelImpostorPbr = pbr;\n return material;\n };\n const snappedMaterials = {\n mapped: createSnappedMaterial(true),\n plain: createSnappedMaterial(false),\n };\n const snappedShell = skinnedSplats\n ? new THREE.SkinnedMesh(splatGeometry, snappedMaterials.mapped)\n : new THREE.Mesh(splatGeometry, snappedMaterials.mapped);\n if (snappedShell instanceof THREE.SkinnedMesh && voxelShell instanceof THREE.SkinnedMesh) {\n snappedShell.bindMode = voxelShell.bindMode;\n snappedShell.bind(voxelShell.skeleton, voxelShell.bindMatrix);\n snappedShell.bindMatrixInverse.copy(voxelShell.bindMatrixInverse);\n }\n asset.updateWorldMatrix(true, true);\n voxelShell?.updateWorldMatrix(true, false);\n if (!useSurfacePoints && voxelShell) {\n snappedShell.matrix.copy(asset.matrixWorld).invert().multiply(voxelShell.matrixWorld);\n snappedShell.matrixAutoUpdate = false;\n }\n snappedShell.name = 'Pixel impostor \u00B7 vertex-snapped shell';\n snappedShell.castShadow = false;\n snappedShell.receiveShadow = false;\n snappedShell.userData.previewPixelImpostor = true;\n snappedShell.userData.pixelImpostorDisplayMode = 'vertex-snap';\n snappedShell.userData.pixelImpostorAlternateMaterials = Object.values(snappedMaterials);\n\n const preview = new THREE.Group();\n preview.name = 'Pixel impostor shader previews';\n preview.visible = false;\n preview.userData.screenPixelSize = screenPixelSize;\n preview.userData.splatPixelSize = splatPixelSize;\n preview.userData.splatScale = splatScale;\n preview.userData.projectedNormalMix = projectedNormalMix;\n preview.userData.projectedNormalMixValue = 1;\n preview.userData.unlitMix = unlitMix;\n preview.userData.raycastMesh = raycast;\n preview.userData.raycastMaterials = raycastMaterials;\n preview.userData.geometryMesh = voxelShell;\n preview.userData.previousGeometryMaterial = previousGeometryMaterial;\n preview.userData.geometryMaterials = geometryMaterials;\n preview.userData.snappedMesh = snappedShell;\n preview.userData.snappedMaterials = snappedMaterials;\n preview.userData.raycastAntialiasEnabled = true;\n preview.userData.snapMode = snapMode;\n preview.userData.viewportSize = viewportSize;\n preview.userData.dpr = dpr;\n preview.userData.pixelSizeValue = 5;\n preview.add(raycast, snappedShell);\n const textureBytes = textureFootprintBytes(atlas)\n + (normalAtlas ? textureFootprintBytes(normalAtlas) : 0)\n + (ormAtlas ? textureFootprintBytes(ormAtlas) : 0)\n + (indexAtlas ? textureFootprintBytes(indexAtlas) : 0);\n const shellStats = voxelShell ? pixelDisplayMeshStats(voxelShell, textureBytes) : null;\n const splatStats = splatsAvailable ? pixelDisplayMeshStats(snappedShell, textureFootprintBytes(atlas)) : null;\n preview.userData.availableModes = [\n ...(voxelShell ? ['geometry'] : []), ...(splatsAvailable ? ['vertex-snap'] : []), 'raycast', 'screen-pixels',\n ];\n const raycastStats = pixelDisplayMeshStats(raycast, textureBytes);\n preview.userData.displayStats = {\n geometry: shellStats,\n 'vertex-snap': splatStats,\n raycast: raycastStats,\n 'screen-pixels': raycastStats,\n };\n return preview;\n}\n\n/** @param {THREE.Mesh} mesh @param {number} textureBytes */\nfunction pixelDisplayMeshStats(mesh, textureBytes) {\n const position = mesh.geometry.getAttribute('position');\n const geometryBytes = bufferGeometryFootprintBytes(mesh.geometry);\n const instances = mesh.geometry instanceof THREE.InstancedBufferGeometry\n ? mesh.geometry.instanceCount : 1;\n return {\n triangles: (mesh.geometry.getIndex()?.count ?? position?.count ?? 0) / 3 * instances,\n vertices: (position?.count ?? 0) * instances,\n drawCalls: 1,\n geometryBytes,\n textureBytes,\n gpuBytes: geometryBytes + textureBytes,\n };\n}\n\n/** @param {THREE.BufferGeometry} geometry */\nfunction bufferGeometryFootprintBytes(geometry) {\n const buffers = new Set();\n let bytes = 0;\n const add = (/** @type {THREE.BufferAttribute | THREE.InterleavedBufferAttribute | null | undefined} */ attribute) => {\n if (!attribute) return;\n const storage = attribute instanceof THREE.InterleavedBufferAttribute ? attribute.data : attribute;\n if (buffers.has(storage)) return;\n buffers.add(storage);\n bytes += storage.array?.byteLength ?? 0;\n };\n add(geometry.getIndex());\n for (const attribute of Object.values(geometry.attributes)) add(attribute);\n return bytes;\n}\n\n/** @param {THREE.Texture} atlas */\nfunction textureFootprintBytes(atlas) {\n const image = /** @type {{width?:number,height?:number,data?:{byteLength?:number}} | null} */ (atlas.image);\n if (image?.data?.byteLength !== undefined) return image.data.byteLength;\n const width = Number(image?.width ?? 0);\n const height = Number(image?.height ?? 0);\n return Number.isFinite(width) && Number.isFinite(height) ? width * height * 4 : 0;\n}\n\n/**\n * Create a voxel, screen-space, or raycast display for a loaded pixel impostor.\n * Register the pixel glTF loader before loading the GLB. Call\n * `updateViewport()` after a resize and `dispose()` before discarding the scene.\n *\n * @param {THREE.Object3D} asset Loaded glTF scene.\n * @param {{mode?: 'geometry'|'vertex-snap'|'raycast'|'screen-pixels',\n * binding?:Record<string,unknown>, attach?:boolean,\n * renderer?: {getPixelRatio?: () => number, domElement?: HTMLCanvasElement},\n * pixelSize?: number, snapMode?: 'nearest-grid'|'single-cell'|'center-only',\n * splatScale?: number, antialias?: boolean, pbr?: boolean,\n * projectedNormalMix?: number}=} options\n */\nexport function createPixelImpostorDisplay(asset, options = {}) {\n /** @type {Record<string, unknown> | null} */\n let binding = options.binding ?? null;\n asset.traverse(object => { if (!binding && object.userData.pixelImpostor) binding = object.userData.pixelImpostor; });\n if (!binding) throw new Error('Load a NEEDLE_pixel_impostor GLB with registerNeedlePixelImpostorLoader first.');\n const preview = createPixelImpostorRaycastPreview(asset, new THREE.Box3().setFromObject(asset), binding);\n if (!preview) throw new Error('The pixel impostor has no supported shader atlas.');\n const originals = new Map();\n asset.traverse(object => {\n if (object instanceof THREE.Mesh) originals.set(object, object.visible);\n });\n if (options.attach !== false) asset.add(preview);\n // Unset options take the display stored in the file, then the defaults.\n const stored = /** @type {Partial<import('./pixel-impostor-metadata.js').PixelImpostorDisplay>} */ (\n /** @type {{display?: object}} */ (binding.descriptor ?? {}).display ?? {});\n options = { ...stored, ...Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined)) };\n let mode = options.mode ?? (preview.userData.availableModes.includes('geometry') ? 'geometry' : 'screen-pixels');\n let pbr = options.pbr ?? true;\n let antialias = options.antialias ?? true;\n const setMode = (/** @type {typeof mode} */ next) => {\n if (!['geometry', 'vertex-snap', 'raycast', 'screen-pixels'].includes(next)) throw new Error(`Unknown pixel display mode: ${next}`);\n if (!preview.userData.availableModes.includes(next)) throw new Error(`This pixel impostor has no voxel shell, so it cannot use the ${next} display mode.`);\n mode = next;\n preview.userData.displayMode = next;\n for (const [mesh, visible] of originals) mesh.visible = next === 'geometry' && visible;\n preview.visible = next !== 'geometry';\n for (const child of preview.children) child.visible = child.userData.pixelImpostorDisplayMode === next\n || (next === 'screen-pixels' && child.userData.pixelImpostorDisplayMode === 'raycast');\n preview.userData.screenPixelSize.value = next === 'screen-pixels' ? (options.pixelSize ?? 5) : 1;\n const raycast = preview.userData.raycastMesh;\n const raycastMaterials = preview.userData.raycastMaterials;\n if (raycast instanceof THREE.Mesh) raycast.material = raycastMaterials[pbr ? 'mapped' : 'plain'][next === 'raycast' && antialias ? 'antialias' : 'fast'];\n const snapped = preview.userData.snappedMesh;\n if (snapped instanceof THREE.Mesh) snapped.material = preview.userData.snappedMaterials[pbr ? 'mapped' : 'plain'];\n const shell = preview.userData.geometryMesh;\n if (shell instanceof THREE.Mesh) shell.material = preview.userData.geometryMaterials[pbr ? 'mapped' : 'plain'];\n return preview.userData.displayStats?.[next] ?? null;\n };\n const updateViewport = () => {\n const canvas = options.renderer?.domElement;\n const viewport = preview.userData.viewportSize.value;\n if (viewport instanceof THREE.Vector2) viewport.set(Math.max(1, canvas?.clientWidth ?? 1), Math.max(1, canvas?.clientHeight ?? 1));\n preview.userData.dpr.value = options.renderer?.getPixelRatio?.() ?? 1;\n };\n preview.userData.splatPixelSize.value = options.pixelSize ?? 5;\n preview.userData.splatScale.value = options.splatScale ?? 1;\n preview.userData.projectedNormalMix.value = options.projectedNormalMix ?? 1;\n preview.userData.snapMode.value = options.snapMode === 'single-cell' ? 1 : options.snapMode === 'center-only' ? 2 : 0;\n setMode(mode);\n updateViewport();\n return {\n preview,\n setMode,\n updateViewport,\n /** @param {boolean} enabled */\n setPbr(enabled) { pbr = Boolean(enabled); setMode(mode); },\n /** @param {boolean} enabled */\n setAntialias(enabled) { antialias = Boolean(enabled); setMode(mode); },\n dispose() {\n preview.removeFromParent();\n for (const [mesh, visible] of originals) mesh.visible = visible;\n const shell = preview.userData.geometryMesh;\n if (shell instanceof THREE.Mesh) shell.material = preview.userData.previousGeometryMaterial;\n for (const child of preview.children) if (child instanceof THREE.Mesh && child.geometry !== preview.userData.geometryMesh?.geometry) child.geometry.dispose();\n for (const materials of [preview.userData.raycastMaterials?.mapped, preview.userData.raycastMaterials?.plain, preview.userData.snappedMaterials, preview.userData.geometryMaterials]) {\n if (materials) for (const material of Object.values(materials)) material.dispose();\n }\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;AACA,SAAS,gCAAgC;AACzC,SAAS,SAAS,iBAAiB,kBAAkB,YAAY;AAK1D,IAAM,0BAAN,cAAsC,yBAAyB;AAAA;AAAA,EAEpE,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,cAAc,SAAS;AACrB,UAAM,WAAW,MAAM,cAAc,OAAO;AAC5C,QAAI,CAAC,KAAK,qBAAsB,QAAO;AACvC,UAAM,QAAQ,iBAAiB,IAAI,KAAK,KAAK,sBAAsB,CAAC,CAAC,EAA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