@woosh/meep-engine 3.81.0 → 3.82.0

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 (245) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/editor/ecs/component/editors/common/BitFlagsEditor.d.ts.map +1 -1
  4. package/editor/ecs/component/editors/common/BitFlagsEditor.js +11 -0
  5. package/editor/prototypeEditorShell.d.ts.map +1 -1
  6. package/editor/prototypeEditorShell.js +4 -1
  7. package/package.json +1 -1
  8. package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.d.ts +13 -0
  9. package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.d.ts.map +1 -0
  10. package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.js +12 -0
  11. package/src/engine/graphics/ecs/mesh-v2/MeshMorph.d.ts +64 -0
  12. package/src/engine/graphics/ecs/mesh-v2/MeshMorph.d.ts.map +1 -0
  13. package/src/engine/graphics/ecs/mesh-v2/MeshMorph.js +89 -0
  14. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.d.ts +1 -1
  15. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.js +1 -1
  16. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.d.ts +1 -0
  17. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +10 -3
  18. package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.d.ts +14 -0
  19. package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.d.ts.map +1 -0
  20. package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.js +21 -0
  21. package/src/engine/graphics3/HairSystem.js +1 -1
  22. package/src/engine/graphics3/MeshMorphSystem.d.ts +48 -0
  23. package/src/engine/graphics3/MeshMorphSystem.d.ts.map +1 -0
  24. package/src/engine/graphics3/MeshMorphSystem.js +355 -0
  25. package/src/engine/graphics3/MeshSkinSystem.js +2 -2
  26. package/src/engine/graphics3/MeshSystem.d.ts +2 -1
  27. package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
  28. package/src/engine/graphics3/MeshSystem.js +2 -1
  29. package/src/engine/graphics3/ShadedGeometrySystem.d.ts +1 -1
  30. package/src/engine/graphics3/ShadedGeometrySystem.js +2 -2
  31. package/src/engine/graphics3/prefab/Prefab.d.ts +14 -0
  32. package/src/engine/graphics3/prefab/Prefab.d.ts.map +1 -1
  33. package/src/engine/graphics3/prefab/Prefab.js +16 -0
  34. package/src/engine/graphics3/prefab/prefab_compile.d.ts.map +1 -1
  35. package/src/engine/graphics3/prefab/prefab_compile.js +8 -1
  36. package/src/engine/graphics3/prefab/prefab_instantiate.d.ts +3 -2
  37. package/src/engine/graphics3/prefab/prefab_instantiate.d.ts.map +1 -1
  38. package/src/engine/graphics3/prefab/prefab_instantiate.js +17 -4
  39. package/src/engine/graphics3/prefab/prefab_place.d.ts +27 -9
  40. package/src/engine/graphics3/prefab/prefab_place.d.ts.map +1 -1
  41. package/src/engine/graphics3/prefab/prefab_place.js +69 -13
  42. package/src/engine/graphics3/register_clips.d.ts.map +1 -1
  43. package/src/engine/graphics3/register_clips.js +8 -2
  44. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  45. package/src/shade/playground/hair_skinned/skinned_hair.js +2 -2
  46. package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.js +1 -1
  47. package/src/shade/playground/skinned_blas_refit/verify_instance_bounds.js +1 -1
  48. package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.js +1 -1
  49. package/src/shade/playground/skinned_mesh_soup/main.js +1 -1
  50. package/src/shade/playground/skinned_mesh_soup/verify_clone_vertices.js +2 -2
  51. package/src/shade/renderer/Renderer.js +2 -2
  52. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  53. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
  54. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  55. package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts +5 -0
  56. package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts.map +1 -1
  57. package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.js +19 -0
  58. package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.d.ts +8 -0
  59. package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.d.ts.map +1 -0
  60. package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.js +19 -0
  61. package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.d.ts +6 -0
  62. package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.d.ts.map +1 -0
  63. package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.js +13 -0
  64. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +71 -0
  65. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  66. package/src/shade/renderer/animation/GPUAnimationManager.js +559 -9
  67. package/src/shade/renderer/animation/ShadeAnimationChannel.d.ts +23 -2
  68. package/src/shade/renderer/animation/ShadeAnimationChannel.d.ts.map +1 -1
  69. package/src/shade/renderer/animation/ShadeAnimationChannel.js +43 -2
  70. package/src/shade/renderer/animation/ShadeAnimationClip.d.ts +9 -3
  71. package/src/shade/renderer/animation/ShadeAnimationClip.d.ts.map +1 -1
  72. package/src/shade/renderer/animation/ShadeAnimationClip.js +67 -3
  73. package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts +3 -2
  74. package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts.map +1 -1
  75. package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.js +6 -3
  76. package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.d.ts +14 -0
  77. package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.d.ts.map +1 -0
  78. package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.js +49 -0
  79. package/src/shade/renderer/animation/ShadeAnimationProperty.d.ts +12 -0
  80. package/src/shade/renderer/animation/ShadeAnimationProperty.d.ts.map +1 -0
  81. package/src/shade/renderer/animation/ShadeAnimationProperty.js +30 -0
  82. package/src/shade/renderer/animation/Skin.d.ts +1 -1
  83. package/src/shade/renderer/animation/Skin.js +1 -1
  84. package/src/shade/renderer/animation/deformation/DEFORMATION_BINDING_STRUCT.d.ts +26 -0
  85. package/src/shade/renderer/animation/deformation/DEFORMATION_BINDING_STRUCT.d.ts.map +1 -0
  86. package/src/shade/renderer/animation/{skinning/SKINNING_BINDING_STRUCT.js → deformation/DEFORMATION_BINDING_STRUCT.js} +33 -8
  87. package/src/shade/renderer/animation/{skinning/GPUMeshSkinningContext.d.ts → deformation/GPUMeshDeformationContext.d.ts} +60 -17
  88. package/src/shade/renderer/animation/deformation/GPUMeshDeformationContext.d.ts.map +1 -0
  89. package/src/shade/renderer/animation/{skinning/GPUMeshSkinningContext.js → deformation/GPUMeshDeformationContext.js} +458 -55
  90. package/src/shade/renderer/animation/{skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.d.ts → deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.d.ts} +2 -2
  91. package/src/shade/renderer/animation/deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.d.ts.map +1 -0
  92. package/src/shade/renderer/animation/{skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.js → deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.js} +3 -3
  93. package/src/shade/renderer/animation/deformation/bounds_refresh/shader_geometry_sphere_derive.d.ts.map +1 -0
  94. package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_geometry_sphere_derive.js +2 -2
  95. package/src/shade/renderer/animation/deformation/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +1 -0
  96. package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_reduce.js +2 -2
  97. package/src/shade/renderer/animation/deformation/bounds_refresh/shader_meshlet_bounds_scatter.d.ts.map +1 -0
  98. package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_scatter.js +2 -2
  99. package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.d.ts +24 -0
  100. package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.d.ts.map +1 -0
  101. package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.js +257 -0
  102. package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.d.ts +18 -0
  103. package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.d.ts.map +1 -0
  104. package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.js +75 -0
  105. package/src/shade/renderer/animation/shader_animation_apply.d.ts.map +1 -1
  106. package/src/shade/renderer/animation/shader_animation_apply.js +3 -1
  107. package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.d.ts.map +1 -1
  108. package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +31 -7
  109. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  110. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  111. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  112. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  113. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  114. package/src/shade/renderer/geometry/GPUGeometryManager.d.ts +8 -1
  115. package/src/shade/renderer/geometry/GPUGeometryManager.d.ts.map +1 -1
  116. package/src/shade/renderer/geometry/GPUGeometryManager.js +18 -1
  117. package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.d.ts +1 -1
  118. package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.js +1 -1
  119. package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts +9 -0
  120. package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts.map +1 -1
  121. package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.js +30 -2
  122. package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts +27 -0
  123. package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts.map +1 -1
  124. package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +85 -6
  125. package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.d.ts +5 -1
  126. package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.d.ts.map +1 -1
  127. package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.js +8 -3
  128. package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.d.ts +13 -0
  129. package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.d.ts.map +1 -1
  130. package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.js +47 -4
  131. package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.d.ts +51 -0
  132. package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.d.ts.map +1 -0
  133. package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.js +60 -0
  134. package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.d.ts +12 -0
  135. package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.d.ts.map +1 -0
  136. package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.js +11 -0
  137. package/src/shade/renderer/geometry/morph/MeshletMorphTargets.d.ts +73 -0
  138. package/src/shade/renderer/geometry/morph/MeshletMorphTargets.d.ts.map +1 -0
  139. package/src/shade/renderer/geometry/morph/MeshletMorphTargets.js +130 -0
  140. package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.d.ts +34 -0
  141. package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.d.ts.map +1 -0
  142. package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.js +126 -0
  143. package/src/shade/renderer/geometry/morph/MorphedGeometry.d.ts +50 -0
  144. package/src/shade/renderer/geometry/morph/MorphedGeometry.d.ts.map +1 -0
  145. package/src/shade/renderer/geometry/morph/MorphedGeometry.js +81 -0
  146. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.d.ts +22 -0
  147. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.d.ts.map +1 -0
  148. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.js +375 -0
  149. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.d.ts +25 -0
  150. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.d.ts.map +1 -0
  151. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.js +134 -0
  152. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.d.ts +15 -0
  153. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.d.ts.map +1 -0
  154. package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.js +110 -0
  155. package/src/shade/renderer/geometry/morph/morphed_geometry_build.d.ts +22 -0
  156. package/src/shade/renderer/geometry/morph/morphed_geometry_build.d.ts.map +1 -0
  157. package/src/shade/renderer/geometry/morph/morphed_geometry_build.js +32 -0
  158. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster.d.ts.map +1 -1
  159. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster.js +2 -1
  160. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  161. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.js +3 -3
  162. package/src/shade/renderer/hair/GPUHairSystem.js +1 -1
  163. package/src/shade/renderer/loader/SceneNode.d.ts +20 -1
  164. package/src/shade/renderer/loader/SceneNode.d.ts.map +1 -1
  165. package/src/shade/renderer/loader/SceneNode.js +142 -114
  166. package/src/shade/renderer/loader/gltf/load_gltf.d.ts +1 -0
  167. package/src/shade/renderer/loader/gltf/load_gltf.d.ts.map +1 -1
  168. package/src/shade/renderer/loader/gltf/load_gltf.js +214 -30
  169. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  170. package/src/shade/renderer/loader/mtf/MTFMorphBinding.d.ts +41 -0
  171. package/src/shade/renderer/loader/mtf/MTFMorphBinding.d.ts.map +1 -0
  172. package/src/shade/renderer/loader/mtf/MTFMorphBinding.js +60 -0
  173. package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.d.ts +31 -0
  174. package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.d.ts.map +1 -0
  175. package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.js +108 -0
  176. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts +3 -0
  177. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts.map +1 -1
  178. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.js +4 -1
  179. package/src/shade/renderer/loader/mtf/mtf_export.d.ts.map +1 -1
  180. package/src/shade/renderer/loader/mtf/mtf_export.js +7 -0
  181. package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts +6 -3
  182. package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts.map +1 -1
  183. package/src/shade/renderer/loader/mtf/mtf_read_scene.js +43 -3
  184. package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts +2 -0
  185. package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts.map +1 -1
  186. package/src/shade/renderer/loader/mtf/mtf_serialization_registry.js +9 -0
  187. package/src/shade/renderer/loader/mtf/mtf_write.d.ts +3 -1
  188. package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
  189. package/src/shade/renderer/loader/mtf/mtf_write.js +20 -1
  190. package/src/shade/renderer/object_property/ObjectType.d.ts +1 -0
  191. package/src/shade/renderer/object_property/ObjectType.js +8 -0
  192. package/src/shade/renderer/object_property/chunk_write_object_property.d.ts +6 -7
  193. package/src/shade/renderer/object_property/chunk_write_object_property.d.ts.map +1 -1
  194. package/src/shade/renderer/object_property/chunk_write_object_property.js +13 -7
  195. package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.d.ts +17 -0
  196. package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.d.ts.map +1 -0
  197. package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.js +38 -0
  198. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  199. package/src/shade/renderer/scene/GPUSceneContext.d.ts +5 -6
  200. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  201. package/src/shade/renderer/scene/GPUSceneContext.js +17 -20
  202. package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.d.ts +1 -1
  203. package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.d.ts.map +1 -1
  204. package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.js +2 -2
  205. package/src/shade/renderer/scene/chunk_mesh_flags.js +3 -3
  206. package/src/shade/renderer/scene/movers/graph_scene_movers.d.ts +1 -1
  207. package/src/shade/renderer/scene/movers/graph_scene_movers.d.ts.map +1 -1
  208. package/src/shade/renderer/scene/movers/graph_scene_movers.js +20 -13
  209. package/src/shade/renderer/scene/movers/shader_scene_deformed_movers.d.ts +25 -0
  210. package/src/shade/renderer/scene/movers/shader_scene_deformed_movers.d.ts.map +1 -0
  211. package/src/shade/renderer/scene/movers/{shader_scene_skinned_movers.js → shader_scene_deformed_movers.js} +28 -18
  212. package/src/shade/renderer/scene/movers/shader_scene_movers.d.ts +1 -1
  213. package/src/shade/renderer/scene/movers/shader_scene_movers.js +2 -2
  214. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts +13 -13
  215. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts.map +1 -1
  216. package/src/shade/renderer/scene/rows/GPUSceneRows.js +30 -30
  217. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.d.ts +17 -0
  218. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.d.ts.map +1 -0
  219. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.js +78 -0
  220. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.d.ts +2 -1
  221. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.d.ts.map +1 -1
  222. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.js +10 -54
  223. package/src/shade/renderer/shadow/vsm/VSMPageManager.d.ts.map +1 -1
  224. package/src/shade/renderer/shadow/vsm/VSMPageManager.js +33 -163
  225. package/src/shade/renderer/texture/virtual/README.md +12 -4
  226. package/src/shade/renderer/texture/virtual/VTLodBiasController.d.ts +116 -0
  227. package/src/shade/renderer/texture/virtual/VTLodBiasController.d.ts.map +1 -0
  228. package/src/shade/renderer/texture/virtual/VTLodBiasController.js +301 -0
  229. package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts +8 -3
  230. package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts.map +1 -1
  231. package/src/shade/renderer/texture/virtual/VirtualTextureManager.js +110 -20
  232. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  233. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
  234. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +0 -1
  235. package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts +0 -22
  236. package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts.map +0 -1
  237. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_geometry_sphere_derive.d.ts.map +0 -1
  238. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +0 -1
  239. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_scatter.d.ts.map +0 -1
  240. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.d.ts.map +0 -1
  241. package/src/shade/renderer/scene/movers/shader_scene_skinned_movers.d.ts +0 -24
  242. package/src/shade/renderer/scene/movers/shader_scene_skinned_movers.d.ts.map +0 -1
  243. /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_geometry_sphere_derive.d.ts +0 -0
  244. /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_reduce.d.ts +0 -0
  245. /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_scatter.d.ts +0 -0
@@ -39,6 +39,8 @@ import { TransformAttachment } from "../../../engine/ecs/transform-attachment/Tr
39
39
  import { TRANSFORM_ATTACHMENT_EVENT_CHANGE } from "../../../engine/ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.js";
40
40
  import { Transform64 } from "../../../engine/ecs/transform/Transform64.js";
41
41
  import { Node3DProperty } from "../object_property/Node3DProperty.js";
42
+ import { ObjectType } from "../object_property/ObjectType.js";
43
+ import { ShadeAnimationProperty } from "./ShadeAnimationProperty.js";
42
44
  import { pose_evaluate_local } from "./pose/pose_evaluate_local.js";
43
45
  import { PosePlayback } from "./pose/PosePlayback.js";
44
46
  import {
@@ -57,6 +59,11 @@ import {
57
59
  shader_skin_matrix_prep,
58
60
  WORKGROUP_SIZE as SKIN_MATRIX_PREP_WORKGROUP_SIZE,
59
61
  } from "./skinning/shader_skin_matrix_prep.js";
62
+ import { ANIMATION_MORPH_WEIGHT_STRUCT } from "./ANIMATION_MORPH_WEIGHT_STRUCT.js";
63
+ import {
64
+ shader_morph_weights_resolve,
65
+ WORKGROUP_SIZE as MORPH_WEIGHTS_RESOLVE_WORKGROUP_SIZE,
66
+ } from "./morph/shader_morph_weights_resolve.js";
60
67
 
61
68
  /**
62
69
  * @typedef {import("../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry} PipelineEnquiry
@@ -170,6 +177,46 @@ function rest_for_property(dataset, entity, property) {
170
177
  */
171
178
 
172
179
  const KEYFRAME_WRITER = generate_record_writer(ANIMATION_CURVE_KEYFRAME_STRUCT);
180
+ const MORPH_WEIGHT_WRITER = generate_record_writer(ANIMATION_MORPH_WEIGHT_STRUCT);
181
+
182
+ /**
183
+ * Scratch record for {@link MORPH_WEIGHT_WRITER}: a base changed in place is written through it, one
184
+ * row at a time, without an object a row.
185
+ *
186
+ * @type {{base: number}}
187
+ */
188
+ const MORPH_WEIGHT = { base: 0 };
189
+
190
+ /**
191
+ * One morph weight is an `f32`.
192
+ */
193
+ const MORPH_WEIGHT_BYTES = 4;
194
+
195
+ /**
196
+ * Initial capacity of each half of the weights buffer, in weights. Doubles on growth.
197
+ */
198
+ const MORPH_WEIGHTS_INITIAL_CAPACITY = 256;
199
+
200
+ /**
201
+ * The handle a {@link ObjectType.MorphWeight} binding carries holds the weight row in 24 bits.
202
+ */
203
+ const MORPH_WEIGHT_ROW_LIMIT = 1 << 24;
204
+
205
+ /**
206
+ * The rest rotation a {@link ShadeAnimationProperty.MorphWeight} binding carries: read by Node3D rotation
207
+ * writers alone, so any value would do, and the identity says nothing.
208
+ */
209
+ const MORPH_WEIGHT_REST_ROTATION = Object.freeze([0, 0, 0, 1]);
210
+
211
+ /**
212
+ * The handle a binding keying weight row `row` carries.
213
+ *
214
+ * @param {number} row
215
+ * @returns {number}
216
+ */
217
+ function morph_weight_handle(row) {
218
+ return ((ObjectType.MorphWeight << 24) | row) >>> 0;
219
+ }
173
220
  const BINDING_WRITER = generate_record_writer(ANIMATION_TRACK_BINDING_STRUCT);
174
221
  const SKIN_JOINT_WRITER = generate_record_writer(ANIMATION_SKIN_JOINT_STRUCT);
175
222
  const FOLIAGE_JOINT_WRITER = generate_record_writer(ANIMATION_FOLIAGE_JOINT_STRUCT);
@@ -546,6 +593,79 @@ export class GPUAnimationManager {
546
593
  */
547
594
  #skin_matrix_count = 0;
548
595
 
596
+ /**
597
+ * Ping-pong pair of morph weight buffers, `f32` each, one holding this frame's weights and the
598
+ * other the last frame's: a weight's value sits at its `animation_morph_weights` row, as a joint's
599
+ * matrix sits at its row of the skin matrices, and the pair flips the way theirs does.
600
+ * {@link #morph_weights_current_index} says which is this frame's.
601
+ *
602
+ * `null` until the first {@link register_morph}.
603
+ *
604
+ * @type {Array<GPUBuffer|null>}
605
+ */
606
+ #morph_weights_buffers = [null, null];
607
+
608
+ /**
609
+ * Weights each of {@link #morph_weights_buffers} holds.
610
+ *
611
+ * @type {number}
612
+ */
613
+ #morph_weights_capacity = 0;
614
+
615
+ /**
616
+ * Which of {@link #morph_weights_buffers} holds this frame's weights: 0 or 1.
617
+ *
618
+ * @type {number}
619
+ */
620
+ #morph_weights_current_index = 0;
621
+
622
+ /**
623
+ * One past the highest weight row any morph has been given.
624
+ *
625
+ * @type {number}
626
+ */
627
+ #morph_weight_count = 0;
628
+
629
+ /**
630
+ * Runs of weight rows, `[first_row, count]`, whose "last frame" the next resolve copies from
631
+ * "this frame": a run just handed out holds another morph's last weights or zeros there, and the
632
+ * morph pass reads it for the previous positions. As {@link #skin_matrix_seed_runs}.
633
+ *
634
+ * @type {Array<[number, number]>}
635
+ */
636
+ #morph_weight_seed_runs = [];
637
+
638
+ /**
639
+ * When true, the next resolve seeds all of "last frame" from "this frame": the buffer was made
640
+ * again at a larger size.
641
+ *
642
+ * @type {boolean}
643
+ */
644
+ #morph_weight_seed_all = false;
645
+
646
+ /**
647
+ * What the clips add to each weight in a frame, one `atomic<u32>` cell (f32 bits) per weight row:
648
+ * the apply pass adds, the resolve drains. Sized with {@link #morph_weights_buffers}; a placeholder
649
+ * of one cell until the first morph, because the apply pass binds it whatever it drives.
650
+ *
651
+ * @type {GPUBuffer|null}
652
+ */
653
+ #morph_accumulator_buffer = null;
654
+
655
+ /**
656
+ * Every registered morph by id: the entity it weighs and its run of weight rows.
657
+ *
658
+ * @type {Map<number, {entity: number, weights_first: number, weight_count: number}>}
659
+ */
660
+ #morphs = new Map();
661
+
662
+ /**
663
+ * The morph id of each entity that has one.
664
+ *
665
+ * @type {Map<number, number>}
666
+ */
667
+ #morph_of_entity = new Map();
668
+
549
669
  /**
550
670
  * The bound clips that drive each entity, by entity — counted by the list's length, and named
551
671
  * so that a hold can find the bindings to mute. An entity's local TRS is the GPU's while the
@@ -566,6 +686,21 @@ export class GPUAnimationManager {
566
686
  */
567
687
  #targets_by_clip = new Map();
568
688
 
689
+ /**
690
+ * The bound clips keying morph weights of each entity, by entity: whose bindings go muted when the
691
+ * entity's weights are given back, and name its weights again when it is given new ones.
692
+ *
693
+ * @type {Map<number, number[]>}
694
+ */
695
+ #clips_weighing = new Map();
696
+
697
+ /**
698
+ * The distinct entities whose morph weights each completed clip keys, by clip id.
699
+ *
700
+ * @type {Map<number, number[]>}
701
+ */
702
+ #weighed_by_clip = new Map();
703
+
569
704
  /**
570
705
  * The CPU's copy of what each registered clip is playing at: the clip itself and the last
571
706
  * time and weight set on it. What a joint is evaluated against when its last clip leaves, so
@@ -808,6 +943,340 @@ export class GPUAnimationManager {
808
943
  return this.#skin_matrices_buffers[1 - this.#skin_matrices_current_index];
809
944
  }
810
945
 
946
+ /**
947
+ * This frame's morph weights, `f32`, a weight at its `animation_morph_weights` row. `null` until
948
+ * the first {@link register_morph}. Flips role every frame with {@link prev_morph_weights_buffer}
949
+ * and is replaced when it grows, so re-fetch each frame.
950
+ *
951
+ * @returns {GPUBuffer|null}
952
+ */
953
+ get morph_weights_buffer() {
954
+ return this.#morph_weights_buffers[this.#morph_weights_current_index];
955
+ }
956
+
957
+ /**
958
+ * The last frame's morph weights, laid out as {@link morph_weights_buffer}: what the morph pass
959
+ * makes previous positions from, and what the movers pass compares against.
960
+ *
961
+ * @returns {GPUBuffer|null}
962
+ */
963
+ get prev_morph_weights_buffer() {
964
+ return this.#morph_weights_buffers[1 - this.#morph_weights_current_index];
965
+ }
966
+
967
+ /**
968
+ * Give a mesh entity its morph target weights: a run of `animation_morph_weights` rows, one per
969
+ * target, holding `base_weights` as their bases. Completes at once, waiting for no other entity.
970
+ * One entity, one registration: {@link unregister_morph} before registering it again.
971
+ *
972
+ * Clip channels keying a weight of `entity` bind once this has run, and the entity's morph binding
973
+ * in the deformation context reads its weights through the id.
974
+ *
975
+ * @param {number} entity
976
+ * @param {ArrayLike<number>} base_weights one per target, at least one
977
+ * @returns {number} morph id (a row of `animation_morphs`)
978
+ */
979
+ register_morph(entity, base_weights) {
980
+ assert.isNonNegativeInteger(entity, 'entity');
981
+ assert.defined(base_weights, 'base_weights');
982
+ assert.greaterThanOrEqual(base_weights.length, 1, 'a morph has at least one target');
983
+ assert.equal(this.#morph_of_entity.has(entity), false, `entity ${entity} already has morph weights; unregister them first`);
984
+
985
+ const count = base_weights.length;
986
+ const records = new Array(count);
987
+
988
+ for (let i = 0; i < count; i++) {
989
+ records[i] = { base: base_weights[i] };
990
+ }
991
+
992
+ const weights_first = this.#database.get('animation_morph_weights').add_run_records(records, MORPH_WEIGHT_WRITER);
993
+
994
+ assert.lessThanOrEqual(weights_first + count, MORPH_WEIGHT_ROW_LIMIT, 'morph weight rows past what a binding handle holds');
995
+
996
+ const morph_id = this.#database.get('animation_morphs').add({
997
+ weights_first,
998
+ weight_count: count,
999
+ });
1000
+
1001
+ const end = weights_first + count;
1002
+
1003
+ if (end > this.#morph_weight_count) {
1004
+ this.#morph_weight_count = end;
1005
+ this.#ensure_morph_weights_capacity(end);
1006
+ }
1007
+
1008
+ // no last frame for these rows yet: the first resolve makes it this frame's
1009
+ this.#morph_weight_seed_runs.push([weights_first, count]);
1010
+
1011
+ this.#morphs.set(morph_id, { entity, weights_first, weight_count: count });
1012
+ this.#morph_of_entity.set(entity, morph_id);
1013
+
1014
+ // clips that bound against weights the entity had before name these now
1015
+ this.#point_weight_bindings(entity, weights_first, count);
1016
+
1017
+ return morph_id;
1018
+ }
1019
+
1020
+ /**
1021
+ * Write a registered morph's bases again, after its `MeshMorph` changed: only these rows' words go
1022
+ * up, and the next resolve publishes them.
1023
+ *
1024
+ * @param {number} morph_id
1025
+ * @param {ArrayLike<number>} base_weights as many as the morph has
1026
+ */
1027
+ set_morph_weights(morph_id, base_weights) {
1028
+ const morph = this.#morphs.get(morph_id);
1029
+
1030
+ assert.defined(morph, `morph ${morph_id}`);
1031
+ assert.equal(base_weights.length, morph.weight_count, 'base_weights.length !== the morph\'s weight count');
1032
+
1033
+ const table = this.#database.get('animation_morph_weights');
1034
+
1035
+ for (let i = 0; i < morph.weight_count; i++) {
1036
+ MORPH_WEIGHT.base = base_weights[i];
1037
+
1038
+ table.set_record(morph.weights_first + i, MORPH_WEIGHT, MORPH_WEIGHT_WRITER);
1039
+ }
1040
+ }
1041
+
1042
+ /**
1043
+ * Give a morph's rows back. The entity's morph binding in the deformation context goes first, so its
1044
+ * next upload names no freed row, and every clip binding keying the weights is muted; registering the
1045
+ * entity again points them at its new weights.
1046
+ *
1047
+ * @param {number} morph_id
1048
+ */
1049
+ unregister_morph(morph_id) {
1050
+ const morph = this.#morphs.get(morph_id);
1051
+
1052
+ if (morph === undefined) {
1053
+ return;
1054
+ }
1055
+
1056
+ this.#scene_context.deformation.unbind_all_by_morph(morph_id);
1057
+
1058
+ // a clip still keying the weights writes nothing from here on, rather than into rows the
1059
+ // next morph is handed
1060
+ this.#point_weight_bindings(morph.entity, 0, 0);
1061
+
1062
+ this.#morphs.delete(morph_id);
1063
+ this.#morph_of_entity.delete(morph.entity);
1064
+
1065
+ const runs = this.#morph_weight_seed_runs;
1066
+
1067
+ for (let i = runs.length - 1; i >= 0; i--) {
1068
+ if (runs[i][0] === morph.weights_first) {
1069
+ runs[i] = runs[runs.length - 1];
1070
+ runs.pop();
1071
+ }
1072
+ }
1073
+
1074
+ // the weights go with the morph
1075
+ this.#database.get('animation_morphs').remove(morph_id);
1076
+ }
1077
+
1078
+ /**
1079
+ * Name the weight run `[weights_first, weights_first + count)` in every binding of a bound clip
1080
+ * keying a weight of `entity`: its `element`'s row, or nothing for an element past `count` —
1081
+ * `count` 0 mutes them all. Only the `instance` word of each binding is written.
1082
+ *
1083
+ * @param {number} entity
1084
+ * @param {number} weights_first
1085
+ * @param {number} count
1086
+ */
1087
+ #point_weight_bindings(entity, weights_first, count) {
1088
+ const clips = this.#clips_weighing.get(entity);
1089
+
1090
+ if (clips === undefined) {
1091
+ return;
1092
+ }
1093
+
1094
+ const clips_table = this.#database.get('animation_clips');
1095
+ const bindings = this.#database.get('animation_bindings');
1096
+
1097
+ for (let c = 0; c < clips.length; c++) {
1098
+ const clip_id = clips[c];
1099
+ const first = clips_table.get_word(clip_id, CLIP_BINDINGS_FIRST_WORD);
1100
+ const channels = this.#playback_by_clip.get(clip_id).clip.channels;
1101
+
1102
+ for (let i = 0; i < channels.length; i++) {
1103
+ const channel = channels[i];
1104
+
1105
+ if (channel.property !== ShadeAnimationProperty.MorphWeight || channel.target !== entity) {
1106
+ continue;
1107
+ }
1108
+
1109
+ assert.ok(count === 0 || channel.element < count, `clip ${clip_id} keys morph target ${channel.element} of entity ${entity}, which has ${count}`);
1110
+
1111
+ BINDING_INSTANCE.instance = channel.element < count
1112
+ ? morph_weight_handle(weights_first + channel.element)
1113
+ : GPU_DATABASE_NULL;
1114
+
1115
+ bindings.set_fields(first + i, BINDING_INSTANCE, BINDING_INSTANCE_WRITER);
1116
+ }
1117
+ }
1118
+ }
1119
+
1120
+ /**
1121
+ * @param {number} entity
1122
+ * @returns {number} the entity's morph id, or -1 while it has none
1123
+ */
1124
+ morph_of_entity(entity) {
1125
+ const id = this.#morph_of_entity.get(entity);
1126
+
1127
+ return id === undefined ? -1 : id;
1128
+ }
1129
+
1130
+ /**
1131
+ * @param {number} morph_id
1132
+ * @returns {number} the morph's first weight row
1133
+ */
1134
+ get_morph_weights_first(morph_id) {
1135
+ const morph = this.#morphs.get(morph_id);
1136
+
1137
+ assert.defined(morph, `morph ${morph_id}`);
1138
+
1139
+ return morph.weights_first;
1140
+ }
1141
+
1142
+ /**
1143
+ * @param {number} morph_id
1144
+ * @returns {number} how many weights the morph has
1145
+ */
1146
+ get_morph_weight_count(morph_id) {
1147
+ const morph = this.#morphs.get(morph_id);
1148
+
1149
+ assert.defined(morph, `morph ${morph_id}`);
1150
+
1151
+ return morph.weight_count;
1152
+ }
1153
+
1154
+ /**
1155
+ * Grow the weights buffers, both, and the accumulator with them. Nothing is copied: "this
1156
+ * frame" is written whole by the next resolve, and "last frame" is seeded from it, all of it, so
1157
+ * every morphed mesh reads no motion for that one frame, as after a skin matrix grow.
1158
+ *
1159
+ * @param {number} required_count weights each buffer must hold
1160
+ */
1161
+ #ensure_morph_weights_capacity(required_count) {
1162
+ if (required_count <= this.#morph_weights_capacity) {
1163
+ return;
1164
+ }
1165
+
1166
+ let capacity = Math.max(this.#morph_weights_capacity, MORPH_WEIGHTS_INITIAL_CAPACITY);
1167
+
1168
+ while (capacity < required_count) {
1169
+ capacity *= 2;
1170
+ }
1171
+
1172
+ for (let i = 0; i < 2; i++) {
1173
+ if (this.#morph_weights_buffers[i] !== null) {
1174
+ this.#morph_weights_buffers[i].destroy();
1175
+ }
1176
+
1177
+ this.#morph_weights_buffers[i] = this.#device.createBuffer({
1178
+ label: `${this.#label}/MorphWeights/${i}`,
1179
+ size: capacity * MORPH_WEIGHT_BYTES,
1180
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
1181
+ });
1182
+ }
1183
+
1184
+ if (this.#morph_accumulator_buffer !== null) {
1185
+ this.#morph_accumulator_buffer.destroy();
1186
+ }
1187
+
1188
+ // createBuffer zeroes it, which is an empty sum for every cell
1189
+ this.#morph_accumulator_buffer = this.#device.createBuffer({
1190
+ label: `${this.#label}/MorphAccumulator`,
1191
+ size: capacity * 4,
1192
+ usage: GPUBufferUsage.STORAGE,
1193
+ });
1194
+
1195
+ this.#morph_weights_capacity = capacity;
1196
+ this.#morph_weight_seed_all = true;
1197
+ }
1198
+
1199
+ /**
1200
+ * The accumulator the apply pass binds, made at its smallest when no morph has asked for one yet.
1201
+ *
1202
+ * @returns {GPUBuffer}
1203
+ */
1204
+ #obtain_morph_accumulator() {
1205
+ if (this.#morph_accumulator_buffer === null) {
1206
+ this.#morph_accumulator_buffer = this.#device.createBuffer({
1207
+ label: `${this.#label}/MorphAccumulator`,
1208
+ size: 4,
1209
+ usage: GPUBufferUsage.STORAGE,
1210
+ });
1211
+ }
1212
+
1213
+ return this.#morph_accumulator_buffer;
1214
+ }
1215
+
1216
+ /**
1217
+ * Resolve this frame's morph weights: flip the pair, write every weight row's base plus what the
1218
+ * clips added into the new "this frame", and seed "last frame" over the rows that have none. After
1219
+ * the apply pass, before any pass that reads the weights. No-op while no morph is registered.
1220
+ *
1221
+ * @param {ShadeGPUCommandContext} cmd_ctx
1222
+ */
1223
+ dispatch_morph_weights_resolve(cmd_ctx) {
1224
+ const groups = this.#database
1225
+ .get('animation_morph_weights')
1226
+ .dispatch_group_count(MORPH_WEIGHTS_RESOLVE_WORKGROUP_SIZE);
1227
+
1228
+ if (groups === 0 || this.#morph_weights_buffers[0] === null) {
1229
+ return;
1230
+ }
1231
+
1232
+ this.#morph_weights_current_index = 1 - this.#morph_weights_current_index;
1233
+
1234
+ shader_morph_weights_resolve.dispatch({
1235
+ encoder: cmd_ctx,
1236
+ group_count_x: groups,
1237
+ bindings: {
1238
+ animation_database: this.#database.buffer,
1239
+ morph_accumulator: this.#morph_accumulator_buffer,
1240
+ morph_weights: this.morph_weights_buffer,
1241
+ },
1242
+ });
1243
+
1244
+ this.#seed_previous_morph_weights(cmd_ctx);
1245
+ }
1246
+
1247
+ /**
1248
+ * Copy this frame's weights over the last frame's on the rows that have no last frame: all of them
1249
+ * after a grow, otherwise the runs handed out since the last resolve.
1250
+ *
1251
+ * @param {ShadeGPUCommandContext} cmd_ctx
1252
+ */
1253
+ #seed_previous_morph_weights(cmd_ctx) {
1254
+ const current = this.morph_weights_buffer;
1255
+ const previous = this.prev_morph_weights_buffer;
1256
+ const runs = this.#morph_weight_seed_runs;
1257
+
1258
+ if (this.#morph_weight_seed_all) {
1259
+ cmd_ctx.copyBufferToBuffer(current, 0, previous, 0, current.size);
1260
+
1261
+ this.#morph_weight_seed_all = false;
1262
+ runs.length = 0;
1263
+
1264
+ return;
1265
+ }
1266
+
1267
+ for (let i = 0; i < runs.length; i++) {
1268
+ const [first, count] = runs[i];
1269
+
1270
+ cmd_ctx.copyBufferToBuffer(
1271
+ current, first * MORPH_WEIGHT_BYTES,
1272
+ previous, first * MORPH_WEIGHT_BYTES,
1273
+ count * MORPH_WEIGHT_BYTES,
1274
+ );
1275
+ }
1276
+
1277
+ runs.length = 0;
1278
+ }
1279
+
811
1280
  /**
812
1281
  * Matrices the buffer has to address: one past the highest joint row any skin has been
813
1282
  * given. Independent of buffer capacity, which is at least this big.
@@ -1403,7 +1872,7 @@ export class GPUAnimationManager {
1403
1872
  skin.meshes.push(entity);
1404
1873
 
1405
1874
  if (skin.named) {
1406
- this.#scene_context.skinning.bind(entity, skin_id);
1875
+ this.#scene_context.deformation.bind(entity, skin_id);
1407
1876
  }
1408
1877
  }
1409
1878
 
@@ -1427,7 +1896,7 @@ export class GPUAnimationManager {
1427
1896
  meshes[index] = meshes[meshes.length - 1];
1428
1897
  meshes.pop();
1429
1898
 
1430
- this.#scene_context.skinning.unbind(entity);
1899
+ this.#scene_context.deformation.unbind(entity);
1431
1900
  }
1432
1901
 
1433
1902
  /**
@@ -1436,7 +1905,7 @@ export class GPUAnimationManager {
1436
1905
  * @param {RegisteredSkin} skin
1437
1906
  */
1438
1907
  #bind_meshes(skin) {
1439
- const skinning = this.#scene_context.skinning;
1908
+ const skinning = this.#scene_context.deformation;
1440
1909
  const meshes = skin.meshes;
1441
1910
 
1442
1911
  for (let i = 0; i < meshes.length; i++) {
@@ -1546,6 +2015,10 @@ export class GPUAnimationManager {
1546
2015
  * the component — a prefab does, on every node a clip reaches — because a grant that could
1547
2016
  * silently do nothing would be a claim nobody could see.
1548
2017
  *
2018
+ * A {@link ShadeAnimationProperty.MorphWeight} channel is different: it waits for its target's morph
2019
+ * weights ({@link register_morph}) rather than its row, keys the weight of its `element`, and hands
2020
+ * nothing to the GPU — the weights were never the CPU's to write.
2021
+ *
1549
2022
  * Curves and tracks are interned synchronously since they're pure data.
1550
2023
  *
1551
2024
  * @param {ShadeAnimationClip} clip
@@ -1580,6 +2053,7 @@ export class GPUAnimationManager {
1580
2053
  track: this.#intern_track(track_channels),
1581
2054
  target: channel.target,
1582
2055
  property: channel.property,
2056
+ element: channel.element,
1583
2057
  };
1584
2058
  }
1585
2059
 
@@ -1620,7 +2094,7 @@ export class GPUAnimationManager {
1620
2094
  *
1621
2095
  * @param {{
1622
2096
  * clip_id: number,
1623
- * channels: Array<{ track: number, target: number, property: number }>,
2097
+ * channels: Array<{ track: number, target: number, property: number, element: number }>,
1624
2098
  * }} pending
1625
2099
  * @returns {boolean}
1626
2100
  */
@@ -1637,6 +2111,26 @@ export class GPUAnimationManager {
1637
2111
 
1638
2112
  assert.isNonNegativeInteger(target, `clip channel ${i} target`);
1639
2113
 
2114
+ if (ch.property === ShadeAnimationProperty.MorphWeight) {
2115
+ const morph = this.#morphs.get(this.morph_of_entity(target));
2116
+
2117
+ if (morph === undefined) return false;
2118
+
2119
+ assert.lessThan(ch.element, morph.weight_count, `clip channel ${i} keys morph target ${ch.element} of entity ${target}, which has ${morph.weight_count}`);
2120
+
2121
+ bindings[i] = {
2122
+ track: ch.track,
2123
+ instance: ch.element < morph.weight_count
2124
+ ? morph_weight_handle(morph.weights_first + ch.element)
2125
+ : GPU_DATABASE_NULL,
2126
+ property: ch.property,
2127
+ clip: clip_id,
2128
+ rest_rotation: MORPH_WEIGHT_REST_ROTATION,
2129
+ };
2130
+
2131
+ continue;
2132
+ }
2133
+
1640
2134
  if (!rows.has(target)) return false;
1641
2135
 
1642
2136
  bindings[i] = {
@@ -1671,7 +2165,7 @@ export class GPUAnimationManager {
1671
2165
  * of them leaves.
1672
2166
  *
1673
2167
  * @param {number} clip_id
1674
- * @param {Array<{target: number}>} channels
2168
+ * @param {Array<{target: number, property: number}>} channels
1675
2169
  */
1676
2170
  #take_targets(clip_id, channels) {
1677
2171
  const rows = this.#scene_context.rows;
@@ -1679,10 +2173,29 @@ export class GPUAnimationManager {
1679
2173
  const driving = this.#clips_driving;
1680
2174
 
1681
2175
  const targets = [];
2176
+ const weighed = [];
1682
2177
 
1683
2178
  for (let i = 0; i < channels.length; i++) {
1684
2179
  const target = channels[i].target;
1685
2180
 
2181
+ if (channels[i].property === ShadeAnimationProperty.MorphWeight) {
2182
+ // a weight is no transform: listed so the binding follows the entity's weights
2183
+ if (weighed.indexOf(target) === -1) {
2184
+ weighed.push(target);
2185
+
2186
+ let clips = this.#clips_weighing.get(target);
2187
+
2188
+ if (clips === undefined) {
2189
+ clips = [];
2190
+ this.#clips_weighing.set(target, clips);
2191
+ }
2192
+
2193
+ clips.push(clip_id);
2194
+ }
2195
+
2196
+ continue;
2197
+ }
2198
+
1686
2199
  if (targets.indexOf(target) !== -1) {
1687
2200
  continue;
1688
2201
  }
@@ -1730,6 +2243,7 @@ export class GPUAnimationManager {
1730
2243
  }
1731
2244
 
1732
2245
  this.#targets_by_clip.set(clip_id, targets);
2246
+ this.#weighed_by_clip.set(clip_id, weighed);
1733
2247
  }
1734
2248
 
1735
2249
  /**
@@ -1771,6 +2285,22 @@ export class GPUAnimationManager {
1771
2285
  * @param {number} clip_id
1772
2286
  */
1773
2287
  #release_targets(clip_id) {
2288
+ const weighed = this.#weighed_by_clip.get(clip_id);
2289
+
2290
+ if (weighed !== undefined) {
2291
+ this.#weighed_by_clip.delete(clip_id);
2292
+
2293
+ for (let i = 0; i < weighed.length; i++) {
2294
+ const clips = this.#clips_weighing.get(weighed[i]);
2295
+
2296
+ clips.splice(clips.indexOf(clip_id), 1);
2297
+
2298
+ if (clips.length === 0) {
2299
+ this.#clips_weighing.delete(weighed[i]);
2300
+ }
2301
+ }
2302
+ }
2303
+
1774
2304
  const targets = this.#targets_by_clip.get(clip_id);
1775
2305
 
1776
2306
  if (targets === undefined) {
@@ -1950,7 +2480,7 @@ export class GPUAnimationManager {
1950
2480
  const channels = this.#playback_by_clip.get(clip_id).clip.channels;
1951
2481
 
1952
2482
  for (let i = 0; i < channels.length; i++) {
1953
- if (channels[i].target === entity) {
2483
+ if (channels[i].target === entity && channels[i].property !== ShadeAnimationProperty.MorphWeight) {
1954
2484
  write_rest_for_property(rest_rotation, rest, channels[i].property);
1955
2485
  bindings.set_fields(first + i, BINDING_UNMUTE, BINDING_UNMUTE_WRITER);
1956
2486
  }
@@ -1993,7 +2523,8 @@ export class GPUAnimationManager {
1993
2523
  const channels = this.#playback_by_clip.get(clip_id).clip.channels;
1994
2524
 
1995
2525
  for (let i = 0; i < channels.length; i++) {
1996
- if (channels[i].target === entity) {
2526
+ // a weight binding is no transform's, and a hold on the node does not mute it
2527
+ if (channels[i].target === entity && channels[i].property !== ShadeAnimationProperty.MorphWeight) {
1997
2528
  bindings.set_fields(first + i, fields, writer);
1998
2529
  }
1999
2530
  }
@@ -2360,7 +2891,7 @@ export class GPUAnimationManager {
2360
2891
  // context's next upload doesn't reference a freed skin row
2361
2892
  // (its upload path looks up skin_matrix_offset via
2362
2893
  // get_skin_matrix_offset, which would assert post-removal).
2363
- this.#scene_context.skinning.unbind_all_by_skin(skin_id);
2894
+ this.#scene_context.deformation.unbind_all_by_skin(skin_id);
2364
2895
 
2365
2896
  const skins_table = this.#database.get('animation_skins');
2366
2897
 
@@ -2861,6 +3392,10 @@ export class GPUAnimationManager {
2861
3392
  cmd_ctx.encodeGraph(graph);
2862
3393
  }
2863
3394
 
3395
+ // The frame's morph weights, from their bases and what the apply added. Every frame while a
3396
+ // morph is registered, clips or not: it is also what publishes a base the CPU changed.
3397
+ this.dispatch_morph_weights_resolve(cmd_ctx);
3398
+
2864
3399
  // Skin matrix prep + skinning deformation. Both no-op when
2865
3400
  // no skins are registered — and both run independent of the
2866
3401
  // bound-track gate above: a registered skin whose joints
@@ -2868,7 +3403,7 @@ export class GPUAnimationManager {
2868
3403
  // each frame, otherwise it renders bind pose forever.
2869
3404
  this.dispatch_skin_matrix_prep(cmd_ctx);
2870
3405
 
2871
- const deformed = this.#scene_context.skinning.update(cmd_ctx);
3406
+ const deformed = this.#scene_context.deformation.update(cmd_ctx);
2872
3407
 
2873
3408
  // Whether anything on the GPU moved a row this frame without the CPU knowing: a clip wrote
2874
3409
  // a TRS, a foliage wind bone deflected, or a skinning pass moved a clone.
@@ -2934,6 +3469,9 @@ export class GPUAnimationManager {
2934
3469
  const gr_materials = graph_import_buffer(
2935
3470
  graph, this.#scene_context.materials.metadata_table.buffer, "materials"
2936
3471
  );
3472
+ const gr_morph_accumulator = graph_import_buffer(
3473
+ graph, this.#obtain_morph_accumulator(), "morph_accumulator"
3474
+ );
2937
3475
  const apply_data = {};
2938
3476
  const apply_pass = graph.add("animation/apply", apply_data, (data, resources, ctx) => {
2939
3477
  shader_animation_apply.dispatch({
@@ -2943,11 +3481,13 @@ export class GPUAnimationManager {
2943
3481
  animation_database: resources.get(data.animation_database),
2944
3482
  pose_accumulator: resources.get(data.pose_accumulator),
2945
3483
  materials: resources.get(data.materials),
3484
+ morph_accumulator: resources.get(data.morph_accumulator),
2946
3485
  },
2947
3486
  });
2948
3487
  });
2949
3488
  apply_data.animation_database = apply_pass.read(gr_animation_database);
2950
3489
  apply_data.materials = apply_pass.write(apply_pass.read(gr_materials));
3490
+ apply_data.morph_accumulator = apply_pass.write(apply_pass.read(gr_morph_accumulator));
2951
3491
  apply_data.pose_accumulator = apply_pass.write(apply_pass.read(last_pose_accumulator));
2952
3492
  last_pose_accumulator = apply_data.pose_accumulator;
2953
3493
  }
@@ -3026,5 +3566,15 @@ export class GPUAnimationManager {
3026
3566
  this.#pose_accumulator_buffer.destroy();
3027
3567
  this.#pose_accumulator_buffer = null;
3028
3568
  }
3569
+ for (let i = 0; i < 2; i++) {
3570
+ if (this.#morph_weights_buffers[i] !== null) {
3571
+ this.#morph_weights_buffers[i].destroy();
3572
+ this.#morph_weights_buffers[i] = null;
3573
+ }
3574
+ }
3575
+ if (this.#morph_accumulator_buffer !== null) {
3576
+ this.#morph_accumulator_buffer.destroy();
3577
+ this.#morph_accumulator_buffer = null;
3578
+ }
3029
3579
  }
3030
3580
  }