@woosh/meep-engine 3.11.3 → 3.12.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 (401) hide show
  1. package/README.md +14 -18
  2. package/editor/SelectionVisualizer.js +127 -127
  3. package/editor/entity_world_bounds.js +27 -27
  4. package/editor/particles/rebuildParticleEmitter.js +31 -31
  5. package/editor/process/SymbolicDisplayProcess.js +1 -1
  6. package/editor/process/symbolic/CameraSymbolicDisplay.js +146 -146
  7. package/editor/process/symbolic/LightSymbolicDisplay.js +172 -172
  8. package/editor/prototypeEditorShell.js +156 -156
  9. package/editor/selection/editor_pick.js +130 -130
  10. package/editor/selection/screen_rect_frustum.js +119 -119
  11. package/editor/tools/v2/TransformControls.js +971 -971
  12. package/package.json +1 -1
  13. package/src/engine/Engine.d.ts +3 -3
  14. package/src/engine/Engine.d.ts.map +1 -1
  15. package/src/engine/Engine.js +726 -726
  16. package/src/engine/EngineHarness.d.ts +1 -1
  17. package/src/engine/EngineHarness.js +590 -590
  18. package/src/engine/ecs/HIERARCHY_REVIEW.md +717 -717
  19. package/src/engine/ecs/terrain/ecs/BuildLightTexture.d.ts +1 -1
  20. package/src/engine/ecs/terrain/ecs/BuildLightTexture.js +27 -27
  21. package/src/engine/ecs/terrain/ecs/Terrain.d.ts +1 -5
  22. package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
  23. package/src/engine/ecs/terrain/ecs/Terrain.js +790 -790
  24. package/src/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +129 -129
  25. package/src/engine/graphics/ecs/camera/camera_find_active.d.ts +1 -1
  26. package/src/engine/graphics/ecs/camera/camera_find_active.js +28 -28
  27. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +1 -1
  28. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +428 -428
  29. package/src/engine/graphics/ecs/water/Water.d.ts +1 -1
  30. package/src/engine/graphics/ecs/water/Water.js +104 -104
  31. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +1 -1
  32. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1 -1
  33. package/src/engine/graphics3/AnimationGraphSystem.d.ts +65 -0
  34. package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -0
  35. package/src/engine/graphics3/AnimationGraphSystem.js +329 -0
  36. package/src/engine/graphics3/AnimationGraphSystem3.d.ts +6 -61
  37. package/src/engine/graphics3/AnimationGraphSystem3.d.ts.map +1 -1
  38. package/src/engine/graphics3/AnimationGraphSystem3.js +6 -325
  39. package/src/engine/graphics3/AnimationSystem.d.ts +76 -0
  40. package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -0
  41. package/src/engine/graphics3/AnimationSystem.js +352 -0
  42. package/src/engine/graphics3/AnimationSystem3.d.ts +6 -72
  43. package/src/engine/graphics3/AnimationSystem3.d.ts.map +1 -1
  44. package/src/engine/graphics3/AnimationSystem3.js +6 -348
  45. package/src/engine/graphics3/CameraSystem.d.ts +49 -0
  46. package/src/engine/graphics3/CameraSystem.d.ts.map +1 -0
  47. package/src/engine/graphics3/CameraSystem.js +170 -0
  48. package/src/engine/graphics3/CameraSystem3.d.ts +6 -45
  49. package/src/engine/graphics3/CameraSystem3.d.ts.map +1 -1
  50. package/src/engine/graphics3/CameraSystem3.js +6 -166
  51. package/src/engine/graphics3/DebugDrawSystem.d.ts +72 -0
  52. package/src/engine/graphics3/DebugDrawSystem.d.ts.map +1 -0
  53. package/src/engine/graphics3/DebugDrawSystem.js +205 -0
  54. package/src/engine/graphics3/DebugDrawSystem3.d.ts +6 -68
  55. package/src/engine/graphics3/DebugDrawSystem3.d.ts.map +1 -1
  56. package/src/engine/graphics3/DebugDrawSystem3.js +6 -201
  57. package/src/engine/graphics3/DecalSystem.d.ts +81 -0
  58. package/src/engine/graphics3/DecalSystem.d.ts.map +1 -0
  59. package/src/engine/graphics3/DecalSystem.js +441 -0
  60. package/src/engine/graphics3/DecalSystem3.d.ts +6 -77
  61. package/src/engine/graphics3/DecalSystem3.d.ts.map +1 -1
  62. package/src/engine/graphics3/DecalSystem3.js +6 -437
  63. package/src/engine/graphics3/FogOfWarSystem.d.ts +74 -0
  64. package/src/engine/graphics3/FogOfWarSystem.d.ts.map +1 -0
  65. package/src/engine/graphics3/FogOfWarSystem.js +265 -0
  66. package/src/engine/graphics3/FogOfWarSystem3.d.ts +6 -70
  67. package/src/engine/graphics3/FogOfWarSystem3.d.ts.map +1 -1
  68. package/src/engine/graphics3/FogOfWarSystem3.js +6 -261
  69. package/src/engine/graphics3/GraphicsEngine.d.ts +340 -0
  70. package/src/engine/graphics3/GraphicsEngine.d.ts.map +1 -0
  71. package/src/engine/graphics3/GraphicsEngine.js +790 -0
  72. package/src/engine/graphics3/GraphicsEngine3.d.ts +6 -336
  73. package/src/engine/graphics3/GraphicsEngine3.d.ts.map +1 -1
  74. package/src/engine/graphics3/GraphicsEngine3.js +6 -786
  75. package/src/engine/graphics3/HighlightSystem.d.ts +82 -0
  76. package/src/engine/graphics3/HighlightSystem.d.ts.map +1 -0
  77. package/src/engine/graphics3/HighlightSystem.js +241 -0
  78. package/src/engine/graphics3/HighlightSystem3.d.ts +6 -78
  79. package/src/engine/graphics3/HighlightSystem3.d.ts.map +1 -1
  80. package/src/engine/graphics3/HighlightSystem3.js +6 -237
  81. package/src/engine/graphics3/LightSystem.d.ts +40 -0
  82. package/src/engine/graphics3/LightSystem.d.ts.map +1 -0
  83. package/src/engine/graphics3/LightSystem.js +211 -0
  84. package/src/engine/graphics3/LightSystem3.d.ts +6 -36
  85. package/src/engine/graphics3/LightSystem3.d.ts.map +1 -1
  86. package/src/engine/graphics3/LightSystem3.js +6 -207
  87. package/src/engine/graphics3/MeshSystem.d.ts +106 -0
  88. package/src/engine/graphics3/MeshSystem.d.ts.map +1 -0
  89. package/src/engine/graphics3/MeshSystem.js +647 -0
  90. package/src/engine/graphics3/MeshSystem3.d.ts +6 -102
  91. package/src/engine/graphics3/MeshSystem3.d.ts.map +1 -1
  92. package/src/engine/graphics3/MeshSystem3.js +6 -642
  93. package/src/engine/graphics3/ParticipatingMedia.d.ts +2 -2
  94. package/src/engine/graphics3/ParticipatingMedia.js +203 -203
  95. package/src/engine/graphics3/ParticipatingMediaSystem.d.ts +87 -0
  96. package/src/engine/graphics3/ParticipatingMediaSystem.d.ts.map +1 -0
  97. package/src/engine/graphics3/ParticipatingMediaSystem.js +184 -0
  98. package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts +6 -83
  99. package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts.map +1 -1
  100. package/src/engine/graphics3/ParticipatingMediaSystem3.js +6 -180
  101. package/src/engine/graphics3/ParticleEmitterSystem.d.ts +76 -0
  102. package/src/engine/graphics3/ParticleEmitterSystem.d.ts.map +1 -0
  103. package/src/engine/graphics3/ParticleEmitterSystem.js +289 -0
  104. package/src/engine/graphics3/ParticleEmitterSystem3.d.ts +6 -72
  105. package/src/engine/graphics3/ParticleEmitterSystem3.d.ts.map +1 -1
  106. package/src/engine/graphics3/ParticleEmitterSystem3.js +6 -285
  107. package/src/engine/graphics3/PathDisplaySystem.d.ts +70 -0
  108. package/src/engine/graphics3/PathDisplaySystem.d.ts.map +1 -0
  109. package/src/engine/graphics3/PathDisplaySystem.js +309 -0
  110. package/src/engine/graphics3/PathDisplaySystem3.d.ts +6 -66
  111. package/src/engine/graphics3/PathDisplaySystem3.d.ts.map +1 -1
  112. package/src/engine/graphics3/PathDisplaySystem3.js +6 -305
  113. package/src/engine/graphics3/Pickable.d.ts +1 -1
  114. package/src/engine/graphics3/Pickable.js +65 -65
  115. package/src/engine/graphics3/PickingQuery.d.ts +1 -1
  116. package/src/engine/graphics3/PickingQuery.js +48 -48
  117. package/src/engine/graphics3/PickingSystem.d.ts +67 -0
  118. package/src/engine/graphics3/PickingSystem.d.ts.map +1 -0
  119. package/src/engine/graphics3/PickingSystem.js +273 -0
  120. package/src/engine/graphics3/PickingSystem3.d.ts +6 -63
  121. package/src/engine/graphics3/PickingSystem3.d.ts.map +1 -1
  122. package/src/engine/graphics3/PickingSystem3.js +6 -269
  123. package/src/engine/graphics3/ShadedGeometrySystem.d.ts +47 -0
  124. package/src/engine/graphics3/ShadedGeometrySystem.d.ts.map +1 -0
  125. package/src/engine/graphics3/ShadedGeometrySystem.js +169 -0
  126. package/src/engine/graphics3/ShadedGeometrySystem3.d.ts +6 -43
  127. package/src/engine/graphics3/ShadedGeometrySystem3.d.ts.map +1 -1
  128. package/src/engine/graphics3/ShadedGeometrySystem3.js +6 -165
  129. package/src/engine/graphics3/TerrainSystem.d.ts +80 -0
  130. package/src/engine/graphics3/TerrainSystem.d.ts.map +1 -0
  131. package/src/engine/graphics3/TerrainSystem.js +566 -0
  132. package/src/engine/graphics3/TerrainSystem3.d.ts +6 -76
  133. package/src/engine/graphics3/TerrainSystem3.d.ts.map +1 -1
  134. package/src/engine/graphics3/TerrainSystem3.js +6 -562
  135. package/src/engine/graphics3/TooltipComponentSystem.d.ts +65 -0
  136. package/src/engine/graphics3/TooltipComponentSystem.d.ts.map +1 -0
  137. package/src/engine/graphics3/TooltipComponentSystem.js +328 -0
  138. package/src/engine/graphics3/TooltipComponentSystem3.d.ts +6 -61
  139. package/src/engine/graphics3/TooltipComponentSystem3.d.ts.map +1 -1
  140. package/src/engine/graphics3/TooltipComponentSystem3.js +6 -324
  141. package/src/engine/graphics3/Trail3DSystem.d.ts +73 -0
  142. package/src/engine/graphics3/Trail3DSystem.d.ts.map +1 -0
  143. package/src/engine/graphics3/Trail3DSystem.js +221 -0
  144. package/src/engine/graphics3/Trail3DSystem3.d.ts +6 -69
  145. package/src/engine/graphics3/Trail3DSystem3.d.ts.map +1 -1
  146. package/src/engine/graphics3/Trail3DSystem3.js +6 -217
  147. package/src/engine/graphics3/VolumetricLightMap.d.ts +2 -2
  148. package/src/engine/graphics3/VolumetricLightMap.js +2 -2
  149. package/src/engine/graphics3/VolumetricLightMapSystem.d.ts +98 -0
  150. package/src/engine/graphics3/VolumetricLightMapSystem.d.ts.map +1 -0
  151. package/src/engine/graphics3/VolumetricLightMapSystem.js +261 -0
  152. package/src/engine/graphics3/VolumetricLightMapSystem3.d.ts +6 -94
  153. package/src/engine/graphics3/VolumetricLightMapSystem3.d.ts.map +1 -1
  154. package/src/engine/graphics3/VolumetricLightMapSystem3.js +10 -261
  155. package/src/engine/graphics3/WaterSystem.d.ts +59 -0
  156. package/src/engine/graphics3/WaterSystem.d.ts.map +1 -0
  157. package/src/engine/graphics3/WaterSystem.js +293 -0
  158. package/src/engine/graphics3/WaterSystem3.d.ts +6 -55
  159. package/src/engine/graphics3/WaterSystem3.d.ts.map +1 -1
  160. package/src/engine/graphics3/WaterSystem3.js +6 -289
  161. package/src/engine/graphics3/animation/AnimationGraphController.d.ts +1 -1
  162. package/src/engine/graphics3/animation/AnimationGraphController.js +518 -518
  163. package/src/engine/graphics3/animation/ClipListPlayer.d.ts +1 -1
  164. package/src/engine/graphics3/animation/ClipListPlayer.js +263 -263
  165. package/src/engine/graphics3/animation/ClipPlayback.d.ts +2 -2
  166. package/src/engine/graphics3/animation/ClipPlayback.js +84 -84
  167. package/src/engine/graphics3/decal/graph_build_decal_clusters.d.ts.map +1 -1
  168. package/src/engine/graphics3/decal/graph_build_decal_clusters.js +6 -8
  169. package/src/engine/graphics3/decal/shader_cluster_assign_decals.d.ts +0 -7
  170. package/src/engine/graphics3/decal/shader_cluster_assign_decals.d.ts.map +1 -1
  171. package/src/engine/graphics3/decal/shader_cluster_assign_decals.js +1 -1
  172. package/src/engine/graphics3/decal/shader_cull_decals_frustum.d.ts +0 -4
  173. package/src/engine/graphics3/decal/shader_cull_decals_frustum.d.ts.map +1 -1
  174. package/src/engine/graphics3/decal/shader_cull_decals_frustum.js +1 -1
  175. package/src/engine/graphics3/highlight/pack_highlight_table.d.ts +2 -2
  176. package/src/engine/graphics3/highlight/pack_highlight_table.d.ts.map +1 -1
  177. package/src/engine/graphics3/highlight/pack_highlight_table.js +74 -74
  178. package/src/engine/graphics3/pose/query_entity_node_world_pose.d.ts +1 -1
  179. package/src/engine/graphics3/pose/query_entity_node_world_pose.js +101 -101
  180. package/src/engine/graphics3/preview/make_model_thumbnail.d.ts +3 -3
  181. package/src/engine/graphics3/preview/make_model_thumbnail.d.ts.map +1 -1
  182. package/src/engine/graphics3/preview/make_model_thumbnail.js +48 -48
  183. package/src/engine/graphics3/shade_camera_projection_ray.d.ts +1 -1
  184. package/src/engine/graphics3/shade_camera_projection_ray.js +77 -77
  185. package/src/engine/graphics3/shade_node_to_entity_composition.d.ts +1 -1
  186. package/src/engine/graphics3/shade_node_to_entity_composition.js +84 -84
  187. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.d.ts.map +1 -1
  188. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.js +0 -1
  189. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_points.d.ts.map +1 -1
  190. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_points.js +0 -1
  191. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.d.ts.map +1 -1
  192. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.js +133 -134
  193. package/src/shade/playground/skinned_blas_refit/verify_leaf_triangles.js +202 -202
  194. package/src/shade/playground/skinned_blas_refit/verify_traversal_reachability.js +249 -249
  195. package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.js +1 -1
  196. package/src/shade/renderer/animation/pose/PosePlayback.d.ts +2 -1
  197. package/src/shade/renderer/animation/pose/PosePlayback.d.ts.map +1 -1
  198. package/src/shade/renderer/animation/pose/PosePlayback.js +2 -1
  199. package/src/shade/renderer/animation/shader_animation_apply.d.ts.map +1 -1
  200. package/src/shade/renderer/animation/shader_animation_apply.js +128 -129
  201. package/src/shade/renderer/animation/shader_animation_pose_resolve.d.ts.map +1 -1
  202. package/src/shade/renderer/animation/shader_animation_pose_resolve.js +176 -177
  203. package/src/shade/renderer/animation/shader_animation_tick.d.ts.map +1 -1
  204. package/src/shade/renderer/animation/shader_animation_tick.js +125 -126
  205. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_geometry_sphere_derive.d.ts.map +1 -1
  206. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_geometry_sphere_derive.js +98 -99
  207. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +1 -1
  208. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_reduce.js +212 -213
  209. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_scatter.d.ts.map +1 -1
  210. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_scatter.js +120 -121
  211. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.d.ts.map +1 -1
  212. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.js +75 -76
  213. package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.d.ts.map +1 -1
  214. package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +371 -372
  215. package/src/shade/renderer/animation/skinning/shader_skin_matrix_prep.d.ts.map +1 -1
  216. package/src/shade/renderer/animation/skinning/shader_skin_matrix_prep.js +104 -105
  217. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts.map +1 -1
  218. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.js +0 -1
  219. package/src/shade/renderer/buffer/graph_inspect_gpu_buffer.js +136 -136
  220. package/src/shade/renderer/buffer/table/GPUDatabase.d.ts.map +1 -1
  221. package/src/shade/renderer/buffer/table/GPUDatabase.js +2 -3
  222. package/src/shade/renderer/buffer/table/single/GPUSingleTypeTable.js +319 -319
  223. package/src/shade/renderer/buffer/util/shader_buffer_copy_storage_to_storage.d.ts.map +1 -1
  224. package/src/shade/renderer/buffer/util/shader_buffer_copy_storage_to_storage.js +41 -42
  225. package/src/shade/renderer/buffer/util/shader_buffer_intra_copy_regions.d.ts.map +1 -1
  226. package/src/shade/renderer/buffer/util/shader_buffer_intra_copy_regions.js +83 -84
  227. package/src/shade/renderer/dynamic/shader_dynamic_mesh.d.ts.map +1 -1
  228. package/src/shade/renderer/dynamic/shader_dynamic_mesh.js +177 -170
  229. package/src/shade/renderer/extension/RENDER_EXTENSION_DESIGN.md +918 -918
  230. package/src/shade/renderer/geometry/bvh/record_blas_refit.js +4 -4
  231. package/src/shade/renderer/geometry/bvh/shader_blas_refit_leaf_bounds.d.ts.map +1 -1
  232. package/src/shade/renderer/geometry/bvh/shader_blas_refit_leaf_bounds.js +121 -122
  233. package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.js +774 -774
  234. package/src/shade/renderer/geometry/meshlet/shader_meshlet_metadata_address_patch.d.ts +1 -1
  235. package/src/shade/renderer/geometry/meshlet/shader_meshlet_metadata_address_patch.d.ts.map +1 -1
  236. package/src/shade/renderer/geometry/meshlet/shader_meshlet_metadata_address_patch.js +69 -70
  237. package/src/shade/renderer/global_illumination/lpv/placement/graph_generate_probe_locations.js +367 -367
  238. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_lvp_atlas_to_sh.js +184 -184
  239. package/src/shade/renderer/gpu_primitive/bvh/GPU_BVH_BUILD_PLAN.md +1115 -1115
  240. package/src/shade/renderer/gpu_primitive/bvh/graph_bvh_build_lbvh.js +217 -217
  241. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_emit_hierarchy.d.ts.map +1 -1
  242. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_emit_hierarchy.js +142 -143
  243. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_morton.d.ts.map +1 -1
  244. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_morton.js +0 -1
  245. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_refit.d.ts.map +1 -1
  246. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_refit.js +140 -141
  247. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.d.ts.map +1 -1
  248. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.js +0 -1
  249. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.d.ts.map +1 -1
  250. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.js +0 -1
  251. package/src/shade/renderer/light/cluster/cull/graph_cull_lights.d.ts.map +1 -1
  252. package/src/shade/renderer/light/cluster/cull/graph_cull_lights.js +191 -198
  253. package/src/shade/renderer/light/cluster/cull/shader_cull_lights_frustum.d.ts +0 -6
  254. package/src/shade/renderer/light/cluster/cull/shader_cull_lights_frustum.d.ts.map +1 -1
  255. package/src/shade/renderer/light/cluster/cull/shader_cull_lights_frustum.js +120 -120
  256. package/src/shade/renderer/light/cluster/cull/shader_cull_lights_hzb.d.ts +0 -4
  257. package/src/shade/renderer/light/cluster/cull/shader_cull_lights_hzb.d.ts.map +1 -1
  258. package/src/shade/renderer/light/cluster/cull/shader_cull_lights_hzb.js +112 -112
  259. package/src/shade/renderer/light/cluster/graph_assign_clsuters.d.ts.map +1 -1
  260. package/src/shade/renderer/light/cluster/graph_assign_clsuters.js +4 -7
  261. package/src/shade/renderer/light/cluster/shader_cluster_assign_lights.d.ts +0 -6
  262. package/src/shade/renderer/light/cluster/shader_cluster_assign_lights.d.ts.map +1 -1
  263. package/src/shade/renderer/light/cluster/shader_cluster_assign_lights.js +1 -1
  264. package/src/shade/renderer/lightmap/bake/raster/shader_lightmap_to_viz_buffer.js +222 -222
  265. package/src/shade/renderer/lightmap/bake/tile/shader_lightmap_tile_composit.js +81 -81
  266. package/src/shade/renderer/material/GPUMaterialContext.js +380 -380
  267. package/src/shade/renderer/material/standard/fragment_gbuffer_vt.js +169 -169
  268. package/src/shade/renderer/object_property/shader_object_property_process.d.ts.map +1 -1
  269. package/src/shade/renderer/object_property/shader_object_property_process.js +83 -84
  270. package/src/shade/renderer/object_property/shader_refresh_all_mesh_bounds.d.ts.map +1 -1
  271. package/src/shade/renderer/object_property/shader_refresh_all_mesh_bounds.js +57 -58
  272. package/src/shade/renderer/particles/prototypeParticleSystem.js +2 -3
  273. package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts.map +1 -1
  274. package/src/shade/renderer/particles/shaders/shader_particle_emit.js +117 -118
  275. package/src/shade/renderer/particles/shaders/shader_particle_finalize.d.ts.map +1 -1
  276. package/src/shade/renderer/particles/shaders/shader_particle_finalize.js +77 -79
  277. package/src/shade/renderer/particles/shaders/shader_particle_render.d.ts.map +1 -1
  278. package/src/shade/renderer/particles/shaders/shader_particle_render.js +190 -183
  279. package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts.map +1 -1
  280. package/src/shade/renderer/particles/shaders/shader_particle_simulate.js +99 -100
  281. package/src/shade/renderer/particles/sort/shader_particle_sort.d.ts.map +1 -1
  282. package/src/shade/renderer/particles/sort/shader_particle_sort.js +158 -161
  283. package/src/shade/renderer/path_tracer/graph_path_trace_scene.js +184 -184
  284. package/src/shade/renderer/postprocess/denoise/graph_atorus_denoise_luma.js +119 -119
  285. package/src/shade/renderer/postprocess/dof/raymarch/graph_postprocess_dof.js +3 -4
  286. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.d.ts.map +1 -1
  287. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.js +266 -267
  288. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.d.ts.map +1 -1
  289. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.js +270 -271
  290. package/src/shade/renderer/postprocess/nss/shader_nss_concat.d.ts.map +1 -1
  291. package/src/shade/renderer/postprocess/nss/shader_nss_concat.js +68 -69
  292. package/src/shade/renderer/postprocess/nss/shader_nss_conv_layer.d.ts.map +1 -1
  293. package/src/shade/renderer/postprocess/nss/shader_nss_conv_layer.js +225 -226
  294. package/src/shade/renderer/postprocess/nss/shader_nss_extract_feedback.d.ts.map +1 -1
  295. package/src/shade/renderer/postprocess/nss/shader_nss_extract_feedback.js +49 -50
  296. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.d.ts.map +1 -1
  297. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.js +291 -292
  298. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.d.ts.map +1 -1
  299. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.js +230 -231
  300. package/src/shade/renderer/postprocess/ssr/reproject/shader_ffx_denoiser_reflections_reproject.d.ts +16 -2
  301. package/src/shade/renderer/postprocess/ssr/reproject/shader_ffx_denoiser_reflections_reproject.d.ts.map +1 -1
  302. package/src/shade/renderer/postprocess/ssr/reproject/shader_ffx_denoiser_reflections_reproject.js +12 -12
  303. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +2 -2
  304. package/src/shade/renderer/rasterize/bucket/shader_count_meshlets_by_material.d.ts.map +1 -1
  305. package/src/shade/renderer/rasterize/bucket/shader_count_meshlets_by_material.js +68 -69
  306. package/src/shade/renderer/rasterize/bucket/shader_make_meshlet_indirect_draw_commands_by_material.d.ts.map +1 -1
  307. package/src/shade/renderer/rasterize/bucket/shader_make_meshlet_indirect_draw_commands_by_material.js +59 -60
  308. package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.d.ts.map +1 -1
  309. package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.js +0 -1
  310. package/src/shade/renderer/rasterize/bucket/shader_sort_meshlets_by_material.d.ts.map +1 -1
  311. package/src/shade/renderer/rasterize/bucket/shader_sort_meshlets_by_material.js +64 -65
  312. package/src/shade/renderer/rasterize/compute/graph_mesh_frustum_cull.d.ts.map +1 -1
  313. package/src/shade/renderer/rasterize/compute/graph_mesh_frustum_cull.js +168 -169
  314. package/src/shade/renderer/rasterize/compute/graph_mesh_sphere_cull.d.ts.map +1 -1
  315. package/src/shade/renderer/rasterize/compute/graph_mesh_sphere_cull.js +160 -161
  316. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_mesh_filter_2way.d.ts.map +1 -1
  317. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_mesh_filter_2way.js +109 -110
  318. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_meshlet_filter_1way_full.d.ts.map +1 -1
  319. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_meshlet_filter_1way_full.js +115 -116
  320. package/src/shade/renderer/rasterize/expand/bucket/mesh/shader_instances_classify_bucket.d.ts.map +1 -1
  321. package/src/shade/renderer/rasterize/expand/bucket/mesh/shader_instances_classify_bucket.js +139 -140
  322. package/src/shade/renderer/rasterize/expand/bucket/mesh/shader_instances_count_by_rasterization_bucket.d.ts.map +1 -1
  323. package/src/shade/renderer/rasterize/expand/bucket/mesh/shader_instances_count_by_rasterization_bucket.js +91 -92
  324. package/src/shade/renderer/rasterize/expand/bucket/mesh/shader_instances_rasterization_bucket_sort.d.ts.map +1 -1
  325. package/src/shade/renderer/rasterize/expand/bucket/mesh/shader_instances_rasterization_bucket_sort.js +88 -89
  326. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_count_by_rasterization_bucket.d.ts.map +1 -1
  327. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_count_by_rasterization_bucket.js +90 -91
  328. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_extract_bucket.d.ts.map +1 -1
  329. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_extract_bucket.js +65 -66
  330. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_rasterization_bucket_sort.d.ts.map +1 -1
  331. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_rasterization_bucket_sort.js +89 -90
  332. package/src/shade/renderer/rasterize/expand/graph_mesh_filter_one_way.d.ts.map +1 -1
  333. package/src/shade/renderer/rasterize/expand/graph_mesh_filter_one_way.js +169 -170
  334. package/src/shade/renderer/rasterize/expand/mesh/shader_mesh_expand_to_meshlets_prefix.d.ts.map +1 -1
  335. package/src/shade/renderer/rasterize/expand/mesh/shader_mesh_expand_to_meshlets_prefix.js +89 -90
  336. package/src/shade/renderer/rasterize/expand/mesh/shader_meshes_to_meshlet_counts.d.ts.map +1 -1
  337. package/src/shade/renderer/rasterize/expand/mesh/shader_meshes_to_meshlet_counts.js +61 -62
  338. package/src/shade/renderer/rasterize/expand/pass1/filter_meshlets.2-way.compute.d.ts.map +1 -1
  339. package/src/shade/renderer/rasterize/expand/pass1/filter_meshlets.2-way.compute.js +153 -154
  340. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +144 -144
  341. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_pass_descriptor.js +88 -88
  342. package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.js +217 -217
  343. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments.js +179 -179
  344. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments_ibl.js +178 -178
  345. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_alpha_tested_pass_descriptor.js +194 -194
  346. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_opaque_pass_descriptor.js +76 -76
  347. package/src/shade/renderer/restir/di/shader_restir_di_denoise.d.ts.map +1 -1
  348. package/src/shade/renderer/restir/di/shader_restir_di_denoise.js +136 -137
  349. package/src/shade/renderer/restir/di/shader_restir_di_resample.d.ts.map +1 -1
  350. package/src/shade/renderer/restir/di/shader_restir_di_resample.js +129 -130
  351. package/src/shade/renderer/restir/di/shader_restir_di_resolve.d.ts.map +1 -1
  352. package/src/shade/renderer/restir/di/shader_restir_di_resolve.js +99 -100
  353. package/src/shade/renderer/restir/di/shader_restir_di_spatial.d.ts.map +1 -1
  354. package/src/shade/renderer/restir/di/shader_restir_di_spatial.js +116 -117
  355. package/src/shade/renderer/scene/GPUInstancesAccelerationStructure.js +383 -383
  356. package/src/shade/renderer/scene/hierarchy/graph_scene_update_transform_hierarchy_naive.js +123 -123
  357. package/src/shade/renderer/scene/hierarchy/shader_nodes_record_input_positions.d.ts.map +1 -1
  358. package/src/shade/renderer/scene/hierarchy/shader_nodes_record_input_positions.js +64 -65
  359. package/src/shade/renderer/scene/hierarchy/shader_nodes_update_transform_hierarchy.d.ts.map +1 -1
  360. package/src/shade/renderer/scene/hierarchy/shader_nodes_update_transform_hierarchy.js +372 -373
  361. package/src/shade/renderer/scene/hierarchy/shader_nodes_update_transform_hierarchy_naive.d.ts.map +1 -1
  362. package/src/shade/renderer/scene/hierarchy/shader_nodes_update_transform_hierarchy_naive.js +111 -112
  363. package/src/shade/renderer/scene/shader_bvh_extract_instance_leaves.d.ts.map +1 -1
  364. package/src/shade/renderer/scene/shader_bvh_extract_instance_leaves.js +0 -1
  365. package/src/shade/renderer/shader/ComputeShader.d.ts +24 -3
  366. package/src/shade/renderer/shader/ComputeShader.d.ts.map +1 -1
  367. package/src/shade/renderer/shader/ComputeShader.js +350 -296
  368. package/src/shade/renderer/shader/ImageShader.js +217 -217
  369. package/src/shade/renderer/shader/ShaderDescriptor.d.ts +5 -0
  370. package/src/shade/renderer/shader/ShaderDescriptor.d.ts.map +1 -1
  371. package/src/shade/renderer/shader/ShaderDescriptor.js +20 -0
  372. package/src/shade/renderer/shader/util/compute_infer_workgroup_size_from_source.d.ts +47 -0
  373. package/src/shade/renderer/shader/util/compute_infer_workgroup_size_from_source.d.ts.map +1 -0
  374. package/src/shade/renderer/shader/util/compute_infer_workgroup_size_from_source.js +448 -0
  375. package/src/shade/renderer/shadow/map/csm/graph_csm_setup_cascades.js +3 -3
  376. package/src/shade/renderer/shadow/ray/staged/gen/graph_gen_rays.js +3 -3
  377. package/src/shade/renderer/shadow/ray/staged/trace/graph_trace_rays.js +2 -2
  378. package/src/shade/renderer/shadow/sdf/cascade/CascadedSceneSDF.js +4 -4
  379. package/src/shade/renderer/texture/virtual/build_shader_vt_feedback.d.ts.map +1 -1
  380. package/src/shade/renderer/texture/virtual/build_shader_vt_feedback.js +231 -232
  381. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +1 -1
  382. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  383. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +12 -15
  384. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts +3 -2
  385. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  386. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +3 -2
  387. package/src/shade/renderer/volumetrics/taa/shader_volumetrics_taa.d.ts +0 -2
  388. package/src/shade/renderer/volumetrics/taa/shader_volumetrics_taa.d.ts.map +1 -1
  389. package/src/shade/renderer/volumetrics/taa/shader_volumetrics_taa.js +17 -6
  390. package/src/shade/renderer/water/shader_water.js +246 -246
  391. package/src/shade/vitest.setup.mjs +1 -1
  392. package/src/shade/wgsl/emulator/ComputeShaderEmulator.js +291 -291
  393. package/src/view/minimap/Minimap.d.ts +2 -2
  394. package/src/view/minimap/Minimap.d.ts.map +1 -1
  395. package/src/view/minimap/Minimap.js +225 -225
  396. package/src/view/minimap/dom/MinimapCameraView.d.ts +3 -3
  397. package/src/view/minimap/dom/MinimapCameraView.d.ts.map +1 -1
  398. package/src/view/minimap/dom/MinimapCameraView.js +206 -206
  399. package/src/shade/renderer/shadow/map/csm/shader/shader_setup_cascades.d.ts +0 -3
  400. package/src/shade/renderer/shadow/map/csm/shader/shader_setup_cascades.d.ts.map +0 -1
  401. package/src/shade/renderer/shadow/map/csm/shader/shader_setup_cascades.js +0 -20
@@ -1,518 +1,518 @@
1
- import { assert } from "../../../core/assert.js";
2
- import { AnimationClipFlag } from "../../graphics/ecs/animation/animator/AnimationClipFlag.js";
3
- import { AnimationState } from "../../graphics/ecs/animation/animator/graph/AnimationState.js";
4
- import { AnimationStateType } from "../../graphics/ecs/animation/animator/graph/AnimationStateType.js";
5
- import { AnimationTransition } from "../../graphics/ecs/animation/animator/graph/AnimationTransition.js";
6
- import { wrap_clip_time } from "./wrap_clip_time.js";
7
-
8
- /**
9
- * One entity's animation state machine: which state it is in, which transitions are running, what
10
- * each clip therefore weighs, and — the part the GPU cannot own — what time each of those clips is
11
- * playing at.
12
- *
13
- * **The clock is here and not on the GPU**, and I-4 is what forces it. Shade advances clip time
14
- * itself in its tick shader, but the time gameplay reads has to be the time the picture is drawn
15
- * from: notifications fire at authored moments off this clock, and the CPU pose evaluator answers
16
- * socket queries from it. Two clocks drift, so there is one, and {@link AnimationGraphSystem3}
17
- * writes it down to the renderer with `set_time` rather than letting the GPU advance anything.
18
- *
19
- * The state machine itself is not new — `AnimationState`, `AnimationTransition`, `BlendStateMatrix`
20
- * and the graph definitions are reused as they stand. What is not reused is the three-only half of
21
- * the legacy `AnimationGraph`: an `AnimationMixer`, the per-clip `AnimationAction`s it owns, and
22
- * writing weights onto them.
23
- */
24
- export class AnimationGraphController {
25
- /**
26
- * @type {AnimationGraphDefinition}
27
- */
28
- def = null;
29
-
30
- /**
31
- * @type {AnimationState[]}
32
- */
33
- states = [];
34
-
35
- /**
36
- * @type {AnimationTransition[]}
37
- */
38
- transitions = [];
39
-
40
- /**
41
- * The state the graph is in. During a transition this is already the target — the source stays
42
- * in {@link simulatedStates} until the transition finishes.
43
- *
44
- * @type {AnimationState}
45
- */
46
- state = null;
47
-
48
- /**
49
- * @type {AnimationTransition[]}
50
- */
51
- activeTransitions = [];
52
-
53
- /**
54
- * Every state whose clock is running: the current one, plus the sources of transitions that
55
- * have not finished.
56
- *
57
- * @type {AnimationState[]}
58
- */
59
- simulatedStates = [];
60
-
61
- /**
62
- * Per-clip weights and time scales, in `def.clipIndex` order. The weights are what reaches the
63
- * GPU; the time scales are consumed here, by {@link AnimationState#tick}, and have no GPU
64
- * counterpart because the time they scale is already integrated into the state's clock.
65
- *
66
- * @type {BlendStateMatrix}
67
- */
68
- blendState = null;
69
-
70
- /**
71
- * Where in its starting clip the graph begins, as a fraction of that clip's duration.
72
- *
73
- * A fraction rather than a time because a clip's duration comes from the model and the model
74
- * loads long after the entity does. Its purpose is to keep identical units from moving in
75
- * lockstep, and it is applied once, at {@link link}, without dispatching the notifications it
76
- * skips over — a unit that spawns mid-stride should not also spawn the footstep it missed.
77
- *
78
- * @type {number}
79
- */
80
- start_phase = 0;
81
-
82
- /**
83
- * The dataset this graph fires its notifications into.
84
- *
85
- * **Public, and named with the leading underscores, because `AnimationState.tick` reads it off
86
- * the graph by exactly that name.** The state classes are reused as they stand, so this is
87
- * their interface rather than an accident of style.
88
- *
89
- * @type {EntityComponentDataset}
90
- */
91
- __dataset = null;
92
-
93
- /**
94
- * The entity those notifications are addressed to. Read by `AnimationState.tick` — see
95
- * {@link __dataset}.
96
- *
97
- * @type {number}
98
- */
99
- __entity = -1;
100
-
101
- /**
102
- * @type {boolean}
103
- */
104
- #linked = false;
105
-
106
- /**
107
- * Playback time of each clip, in `def.clipIndex` order, already wrapped or clamped into the
108
- * clip's own duration — which is what the renderer's clip record wants, and what a pose query
109
- * has to agree with.
110
- *
111
- * @type {Float64Array}
112
- */
113
- #clip_times = new Float64Array(0);
114
-
115
- /**
116
- * @returns {boolean}
117
- */
118
- get linked() {
119
- return this.#linked;
120
- }
121
-
122
- /**
123
- * Build the runtime graph — one {@link AnimationState} per state definition, one
124
- * {@link AnimationTransition} per transition definition, wired to each other.
125
- *
126
- * @param {AnimationGraphDefinition} def
127
- */
128
- initialize(def) {
129
- assert.defined(def, 'def');
130
- assert.equal(this.#linked, false, 'graph is linked');
131
-
132
- this.def = def;
133
-
134
- this.blendState = def.createBlendState();
135
- this.#clip_times = new Float64Array(def.clipIndex.length);
136
-
137
- const state_definitions = def.states;
138
- const state_count = state_definitions.length;
139
-
140
- this.states = [];
141
-
142
- for (let i = 0; i < state_count; i++) {
143
- const state = new AnimationState();
144
-
145
- state.def = state_definitions[i];
146
- state.graph = this;
147
-
148
- this.states[i] = state;
149
- }
150
-
151
- const transition_definitions = def.transitions;
152
- const transition_count = transition_definitions.length;
153
-
154
- this.transitions = [];
155
-
156
- for (let i = 0; i < transition_count; i++) {
157
- const transition = new AnimationTransition();
158
-
159
- transition.def = transition_definitions[i];
160
- transition.graph = this;
161
-
162
- this.transitions[i] = transition;
163
- }
164
-
165
- this.state = this.state_by_definition(def.startingSate);
166
-
167
- for (let i = 0; i < transition_count; i++) {
168
- const transition = this.transitions[i];
169
-
170
- transition.source = this.state_by_definition(transition.def.source);
171
- transition.target = this.state_by_definition(transition.def.target);
172
-
173
- transition.initialize();
174
- }
175
-
176
- for (let i = 0; i < state_count; i++) {
177
- const state = this.states[i];
178
-
179
- state.inEdges = state.def.inEdges.map(this.transition_by_definition, this);
180
- state.outEdges = state.def.outEdges.map(this.transition_by_definition, this);
181
-
182
- state.initialize();
183
- }
184
- }
185
-
186
- /**
187
- * @param {AnimationStateDefinition} definition
188
- * @returns {AnimationState|undefined}
189
- */
190
- state_by_definition(definition) {
191
- assert.defined(definition, 'definition');
192
-
193
- const states = this.states;
194
-
195
- for (let i = 0; i < states.length; i++) {
196
- if (states[i].def === definition) {
197
- return states[i];
198
- }
199
- }
200
-
201
- return undefined;
202
- }
203
-
204
- /**
205
- * @param {string} name
206
- * @returns {AnimationState|undefined}
207
- */
208
- state_by_name(name) {
209
- const states = this.states;
210
-
211
- for (let i = 0; i < states.length; i++) {
212
- if (states[i].def.name === name) {
213
- return states[i];
214
- }
215
- }
216
-
217
- return undefined;
218
- }
219
-
220
- /**
221
- * @param {string} name name of the clip the state plays
222
- * @returns {AnimationState|undefined}
223
- */
224
- state_by_clip_name(name) {
225
- const states = this.states;
226
-
227
- for (let i = 0; i < states.length; i++) {
228
- const definition = states[i].def;
229
-
230
- if (definition.type !== AnimationStateType.Clip) {
231
- continue;
232
- }
233
-
234
- if (definition.motion.def.name === name) {
235
- return states[i];
236
- }
237
- }
238
-
239
- return undefined;
240
- }
241
-
242
- /**
243
- * @param {AnimationTransitionDefinition} definition
244
- * @returns {AnimationTransition|undefined}
245
- */
246
- transition_by_definition(definition) {
247
- const transitions = this.transitions;
248
-
249
- for (let i = 0; i < transitions.length; i++) {
250
- if (transitions[i].def === definition) {
251
- return transitions[i];
252
- }
253
- }
254
-
255
- return undefined;
256
- }
257
-
258
- /**
259
- * Start the graph: take the clip durations the model turned out to have, enter the starting
260
- * state, and begin listening for the events its transitions fire on.
261
- *
262
- * **Durations arrive here rather than at construction** because they are the model's and not
263
- * the graph's — `animation-graph.json` names clips, the `.glb` says how long they are — and the
264
- * notification path needs them to be right before a single frame is ticked. They are written
265
- * onto the shared clip definitions, which is where {@link AnimationClip} reads them.
266
- *
267
- * @param {number} entity
268
- * @param {EntityComponentDataset} ecd
269
- * @param {ArrayLike<number>} durations seconds, one per `def.clipIndex` entry, in that order
270
- */
271
- link(entity, ecd, durations) {
272
- assert.isNonNegativeInteger(entity, 'entity');
273
- assert.defined(ecd, 'ecd');
274
- assert.equal(this.#linked, false, 'graph is already linked, call unlink first');
275
-
276
- const clip_index = this.def.clipIndex;
277
-
278
- assert.equal(durations.length, clip_index.length, 'durations.length');
279
-
280
- for (let i = 0; i < clip_index.length; i++) {
281
- clip_index[i].duration = durations[i];
282
- }
283
-
284
- this.__entity = entity;
285
- this.__dataset = ecd;
286
-
287
- this.#linked = true;
288
-
289
- this.enter_state(this.state);
290
-
291
- this.state.time = this.start_phase * this.#state_clip_duration(this.state);
292
-
293
- this.update_blend_state();
294
- }
295
-
296
- /**
297
- * Stop listening. The graph keeps the state it was in, so a re-link resumes rather than
298
- * restarts.
299
- */
300
- unlink() {
301
- if (!this.#linked) {
302
- return;
303
- }
304
-
305
- this.exit_state(this.state);
306
-
307
- this.#linked = false;
308
- }
309
-
310
- /**
311
- * Advance every running clock by `time_delta`, fire whatever notifications were crossed, and
312
- * recompute the blend.
313
- *
314
- * Unconditional by design: §2.6-2's split puts pose evaluation and its events on the CPU
315
- * precisely so that camera framing cannot decide whether a projectile spawns. The screen-area
316
- * cull the legacy system applied has no counterpart here.
317
- *
318
- * @param {number} time_delta in seconds
319
- */
320
- tick(time_delta) {
321
- assert.equal(this.#linked, true, 'graph is not linked');
322
-
323
- const active_transitions = this.activeTransitions;
324
-
325
- let transition_count = active_transitions.length;
326
-
327
- transitions: for (let i = 0; i < transition_count; i++) {
328
- const active = active_transitions[i];
329
-
330
- active.tick(time_delta);
331
-
332
- if (!active.isFinished()) {
333
- continue;
334
- }
335
-
336
- active_transitions.splice(i, 1);
337
-
338
- transition_count--;
339
- i--;
340
-
341
- for (let j = 0; j < transition_count; j++) {
342
- const other = active_transitions[j];
343
-
344
- if (other.source === active.source || other.target === active.source) {
345
- // the state it came from is still in use by another transition
346
- continue transitions;
347
- }
348
- }
349
-
350
- this.stop_state_simulation(active.source);
351
- }
352
-
353
- const simulated = this.simulatedStates;
354
-
355
- for (let i = 0; i < simulated.length; i++) {
356
- simulated[i].tick(time_delta);
357
- }
358
-
359
- this.update_blend_state();
360
- }
361
-
362
- /**
363
- * @param {AnimationState} state
364
- * @returns {boolean} `false` when the state was not being simulated
365
- */
366
- stop_state_simulation(state) {
367
- const i = this.simulatedStates.indexOf(state);
368
-
369
- if (i === -1) {
370
- return false;
371
- }
372
-
373
- this.simulatedStates.splice(i, 1);
374
-
375
- return true;
376
- }
377
-
378
- /**
379
- * Recompute per-clip weights from the states and transitions that are running, and the time
380
- * each of those clips is at.
381
- */
382
- update_blend_state() {
383
- const simulated = this.simulatedStates;
384
-
385
- for (let i = 0; i < simulated.length; i++) {
386
- simulated[i].updateBlendState();
387
- }
388
-
389
- const active_transitions = this.activeTransitions;
390
- const transition_count = active_transitions.length;
391
-
392
- const blend = this.blendState;
393
-
394
- if (transition_count === 1) {
395
- const first = active_transitions[0];
396
-
397
- first.updateBlendsState();
398
-
399
- blend.copy(first.blendState);
400
- } else if (transition_count > 1) {
401
- blend.zero();
402
-
403
- for (let i = 0; i < transition_count; i++) {
404
- const active = active_transitions[i];
405
-
406
- active.updateBlendsState();
407
-
408
- blend.add(active.blendState);
409
- }
410
-
411
- blend.weightsMultiplyScalar(1 / transition_count);
412
- } else {
413
- blend.copy(this.state.blendState);
414
- }
415
-
416
- const times = this.#clip_times;
417
-
418
- for (let i = 0; i < simulated.length; i++) {
419
- const state = simulated[i];
420
-
421
- if (state.def.type !== AnimationStateType.Clip) {
422
- continue;
423
- }
424
-
425
- const clip = state.def.motion;
426
-
427
- times[this.def.getClipIndex(clip.def)] = wrap_clip_time(
428
- state.time,
429
- clip.def.duration,
430
- clip.getFlag(AnimationClipFlag.Repeat)
431
- );
432
- }
433
- }
434
-
435
- /**
436
- * Where clip `clip_index` is playing, in seconds from its own start — wrapped for a looping
437
- * clip and clamped for a one-shot, so it is directly what the renderer's clip record holds and
438
- * what a pose query has to be asked at.
439
- *
440
- * Only meaningful for a clip the blend gives weight to; a clip nothing is playing keeps
441
- * whatever time it last stopped at.
442
- *
443
- * @param {number} clip_index
444
- * @returns {number}
445
- */
446
- clip_time(clip_index) {
447
- return this.#clip_times[clip_index];
448
- }
449
-
450
- /**
451
- * @param {AnimationState} state
452
- * @returns {number}
453
- */
454
- #state_clip_duration(state) {
455
- if (state.def.type !== AnimationStateType.Clip) {
456
- return 0;
457
- }
458
-
459
- return state.def.motion.def.duration;
460
- }
461
-
462
- /**
463
- * @param {AnimationState} state
464
- */
465
- enter_state(state) {
466
- this.state = state;
467
-
468
- if (this.simulatedStates.indexOf(state) === -1) {
469
- this.simulatedStates.push(state);
470
- }
471
-
472
- state.activate(this.__entity, this.__dataset);
473
- }
474
-
475
- /**
476
- * @param {AnimationState} state
477
- */
478
- exit_state(state) {
479
- state.deactivate(this.__entity, this.__dataset);
480
- }
481
-
482
- /**
483
- * @param {AnimationState} state
484
- */
485
- activate_state(state) {
486
- this.exit_state(this.state);
487
-
488
- this.enter_state(state);
489
- }
490
-
491
- /**
492
- * Begin a transition that has just fired.
493
- *
494
- * **Named for `AnimationTransition.transition`, which calls it** — the transitions listen to
495
- * ECS events themselves and push the result back here.
496
- *
497
- * @param {AnimationTransition} transition
498
- */
499
- transition(transition) {
500
- this.activeTransitions.push(transition);
501
-
502
- this.activate_state(transition.target);
503
- }
504
- }
505
-
506
- /**
507
- * What the binary serialization registry knows this component by.
508
- *
509
- * The controller is built transiently — `CombatUnitEntityDecorator` constructs one from the
510
- * creature's `animation-graph.json` every time it decorates a unit — so nothing writes one to disk
511
- * and there is no adapter behind this name. It is here because the registry warns on any component
512
- * class that reaches it unnamed, once per boot, printing the whole class source; and because a
513
- * component with no name cannot be told apart from another one later, which is I-13's business
514
- * whether or not it round-trips today.
515
- *
516
- * @type {string}
517
- */
518
- AnimationGraphController.typeName = "AnimationGraphController";
1
+ import { assert } from "../../../core/assert.js";
2
+ import { AnimationClipFlag } from "../../graphics/ecs/animation/animator/AnimationClipFlag.js";
3
+ import { AnimationState } from "../../graphics/ecs/animation/animator/graph/AnimationState.js";
4
+ import { AnimationStateType } from "../../graphics/ecs/animation/animator/graph/AnimationStateType.js";
5
+ import { AnimationTransition } from "../../graphics/ecs/animation/animator/graph/AnimationTransition.js";
6
+ import { wrap_clip_time } from "./wrap_clip_time.js";
7
+
8
+ /**
9
+ * One entity's animation state machine: which state it is in, which transitions are running, what
10
+ * each clip therefore weighs, and — the part the GPU cannot own — what time each of those clips is
11
+ * playing at.
12
+ *
13
+ * **The clock is here and not on the GPU**, and I-4 is what forces it. Shade advances clip time
14
+ * itself in its tick shader, but the time gameplay reads has to be the time the picture is drawn
15
+ * from: notifications fire at authored moments off this clock, and the CPU pose evaluator answers
16
+ * socket queries from it. Two clocks drift, so there is one, and {@link AnimationGraphSystem}
17
+ * writes it down to the renderer with `set_time` rather than letting the GPU advance anything.
18
+ *
19
+ * The state machine itself is not new — `AnimationState`, `AnimationTransition`, `BlendStateMatrix`
20
+ * and the graph definitions are reused as they stand. What is not reused is the three-only half of
21
+ * the legacy `AnimationGraph`: an `AnimationMixer`, the per-clip `AnimationAction`s it owns, and
22
+ * writing weights onto them.
23
+ */
24
+ export class AnimationGraphController {
25
+ /**
26
+ * @type {AnimationGraphDefinition}
27
+ */
28
+ def = null;
29
+
30
+ /**
31
+ * @type {AnimationState[]}
32
+ */
33
+ states = [];
34
+
35
+ /**
36
+ * @type {AnimationTransition[]}
37
+ */
38
+ transitions = [];
39
+
40
+ /**
41
+ * The state the graph is in. During a transition this is already the target — the source stays
42
+ * in {@link simulatedStates} until the transition finishes.
43
+ *
44
+ * @type {AnimationState}
45
+ */
46
+ state = null;
47
+
48
+ /**
49
+ * @type {AnimationTransition[]}
50
+ */
51
+ activeTransitions = [];
52
+
53
+ /**
54
+ * Every state whose clock is running: the current one, plus the sources of transitions that
55
+ * have not finished.
56
+ *
57
+ * @type {AnimationState[]}
58
+ */
59
+ simulatedStates = [];
60
+
61
+ /**
62
+ * Per-clip weights and time scales, in `def.clipIndex` order. The weights are what reaches the
63
+ * GPU; the time scales are consumed here, by {@link AnimationState#tick}, and have no GPU
64
+ * counterpart because the time they scale is already integrated into the state's clock.
65
+ *
66
+ * @type {BlendStateMatrix}
67
+ */
68
+ blendState = null;
69
+
70
+ /**
71
+ * Where in its starting clip the graph begins, as a fraction of that clip's duration.
72
+ *
73
+ * A fraction rather than a time because a clip's duration comes from the model and the model
74
+ * loads long after the entity does. Its purpose is to keep identical units from moving in
75
+ * lockstep, and it is applied once, at {@link link}, without dispatching the notifications it
76
+ * skips over — a unit that spawns mid-stride should not also spawn the footstep it missed.
77
+ *
78
+ * @type {number}
79
+ */
80
+ start_phase = 0;
81
+
82
+ /**
83
+ * The dataset this graph fires its notifications into.
84
+ *
85
+ * **Public, and named with the leading underscores, because `AnimationState.tick` reads it off
86
+ * the graph by exactly that name.** The state classes are reused as they stand, so this is
87
+ * their interface rather than an accident of style.
88
+ *
89
+ * @type {EntityComponentDataset}
90
+ */
91
+ __dataset = null;
92
+
93
+ /**
94
+ * The entity those notifications are addressed to. Read by `AnimationState.tick` — see
95
+ * {@link __dataset}.
96
+ *
97
+ * @type {number}
98
+ */
99
+ __entity = -1;
100
+
101
+ /**
102
+ * @type {boolean}
103
+ */
104
+ #linked = false;
105
+
106
+ /**
107
+ * Playback time of each clip, in `def.clipIndex` order, already wrapped or clamped into the
108
+ * clip's own duration — which is what the renderer's clip record wants, and what a pose query
109
+ * has to agree with.
110
+ *
111
+ * @type {Float64Array}
112
+ */
113
+ #clip_times = new Float64Array(0);
114
+
115
+ /**
116
+ * @returns {boolean}
117
+ */
118
+ get linked() {
119
+ return this.#linked;
120
+ }
121
+
122
+ /**
123
+ * Build the runtime graph — one {@link AnimationState} per state definition, one
124
+ * {@link AnimationTransition} per transition definition, wired to each other.
125
+ *
126
+ * @param {AnimationGraphDefinition} def
127
+ */
128
+ initialize(def) {
129
+ assert.defined(def, 'def');
130
+ assert.equal(this.#linked, false, 'graph is linked');
131
+
132
+ this.def = def;
133
+
134
+ this.blendState = def.createBlendState();
135
+ this.#clip_times = new Float64Array(def.clipIndex.length);
136
+
137
+ const state_definitions = def.states;
138
+ const state_count = state_definitions.length;
139
+
140
+ this.states = [];
141
+
142
+ for (let i = 0; i < state_count; i++) {
143
+ const state = new AnimationState();
144
+
145
+ state.def = state_definitions[i];
146
+ state.graph = this;
147
+
148
+ this.states[i] = state;
149
+ }
150
+
151
+ const transition_definitions = def.transitions;
152
+ const transition_count = transition_definitions.length;
153
+
154
+ this.transitions = [];
155
+
156
+ for (let i = 0; i < transition_count; i++) {
157
+ const transition = new AnimationTransition();
158
+
159
+ transition.def = transition_definitions[i];
160
+ transition.graph = this;
161
+
162
+ this.transitions[i] = transition;
163
+ }
164
+
165
+ this.state = this.state_by_definition(def.startingSate);
166
+
167
+ for (let i = 0; i < transition_count; i++) {
168
+ const transition = this.transitions[i];
169
+
170
+ transition.source = this.state_by_definition(transition.def.source);
171
+ transition.target = this.state_by_definition(transition.def.target);
172
+
173
+ transition.initialize();
174
+ }
175
+
176
+ for (let i = 0; i < state_count; i++) {
177
+ const state = this.states[i];
178
+
179
+ state.inEdges = state.def.inEdges.map(this.transition_by_definition, this);
180
+ state.outEdges = state.def.outEdges.map(this.transition_by_definition, this);
181
+
182
+ state.initialize();
183
+ }
184
+ }
185
+
186
+ /**
187
+ * @param {AnimationStateDefinition} definition
188
+ * @returns {AnimationState|undefined}
189
+ */
190
+ state_by_definition(definition) {
191
+ assert.defined(definition, 'definition');
192
+
193
+ const states = this.states;
194
+
195
+ for (let i = 0; i < states.length; i++) {
196
+ if (states[i].def === definition) {
197
+ return states[i];
198
+ }
199
+ }
200
+
201
+ return undefined;
202
+ }
203
+
204
+ /**
205
+ * @param {string} name
206
+ * @returns {AnimationState|undefined}
207
+ */
208
+ state_by_name(name) {
209
+ const states = this.states;
210
+
211
+ for (let i = 0; i < states.length; i++) {
212
+ if (states[i].def.name === name) {
213
+ return states[i];
214
+ }
215
+ }
216
+
217
+ return undefined;
218
+ }
219
+
220
+ /**
221
+ * @param {string} name name of the clip the state plays
222
+ * @returns {AnimationState|undefined}
223
+ */
224
+ state_by_clip_name(name) {
225
+ const states = this.states;
226
+
227
+ for (let i = 0; i < states.length; i++) {
228
+ const definition = states[i].def;
229
+
230
+ if (definition.type !== AnimationStateType.Clip) {
231
+ continue;
232
+ }
233
+
234
+ if (definition.motion.def.name === name) {
235
+ return states[i];
236
+ }
237
+ }
238
+
239
+ return undefined;
240
+ }
241
+
242
+ /**
243
+ * @param {AnimationTransitionDefinition} definition
244
+ * @returns {AnimationTransition|undefined}
245
+ */
246
+ transition_by_definition(definition) {
247
+ const transitions = this.transitions;
248
+
249
+ for (let i = 0; i < transitions.length; i++) {
250
+ if (transitions[i].def === definition) {
251
+ return transitions[i];
252
+ }
253
+ }
254
+
255
+ return undefined;
256
+ }
257
+
258
+ /**
259
+ * Start the graph: take the clip durations the model turned out to have, enter the starting
260
+ * state, and begin listening for the events its transitions fire on.
261
+ *
262
+ * **Durations arrive here rather than at construction** because they are the model's and not
263
+ * the graph's — `animation-graph.json` names clips, the `.glb` says how long they are — and the
264
+ * notification path needs them to be right before a single frame is ticked. They are written
265
+ * onto the shared clip definitions, which is where {@link AnimationClip} reads them.
266
+ *
267
+ * @param {number} entity
268
+ * @param {EntityComponentDataset} ecd
269
+ * @param {ArrayLike<number>} durations seconds, one per `def.clipIndex` entry, in that order
270
+ */
271
+ link(entity, ecd, durations) {
272
+ assert.isNonNegativeInteger(entity, 'entity');
273
+ assert.defined(ecd, 'ecd');
274
+ assert.equal(this.#linked, false, 'graph is already linked, call unlink first');
275
+
276
+ const clip_index = this.def.clipIndex;
277
+
278
+ assert.equal(durations.length, clip_index.length, 'durations.length');
279
+
280
+ for (let i = 0; i < clip_index.length; i++) {
281
+ clip_index[i].duration = durations[i];
282
+ }
283
+
284
+ this.__entity = entity;
285
+ this.__dataset = ecd;
286
+
287
+ this.#linked = true;
288
+
289
+ this.enter_state(this.state);
290
+
291
+ this.state.time = this.start_phase * this.#state_clip_duration(this.state);
292
+
293
+ this.update_blend_state();
294
+ }
295
+
296
+ /**
297
+ * Stop listening. The graph keeps the state it was in, so a re-link resumes rather than
298
+ * restarts.
299
+ */
300
+ unlink() {
301
+ if (!this.#linked) {
302
+ return;
303
+ }
304
+
305
+ this.exit_state(this.state);
306
+
307
+ this.#linked = false;
308
+ }
309
+
310
+ /**
311
+ * Advance every running clock by `time_delta`, fire whatever notifications were crossed, and
312
+ * recompute the blend.
313
+ *
314
+ * Unconditional by design: §2.6-2's split puts pose evaluation and its events on the CPU
315
+ * precisely so that camera framing cannot decide whether a projectile spawns. The screen-area
316
+ * cull the legacy system applied has no counterpart here.
317
+ *
318
+ * @param {number} time_delta in seconds
319
+ */
320
+ tick(time_delta) {
321
+ assert.equal(this.#linked, true, 'graph is not linked');
322
+
323
+ const active_transitions = this.activeTransitions;
324
+
325
+ let transition_count = active_transitions.length;
326
+
327
+ transitions: for (let i = 0; i < transition_count; i++) {
328
+ const active = active_transitions[i];
329
+
330
+ active.tick(time_delta);
331
+
332
+ if (!active.isFinished()) {
333
+ continue;
334
+ }
335
+
336
+ active_transitions.splice(i, 1);
337
+
338
+ transition_count--;
339
+ i--;
340
+
341
+ for (let j = 0; j < transition_count; j++) {
342
+ const other = active_transitions[j];
343
+
344
+ if (other.source === active.source || other.target === active.source) {
345
+ // the state it came from is still in use by another transition
346
+ continue transitions;
347
+ }
348
+ }
349
+
350
+ this.stop_state_simulation(active.source);
351
+ }
352
+
353
+ const simulated = this.simulatedStates;
354
+
355
+ for (let i = 0; i < simulated.length; i++) {
356
+ simulated[i].tick(time_delta);
357
+ }
358
+
359
+ this.update_blend_state();
360
+ }
361
+
362
+ /**
363
+ * @param {AnimationState} state
364
+ * @returns {boolean} `false` when the state was not being simulated
365
+ */
366
+ stop_state_simulation(state) {
367
+ const i = this.simulatedStates.indexOf(state);
368
+
369
+ if (i === -1) {
370
+ return false;
371
+ }
372
+
373
+ this.simulatedStates.splice(i, 1);
374
+
375
+ return true;
376
+ }
377
+
378
+ /**
379
+ * Recompute per-clip weights from the states and transitions that are running, and the time
380
+ * each of those clips is at.
381
+ */
382
+ update_blend_state() {
383
+ const simulated = this.simulatedStates;
384
+
385
+ for (let i = 0; i < simulated.length; i++) {
386
+ simulated[i].updateBlendState();
387
+ }
388
+
389
+ const active_transitions = this.activeTransitions;
390
+ const transition_count = active_transitions.length;
391
+
392
+ const blend = this.blendState;
393
+
394
+ if (transition_count === 1) {
395
+ const first = active_transitions[0];
396
+
397
+ first.updateBlendsState();
398
+
399
+ blend.copy(first.blendState);
400
+ } else if (transition_count > 1) {
401
+ blend.zero();
402
+
403
+ for (let i = 0; i < transition_count; i++) {
404
+ const active = active_transitions[i];
405
+
406
+ active.updateBlendsState();
407
+
408
+ blend.add(active.blendState);
409
+ }
410
+
411
+ blend.weightsMultiplyScalar(1 / transition_count);
412
+ } else {
413
+ blend.copy(this.state.blendState);
414
+ }
415
+
416
+ const times = this.#clip_times;
417
+
418
+ for (let i = 0; i < simulated.length; i++) {
419
+ const state = simulated[i];
420
+
421
+ if (state.def.type !== AnimationStateType.Clip) {
422
+ continue;
423
+ }
424
+
425
+ const clip = state.def.motion;
426
+
427
+ times[this.def.getClipIndex(clip.def)] = wrap_clip_time(
428
+ state.time,
429
+ clip.def.duration,
430
+ clip.getFlag(AnimationClipFlag.Repeat)
431
+ );
432
+ }
433
+ }
434
+
435
+ /**
436
+ * Where clip `clip_index` is playing, in seconds from its own start — wrapped for a looping
437
+ * clip and clamped for a one-shot, so it is directly what the renderer's clip record holds and
438
+ * what a pose query has to be asked at.
439
+ *
440
+ * Only meaningful for a clip the blend gives weight to; a clip nothing is playing keeps
441
+ * whatever time it last stopped at.
442
+ *
443
+ * @param {number} clip_index
444
+ * @returns {number}
445
+ */
446
+ clip_time(clip_index) {
447
+ return this.#clip_times[clip_index];
448
+ }
449
+
450
+ /**
451
+ * @param {AnimationState} state
452
+ * @returns {number}
453
+ */
454
+ #state_clip_duration(state) {
455
+ if (state.def.type !== AnimationStateType.Clip) {
456
+ return 0;
457
+ }
458
+
459
+ return state.def.motion.def.duration;
460
+ }
461
+
462
+ /**
463
+ * @param {AnimationState} state
464
+ */
465
+ enter_state(state) {
466
+ this.state = state;
467
+
468
+ if (this.simulatedStates.indexOf(state) === -1) {
469
+ this.simulatedStates.push(state);
470
+ }
471
+
472
+ state.activate(this.__entity, this.__dataset);
473
+ }
474
+
475
+ /**
476
+ * @param {AnimationState} state
477
+ */
478
+ exit_state(state) {
479
+ state.deactivate(this.__entity, this.__dataset);
480
+ }
481
+
482
+ /**
483
+ * @param {AnimationState} state
484
+ */
485
+ activate_state(state) {
486
+ this.exit_state(this.state);
487
+
488
+ this.enter_state(state);
489
+ }
490
+
491
+ /**
492
+ * Begin a transition that has just fired.
493
+ *
494
+ * **Named for `AnimationTransition.transition`, which calls it** — the transitions listen to
495
+ * ECS events themselves and push the result back here.
496
+ *
497
+ * @param {AnimationTransition} transition
498
+ */
499
+ transition(transition) {
500
+ this.activeTransitions.push(transition);
501
+
502
+ this.activate_state(transition.target);
503
+ }
504
+ }
505
+
506
+ /**
507
+ * What the binary serialization registry knows this component by.
508
+ *
509
+ * The controller is built transiently — `CombatUnitEntityDecorator` constructs one from the
510
+ * creature's `animation-graph.json` every time it decorates a unit — so nothing writes one to disk
511
+ * and there is no adapter behind this name. It is here because the registry warns on any component
512
+ * class that reaches it unnamed, once per boot, printing the whole class source; and because a
513
+ * component with no name cannot be told apart from another one later, which is I-13's business
514
+ * whether or not it round-trips today.
515
+ *
516
+ * @type {string}
517
+ */
518
+ AnimationGraphController.typeName = "AnimationGraphController";