@needle-tools/three-mesh-effects 0.0.0-stage → 0.1.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -3
  3. package/build/deformation-runtime.js +2143 -0
  4. package/build/deformation-runtime.js.map +7 -0
  5. package/build/impostor-runtime-needle-engine.js +42 -0
  6. package/build/impostor-runtime-needle-engine.js.map +7 -0
  7. package/build/impostor-runtime.js +1333 -0
  8. package/build/impostor-runtime.js.map +7 -0
  9. package/build/internal/deformation/cloth-surface.js +288 -0
  10. package/build/internal/deformation/cloth-surface.js.map +7 -0
  11. package/build/internal/deformation/fur-surface.js +130 -0
  12. package/build/internal/deformation/fur-surface.js.map +7 -0
  13. package/build/internal/deformation/ik-constraints.js +44 -0
  14. package/build/internal/deformation/ik-constraints.js.map +7 -0
  15. package/build/internal/deformation/joints-json.js +197 -0
  16. package/build/internal/deformation/joints-json.js.map +7 -0
  17. package/build/internal/deformation/limits.js +16 -0
  18. package/build/internal/deformation/limits.js.map +7 -0
  19. package/build/internal/deformation/motion-settings.js +12 -0
  20. package/build/internal/deformation/motion-settings.js.map +7 -0
  21. package/build/internal/deformation/pin-cloth.js +196 -0
  22. package/build/internal/deformation/pin-cloth.js.map +7 -0
  23. package/build/internal/deformation/pin-ik.js +650 -0
  24. package/build/internal/deformation/pin-ik.js.map +7 -0
  25. package/build/internal/deformation/pin-types.js +12 -0
  26. package/build/internal/deformation/pin-types.js.map +7 -0
  27. package/build/internal/deformation/pin-wiggle.js +249 -0
  28. package/build/internal/deformation/pin-wiggle.js.map +7 -0
  29. package/build/internal/deformation/pose-slots.js +84 -0
  30. package/build/internal/deformation/pose-slots.js.map +7 -0
  31. package/build/internal/deformation/pose-timeline.js +210 -0
  32. package/build/internal/deformation/pose-timeline.js.map +7 -0
  33. package/build/internal/deformation/rig-drivers.js +48 -0
  34. package/build/internal/deformation/rig-drivers.js.map +7 -0
  35. package/build/internal/deformation/rig-extension.js +334 -0
  36. package/build/internal/deformation/rig-extension.js.map +7 -0
  37. package/build/internal/deformation/rig-runtime.js +2141 -0
  38. package/build/internal/deformation/rig-runtime.js.map +7 -0
  39. package/build/internal/deformation/wind.js +34 -0
  40. package/build/internal/deformation/wind.js.map +7 -0
  41. package/build/internal/impostor/impostor-metadata.js +77 -0
  42. package/build/internal/impostor/impostor-metadata.js.map +7 -0
  43. package/build/internal/impostor/impostor-node-material.js +1331 -0
  44. package/build/internal/impostor/impostor-node-material.js.map +7 -0
  45. package/build/internal/impostor/impostor-runtime-support.js +162 -0
  46. package/build/internal/impostor/impostor-runtime-support.js.map +7 -0
  47. package/build/internal/impostor/octahedral.js +232 -0
  48. package/build/internal/impostor/octahedral.js.map +7 -0
  49. package/build/internal/pixel-impostor/pixel-impostor-display.js +728 -0
  50. package/build/internal/pixel-impostor/pixel-impostor-display.js.map +7 -0
  51. package/build/internal/pixel-impostor/pixel-impostor-metadata.js +71 -0
  52. package/build/internal/pixel-impostor/pixel-impostor-metadata.js.map +7 -0
  53. package/build/internal/pixel-impostor/pixel-impostor-runtime.js +150 -0
  54. package/build/internal/pixel-impostor/pixel-impostor-runtime.js.map +7 -0
  55. package/build/internal/public/deformation-runtime.js +2143 -0
  56. package/build/internal/public/deformation-runtime.js.map +7 -0
  57. package/build/internal/public/impostor-runtime-needle-engine.js +42 -0
  58. package/build/internal/public/impostor-runtime-needle-engine.js.map +7 -0
  59. package/build/internal/public/impostor-runtime.js +1333 -0
  60. package/build/internal/public/impostor-runtime.js.map +7 -0
  61. package/build/internal/public/pixel-impostor-runtime.js +876 -0
  62. package/build/internal/public/pixel-impostor-runtime.js.map +7 -0
  63. package/build/internal/public/wrap-effects.js +5640 -0
  64. package/build/internal/public/wrap-effects.js.map +7 -0
  65. package/build/internal/rendering/skin-projection.js +4630 -0
  66. package/build/internal/rendering/skin-projection.js.map +7 -0
  67. package/build/internal/rendering/surface-query.js +4519 -0
  68. package/build/internal/rendering/surface-query.js.map +7 -0
  69. package/build/internal/rendering/wireframe.js +112 -0
  70. package/build/internal/rendering/wireframe.js.map +7 -0
  71. package/build/internal/rendering/wrap-preview-settings.js +126 -0
  72. package/build/internal/rendering/wrap-preview-settings.js.map +7 -0
  73. package/build/internal/rendering/wrap-preview.js +5610 -0
  74. package/build/internal/rendering/wrap-preview.js.map +7 -0
  75. package/build/internal/rendering/wrap-skin.js +4746 -0
  76. package/build/internal/rendering/wrap-skin.js.map +7 -0
  77. package/build/pixel-impostor-runtime.js +876 -0
  78. package/build/pixel-impostor-runtime.js.map +7 -0
  79. package/build/types/deformation/cloth-surface.d.ts +39 -0
  80. package/build/types/deformation/cloth-surface.js +1 -0
  81. package/build/types/deformation/fur-surface.d.ts +27 -0
  82. package/build/types/deformation/fur-surface.js +1 -0
  83. package/build/types/deformation/ik-constraints.d.ts +18 -0
  84. package/build/types/deformation/ik-constraints.js +1 -0
  85. package/build/types/deformation/joints-json.d.ts +17 -0
  86. package/build/types/deformation/joints-json.js +1 -0
  87. package/build/types/deformation/limits.d.ts +23 -0
  88. package/build/types/deformation/limits.js +1 -0
  89. package/build/types/deformation/motion-settings.d.ts +9 -0
  90. package/build/types/deformation/motion-settings.js +1 -0
  91. package/build/types/deformation/pin-cloth.d.ts +28 -0
  92. package/build/types/deformation/pin-cloth.js +1 -0
  93. package/build/types/deformation/pin-ik.d.ts +37 -0
  94. package/build/types/deformation/pin-ik.js +1 -0
  95. package/build/types/deformation/pin-types.d.ts +53 -0
  96. package/build/types/deformation/pin-types.js +1 -0
  97. package/build/types/deformation/pin-wiggle.d.ts +16 -0
  98. package/build/types/deformation/pin-wiggle.js +1 -0
  99. package/build/types/deformation/pose-slots.d.ts +41 -0
  100. package/build/types/deformation/pose-slots.js +1 -0
  101. package/build/types/deformation/pose-timeline.d.ts +65 -0
  102. package/build/types/deformation/pose-timeline.js +1 -0
  103. package/build/types/deformation/rig-drivers.d.ts +19 -0
  104. package/build/types/deformation/rig-drivers.js +1 -0
  105. package/build/types/deformation/rig-extension.d.ts +33 -0
  106. package/build/types/deformation/rig-extension.js +1 -0
  107. package/build/types/deformation/rig-runtime.d.ts +95 -0
  108. package/build/types/deformation/rig-runtime.js +1 -0
  109. package/build/types/deformation/wind.d.ts +16 -0
  110. package/build/types/deformation/wind.js +1 -0
  111. package/build/types/impostor/impostor-metadata.d.ts +61 -0
  112. package/build/types/impostor/impostor-metadata.js +1 -0
  113. package/build/types/impostor/impostor-node-material.d.ts +140 -0
  114. package/build/types/impostor/impostor-node-material.js +1 -0
  115. package/build/types/impostor/impostor-runtime-support.d.ts +52 -0
  116. package/build/types/impostor/impostor-runtime-support.js +1 -0
  117. package/build/types/impostor/octahedral.d.ts +84 -0
  118. package/build/types/impostor/octahedral.js +1 -0
  119. package/build/types/pixel-impostor/pixel-impostor-display.d.ts +48 -0
  120. package/build/types/pixel-impostor/pixel-impostor-display.js +1 -0
  121. package/build/types/pixel-impostor/pixel-impostor-metadata.d.ts +34 -0
  122. package/build/types/pixel-impostor/pixel-impostor-metadata.js +1 -0
  123. package/build/types/pixel-impostor/pixel-impostor-runtime.d.ts +18 -0
  124. package/build/types/pixel-impostor/pixel-impostor-runtime.js +1 -0
  125. package/build/types/public/deformation-runtime.d.ts +3 -0
  126. package/build/types/public/deformation-runtime.js +1 -0
  127. package/build/types/public/impostor-runtime-needle-engine.d.ts +31 -0
  128. package/build/types/public/impostor-runtime-needle-engine.js +1 -0
  129. package/build/types/public/impostor-runtime.d.ts +6 -0
  130. package/build/types/public/impostor-runtime.js +1 -0
  131. package/build/types/public/pixel-impostor-runtime.d.ts +3 -0
  132. package/build/types/public/pixel-impostor-runtime.js +1 -0
  133. package/build/types/public/wrap-effects.d.ts +4 -0
  134. package/build/types/public/wrap-effects.js +1 -0
  135. package/build/types/rendering/skin-projection.d.ts +44 -0
  136. package/build/types/rendering/skin-projection.js +1 -0
  137. package/build/types/rendering/surface-query.d.ts +66 -0
  138. package/build/types/rendering/surface-query.js +1 -0
  139. package/build/types/rendering/wireframe.d.ts +25 -0
  140. package/build/types/rendering/wireframe.js +1 -0
  141. package/build/types/rendering/wrap-preview-settings.d.ts +22 -0
  142. package/build/types/rendering/wrap-preview-settings.js +1 -0
  143. package/build/types/rendering/wrap-preview.d.ts +39 -0
  144. package/build/types/rendering/wrap-preview.js +1 -0
  145. package/build/types/rendering/wrap-skin.d.ts +14 -0
  146. package/build/types/rendering/wrap-skin.js +1 -0
  147. package/build/wrap-effects.js +5640 -0
  148. package/build/wrap-effects.js.map +7 -0
  149. package/package.json +94 -6
  150. package/src/deformation/cloth-surface.ts +223 -0
  151. package/src/deformation/fur-surface.ts +129 -0
  152. package/src/deformation/ik-constraints.ts +37 -0
  153. package/src/deformation/joints-json.ts +94 -0
  154. package/src/deformation/limits.ts +25 -0
  155. package/src/deformation/motion-settings.ts +9 -0
  156. package/src/deformation/pin-cloth.ts +149 -0
  157. package/src/deformation/pin-ik.ts +582 -0
  158. package/src/deformation/pin-types.ts +22 -0
  159. package/src/deformation/pin-wiggle.ts +119 -0
  160. package/src/deformation/pose-slots.ts +106 -0
  161. package/src/deformation/pose-timeline.ts +242 -0
  162. package/src/deformation/rig-drivers.ts +32 -0
  163. package/src/deformation/rig-extension.ts +87 -0
  164. package/src/deformation/rig-runtime.ts +416 -0
  165. package/src/deformation/wind.ts +36 -0
  166. package/src/impostor/impostor-metadata.js +137 -0
  167. package/src/impostor/impostor-node-material.js +1581 -0
  168. package/src/impostor/impostor-runtime-support.js +139 -0
  169. package/src/impostor/octahedral.js +280 -0
  170. package/src/pixel-impostor/pixel-impostor-display.js +794 -0
  171. package/src/pixel-impostor/pixel-impostor-metadata.js +74 -0
  172. package/src/pixel-impostor/pixel-impostor-runtime.js +78 -0
  173. package/src/public/deformation-runtime.ts +3 -0
  174. package/src/public/impostor-runtime-needle-engine.js +56 -0
  175. package/src/public/impostor-runtime.js +21 -0
  176. package/src/public/pixel-impostor-runtime.js +5 -0
  177. package/src/public/wrap-effects.js +21 -0
  178. package/src/rendering/skin-projection.js +113 -0
  179. package/src/rendering/surface-query.js +88 -0
  180. package/src/rendering/wireframe.js +115 -0
  181. package/src/rendering/wrap-preview-settings.js +123 -0
  182. package/src/rendering/wrap-preview.js +645 -0
  183. package/src/rendering/wrap-skin.js +109 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/pixel-impostor/pixel-impostor-runtime.js", "../src/pixel-impostor/pixel-impostor-metadata.js", "../src/pixel-impostor/pixel-impostor-display.js"],
4
+ "sourcesContent": ["// @ts-check\r\n\r\nimport { ClampToEdgeWrapping, NearestFilter, NoColorSpace, SRGBColorSpace } from 'three';\r\nimport { NEEDLE_PIXEL_IMPOSTOR, parsePixelImpostorDescriptor } from './pixel-impostor-metadata.js';\r\n\r\n/**\r\n * Three.js GLTFLoader plugin for versioned pixel impostor atlas bindings.\r\n * It leaves the portable voxel shell intact. Use `createPixelImpostorDisplay`\r\n * after loading to select the workbench's TSL display modes.\r\n */\r\nexport class NeedlePixelImpostorLoaderPlugin {\r\n /** @param {unknown} parser */\r\n constructor(parser) { this.name = NEEDLE_PIXEL_IMPOSTOR; this.parser = parser; }\r\n /** @param {import('three/addons/loaders/GLTFLoader.js').GLTF} result */\r\n async afterRoot(result) {\r\n const parser = /** @type {{json:{meshes?:Array<{primitives:Array<{extensions?:Record<string,unknown>}>}>},associations:Map<import('three').Object3D,{meshes?:number,primitives?:number}>,getDependency(type:'texture',index:number):Promise<import('three').Texture>,getDependency(type:'accessor',index:number):Promise<import('three').BufferAttribute>}} */ (this.parser);\r\n const pending = /** @type {Promise<void>[]} */ ([]);\r\n // Scene-less glTFs are legal (e.g. material libraries). Leave validation\r\n // to the consuming app instead of crashing during loader postprocessing.\r\n result.scene?.traverse((object) => {\r\n if (!('isMesh' in object) || object.isMesh !== true) return;\r\n const association = parser.associations.get(object);\r\n if (association?.meshes === undefined || association.primitives === undefined) return;\r\n const raw = parser.json.meshes?.[association.meshes]\r\n ?.primitives[association.primitives]?.extensions?.[NEEDLE_PIXEL_IMPOSTOR];\r\n const descriptor = parsePixelImpostorDescriptor(raw);\r\n if (!descriptor || !raw || typeof raw !== 'object') return;\r\n const record = /** @type {Record<string, unknown>} */ (raw);\r\n const atlasInfo = record.atlas;\r\n const atlasIndex = atlasInfo && typeof atlasInfo === 'object' ? Reflect.get(atlasInfo, 'index') : undefined;\r\n if (!Number.isInteger(atlasIndex)) throw new Error('NEEDLE_pixel_impostor has no atlas binding.');\r\n /** @param {string} role @param {string} colorSpace @param {boolean} [required] */\r\n const loadTexture = async (role, colorSpace, required = false) => {\r\n const info = record[role];\r\n const index = info && typeof info === 'object' ? Reflect.get(info, 'index') : undefined;\r\n if (!Number.isInteger(index)) {\r\n if (required) throw new Error(`NEEDLE_pixel_impostor has no ${role} binding.`);\r\n return null;\r\n }\r\n const texture = await parser.getDependency('texture', Number(index));\r\n texture.colorSpace = colorSpace;\r\n texture.magFilter = NearestFilter;\r\n texture.minFilter = NearestFilter;\r\n texture.wrapS = ClampToEdgeWrapping;\r\n texture.wrapT = ClampToEdgeWrapping;\r\n texture.generateMipmaps = false;\r\n texture.needsUpdate = true;\r\n return texture;\r\n };\r\n const surfacePointsIndex = record.surfacePoints;\r\n const surfacePointsPromise = Number.isInteger(surfacePointsIndex)\r\n ? parser.getDependency('accessor', Number(surfacePointsIndex))\r\n : Promise.resolve(null);\r\n pending.push(Promise.all([\r\n loadTexture('atlas', SRGBColorSpace, true),\r\n loadTexture('normalAtlas', NoColorSpace),\r\n loadTexture('ormAtlas', NoColorSpace),\r\n loadTexture('indexAtlas', NoColorSpace, descriptor.version === 3),\r\n surfacePointsPromise,\r\n ]).then(([atlas, normalAtlas, ormAtlas, indexAtlas, surfacePoints]) => {\r\n if (!atlas) throw new Error('NEEDLE_pixel_impostor atlas is unavailable.');\r\n object.userData.pixelImpostor = {\r\n descriptor, atlas, normalAtlas, ormAtlas, indexAtlas, surfacePoints,\r\n };\r\n }));\r\n });\r\n await Promise.all(pending);\r\n }\r\n}\r\n\r\n/** Register pixel atlas loading before calling `loadAsync`; returns the same loader.\r\n * @template {import('three/addons/loaders/GLTFLoader.js').GLTFLoader} T\r\n * @param {T} loader @returns {T}\r\n */\r\nexport function registerNeedlePixelImpostorLoader(loader) {\r\n loader.register((parser) => new NeedlePixelImpostorLoaderPlugin(parser));\r\n return loader;\r\n}\r\n", "// @ts-check\r\n\r\nexport const NEEDLE_PIXEL_IMPOSTOR = 'NEEDLE_pixel_impostor';\r\n\r\n/**\r\n * @typedef {object} PixelImpostorDescriptor\r\n * @property {1 | 2 | 3} version\r\n * @property {[number, number, number]} dimensions\r\n * @property {number} atlasColumns\r\n * @property {number} atlasRows\r\n * @property {[number, number, number]} volumeMin\r\n * @property {[number, number, number]} volumeSize\r\n * @property {[number, number, number]} occupiedMin\r\n * @property {[number, number, number]} occupiedSize\r\n * @property {number} alphaCutoff\r\n * @property {'dense' | 'sparse'} storage\r\n * @property {number=} surfaceCount\r\n * @property {[number, number]=} surfaceAtlasSize\r\n * @property {[number, number]=} indexAtlasSize\r\n */\r\n\r\n/** @param {unknown} value @returns {PixelImpostorDescriptor | null} */\r\nexport function parsePixelImpostorDescriptor(value) {\r\n if (!value || typeof value !== 'object') return null;\r\n const raw = /** @type {Record<string, unknown>} */ (value);\r\n if ((raw.version !== 1 && raw.version !== 2 && raw.version !== 3) || !triplet(raw.dimensions) || !triplet(raw.volumeMin)\r\n || !triplet(raw.volumeSize)) return null;\r\n const dimensions = /** @type {number[]} */ (raw.dimensions);\r\n const volumeSize = /** @type {number[]} */ (raw.volumeSize);\r\n const occupiedMin = triplet(raw.occupiedMin)\r\n ? /** @type {number[]} */ (raw.occupiedMin)\r\n : /** @type {number[]} */ (raw.volumeMin);\r\n const occupiedSize = triplet(raw.occupiedSize)\r\n ? /** @type {number[]} */ (raw.occupiedSize)\r\n : volumeSize;\r\n if (!dimensions.every((item) => Number.isInteger(item) && item > 0)\r\n || !volumeSize.every((item) => Number.isFinite(item) && item > 0)\r\n || !occupiedSize.every((item) => Number.isFinite(item) && item > 0)\r\n || (raw.version !== 3 && (!Number.isInteger(raw.atlasColumns) || Number(raw.atlasColumns) < 1\r\n || !Number.isInteger(raw.atlasRows) || Number(raw.atlasRows) < 1))) return null;\r\n const sparse = raw.version === 3 && raw.storage === 'sparse';\r\n if (raw.version === 3 && (!sparse\r\n || !Number.isInteger(raw.surfaceCount) || Number(raw.surfaceCount) < 1\r\n || !pair(raw.surfaceAtlasSize) || !pair(raw.indexAtlasSize))) return null;\r\n return /** @type {PixelImpostorDescriptor} */ ({\r\n version: /** @type {1 | 2 | 3} */ (raw.version),\r\n dimensions: [...dimensions],\r\n atlasColumns: sparse ? 0 : Number(raw.atlasColumns),\r\n atlasRows: sparse ? 0 : Number(raw.atlasRows),\r\n volumeMin: [.../** @type {number[]} */ (raw.volumeMin)],\r\n volumeSize: [...volumeSize],\r\n occupiedMin: [...occupiedMin],\r\n occupiedSize: [...occupiedSize],\r\n alphaCutoff: Number.isFinite(raw.alphaCutoff) ? Number(raw.alphaCutoff) : 0.5,\r\n storage: sparse ? 'sparse' : 'dense',\r\n ...(sparse ? {\r\n surfaceCount: Number(raw.surfaceCount),\r\n surfaceAtlasSize: [.../** @type {number[]} */ (raw.surfaceAtlasSize)],\r\n indexAtlasSize: [.../** @type {number[]} */ (raw.indexAtlasSize)],\r\n } : {}),\r\n });\r\n}\r\n\r\n/** @param {unknown} value */\r\nfunction triplet(value) {\r\n return Array.isArray(value) && value.length === 3\r\n && value.every((item) => Number.isFinite(item));\r\n}\r\n\r\n/** @param {unknown} value */\r\nfunction pair(value) {\r\n return Array.isArray(value) && value.length === 2\r\n && value.every((item) => Number.isInteger(item) && item > 0);\r\n}\r\n", "// @ts-check\r\nimport * as THREE from 'three';\r\nimport { MeshBasicNodeMaterial, MeshStandardNodeMaterial } from 'three/webgpu';\r\nimport {\r\n Break,\r\n Fn,\r\n If,\r\n Loop,\r\n abs,\r\n attribute,\r\n cameraProjectionMatrix,\r\n cameraProjectionMatrixInverse,\r\n cameraFar,\r\n cameraNear,\r\n cameraPosition,\r\n cameraWorldMatrix,\r\n ceil,\r\n clamp,\r\n countOneBits,\r\n float,\r\n fwidth,\r\n getViewPosition,\r\n max,\r\n min,\r\n mix,\r\n modelViewMatrix,\r\n modelWorldMatrix,\r\n modelWorldMatrixInverse,\r\n mod,\r\n normalMap as normalMapNode,\r\n normalView,\r\n smoothstep,\r\n step,\r\n sRGBTransferEOTF,\r\n positionLocal,\r\n screenCoordinate,\r\n screenSize,\r\n texture,\r\n transformNormalToView,\r\n uint,\r\n uniform,\r\n uvec4,\r\n uv,\r\n vec2,\r\n vec3,\r\n vec4,\r\n vertexColor,\r\n viewZToOrthographicDepth,\r\n viewZToPerspectiveDepth,\r\n} from 'three/tsl';\r\n\r\n/**\r\n * Builds the shader alternative to the exported voxel shell. The box supplies\r\n * interpolated ray-entry positions; the fragment node walks the packed solid\r\n * volume and returns the first occupied cell in a single draw/pass.\r\n *\r\n * @param {THREE.Object3D} asset\r\n * @param {THREE.Box3} bounds\r\n * @param {Record<string, unknown>} descriptor\r\n */\r\nexport function createPixelImpostorRaycastPreview(asset, bounds, descriptor) {\r\n const binding = descriptor;\r\n descriptor = binding.descriptor && typeof binding.descriptor === 'object'\r\n ? /** @type {Record<string, unknown>} */ (binding.descriptor)\r\n : descriptor;\r\n const dimensions = Array.isArray(descriptor.dimensions)\r\n ? descriptor.dimensions.map(Number)\r\n : [];\r\n const planar = Math.round(dimensions[0] ?? 0);\r\n const layers = Math.round(dimensions[1] ?? 0);\r\n if (!(planar > 0) || !(layers > 0) || Math.round(dimensions[2] ?? 0) !== planar) return null;\r\n const atlasTextures = /** @type {THREE.Texture[]} */ ([]);\r\n if (binding.atlas instanceof THREE.Texture) atlasTextures.push(binding.atlas);\r\n asset.traverse((object) => {\r\n if (atlasTextures.length > 0 || !(object instanceof THREE.Mesh)) return;\r\n const materials = Array.isArray(object.material) ? object.material : [object.material];\r\n for (const material of materials) {\r\n const map = /** @type {THREE.MeshBasicMaterial} */ (material).map;\r\n if (map) { atlasTextures.push(map); break; }\r\n }\r\n });\r\n const atlas = atlasTextures[0];\r\n if (!atlas) return null;\r\n atlas.magFilter = THREE.NearestFilter;\r\n atlas.minFilter = THREE.NearestFilter;\r\n atlas.generateMipmaps = false;\r\n atlas.needsUpdate = true;\r\n const normalAtlas = binding.normalAtlas instanceof THREE.Texture ? binding.normalAtlas : null;\r\n const ormAtlas = binding.ormAtlas instanceof THREE.Texture ? binding.ormAtlas : null;\r\n const indexAtlas = binding.indexAtlas instanceof THREE.Texture ? binding.indexAtlas : null;\r\n const sparse = descriptor.version === 3 && descriptor.storage === 'sparse';\r\n if (sparse && !indexAtlas) return null;\r\n for (const map of [normalAtlas, ormAtlas, indexAtlas]) {\r\n if (!map) continue;\r\n map.colorSpace = THREE.NoColorSpace;\r\n map.magFilter = THREE.NearestFilter;\r\n map.minFilter = THREE.NearestFilter;\r\n map.generateMipmaps = false;\r\n map.needsUpdate = true;\r\n }\r\n\r\n const authoredMin = Array.isArray(descriptor.volumeMin) ? descriptor.volumeMin.map(Number) : null;\r\n const authoredSize = Array.isArray(descriptor.volumeSize) ? descriptor.volumeSize.map(Number) : null;\r\n const size = authoredSize?.length === 3 && authoredSize.every((value) => value > 0)\r\n ? new THREE.Vector3().fromArray(authoredSize)\r\n : bounds.getSize(new THREE.Vector3());\r\n const center = authoredMin?.length === 3\r\n ? new THREE.Vector3().fromArray(authoredMin).addScaledVector(size, 0.5)\r\n : bounds.getCenter(new THREE.Vector3());\r\n const authoredOccupiedMin = Array.isArray(descriptor.occupiedMin)\r\n ? descriptor.occupiedMin.map(Number) : null;\r\n const authoredOccupiedSize = Array.isArray(descriptor.occupiedSize)\r\n ? descriptor.occupiedSize.map(Number) : null;\r\n const raycastSize = authoredOccupiedSize?.length === 3\r\n && authoredOccupiedSize.every((value) => value > 0)\r\n ? new THREE.Vector3().fromArray(authoredOccupiedSize)\r\n : size.clone();\r\n const raycastCenter = authoredOccupiedMin?.length === 3\r\n ? new THREE.Vector3().fromArray(authoredOccupiedMin).addScaledVector(raycastSize, 0.5)\r\n : center.clone();\r\n const raycastOffset = raycastCenter.clone().sub(center);\r\n const atlasColumns = Math.max(1, Math.round(Number(descriptor.atlasColumns) || Math.ceil(Math.sqrt(layers))));\r\n const atlasRows = Math.max(1, Math.round(Number(descriptor.atlasRows) || Math.ceil(layers / atlasColumns)));\r\n const surfaceAtlasSize = Array.isArray(descriptor.surfaceAtlasSize)\r\n ? descriptor.surfaceAtlasSize.map(Number) : [atlas.image.width, atlas.image.height];\r\n const indexAtlasSize = Array.isArray(descriptor.indexAtlasSize)\r\n ? descriptor.indexAtlasSize.map(Number) : [1, 1];\r\n const sizeNode = uniform(size.clone());\r\n const raycastHalfSize = uniform(raycastSize.clone().multiplyScalar(0.5));\r\n const raycastOffsetNode = uniform(raycastOffset);\r\n const screenPixelSize = uniform(1);\r\n const splatPixelSize = uniform(5);\r\n const splatScale = uniform(1);\r\n const projectedNormalMix = uniform(1);\r\n const unlitMix = uniform(0);\r\n const snapMode = uniform(0);\r\n const viewportSize = uniform(new THREE.Vector2(1, 1));\r\n const dpr = uniform(1);\r\n const volumeDimensions = vec3(planar, layers, planar);\r\n const voxelHalfExtents = vec3(\r\n size.x / planar * 0.5,\r\n size.y / layers * 0.5,\r\n size.z / planar * 0.5,\r\n );\r\n const minimumCellSize = Math.min(size.x / planar, size.y / layers, size.z / planar);\r\n const maximumSteps = planar * 2 + layers + 3;\r\n const linearTextureUv = (/** @type {import('three/webgpu').Node<'float'>} */ index, /** @type {number[]} */ dimensions) => vec2(\r\n mod(index, dimensions[0]).add(0.5).div(dimensions[0]),\r\n index.div(dimensions[0]).floor().add(0.5).div(dimensions[1]),\r\n );\r\n const sparseUint = (/** @type {import('three/webgpu').Node<'float'>} */ texel) => {\r\n if (!indexAtlas) throw new Error('Sparse pixel impostor requires an index atlas');\r\n const bytes = uvec4(texture(indexAtlas, linearTextureUv(texel, indexAtlasSize)).mul(255).round());\r\n return bytes.x\r\n .bitOr(bytes.y.shiftLeft(8))\r\n .bitOr(bytes.z.shiftLeft(16))\r\n .bitOr(bytes.w.shiftLeft(24));\r\n };\r\n // @ts-ignore -- TSL's Fn declaration exposes NodeBuilder instead of its shader parameters.\r\n const traceVolumeNode = Fn(([sampleOffset]) => {\r\n // Reconstructing the ray from the snapped screen coordinate avoids the\r\n // derivative discontinuity along the two triangles of each box face.\r\n const rasterPixelSize = screenPixelSize.mul(dpr);\r\n const sampleCoordinate = screenCoordinate.div(rasterPixelSize).floor()\r\n .mul(rasterPixelSize).add(\r\n rasterPixelSize.mul(vec2(0.5).add(sampleOffset)),\r\n );\r\n const sampleUv = sampleCoordinate.div(screenSize);\r\n const nearView = getViewPosition(sampleUv, float(0), cameraProjectionMatrixInverse);\r\n const farView = getViewPosition(sampleUv, float(1), cameraProjectionMatrixInverse);\r\n const nearWorld = cameraWorldMatrix.mul(vec4(nearView, 1));\r\n const farWorld = cameraWorldMatrix.mul(vec4(farView, 1));\r\n const rayOrigin = modelWorldMatrixInverse.mul(nearWorld).xyz;\r\n const rayFar = modelWorldMatrixInverse.mul(farWorld).xyz;\r\n const rayDirection = rayFar.sub(rayOrigin).normalize();\r\n const distanceA = raycastHalfSize.negate().sub(rayOrigin).div(rayDirection);\r\n const distanceB = raycastHalfSize.sub(rayOrigin).div(rayDirection);\r\n const nearestDistance = max(\r\n max(min(distanceA.x, distanceB.x), min(distanceA.y, distanceB.y)),\r\n min(distanceA.z, distanceB.z),\r\n ).max(0);\r\n const exitDistance = min(\r\n min(max(distanceA.x, distanceB.x), max(distanceA.y, distanceB.y)),\r\n max(distanceA.z, distanceB.z),\r\n );\r\n const entry = rayOrigin.add(rayDirection.mul(nearestDistance));\r\n const gridVelocity = rayDirection.div(sizeNode).mul(volumeDimensions);\r\n const gridPoint = entry.add(raycastOffsetNode).div(sizeNode).add(0.5).mul(volumeDimensions)\r\n .add(gridVelocity.mul(minimumCellSize * 0.001));\r\n // Rasterization only guarantees that the center ray intersects the proxy.\r\n // An AA sub-sample can lie outside it; reject that ray instead of feeding\r\n // its invalid slab entry into the voxel traversal (which drew box lines).\r\n const cell = exitDistance.greaterThanEqual(nearestDistance)\r\n .select(gridPoint.floor(), vec3(-1)).toVar();\r\n const directionStep = step(0, gridVelocity).mul(2).sub(1);\r\n const absoluteVelocity = abs(gridVelocity).max(1e-6);\r\n const cellFraction = gridPoint.sub(cell);\r\n const positiveAxis = step(0, gridVelocity);\r\n const nextDistance = cellFraction.mul(vec3(1).sub(positiveAxis))\r\n .add(vec3(1).sub(cellFraction).mul(positiveAxis));\r\n const nextCrossing = nextDistance.div(absoluteVelocity).toVar();\r\n const crossingDelta = vec3(1).div(absoluteVelocity);\r\n // xyz is the reconstructed local hit; w is the linear cell index + 1.\r\n // Keeping both in one vec4 avoids rebuilding the camera ray after traversal.\r\n const result = vec4(0, 0, 0, 0).toVar();\r\n const travelled = nearestDistance.toVar();\r\n Loop(maximumSteps, () => {\r\n const outside = cell.x.lessThan(0).or(cell.y.lessThan(0)).or(cell.z.lessThan(0))\r\n .or(cell.x.greaterThanEqual(planar)).or(cell.y.greaterThanEqual(layers)).or(cell.z.greaterThanEqual(planar));\r\n If(outside, () => { Break(); });\r\n // Keep every operation in the TSL graph. JavaScript arithmetic coerces\r\n // node expressions to NaN, which then produces invalid WGSL (`NaN.0`).\r\n const linearCell = cell.x.add(cell.z.add(cell.y.mul(planar)).mul(planar));\r\n let cellOccupied;\r\n if (sparse) {\r\n const wordIndex = linearCell.div(32).floor();\r\n const word = sparseUint(wordIndex.mul(2));\r\n const bit = uint(mod(linearCell, 32));\r\n cellOccupied = word.shiftRight(bit).bitAnd(1).equal(1);\r\n } else {\r\n const atlasColumn = mod(cell.y, atlasColumns);\r\n const atlasRow = cell.y.div(atlasColumns).floor();\r\n const atlasUv = vec2(\r\n atlasColumn.mul(planar).add(cell.x).add(0.5).div(atlasColumns * planar),\r\n atlasRow.mul(planar).add(cell.z).add(0.5).div(atlasRows * planar),\r\n );\r\n cellOccupied = texture(atlas, atlasUv).a.greaterThan(0.5);\r\n }\r\n If(cellOccupied, () => {\r\n result.assign(vec4(\r\n rayOrigin.add(rayDirection.mul(travelled)),\r\n linearCell.add(1),\r\n ));\r\n Break();\r\n });\r\n const nearestCrossing = min(nextCrossing.x, min(nextCrossing.y, nextCrossing.z));\r\n travelled.assign(nearestDistance.add(nearestCrossing));\r\n // Independent branches intentionally advance two or three axes for an\r\n // exact edge/corner crossing; that avoids revisiting zero-width cells.\r\n If(nextCrossing.x.lessThanEqual(nearestCrossing.add(1e-6)), () => {\r\n cell.x.addAssign(directionStep.x);\r\n nextCrossing.x.addAssign(crossingDelta.x);\r\n });\r\n If(nextCrossing.y.lessThanEqual(nearestCrossing.add(1e-6)), () => {\r\n cell.y.addAssign(directionStep.y);\r\n nextCrossing.y.addAssign(crossingDelta.y);\r\n });\r\n If(nextCrossing.z.lessThanEqual(nearestCrossing.add(1e-6)), () => {\r\n cell.z.addAssign(directionStep.z);\r\n nextCrossing.z.addAssign(crossingDelta.z);\r\n });\r\n });\r\n return result;\r\n });\r\n const traceVolume = /** @type {(sampleOffset: import('three/webgpu').Node<'vec2'>) => import('three/webgpu').Node<'vec4'>} */ (\r\n /** @type {unknown} */ (traceVolumeNode)\r\n );\r\n // @ts-ignore -- TSL's Fn declaration erases tuple and builder member types.\r\n const reconstructedDepth = Fn(([localPosition], builder) => {\r\n const viewZ = modelViewMatrix.mul(vec4(localPosition, 1)).z;\r\n return builder.camera.isPerspectiveCamera\r\n ? viewZToPerspectiveDepth(viewZ, cameraNear, cameraFar)\r\n : viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\r\n }, 'float');\r\n const createRaycastMaterial = (\r\n /** @type {boolean} */ antialias,\r\n /** @type {boolean} */ pbr,\r\n ) => {\r\n // Baked material maps are a cached graph variant, not a uniform branch:\r\n // the plain lit graph retains lighting and projected normals but contains\r\n // no voxel ORM sampling or AO/roughness/metalness nodes.\r\n const centerHit = traceVolume(vec2(0));\r\n const occupied = centerHit.w.greaterThan(0);\r\n /** @type {import('three/webgpu').Node<'float'>} */\r\n let coverage = float(1);\r\n if (antialias) {\r\n // This JavaScript branch specializes the TSL graph: the fast material\r\n // contains one DDA trace, while the AA material contains five. There is\r\n // no runtime AA branch or dormant extra tracing in the fast pipeline.\r\n const sampleHits = [\r\n traceVolume(vec2(-0.125, -0.375)),\r\n traceVolume(vec2(0.375, -0.125)),\r\n traceVolume(vec2(-0.375, 0.125)),\r\n traceVolume(vec2(0.125, 0.375)),\r\n ];\r\n const sampleOccupancy = sampleHits.map((sampleHit) => sampleHit.w.greaterThan(0));\r\n coverage = sampleOccupancy[0].select(1, 0)\r\n .add(sampleOccupancy[1].select(1, 0))\r\n .add(sampleOccupancy[2].select(1, 0))\r\n .add(sampleOccupancy[3].select(1, 0))\r\n .mul(0.25).mul(occupied.select(1, 0));\r\n }\r\n const hit = centerHit.toVar(antialias ? 'pixelImpostorAaHit' : 'pixelImpostorFastHit');\r\n const linearHitCell = hit.w.sub(1).max(0);\r\n const hitLayer = linearHitCell.div(planar * planar).floor();\r\n const hitSliceCell = mod(linearHitCell, planar * planar);\r\n const hitCell = vec3(mod(hitSliceCell, planar), hitLayer, hitSliceCell.div(planar).floor());\r\n let hitAtlasUv;\r\n if (sparse) {\r\n const wordIndex = linearHitCell.div(32).floor();\r\n const word = sparseUint(wordIndex.mul(2));\r\n const prefixRank = sparseUint(wordIndex.mul(2).add(1));\r\n const bit = uint(mod(linearHitCell, 32));\r\n const precedingMask = uint(1).shiftLeft(bit).sub(1);\r\n // Three's nodeProxyIntent returns a typed TSL node; @types/three\r\n // currently declares the bare BitcountNode class instead. A uint input\r\n // produces uint output (WGSL countOneBits preserves its input type).\r\n const precedingCount = /** @type {ReturnType<typeof countOneBits> & import('three/webgpu').Node<'uint'>} */ (countOneBits(word.bitAnd(precedingMask)));\r\n const record = prefixRank.add(precedingCount);\r\n hitAtlasUv = linearTextureUv(float(record), surfaceAtlasSize);\r\n } else {\r\n const hitAtlasColumn = mod(hitCell.y, atlasColumns);\r\n const hitAtlasRow = hitCell.y.div(atlasColumns).floor();\r\n hitAtlasUv = vec2(\r\n hitAtlasColumn.mul(planar).add(hitCell.x).add(0.5).div(atlasColumns * planar),\r\n hitAtlasRow.mul(planar).add(hitCell.z).add(0.5).div(atlasRows * planar),\r\n );\r\n }\r\n const baseSample = texture(atlas, hitAtlasUv);\r\n const ormSample = ormAtlas ? texture(ormAtlas, hitAtlasUv) : vec4(1, 1, 0, 1);\r\n const hitPosition = hit.xyz;\r\n const hitToCamera = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz.sub(hitPosition);\r\n const faceSign = step(0, hitToCamera).mul(2).sub(1);\r\n const hitCellCenter = hitCell.add(0.5).div(volumeDimensions).sub(0.5)\r\n .mul(sizeNode).sub(raycastOffsetNode);\r\n const cellDelta = hitPosition.sub(hitCellCenter).div(sizeNode).mul(volumeDimensions);\r\n const absoluteCellDelta = cellDelta.abs();\r\n const boundaryDistance = max(absoluteCellDelta.x,\r\n max(absoluteCellDelta.y, absoluteCellDelta.z));\r\n const faceDirection = hitToCamera.abs().normalize();\r\n // At an edge/corner more than one face is a valid entry face. Floating\r\n // error used to make the largest coordinate flicker between them. Treat\r\n // near-ties as the same boundary and choose the most camera-facing face.\r\n const xFaceScore = absoluteCellDelta.x.greaterThanEqual(boundaryDistance.sub(1e-4))\r\n .select(faceDirection.x, -1);\r\n const yFaceScore = absoluteCellDelta.y.greaterThanEqual(boundaryDistance.sub(1e-4))\r\n .select(faceDirection.y, -1);\r\n const zFaceScore = absoluteCellDelta.z.greaterThanEqual(boundaryDistance.sub(1e-4))\r\n .select(faceDirection.z, -1);\r\n const geometricNormal = xFaceScore.greaterThanEqual(yFaceScore)\r\n .and(xFaceScore.greaterThanEqual(zFaceScore))\r\n .select(vec3(faceSign.x, 0, 0), yFaceScore.greaterThanEqual(zFaceScore)\r\n .select(vec3(0, faceSign.y, 0), vec3(0, 0, faceSign.z)));\r\n const sampledNormal = normalAtlas\r\n ? texture(normalAtlas, hitAtlasUv).xyz.mul(2).sub(1)\r\n : geometricNormal;\r\n const bakedNormal = sampledNormal.dot(sampledNormal).greaterThan(1e-8)\r\n .select(sampledNormal.normalize(), geometricNormal);\r\n const projectedNormal = bakedNormal.dot(geometricNormal).lessThan(0)\r\n .select(bakedNormal.negate(), bakedNormal);\r\n const shadingNormal = mix(geometricNormal, projectedNormal, projectedNormalMix).normalize();\r\n const materialName = `Pixel impostor \u00B7 volume raycast \u00B7 ${antialias ? 'AA' : 'fast'} \u00B7 ${pbr ? 'PBR maps' : 'plain lit'}`;\r\n const material = new MeshStandardNodeMaterial({\r\n name: materialName,\r\n side: THREE.FrontSide,\r\n depthTest: true,\r\n depthWrite: true,\r\n });\r\n material.colorNode = vec4(baseSample.rgb.mul(float(1).sub(unlitMix)),\r\n antialias ? baseSample.a.mul(coverage) : baseSample.a);\r\n material.emissiveNode = baseSample.rgb.mul(pbr ? ormSample.r : 1).mul(unlitMix);\r\n material.normalNode = transformNormalToView(shadingNormal);\r\n if (pbr) {\r\n material.aoNode = ormSample.r;\r\n material.roughnessNode = ormSample.g.max(0.04);\r\n material.metalnessNode = ormSample.b;\r\n }\r\n material.receivedShadowPositionNode = modelWorldMatrix.mul(vec4(hitPosition, 1)).xyz;\r\n material.maskNode = occupied.and(\r\n baseSample.a.greaterThan(Number(descriptor.alphaCutoff) || 0.5),\r\n );\r\n material.maskShadowNode = antialias ? coverage.greaterThanEqual(0.5) : occupied;\r\n material.alphaToCoverage = antialias;\r\n material.depthNode = reconstructedDepth(hitPosition);\r\n material.toneMapped = true;\r\n material.userData.screenPixelSize = screenPixelSize;\r\n material.userData.pixelImpostorRaycastAntialias = antialias;\r\n material.userData.pixelImpostorRaySamples = antialias ? 5 : 1;\r\n material.userData.pixelImpostorPbr = pbr;\r\n return material;\r\n };\r\n const raycastMaterials = {\r\n mapped: {\r\n fast: createRaycastMaterial(false, true),\r\n antialias: createRaycastMaterial(true, true),\r\n },\r\n plain: {\r\n fast: createRaycastMaterial(false, false),\r\n antialias: createRaycastMaterial(true, false),\r\n },\r\n };\r\n const raycast = new THREE.Mesh(new THREE.BoxGeometry(\r\n raycastSize.x,\r\n raycastSize.y,\r\n raycastSize.z,\r\n ), raycastMaterials.mapped.antialias);\r\n raycast.name = 'Pixel impostor \u00B7 volume raycast';\r\n raycast.position.copy(raycastCenter);\r\n raycast.castShadow = true;\r\n raycast.receiveShadow = true;\r\n raycast.userData.previewPixelImpostor = true;\r\n raycast.userData.pixelImpostorDisplayMode = 'raycast';\r\n raycast.userData.pixelImpostorAlternateMaterials = [\r\n ...Object.values(raycastMaterials.mapped),\r\n ...Object.values(raycastMaterials.plain),\r\n ];\r\n\r\n const surfacePoints = binding.surfacePoints instanceof THREE.BufferAttribute\r\n || binding.surfacePoints instanceof THREE.InterleavedBufferAttribute\r\n ? binding.surfacePoints : null;\r\n // Keep the portable face-culled shell as one ordinary draw. Each vertex is\r\n // marked with its source voxel center, so every corner from one voxel gets\r\n // exactly the same screen-space displacement and the cell remains coherent.\r\n /** @type {THREE.Mesh | null} */\r\n let shell = null;\r\n asset.traverse((object) => {\r\n if (!shell && object instanceof THREE.Mesh\r\n && (object.geometry.getAttribute('_voxel_center') || surfacePoints)) {\r\n shell = object;\r\n }\r\n });\r\n if (!shell) return null;\r\n const voxelShell = /** @type {THREE.Mesh} */ (shell);\r\n const geometryBaseSample = texture(atlas, uv());\r\n const geometryOrmSample = ormAtlas ? texture(ormAtlas, uv()) : vec4(1, 1, 0, 1);\r\n const geometryNormal = attribute('normal', /** @type {const} */ ('vec3')).normalize();\r\n const geometryProjectedNormal = normalAtlas\r\n ? texture(normalAtlas, uv()).xyz.mul(2).sub(1).normalize()\r\n : geometryNormal;\r\n const geometryAlignedNormal = geometryProjectedNormal.dot(geometryNormal).lessThan(0)\r\n .select(geometryProjectedNormal.negate(), geometryProjectedNormal);\r\n const createGeometryMaterial = (/** @type {boolean} */ pbr) => {\r\n const material = new MeshStandardNodeMaterial({\r\n name: `Pixel impostor \u00B7 voxel geometry \u00B7 ${pbr ? 'mapped' : 'plain'}`,\r\n side: THREE.FrontSide,\r\n depthTest: true,\r\n depthWrite: true,\r\n });\r\n material.colorNode = vec4(geometryBaseSample.rgb.mul(float(1).sub(unlitMix)),\r\n geometryBaseSample.a);\r\n material.emissiveNode = geometryBaseSample.rgb.mul(pbr ? geometryOrmSample.r : 1).mul(unlitMix);\r\n material.normalNode = transformNormalToView(\r\n mix(geometryNormal, geometryAlignedNormal, projectedNormalMix).normalize(),\r\n );\r\n if (pbr) {\r\n material.aoNode = geometryOrmSample.r;\r\n material.roughnessNode = geometryOrmSample.g.max(0.04);\r\n material.metalnessNode = geometryOrmSample.b;\r\n }\r\n material.maskNode = geometryBaseSample.a.greaterThan(\r\n Number(descriptor.alphaCutoff) || 0.5,\r\n );\r\n material.toneMapped = true;\r\n material.userData.pixelImpostorPbr = pbr;\r\n return material;\r\n };\r\n const geometryMaterials = {\r\n mapped: createGeometryMaterial(true),\r\n plain: createGeometryMaterial(false),\r\n };\r\n const previousGeometryMaterial = voxelShell.material;\r\n voxelShell.material = geometryMaterials.mapped;\r\n voxelShell.userData.pixelImpostorAlternateMaterials = Object.values(geometryMaterials);\r\n const skinnedSplats = voxelShell instanceof THREE.SkinnedMesh;\r\n // Sparse instancing deliberately omits the carrier mesh's per-vertex data.\r\n // Animated exports retain that data, so use their dense carriers and let\r\n // standard Three.js skinning deform each voxel center before screen-aligning\r\n // its quad. Static sparse files keep the smaller instanced path.\r\n const useSurfacePoints = surfacePoints && !skinnedSplats;\r\n let splatGeometry = skinnedSplats ? voxelShell.geometry.clone() : voxelShell.geometry;\r\n if (skinnedSplats) {\r\n const centers = voxelShell.geometry.getAttribute('_voxel_center');\r\n if (!centers) throw new Error('Animated voxel splats require retained voxel centers.');\r\n splatGeometry.setAttribute('position', centers.clone());\r\n }\r\n if (useSurfacePoints) {\r\n const count = surfacePoints.count;\r\n const coordinates = new Float32Array(count * 3);\r\n const records = new Float32Array(count);\r\n for (let index = 0; index < count; index++) {\r\n coordinates[index * 3] = surfacePoints.getX(index);\r\n coordinates[index * 3 + 1] = surfacePoints.getY(index);\r\n coordinates[index * 3 + 2] = surfacePoints.getZ(index);\r\n records[index] = index;\r\n }\r\n const instancedGeometry = new THREE.InstancedBufferGeometry();\r\n instancedGeometry.instanceCount = count;\r\n splatGeometry = instancedGeometry;\r\n splatGeometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(12), 3));\r\n splatGeometry.setAttribute('_voxel_corner', new THREE.BufferAttribute(new Float32Array([\r\n -1, -1, 1, -1, 1, 1, -1, 1,\r\n ]), 2));\r\n splatGeometry.setAttribute('_voxel_coord', new THREE.InstancedBufferAttribute(coordinates, 3));\r\n splatGeometry.setAttribute('_voxel_record', new THREE.InstancedBufferAttribute(records, 1));\r\n splatGeometry.setIndex([0, 1, 2, 0, 2, 3]);\r\n splatGeometry.boundingBox = voxelShell.geometry.boundingBox?.clone() ?? bounds.clone();\r\n splatGeometry.boundingSphere = voxelShell.geometry.boundingSphere?.clone()\r\n ?? splatGeometry.boundingBox.getBoundingSphere(new THREE.Sphere());\r\n }\r\n const voxelCoordinate = attribute('_voxel_coord', /** @type {const} */ ('vec3'));\r\n const voxelCenter = skinnedSplats\r\n ? positionLocal\r\n : useSurfacePoints\r\n ? voxelCoordinate.add(0.5).div(volumeDimensions)\r\n .sub(0.5).mul(sizeNode).add(uniform(center.clone()))\r\n : attribute('_voxel_center', /** @type {const} */ ('vec3'));\r\n const voxelCorner = attribute('_voxel_corner', /** @type {const} */ ('vec2'));\r\n const centerView = modelViewMatrix.mul(vec4(voxelCenter, 1));\r\n const centerClip = cameraProjectionMatrix.mul(centerView);\r\n const centerNdc = centerClip.xy.div(centerClip.w);\r\n const cssViewport = viewportSize;\r\n const centerCss = centerNdc.mul(0.5).add(0.5).mul(cssViewport);\r\n const projectVoxelPoint = (/** @type {import('three/webgpu').Node<'vec3'>} */ point) => {\r\n const projected = cameraProjectionMatrix.mul(modelViewMatrix.mul(vec4(point, 1)));\r\n return projected.xy.div(projected.w).mul(0.5).add(0.5).mul(cssViewport);\r\n };\r\n const projectedX = projectVoxelPoint(voxelCenter.add(vec3(voxelHalfExtents.x, 0, 0)));\r\n const projectedY = projectVoxelPoint(voxelCenter.add(vec3(0, voxelHalfExtents.y, 0)));\r\n const projectedZ = projectVoxelPoint(voxelCenter.add(vec3(0, 0, voxelHalfExtents.z)));\r\n const projectedHalfFootprint = projectedX.sub(centerCss).abs()\r\n .add(projectedY.sub(centerCss).abs())\r\n .add(projectedZ.sub(centerCss).abs());\r\n const projectedVoxelSize = max(projectedHalfFootprint.x, projectedHalfFootprint.y).mul(2);\r\n const projectedCellSpan = projectedVoxelSize.div(splatPixelSize);\r\n // `floor()` in this vertex-node graph causes pathological WebGPU pipeline\r\n // compilation on current Chrome/Metal. Inputs are positive, so this is the\r\n // same nearest-integer quantization with half values biased downward.\r\n const nearestCellSpan = ceil(projectedCellSpan.sub(0.5)).max(1);\r\n const singleCell = snapMode.equal(1);\r\n const centerOnly = snapMode.equal(2);\r\n const cellSpan = singleCell.select(1, nearestCellSpan);\r\n const cellCenter = centerCss.div(splatPixelSize).floor()\r\n .mul(splatPixelSize).add(splatPixelSize.mul(0.5));\r\n const gridIntersection = centerCss.div(splatPixelSize).add(0.5).floor().mul(splatPixelSize);\r\n const oddCellSpan = mod(cellSpan, 2);\r\n const parityAlignedCenter = oddCellSpan.greaterThan(0.5).select(cellCenter, gridIntersection);\r\n const snappedCss = centerOnly.select(cellCenter, parityAlignedCenter);\r\n const splatSize = cellSpan.mul(splatPixelSize).mul(splatScale);\r\n // The original exposed face is only a carrier. Replace its four positions\r\n // with a camera-facing square centered on the voxel. A small overlap avoids\r\n // pinholes between neighboring screen pixels under perspective projection.\r\n const quadCss = snappedCss.add(voxelCorner.mul(splatSize.mul(0.52)));\r\n const quadNdc = quadCss.div(cssViewport).mul(2).sub(1);\r\n const quadClip = vec4(quadNdc.mul(centerClip.w), centerClip.z, centerClip.w);\r\n const quadViewHomogeneous = cameraProjectionMatrixInverse.mul(quadClip);\r\n const quadView = quadViewHomogeneous.xyz.div(quadViewHomogeneous.w);\r\n const quadWorld = cameraWorldMatrix.mul(vec4(quadView, 1));\r\n const quadLocalHomogeneous = modelWorldMatrixInverse.mul(quadWorld);\r\n const quadLocal = quadLocalHomogeneous.xyz.div(quadLocalHomogeneous.w);\r\n\r\n const splatUv = useSurfacePoints\r\n ? linearTextureUv(attribute('_voxel_record', /** @type {const} */ ('float')), surfaceAtlasSize)\r\n : uv();\r\n const splatColor = texture(atlas, splatUv);\r\n const splatOrm = ormAtlas ? texture(ormAtlas, splatUv) : vec4(1, 1, 0, 1);\r\n const cameraLocal = modelWorldMatrixInverse.mul(vec4(cameraPosition, 1)).xyz;\r\n const viewDirection = cameraLocal.sub(voxelCenter).normalize();\r\n const splatBakedNormal = normalAtlas\r\n ? texture(normalAtlas, splatUv).xyz.mul(2).sub(1).normalize()\r\n : viewDirection;\r\n const splatProjectedNormal = splatBakedNormal.dot(viewDirection).lessThan(0)\r\n .select(splatBakedNormal.negate(), splatBakedNormal);\r\n const splatShadingNormal = mix(\r\n viewDirection,\r\n splatProjectedNormal,\r\n projectedNormalMix,\r\n ).normalize();\r\n let splatMask;\r\n if (useSurfacePoints) {\r\n splatMask = splatColor.a.greaterThan(0.5);\r\n } else {\r\n // Legacy v3 files duplicate a voxel once per exposed face. Select exactly\r\n // one carrier before rotating it into the screen-aligned square.\r\n const voxelFaceMask = float(attribute('_voxel_face_mask', /** @type {const} */ ('float')));\r\n const faceScores = [\r\n viewDirection.x.negate(), viewDirection.x,\r\n viewDirection.z.negate(), viewDirection.z,\r\n viewDirection.y.negate(), viewDirection.y,\r\n ];\r\n const exposedScore = (/** @type {number} */ face) => {\r\n const exposed = mod(voxelFaceMask.div(2 ** face).floor(), 2);\r\n return mix(-2, faceScores[face], exposed);\r\n };\r\n const bestFaceScore = max(\r\n max(max(exposedScore(0), exposedScore(1)), max(exposedScore(2), exposedScore(3))),\r\n max(exposedScore(4), exposedScore(5)),\r\n );\r\n const sourceFaceNormal = attribute('normal', /** @type {const} */ ('vec3'));\r\n splatMask = sourceFaceNormal.dot(viewDirection)\r\n .greaterThanEqual(bestFaceScore.sub(1e-5)).and(splatColor.a.greaterThan(0.5));\r\n }\r\n const createSnappedMaterial = (/** @type {boolean} */ pbr) => {\r\n const material = new MeshStandardNodeMaterial({\r\n name: `Pixel impostor \u00B7 vertex-snapped shell \u00B7 ${pbr ? 'mapped' : 'plain'}`,\r\n side: THREE.FrontSide,\r\n depthTest: true,\r\n depthWrite: true,\r\n });\r\n material.positionNode = quadLocal;\r\n material.colorNode = vec4(splatColor.rgb.mul(float(1).sub(unlitMix)), splatColor.a);\r\n material.emissiveNode = splatColor.rgb.mul(pbr ? splatOrm.r : 1).mul(unlitMix);\r\n material.normalNode = transformNormalToView(splatShadingNormal);\r\n if (pbr) {\r\n material.aoNode = splatOrm.r;\r\n material.roughnessNode = splatOrm.g.max(0.04);\r\n material.metalnessNode = splatOrm.b;\r\n }\r\n material.maskNode = splatMask;\r\n material.toneMapped = true;\r\n material.userData.pixelImpostorPbr = pbr;\r\n return material;\r\n };\r\n const snappedMaterials = {\r\n mapped: createSnappedMaterial(true),\r\n plain: createSnappedMaterial(false),\r\n };\r\n const snappedShell = skinnedSplats\r\n ? new THREE.SkinnedMesh(splatGeometry, snappedMaterials.mapped)\r\n : new THREE.Mesh(splatGeometry, snappedMaterials.mapped);\r\n if (snappedShell instanceof THREE.SkinnedMesh && voxelShell instanceof THREE.SkinnedMesh) {\r\n snappedShell.bindMode = voxelShell.bindMode;\r\n snappedShell.bind(voxelShell.skeleton, voxelShell.bindMatrix);\r\n snappedShell.bindMatrixInverse.copy(voxelShell.bindMatrixInverse);\r\n }\r\n asset.updateWorldMatrix(true, true);\r\n voxelShell.updateWorldMatrix(true, false);\r\n if (!useSurfacePoints) {\r\n snappedShell.matrix.copy(asset.matrixWorld).invert().multiply(voxelShell.matrixWorld);\r\n snappedShell.matrixAutoUpdate = false;\r\n }\r\n snappedShell.name = 'Pixel impostor \u00B7 vertex-snapped shell';\r\n snappedShell.castShadow = false;\r\n snappedShell.receiveShadow = false;\r\n snappedShell.userData.previewPixelImpostor = true;\r\n snappedShell.userData.pixelImpostorDisplayMode = 'vertex-snap';\r\n snappedShell.userData.pixelImpostorAlternateMaterials = Object.values(snappedMaterials);\r\n\r\n const preview = new THREE.Group();\r\n preview.name = 'Pixel impostor shader previews';\r\n preview.visible = false;\r\n preview.userData.screenPixelSize = screenPixelSize;\r\n preview.userData.splatPixelSize = splatPixelSize;\r\n preview.userData.splatScale = splatScale;\r\n preview.userData.projectedNormalMix = projectedNormalMix;\r\n preview.userData.projectedNormalMixValue = 1;\r\n preview.userData.unlitMix = unlitMix;\r\n preview.userData.raycastMesh = raycast;\r\n preview.userData.raycastMaterials = raycastMaterials;\r\n preview.userData.geometryMesh = voxelShell;\r\n preview.userData.previousGeometryMaterial = previousGeometryMaterial;\r\n preview.userData.geometryMaterials = geometryMaterials;\r\n preview.userData.snappedMesh = snappedShell;\r\n preview.userData.snappedMaterials = snappedMaterials;\r\n preview.userData.raycastAntialiasEnabled = true;\r\n preview.userData.snapMode = snapMode;\r\n preview.userData.viewportSize = viewportSize;\r\n preview.userData.dpr = dpr;\r\n preview.userData.pixelSizeValue = 5;\r\n preview.add(raycast, snappedShell);\r\n const textureBytes = textureFootprintBytes(atlas)\r\n + (normalAtlas ? textureFootprintBytes(normalAtlas) : 0)\r\n + (ormAtlas ? textureFootprintBytes(ormAtlas) : 0)\r\n + (indexAtlas ? textureFootprintBytes(indexAtlas) : 0);\r\n const shellStats = pixelDisplayMeshStats(voxelShell, textureBytes);\r\n const splatStats = pixelDisplayMeshStats(snappedShell, textureFootprintBytes(atlas));\r\n const raycastStats = pixelDisplayMeshStats(raycast, textureBytes);\r\n preview.userData.displayStats = {\r\n geometry: shellStats,\r\n 'vertex-snap': splatStats,\r\n raycast: raycastStats,\r\n 'screen-pixels': raycastStats,\r\n };\r\n return preview;\r\n}\r\n\r\n/** @param {THREE.Mesh} mesh @param {number} textureBytes */\r\nfunction pixelDisplayMeshStats(mesh, textureBytes) {\r\n const position = mesh.geometry.getAttribute('position');\r\n const geometryBytes = bufferGeometryFootprintBytes(mesh.geometry);\r\n const instances = mesh.geometry instanceof THREE.InstancedBufferGeometry\r\n ? mesh.geometry.instanceCount : 1;\r\n return {\r\n triangles: (mesh.geometry.getIndex()?.count ?? position?.count ?? 0) / 3 * instances,\r\n vertices: (position?.count ?? 0) * instances,\r\n drawCalls: 1,\r\n geometryBytes,\r\n textureBytes,\r\n gpuBytes: geometryBytes + textureBytes,\r\n };\r\n}\r\n\r\n/** @param {THREE.BufferGeometry} geometry */\r\nfunction bufferGeometryFootprintBytes(geometry) {\r\n const buffers = new Set();\r\n let bytes = 0;\r\n const add = (/** @type {THREE.BufferAttribute | THREE.InterleavedBufferAttribute | null | undefined} */ attribute) => {\r\n if (!attribute) return;\r\n const storage = attribute instanceof THREE.InterleavedBufferAttribute ? attribute.data : attribute;\r\n if (buffers.has(storage)) return;\r\n buffers.add(storage);\r\n bytes += storage.array?.byteLength ?? 0;\r\n };\r\n add(geometry.getIndex());\r\n for (const attribute of Object.values(geometry.attributes)) add(attribute);\r\n return bytes;\r\n}\r\n\r\n/** @param {THREE.Texture} atlas */\r\nfunction textureFootprintBytes(atlas) {\r\n const image = /** @type {{width?:number,height?:number,data?:{byteLength?:number}} | null} */ (atlas.image);\r\n if (image?.data?.byteLength !== undefined) return image.data.byteLength;\r\n const width = Number(image?.width ?? 0);\r\n const height = Number(image?.height ?? 0);\r\n return Number.isFinite(width) && Number.isFinite(height) ? width * height * 4 : 0;\r\n}\r\n\r\n/**\r\n * Install the same voxel, screen-snap, and raycast TSL display used by the\r\n * workbench. Register the pixel glTF loader before loading the GLB. Call\r\n * `updateViewport()` after a resize and `dispose()` before discarding the scene.\r\n *\r\n * @param {THREE.Object3D} asset Loaded glTF scene.\r\n * @param {{mode?: 'geometry'|'vertex-snap'|'raycast'|'screen-pixels',\r\n * binding?:Record<string,unknown>, attach?:boolean,\r\n * renderer?: {getPixelRatio?: () => number, domElement?: HTMLCanvasElement},\r\n * pixelSize?: number, snapMode?: 'nearest-grid'|'single-cell'|'center-only',\r\n * splatScale?: number, antialias?: boolean, pbr?: boolean,\r\n * projectedNormalMix?: number}=} options\r\n */\r\nexport function createPixelImpostorDisplay(asset, options = {}) {\r\n /** @type {Record<string, unknown> | null} */\r\n let binding = options.binding ?? null;\r\n asset.traverse(object => { if (!binding && object.userData.pixelImpostor) binding = object.userData.pixelImpostor; });\r\n if (!binding) throw new Error('Load a NEEDLE_pixel_impostor GLB with registerNeedlePixelImpostorLoader first.');\r\n const preview = createPixelImpostorRaycastPreview(asset, new THREE.Box3().setFromObject(asset), binding);\r\n if (!preview) throw new Error('The pixel impostor has no supported shader atlas.');\r\n const originals = new Map();\r\n asset.traverse(object => {\r\n if (object instanceof THREE.Mesh) originals.set(object, object.visible);\r\n });\r\n if (options.attach !== false) asset.add(preview);\r\n let mode = options.mode ?? 'geometry';\r\n let pbr = options.pbr ?? true;\r\n let antialias = options.antialias ?? true;\r\n const setMode = (/** @type {typeof mode} */ next) => {\r\n if (!['geometry', 'vertex-snap', 'raycast', 'screen-pixels'].includes(next)) throw new Error(`Unknown pixel display mode: ${next}`);\r\n mode = next;\r\n preview.userData.displayMode = next;\r\n for (const [mesh, visible] of originals) mesh.visible = next === 'geometry' && visible;\r\n preview.visible = next !== 'geometry';\r\n for (const child of preview.children) child.visible = child.userData.pixelImpostorDisplayMode === next\r\n || (next === 'screen-pixels' && child.userData.pixelImpostorDisplayMode === 'raycast');\r\n preview.userData.screenPixelSize.value = next === 'screen-pixels' ? (options.pixelSize ?? 5) : 1;\r\n const raycast = preview.userData.raycastMesh;\r\n const raycastMaterials = preview.userData.raycastMaterials;\r\n if (raycast instanceof THREE.Mesh) raycast.material = raycastMaterials[pbr ? 'mapped' : 'plain'][next === 'raycast' && antialias ? 'antialias' : 'fast'];\r\n const snapped = preview.userData.snappedMesh;\r\n if (snapped instanceof THREE.Mesh) snapped.material = preview.userData.snappedMaterials[pbr ? 'mapped' : 'plain'];\r\n const shell = preview.userData.geometryMesh;\r\n if (shell instanceof THREE.Mesh) shell.material = preview.userData.geometryMaterials[pbr ? 'mapped' : 'plain'];\r\n return preview.userData.displayStats?.[next] ?? null;\r\n };\r\n const updateViewport = () => {\r\n const canvas = options.renderer?.domElement;\r\n const viewport = preview.userData.viewportSize.value;\r\n if (viewport instanceof THREE.Vector2) viewport.set(Math.max(1, canvas?.clientWidth ?? 1), Math.max(1, canvas?.clientHeight ?? 1));\r\n preview.userData.dpr.value = options.renderer?.getPixelRatio?.() ?? 1;\r\n };\r\n preview.userData.splatPixelSize.value = options.pixelSize ?? 5;\r\n preview.userData.splatScale.value = options.splatScale ?? 1;\r\n preview.userData.projectedNormalMix.value = options.projectedNormalMix ?? 1;\r\n preview.userData.snapMode.value = options.snapMode === 'single-cell' ? 1 : options.snapMode === 'center-only' ? 2 : 0;\r\n setMode(mode);\r\n updateViewport();\r\n return {\r\n preview,\r\n setMode,\r\n updateViewport,\r\n /** @param {boolean} enabled */\r\n setPbr(enabled) { pbr = Boolean(enabled); setMode(mode); },\r\n /** @param {boolean} enabled */\r\n setAntialias(enabled) { antialias = Boolean(enabled); setMode(mode); },\r\n dispose() {\r\n preview.removeFromParent();\r\n for (const [mesh, visible] of originals) mesh.visible = visible;\r\n const shell = preview.userData.geometryMesh;\r\n if (shell instanceof THREE.Mesh) shell.material = preview.userData.previousGeometryMaterial;\r\n for (const child of preview.children) if (child instanceof THREE.Mesh && child.geometry !== preview.userData.geometryMesh?.geometry) child.geometry.dispose();\r\n for (const materials of [preview.userData.raycastMaterials?.mapped, preview.userData.raycastMaterials?.plain, preview.userData.snappedMaterials, preview.userData.geometryMaterials]) {\r\n if (materials) for (const material of Object.values(materials)) material.dispose();\r\n }\r\n },\r\n };\r\n}\r\n"],
5
+ "mappings": ";;;AAEA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A,IAEzD,aAAa,SAAS;AAAE,kBAAY,QAAQ,OAAO;AAAG,cAAQ,IAAI;AAAA,IAAG;AAAA,IACrE,UAAU;AACR,cAAQ,iBAAiB;AACzB,iBAAW,CAAC,MAAM,OAAO,KAAK,UAAW,MAAK,UAAU;AACxD,YAAM,QAAQ,QAAQ,SAAS;AAC/B,UAAI,iBAAuB,WAAM,OAAM,WAAW,QAAQ,SAAS;AACnE,iBAAW,SAAS,QAAQ,SAAU,KAAI,iBAAuB,cAAQ,MAAM,aAAa,QAAQ,SAAS,cAAc,SAAU,OAAM,SAAS,QAAQ;AAC5J,iBAAW,aAAa,CAAC,QAAQ,SAAS,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;",
6
+ "names": ["texture", "dimensions", "attribute"]
7
+ }
@@ -0,0 +1,39 @@
1
+ import { Vector3 } from 'three';
2
+ import type { PinRecord } from './pin-types.js';
3
+ import type { ClothCollider } from './pin-cloth.js';
4
+ import { type MotionSettings } from './motion-settings.js';
5
+ type Edge = {
6
+ a: number;
7
+ b: number;
8
+ length: number;
9
+ bend: boolean;
10
+ };
11
+ type Triangle = {
12
+ a: number;
13
+ b: number;
14
+ c: number;
15
+ };
16
+ type Particle = {
17
+ position: Vector3;
18
+ previous: Vector3;
19
+ base: Vector3;
20
+ share: number;
21
+ anchor: number;
22
+ };
23
+ export declare function clothSurfaceMotion(pins: readonly PinRecord[]): MotionSettings;
24
+ /** A topology-connected fabric layer over the portable skinned/voxel result.
25
+ * Vertices at UV seams share one particle; all other vertices keep the source
26
+ * triangle topology. Body controls attach the sheet, cloth controls release it. */
27
+ export declare class ClothSurface {
28
+ readonly particles: Particle[];
29
+ readonly vertexParticle: Uint32Array;
30
+ readonly triangles: Triangle[];
31
+ readonly edges: Edge[];
32
+ readonly scale: number;
33
+ private time;
34
+ constructor(restVertices: Float32Array, indices: ArrayLike<number>, pins: readonly PinRecord[]);
35
+ get movableCount(): number;
36
+ reset(): void;
37
+ step(baseVertices: Float32Array, seconds: number, windStrength: number, colliders?: readonly ClothCollider[], motion?: Readonly<MotionSettings>): Float32Array<ArrayBuffer>;
38
+ }
39
+ export {};
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/cloth-surface.ts';
@@ -0,0 +1,27 @@
1
+ import { SkinnedMesh, type BufferGeometry, type Material, type Object3D, type Texture } from 'three';
2
+ import { MeshStandardNodeMaterial } from 'three/webgpu';
3
+ import type { RigDescriptor } from './rig-extension.js';
4
+ interface Surface {
5
+ mesh: SkinnedMesh;
6
+ geometry: BufferGeometry;
7
+ modified: BufferGeometry;
8
+ material: Material | Material[];
9
+ variants: MeshStandardNodeMaterial[];
10
+ }
11
+ /** Optional GPU detail for a portable skinned GLB. Nothing is written into its
12
+ * fallback material or geometry, and the variant is absent without Fur pins. */
13
+ export declare class FurSurface {
14
+ readonly surfaces: Surface[];
15
+ private height;
16
+ private clock;
17
+ private wind;
18
+ constructor(scene: Object3D, descriptor: RigDescriptor, nodes: readonly Object3D[], helpers: readonly Object3D[]);
19
+ setHeightMap(height: Texture | null): void;
20
+ update(seconds: number, windStrength: number): void;
21
+ /** GLTFExporter must only see standard portable materials and attributes. */
22
+ setPortable(portable: boolean): void;
23
+ dispose(): void;
24
+ private rebuild;
25
+ private material;
26
+ }
27
+ export {};
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/fur-surface.ts';
@@ -0,0 +1,18 @@
1
+ import { Quaternion, Vector3 } from 'three';
2
+ export type IKConstraint = {
3
+ mode: 'free' | 'cone' | 'hinge' | 'locked';
4
+ axis: 'auto' | 'x' | 'y' | 'z';
5
+ min: number;
6
+ max: number;
7
+ orientation?: [number, number, number, number];
8
+ maxY?: number;
9
+ };
10
+ export declare const DEFAULT_IK_CONSTRAINT: Readonly<IKConstraint>;
11
+ export declare function validateIKConstraint(value: IKConstraint): void;
12
+ /** Stable parent-local cone frame. Z follows the rest bone; X/Y are aperture axes. */
13
+ export declare function coneFrame(axis: Vector3, constraint: Readonly<IKConstraint>): Quaternion;
14
+ /** Angular ellipse (also valid beyond 90 degrees), rather than a tangent-plane box. */
15
+ export declare function coneAngle(constraint: Readonly<IKConstraint>, azimuth: number): number;
16
+ export declare function constrainCone(rotation: Quaternion, axis: Vector3, constraint: Readonly<IKConstraint>, movingAxis?: Vector3): Quaternion;
17
+ /** Circular swing cone, not an Euler-angle box. Twist remains free. */
18
+ export declare function constrainSwing(rotation: Quaternion, axis: Vector3, degrees: number): Quaternion;
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/ik-constraints.ts';
@@ -0,0 +1,17 @@
1
+ import { type PinRecord } from './pin-types.js';
2
+ import { type PoseSlot } from './pose-slots.js';
3
+ import type { PinParents } from './pin-types.js';
4
+ import { type PoseTiming } from './pose-timeline.js';
5
+ export declare function validateJoints(value: unknown, maximum?: number): readonly PinRecord[];
6
+ export interface JointsRig {
7
+ pins: readonly PinRecord[];
8
+ activePose: number;
9
+ poseSlots: readonly PoseSlot[];
10
+ poseTimes: readonly PoseTiming[];
11
+ windStrength?: number;
12
+ }
13
+ /** Slots are written out in full. A pin the hierarchy places is left unsaid in
14
+ * the editor so it keeps following its parent, but a file has no voxel field to
15
+ * rebuild that hierarchy from and older readers would drop it to rest, so the
16
+ * inherited pose is resolved here and stored. */
17
+ export declare function validateRig(value: JointsRig, maximum?: number, parents?: PinParents): JointsRig;
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/joints-json.ts';
@@ -0,0 +1,23 @@
1
+ /** Shared document, import, UI and GPU capacity. Pin records are 64 bytes. */
2
+ export declare const MAX_DEFORMATION_PINS = 128;
3
+ /** What one sweep of the Suggested pins slider will place. Well short of the
4
+ * document cap: past this the slider stops placing body anchors and starts
5
+ * splitting fine branches, which is hand work rather than a slider's job. */
6
+ export declare const MAX_SUGGESTED_PINS = 64;
7
+ /** Cells along the longest axis of the solver lattice.
8
+ *
9
+ * The lattice is N by N by N over the model's bounds, and everything the solver
10
+ * measures — how thick a part is, how far a contact reaches, how much an
11
+ * element is strained — is in units of those cells. What a grid can represent
12
+ * is what it can resolve: on a posed arm a finger is 2.7 cells across at 32 and
13
+ * 3.5 at 40, which is a rod three nodes thick.
14
+ *
15
+ * The ceiling is a memory bound rather than a speed one. Node buffers are 16
16
+ * bytes each and there are about ten of them, so 64 costs roughly 42 MB of
17
+ * those; the harmonic weights are the one that hurts, at four bytes per node
18
+ * per pin slot, which for a full 128 pins is 268 MB at 64 against 67 MB at 40. */
19
+ export declare const MIN_DEFORMATION_RESOLUTION = 16;
20
+ export declare const MAX_DEFORMATION_RESOLUTION = 64;
21
+ /** Bones the skeleton solver turns on its own: every part of the body no pin
22
+ * drives, cut along the curve skeleton. 132 bytes of GPU state each. */
23
+ export declare const MAX_SKELETON_BONES = 2048;
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/limits.ts';
@@ -0,0 +1,9 @@
1
+ export type MotionSettings = {
2
+ reach: number;
3
+ frequency: number;
4
+ damping: number;
5
+ massInfluence: number;
6
+ strength: number;
7
+ };
8
+ export declare const DEFAULT_MOTION: Readonly<MotionSettings>;
9
+ export declare function validateMotionSettings(value: MotionSettings): void;
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/motion-settings.ts';
@@ -0,0 +1,28 @@
1
+ import type { PinRecord, Point } from './pin-types.js';
2
+ import type { PinParents, HierarchyEdge } from './pin-types.js';
3
+ export type ClothLink = {
4
+ a: string;
5
+ b: string;
6
+ length: number;
7
+ };
8
+ export type ClothCollider = {
9
+ position: Point;
10
+ radius: number;
11
+ driver?: string;
12
+ };
13
+ /** Connect authored cloth controls along the occupied-volume geodesic, not
14
+ * across the shortest line through empty space. The tree is a coarse fabric
15
+ * constraint network; the ordinary skin remains its portable GLB fallback. */
16
+ export declare function clothLinks(pins: readonly PinRecord[], parents: PinParents, edges?: readonly HierarchyEdge[], components?: ReadonlyMap<string, number>): ClothLink[];
17
+ /** Small, fixed-step Verlet graph. The editor passes deformed voxel centers;
18
+ * the GLB loader passes the same collider proxy driven by its joint graph. */
19
+ export declare class PinCloth {
20
+ private particles;
21
+ private layout;
22
+ private windTime;
23
+ reset(): void;
24
+ step(pins: readonly PinRecord[], parents: PinParents, seconds: number, links: readonly ClothLink[], colliders?: readonly ClothCollider[], windStrength?: number): {
25
+ pins: readonly PinRecord[];
26
+ active: boolean;
27
+ };
28
+ }
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/pin-cloth.ts';
@@ -0,0 +1,37 @@
1
+ import type { PinRecord, PinPose, Point, Rotation } from './pin-types.js';
2
+ import type { PinParents } from './pin-types.js';
3
+ /** IDs are derived each time; no stale authored chain survives topology edits. */
4
+ export declare function ikChain(pins: readonly PinRecord[], parents: PinParents, id: string, mass?: ReadonlyMap<string, number>): PinRecord[];
5
+ export declare function solvePinIK(pins: readonly PinRecord[], parents: PinParents, id: string, target: Point, mass?: ReadonlyMap<string, number>, targetRotation?: Rotation): {
6
+ id: string;
7
+ pose: PinPose;
8
+ }[];
9
+ export type IKGoal = {
10
+ id: string;
11
+ position: Point;
12
+ rotation: Rotation;
13
+ };
14
+ /** Endpoint editing is local. Shared body frames and sibling branches retain
15
+ * their authored poses; root/body edits use the separate multi-goal solve. */
16
+ export declare function solveLocalPinIK(pins: readonly PinRecord[], parents: PinParents, goal: IKGoal, mass?: ReadonlyMap<string, number>, floor?: number): {
17
+ id: string;
18
+ pose: PinPose;
19
+ }[];
20
+ /** Solve separate planted limbs against the same body pose. Their temporary
21
+ * attachment rotations must not become rotations of the shared torso frame. */
22
+ export declare function solvePlantedPinIKGoals(pins: readonly PinRecord[], parents: PinParents, goals: readonly IKGoal[], mass?: ReadonlyMap<string, number>, fixed?: ReadonlySet<string>, floor?: number): {
23
+ id: string;
24
+ pose: PinPose;
25
+ }[];
26
+ /** Body motion and imported-pose reconstruction use the same full-chain solve.
27
+ * Shared attachment frames are held; each limb gets its own branch pivot. */
28
+ export declare function solveBodyIKGoals(pins: readonly PinRecord[], parents: PinParents, goals: readonly IKGoal[], mass: ReadonlyMap<string, number>, fixed: ReadonlySet<string>, floor?: number): {
29
+ id: string;
30
+ pose: PinPose;
31
+ }[];
32
+ /** One articulated forest, one joint solve. Shared joints are never overwritten
33
+ * by a later endpoint, and every child offset retains its authored length. */
34
+ export declare function solvePinIKGoals(pins: readonly PinRecord[], parents: PinParents, goals: readonly IKGoal[], mass?: ReadonlyMap<string, number>, fixed?: ReadonlySet<string>, retained?: ReadonlySet<string>, floor?: number, poleChains?: ReadonlyMap<string, readonly PinRecord[]>): {
35
+ id: string;
36
+ pose: PinPose;
37
+ }[];
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/pin-ik.ts';
@@ -0,0 +1,53 @@
1
+ import type { IKConstraint } from './ik-constraints.js';
2
+ import type { MotionSettings } from './motion-settings.js';
3
+ /** Shared data contract; deliberately independent of editor history and GPU types. */
4
+ export type Point = readonly [number, number, number];
5
+ export type Rotation = readonly [number, number, number, number];
6
+ export type PinPose = {
7
+ readonly position: Point;
8
+ readonly rotation: Rotation;
9
+ readonly scale: Point;
10
+ };
11
+ export type PinParents = ReadonlyMap<string, string>;
12
+ export type HierarchyEdge = {
13
+ from: string;
14
+ to: string;
15
+ cost: number;
16
+ geodesic?: number;
17
+ };
18
+ export type PinMotion = 'none' | 'ik' | 'wiggle' | 'cloth' | 'fur';
19
+ export declare const DEFAULT_FUR_DEPTH = 0.1;
20
+ export declare const MAX_FUR_DEPTH = 0.5;
21
+ export type IKTarget = {
22
+ readonly position: Point;
23
+ readonly rotation: Rotation;
24
+ };
25
+ export declare const IK_CHAIN_KINDS: readonly ["leg", "arm", "head", "tail", "wing", "fin", "tentacle", "spine"];
26
+ export type IKChainRole = {
27
+ readonly kind: typeof IK_CHAIN_KINDS[number];
28
+ readonly side: 'center' | 'left' | 'right';
29
+ readonly position?: 'front' | 'hind';
30
+ };
31
+ export type PinRecord = {
32
+ readonly id: string;
33
+ readonly rest: Point;
34
+ readonly pose: PinPose;
35
+ readonly rigidGroup: string | null;
36
+ readonly independent: boolean;
37
+ /** This pose was set on purpose in the slot now open, rather than reached by
38
+ * being carried by a parent or swept along by an IK solve. A slot still
39
+ * stores an unauthored pose it could not otherwise reproduce — an IK chain
40
+ * does not come back the same way twice — but only an authored one is shown
41
+ * as deliberate and only an authored one can be released. */
42
+ readonly authored?: boolean;
43
+ readonly guide?: boolean;
44
+ readonly ik?: boolean;
45
+ readonly wiggle?: boolean;
46
+ readonly cloth?: boolean;
47
+ readonly fur?: boolean;
48
+ readonly furDepth?: number;
49
+ readonly motion?: MotionSettings;
50
+ readonly ikTarget?: IKTarget;
51
+ readonly ikConstraint?: IKConstraint;
52
+ readonly chainRole?: IKChainRole;
53
+ };
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/pin-types.ts';
@@ -0,0 +1,16 @@
1
+ import { type PinRecord } from './pin-types.js';
2
+ import type { PinParents } from './pin-types.js';
3
+ /** Disposable secondary motion. Never writes authored pins or history. */
4
+ export declare class PinWiggle {
5
+ private springs;
6
+ private topology;
7
+ private lastPins;
8
+ private lastParents;
9
+ private awake;
10
+ private windTime;
11
+ reset(): void;
12
+ step(pins: readonly PinRecord[], parents: PinParents, seconds: number, masses?: ReadonlyMap<string, number>, windStrength?: number): {
13
+ pins: readonly PinRecord[];
14
+ active: boolean;
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/pin-wiggle.ts';
@@ -0,0 +1,41 @@
1
+ import type { IKTarget, PinPose, PinRecord, Point } from './pin-types.js';
2
+ import type { PinParents } from './pin-types.js';
3
+ export type StoredPose = {
4
+ readonly id: string;
5
+ readonly pose: PinPose;
6
+ readonly ikTarget?: IKTarget;
7
+ readonly authored?: boolean;
8
+ };
9
+ export type PoseSlot = {
10
+ readonly slot: number;
11
+ readonly poses: readonly StoredPose[];
12
+ };
13
+ export declare const POSE_SLOTS = 9;
14
+ export declare function capturePose(pins: readonly PinRecord[]): readonly StoredPose[];
15
+ /** Where a pin lands when its parent carries it from rest. A parent's pose IS
16
+ * a similarity out of its own rest frame, so the child keeps its rest offset
17
+ * through that same rotation and scale — the transform hierarchy posing applies
18
+ * when a parent moves, written as one step from rest instead of accumulated. */
19
+ export declare function carriedPose(rest: Point, parentRest: Point, parent: PinPose): PinPose;
20
+ /** Only the poses a slot actually authors. A pin the hierarchy already places
21
+ * is left out, so a point added while another pose was open keeps following its
22
+ * parent everywhere else until it is deliberately posed there. */
23
+ export declare function authoredPoses(pins: readonly PinRecord[], parents?: PinParents): readonly StoredPose[];
24
+ /** Active pins are the edit register. Inactive slots contain transforms only;
25
+ * topology, rest positions and settings remain shared and action-owned. A pin
26
+ * the slot does not mention inherits through the hierarchy rather than dropping
27
+ * to rest, which is what keeps a newly placed point attached to its parent in
28
+ * every other pose. */
29
+ export declare function resolvePose(pins: readonly PinRecord[], slot: PoseSlot, parents?: PinParents): readonly PinRecord[];
30
+ export declare function definedPoses(model: {
31
+ readonly pins: readonly PinRecord[];
32
+ readonly poseSlots: readonly PoseSlot[];
33
+ readonly activePose: number;
34
+ }): PoseSlot[];
35
+ /** Pose 0 is derived from shared rest positions, never an editable pose slot. */
36
+ export declare function restPoseSlot(pins: readonly PinRecord[]): PoseSlot;
37
+ export declare function playablePoses(model: {
38
+ readonly pins: readonly PinRecord[];
39
+ readonly poseSlots: readonly PoseSlot[];
40
+ readonly activePose: number;
41
+ }): PoseSlot[];
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/pose-slots.ts';
@@ -0,0 +1,65 @@
1
+ import type { PinRecord, Rotation } from './pin-types.js';
2
+ import type { PinParents } from './pin-types.js';
3
+ /** A pose slot's time controls its share of the loop around its own moment.
4
+ * The transition settles at each authored pose without holding a flat frame. */
5
+ export declare const DEFAULT_POSE_SECONDS = 0.7;
6
+ export declare const MIN_POSE_SECONDS = 0.05;
7
+ export declare const MAX_POSE_SECONDS = 60;
8
+ /** Travel kept below the longest pose so a slider dragged to the bottom can
9
+ * always be dragged further on the next pass, and shrinks back when shortened. */
10
+ export declare const POSE_TIME_HEADROOM = 0.5;
11
+ export type PoseTiming = {
12
+ readonly slot: number;
13
+ readonly seconds: number;
14
+ };
15
+ export type PoseTimeline = readonly PoseTiming[];
16
+ export declare function poseTimeScale(timeline: PoseTimeline): number;
17
+ /** The strip reads downwards: zero at the top, the scale at the bottom, which
18
+ * is what makes "drag down" mean "stay longer". */
19
+ export declare function poseSecondsAt(offset: number, height: number, scale: number): number;
20
+ /** How far down the strip a time sits, as a percentage for the fill and handle. */
21
+ export declare function poseTimeOffset(seconds: number, scale: number): number;
22
+ export declare function poseLoopSeconds(timeline: PoseTimeline): number;
23
+ /** The moment each pose is reached. Neighbours split the gap between them in
24
+ * proportion to their own times, which is what makes a time an ownership share
25
+ * rather than the length of one arc. */
26
+ export declare function poseKnots(timeline: PoseTimeline): number[];
27
+ /** How long one pass takes: the first pose's moment to the last one's.
28
+ * Looping playback adds the closing transition up to poseLoopSeconds. */
29
+ export declare function posePassSeconds(timeline: PoseTimeline): number;
30
+ export declare function poseTimeOf(timeline: PoseTimeline, slot: number): number;
31
+ /** Septic: zero first, second AND third derivative at both ends, so a one-shot
32
+ * move away from rest and back to rest is G3 at the moment it starts and the
33
+ * moment it settles. A cubic smoothstep leaves a jerk step at both. */
34
+ export declare function smoothStep(t: number): number;
35
+ export interface PoseSpline {
36
+ readonly slots: readonly number[];
37
+ readonly loop: number;
38
+ /** How much each pose owns of the frame at this moment; sums to one, and is
39
+ * one on a pose exactly at its own moment. */
40
+ weightsAt(time: number): number[];
41
+ }
42
+ /** A periodic C2 interpolant of the authored poses. Its weights are shared by
43
+ * rig playback, GLB clip mixing and trajectory sampling, so the visible path
44
+ * is the path the animation actually follows. */
45
+ export declare function preparePoseSpline(timeline: PoseTimeline): PoseSpline;
46
+ /** The active pair shares one hemisphere, including the last-to-first seam. */
47
+ export declare function blendRotations(rotations: readonly Rotation[], weights: readonly number[]): Rotation;
48
+ /** Blends by id, so a pin missing from either side simply keeps its own pose —
49
+ * it appears on both sides of the blend and cannot move. Everything but the
50
+ * transform comes from the destination: ids, rest positions and flags are
51
+ * shared between slots and are not animated. */
52
+ export declare function blendPins(from: readonly PinRecord[], to: readonly PinRecord[], t: number, parents?: PinParents): readonly PinRecord[];
53
+ /** Every pose at once, by weight. `poses` are the same pins in the same order
54
+ * as `base` — they all come from resolving one document — so this walks them by
55
+ * index rather than searching per pin per frame.
56
+ *
57
+ * The blend happens in each pin's PARENT frame, never in world space. A chain
58
+ * posed two ways differs mostly in its joints' rotations, and averaging world
59
+ * positions cuts the chord between them: the limb shortens in the middle of
60
+ * every transition and lengthens again at each pose. In the parent's frame only
61
+ * the joint's own rotation and offset move, so the chain keeps its shape, and a
62
+ * pin's transform stays relative to whatever IK did to its parent — which is
63
+ * what makes moving an IK target interpolate as one arc rather than dragging
64
+ * every pin along a straight line of its own. */
65
+ export declare function blendPoses(base: readonly PinRecord[], poses: readonly (readonly PinRecord[])[], weights: readonly number[], parents?: PinParents): readonly PinRecord[];
@@ -0,0 +1 @@
1
+ export * from '../../../src/deformation/pose-timeline.ts';