@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,971 +1,971 @@
1
- import { assert } from "../../../src/core/assert.js";
2
- import Quaternion from "../../../src/core/geom/Quaternion.js";
3
- import Vector3 from "../../../src/core/geom/Vector3.js";
4
- import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
5
- import { FrameRunner } from "../../../src/engine/graphics/FrameRunner.js";
6
- import { GizmoNode } from "./GizmoNode.js";
7
- import { gizmo_drag_plane_normal, gizmo_ray_plane_point } from "./handle/gizmo_drag_plane.js";
8
- import { gizmo_draw } from "./handle/gizmo_draw.js";
9
- import { gizmo_handles_of_mode, gizmo_pick_handle } from "./handle/gizmo_handles.js";
10
- import { TransformMode } from "./TransformMode.js";
11
-
12
- /**
13
- * @type {Object<string, Vector3>}
14
- */
15
- const UNIT = {
16
- X: new Vector3(1, 0, 0),
17
- Y: new Vector3(0, 1, 0),
18
- Z: new Vector3(0, 0, 1)
19
- };
20
-
21
- /**
22
- * How fast a free rotation follows the pointer, in radians per world unit at one unit from the
23
- * camera. Carried over from the three gizmo unchanged, because it is a feel and not a derivation.
24
- *
25
- * @type {number}
26
- */
27
- const ROTATION_SPEED = 20;
28
-
29
- /**
30
- * The largest the gizmo is allowed to grow relative to its distance, which caps how big a very wide
31
- * field of view can make it. three's number, kept for the same reason.
32
- *
33
- * @type {number}
34
- */
35
- const SIZE_CLAMP = 7;
36
-
37
- const _changeEvent = { type: 'change' };
38
- const _mouseDownEvent = { type: 'mouseDown', mode: null };
39
- const _mouseUpEvent = { type: 'mouseUp', mode: null };
40
- const _objectChangeEvent = { type: 'objectChange' };
41
-
42
- /**
43
- * @type {Vector3}
44
- */
45
- const ray_origin = new Vector3();
46
-
47
- /**
48
- * @type {Vector3}
49
- */
50
- const ray_direction = new Vector3();
51
-
52
- /**
53
- * @type {Vector3}
54
- */
55
- const scratch_point = new Vector3();
56
-
57
- /**
58
- * @type {Vector3}
59
- */
60
- const scratch_vector = new Vector3();
61
-
62
- /**
63
- * @type {Vector3}
64
- */
65
- const scratch_vector_2 = new Vector3();
66
-
67
- /**
68
- * @type {Quaternion}
69
- */
70
- const scratch_quaternion = new Quaternion();
71
-
72
- /**
73
- * @readonly
74
- * @type {Transform}
75
- */
76
- const _tempTransform = new Transform();
77
-
78
- /**
79
- * The transform gizmo.
80
- *
81
- * **What it controls is an entity, and what it needs from a renderer is one ray.** Both of those are
82
- * why this can be renderer-neutral at all: `Transform` is world-space by contract, so there is no
83
- * scene graph to walk, and `viewportProjectionRay` is on both graphics engines and answers in world
84
- * space. Everything else — which handle the pointer is on, what surface a drag is measured on, where
85
- * the handles are drawn — is arithmetic, and lives in `handle/`.
86
- *
87
- * The three version answered the first two questions by building meshes and raycasting them: an
88
- * invisible cone per arm, an invisible 100000-unit `PlaneGeometry` per drag. That is why it needed
89
- * a three camera object on the component. It needs none now:
90
- * the ray through the middle of the viewport starts at the eye and points where the camera looks,
91
- * and the ray through the top edge gives the field of view the gizmo is sized against.
92
- *
93
- * The **drag maths is the three version's**, ported to meep `Vector3`/`Quaternion` — this is the
94
- * feel of a tool people have used, not something to redesign. Two things did change:
95
- *
96
- * - the parent transform is gone. It was set to the identity on every update and multiplied through
97
- * the whole of `pointerMove`, because `Transform` is world-space and there is no parent to
98
- * compose with.
99
- * - a drag no longer starts when the drag plane is edge-on to the pointer. three started one anyway,
100
- * from whatever `pointStart` the previous drag left behind.
101
- *
102
- * The three gizmo's `showX`/`showY`/`showZ` are gone with the meshes they hid; nothing in the tree
103
- * set them.
104
- */
105
- class TransformControls extends GizmoNode {
106
- /**
107
- * Entity ID that we are controlling. -1 indicates no entity
108
- * @type {number}
109
- */
110
- object = -1;
111
-
112
- isTransformControls = true;
113
-
114
- /**
115
- * @type {boolean}
116
- */
117
- enabled = true;
118
-
119
- /**
120
- * The handle under the pointer, or the one being dragged. One of the names in
121
- * {@link gizmo_handles_of_mode}, or `null`.
122
- *
123
- * @type {string|null}
124
- */
125
- axis = null;
126
-
127
- /**
128
- * @type {string} one of {@link TransformMode}
129
- */
130
- mode = TransformMode.Translate;
131
-
132
- /**
133
- * @type {string} `'world'` or `'local'`
134
- */
135
- space = 'world';
136
-
137
- /**
138
- * How big the gizmo is drawn, as a multiple of its default screen size.
139
- *
140
- * @type {number}
141
- */
142
- size = 1;
143
-
144
- /**
145
- * @type {boolean}
146
- */
147
- dragging = false;
148
-
149
- /**
150
- * World units per step, or `null` for none.
151
- *
152
- * @type {number|null}
153
- */
154
- translationSnap = null;
155
-
156
- /**
157
- * Radians per step, or `null` for none.
158
- *
159
- * @type {number|null}
160
- */
161
- rotationSnap = null;
162
-
163
- /**
164
- * @type {number|null}
165
- */
166
- scaleSnap = null;
167
-
168
- /**
169
- * @type {Vector3}
170
- */
171
- worldPosition = new Vector3();
172
-
173
- /**
174
- * @type {Quaternion}
175
- */
176
- worldQuaternion = new Quaternion();
177
-
178
- /**
179
- * Where the controlled entity was when the drag started. The tool reads these to build its undo
180
- * state, because by the time it looks the entity has already moved.
181
- *
182
- * @type {Vector3}
183
- */
184
- worldPositionStart = new Vector3();
185
-
186
- /**
187
- * @type {Quaternion}
188
- */
189
- worldQuaternionStart = new Quaternion();
190
-
191
- /**
192
- * @type {Vector3}
193
- */
194
- _worldScaleStart = new Vector3(1, 1, 1);
195
-
196
- /**
197
- * @type {Vector3}
198
- */
199
- _worldScale = new Vector3(1, 1, 1);
200
-
201
- /**
202
- * @type {Quaternion}
203
- */
204
- _worldQuaternionInv = new Quaternion();
205
-
206
- /**
207
- * @type {Vector3}
208
- */
209
- _positionStart = new Vector3();
210
-
211
- /**
212
- * @type {Quaternion}
213
- */
214
- _quaternionStart = new Quaternion();
215
-
216
- /**
217
- * @type {Vector3}
218
- */
219
- _scaleStart = new Vector3(1, 1, 1);
220
-
221
- /**
222
- * Where the pointer met the drag plane when the drag started, relative to the gizmo.
223
- *
224
- * @type {Vector3}
225
- */
226
- pointStart = new Vector3();
227
-
228
- /**
229
- * @type {Vector3}
230
- */
231
- pointEnd = new Vector3();
232
-
233
- /**
234
- * @type {Vector3}
235
- */
236
- _offset = new Vector3();
237
-
238
- /**
239
- * @type {Vector3}
240
- */
241
- _startNorm = new Vector3();
242
-
243
- /**
244
- * @type {Vector3}
245
- */
246
- _endNorm = new Vector3();
247
-
248
- /**
249
- * @type {Vector3}
250
- */
251
- rotationAxis = new Vector3();
252
-
253
- /**
254
- * @type {number}
255
- */
256
- rotationAngle = 0;
257
-
258
- /**
259
- * Where the camera is, and a unit vector from the gizmo towards it.
260
- *
261
- * @type {Vector3}
262
- */
263
- cameraPosition = new Vector3();
264
-
265
- /**
266
- * @type {Vector3}
267
- */
268
- eye = new Vector3(0, 0, 1);
269
-
270
- /**
271
- * The direction the camera looks along.
272
- *
273
- * @type {Vector3}
274
- */
275
- #camera_forward = new Vector3(0, 0, -1);
276
-
277
- /**
278
- * A ray through the top edge of the viewport, which is half a field of view away from
279
- * {@link #camera_forward}.
280
- *
281
- * @type {Vector3}
282
- */
283
- #camera_edge = new Vector3(0, 0, -1);
284
-
285
- /**
286
- * The surface a drag is measured on, rebuilt every update from the current mode, axis, space and
287
- * eye.
288
- *
289
- * A drag measures a delta between two points on this surface, so it would matter if the surface
290
- * moved mid-drag — and it cannot. An arm's plane is built from the part of the eye perpendicular
291
- * to that arm, and moving the object along the arm changes only the part parallel to it; a tile's
292
- * is a basis vector; a free drag's and a rotation's is the view direction. Nothing a drag does to
293
- * the object it is dragging can change any of them.
294
- *
295
- * @type {Vector3}
296
- */
297
- #plane_normal = new Vector3(0, 0, 1);
298
-
299
- /**
300
- * How the handles are turned: the identity in world space, the object's own rotation in local
301
- * space and always in scale mode.
302
- *
303
- * @type {Quaternion}
304
- */
305
- #handle_rotation = new Quaternion();
306
-
307
- /**
308
- * How big the gizmo is in world units, one gizmo unit each.
309
- *
310
- * @type {number}
311
- */
312
- #handle_size = 1;
313
-
314
- /**
315
- * @type {function}
316
- */
317
- #draw;
318
-
319
- /**
320
- * @param {GraphicsEngine|GraphicsEngine3} graphics the only thing a renderer is asked for is
321
- * {@link GraphicsEngine3#viewportProjectionRay} and the `preRender` signal to draw on
322
- * @param {HTMLElement} domElement
323
- * @param {boolean} [autoUpdate] update on a frame loop of its own, rather than being driven
324
- */
325
- constructor(graphics, domElement, autoUpdate = true) {
326
- super();
327
-
328
- assert.defined(graphics, 'graphics');
329
- assert.defined(domElement, 'domElement');
330
-
331
- this.graphics = graphics;
332
- this.domElement = domElement;
333
-
334
- this.domElement.style.touchAction = 'none'; // disable touch scroll
335
-
336
- this.visible = false;
337
-
338
- this._getPointer = getPointer.bind(this);
339
- this._onPointerDown = onPointerDown.bind(this);
340
- this._onPointerHover = onPointerHover.bind(this);
341
- this._onPointerMove = onPointerMove.bind(this);
342
- this._onPointerUp = onPointerUp.bind(this);
343
-
344
- this.domElement.addEventListener('pointerdown', this._onPointerDown);
345
- this.domElement.addEventListener('pointermove', this._onPointerHover);
346
- this.domElement.addEventListener('pointerup', this._onPointerUp);
347
-
348
- this.#draw = () => this.#record();
349
-
350
- if (autoUpdate) {
351
- const fr = new FrameRunner(this.update.bind(this));
352
- this.on.built.add(fr.startup, fr);
353
- this.on.destroyed.add(fr.shutdown, fr);
354
- }
355
- }
356
-
357
- /**
358
- * @param {EntityComponentDataset} ecd
359
- */
360
- build(ecd) {
361
- super.build(ecd);
362
-
363
- this.graphics.on.preRender.add(this.#draw);
364
- }
365
-
366
- /**
367
- * How big one gizmo unit is in world units.
368
- *
369
- * The gizmo is a fixed size on screen, so its world size is the distance to it times the tangent
370
- * of half the vertical field of view — and that tangent comes from the angle between the ray
371
- * through the middle of the viewport and the ray through its top edge, which is the same
372
- * measurement on either renderer and needs no camera object.
373
- *
374
- * A parallel projection has no such angle and would size the gizmo to nothing;
375
- * `viewportProjectionRay` does not describe one on either engine, so nothing here branches on it.
376
- *
377
- * @returns {number}
378
- */
379
- #size_in_world() {
380
- const cos = this.#camera_forward.dot(this.#camera_edge);
381
-
382
- const tan = Math.sqrt(1 - cos * cos) / cos;
383
-
384
- const distance = this.cameraPosition.distanceTo(this.worldPosition);
385
-
386
- return distance * Math.min(1.9 * tan, SIZE_CLAMP) * this.size / 4;
387
- }
388
-
389
- /**
390
- * Key transformation variables, and the drag surface, for this frame.
391
- */
392
- update() {
393
- const graphics = this.graphics;
394
-
395
- // both camera facts come out of the projection itself: the ray through the middle of the
396
- // viewport starts at the eye and points where the camera looks
397
- graphics.viewportProjectionRay(0, 0, this.cameraPosition, this.#camera_forward);
398
- graphics.viewportProjectionRay(0, 1, scratch_point, this.#camera_edge);
399
-
400
- if (this.object !== -1) {
401
-
402
- const object_transform = this.object_transform;
403
-
404
- this.worldPosition.copy(object_transform.position);
405
- this.worldQuaternion.copy(object_transform.rotation);
406
- this._worldScale.copy(object_transform.scale);
407
-
408
- this._worldQuaternionInv.copy(this.worldQuaternion).invert();
409
-
410
- }
411
-
412
- this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize();
413
-
414
- const local = this.mode === TransformMode.Scale || this.space === 'local';
415
-
416
- if (local) {
417
- this.#handle_rotation.copy(this.worldQuaternion);
418
- } else {
419
- this.#handle_rotation.set(0, 0, 0, 1);
420
- }
421
-
422
- this.#handle_size = this.#size_in_world();
423
-
424
- if (this.axis !== null) {
425
- gizmo_drag_plane_normal(
426
- this.#plane_normal,
427
- this.mode, this.axis, this.space,
428
- this.worldQuaternion,
429
- this.eye, this.#camera_forward
430
- );
431
- }
432
-
433
- super.update();
434
- }
435
-
436
- /**
437
- * One frame of the gizmo, onto the debug-draw pass.
438
- */
439
- #record() {
440
- if (!this.visible || this.object === -1) {
441
- return;
442
- }
443
-
444
- gizmo_draw(
445
- this.mode,
446
- this.worldPosition,
447
- this.#handle_rotation,
448
- this.#handle_size,
449
- this.axis,
450
- this.#camera_forward
451
- );
452
- }
453
-
454
- /**
455
- * The world ray under a pointer, into the module's own scratch.
456
- *
457
- * @param {{x:number, y:number}} pointer clip space
458
- */
459
- #pointer_ray(pointer) {
460
- this.graphics.viewportProjectionRay(pointer.x, pointer.y, ray_origin, ray_direction);
461
- }
462
-
463
- pointerHover(pointer) {
464
-
465
- if (this.object === -1 || this.dragging === true) return;
466
-
467
- this.#pointer_ray(pointer);
468
-
469
- this.axis = gizmo_pick_handle(
470
- gizmo_handles_of_mode(this.mode),
471
- ray_origin, ray_direction,
472
- this.worldPosition, this.#handle_rotation, this.#handle_size
473
- );
474
-
475
- }
476
-
477
- pointerDown(pointer) {
478
-
479
- if (this.object === -1 || this.dragging === true || pointer.button !== 0) return;
480
-
481
- if (this.axis === null) return;
482
-
483
- const ot = this.object_transform;
484
-
485
- this.#pointer_ray(pointer);
486
-
487
- gizmo_drag_plane_normal(
488
- this.#plane_normal,
489
- this.mode, this.axis, this.space,
490
- ot.rotation,
491
- this.eye, this.#camera_forward
492
- );
493
-
494
- if (!gizmo_ray_plane_point(
495
- scratch_point, ray_origin, ray_direction, ot.position, this.#plane_normal
496
- )) {
497
- // the drag surface is edge-on to the pointer, so there is no point on it to drag from
498
- return;
499
- }
500
-
501
- this._positionStart.copy(ot.position);
502
- this._quaternionStart.copy(ot.rotation);
503
- this._scaleStart.copy(ot.scale);
504
-
505
- this.worldPositionStart.copy(ot.position);
506
- this.worldQuaternionStart.copy(ot.rotation);
507
- this._worldScaleStart.copy(ot.scale);
508
-
509
- this.pointStart.copy(scratch_point).sub(this.worldPositionStart);
510
-
511
- this.dragging = true;
512
-
513
- _mouseDownEvent.mode = this.mode;
514
- this.dispatchEvent(_mouseDownEvent);
515
-
516
- }
517
-
518
- /**
519
- *
520
- * @param {{type:string}} event
521
- */
522
- dispatchEvent(event) {
523
- this.entity.sendEvent(event.type, event);
524
- }
525
-
526
- pointerMove(pointer) {
527
-
528
- const axis = this.axis;
529
- const mode = this.mode;
530
- const object = this.object;
531
-
532
- let space = this.space;
533
-
534
- if (mode === TransformMode.Scale) {
535
-
536
- space = 'local';
537
-
538
- } else if (axis === 'E' || axis === 'XYZE' || axis === 'XYZ') {
539
-
540
- space = 'world';
541
-
542
- }
543
-
544
- if (object === -1 || axis === null || this.dragging === false || pointer.button !== -1) return;
545
-
546
- const object_transform = this.object_transform;
547
-
548
- this.#pointer_ray(pointer);
549
-
550
- if (!gizmo_ray_plane_point(
551
- scratch_point, ray_origin, ray_direction, this.worldPositionStart, this.#plane_normal
552
- )) {
553
- return;
554
- }
555
-
556
- this.pointEnd.copy(scratch_point).sub(this.worldPositionStart);
557
-
558
- if (mode === TransformMode.Translate) {
559
-
560
- // Apply translate
561
-
562
- this._offset.copy(this.pointEnd).sub(this.pointStart);
563
-
564
- if (space === 'local' && axis !== 'XYZ') {
565
-
566
- this._offset.applyQuaternion(this._worldQuaternionInv);
567
-
568
- }
569
-
570
- if (axis.indexOf('X') === -1) this._offset.x = 0;
571
- if (axis.indexOf('Y') === -1) this._offset.y = 0;
572
- if (axis.indexOf('Z') === -1) this._offset.z = 0;
573
-
574
- if (space === 'local' && axis !== 'XYZ') {
575
-
576
- this._offset.applyQuaternion(this._quaternionStart);
577
-
578
- }
579
-
580
- _tempTransform.position.copy(this._offset);
581
- _tempTransform.position.add(this._positionStart);
582
-
583
- // Apply translation snap; snapping operates on the candidate position — the
584
- // controlled object is an entity id, Transforms are world-space by contract
585
- if (this.translationSnap) {
586
-
587
- if (space === 'local') {
588
-
589
- _tempTransform.position.applyQuaternion(
590
- scratch_quaternion.copy(this._quaternionStart).invert()
591
- );
592
-
593
- }
594
-
595
- if (axis.search('X') !== -1) {
596
-
597
- _tempTransform.position.setX(Math.round(_tempTransform.position.x / this.translationSnap) * this.translationSnap);
598
-
599
- }
600
-
601
- if (axis.search('Y') !== -1) {
602
-
603
- _tempTransform.position.setY(Math.round(_tempTransform.position.y / this.translationSnap) * this.translationSnap);
604
-
605
- }
606
-
607
- if (axis.search('Z') !== -1) {
608
-
609
- _tempTransform.position.setZ(Math.round(_tempTransform.position.z / this.translationSnap) * this.translationSnap);
610
-
611
- }
612
-
613
- if (space === 'local') {
614
-
615
- _tempTransform.position.applyQuaternion(this._quaternionStart);
616
-
617
- }
618
-
619
- }
620
-
621
- // write
622
- object_transform.position.copy(_tempTransform.position);
623
-
624
- } else if (mode === TransformMode.Scale) {
625
-
626
- if (axis.search('XYZ') !== -1) {
627
-
628
- let d = this.pointEnd.length() / this.pointStart.length();
629
-
630
- if (this.pointEnd.dot(this.pointStart) < 0) d *= -1;
631
-
632
- scratch_vector_2.set(d, d, d);
633
-
634
- } else {
635
-
636
- scratch_vector.copy(this.pointStart);
637
- scratch_vector_2.copy(this.pointEnd);
638
-
639
- scratch_vector.applyQuaternion(this._worldQuaternionInv);
640
- scratch_vector_2.applyQuaternion(this._worldQuaternionInv);
641
-
642
- scratch_vector_2.divide(scratch_vector);
643
-
644
- if (axis.search('X') === -1) {
645
-
646
- scratch_vector_2.x = 1;
647
-
648
- }
649
-
650
- if (axis.search('Y') === -1) {
651
-
652
- scratch_vector_2.y = 1;
653
-
654
- }
655
-
656
- if (axis.search('Z') === -1) {
657
-
658
- scratch_vector_2.z = 1;
659
-
660
- }
661
-
662
- }
663
-
664
- // Apply scale
665
-
666
- _tempTransform.scale.copy(this._scaleStart);
667
- _tempTransform.scale.multiply(scratch_vector_2);
668
-
669
- if (this.scaleSnap) {
670
-
671
- if (axis.search('X') !== -1) {
672
-
673
- _tempTransform.scale.setX(Math.round(_tempTransform.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap);
674
-
675
- }
676
-
677
- if (axis.search('Y') !== -1) {
678
-
679
- _tempTransform.scale.setY(Math.round(_tempTransform.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap);
680
-
681
- }
682
-
683
- if (axis.search('Z') !== -1) {
684
-
685
- _tempTransform.scale.setZ(Math.round(_tempTransform.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap);
686
-
687
- }
688
-
689
- }
690
-
691
- object_transform.scale.copy(_tempTransform.scale);
692
-
693
- } else if (mode === TransformMode.Rotate) {
694
-
695
- this._offset.copy(this.pointEnd).sub(this.pointStart);
696
-
697
- const speed = ROTATION_SPEED / this.worldPosition.distanceTo(this.cameraPosition);
698
-
699
- if (axis === 'E') {
700
-
701
- this.rotationAxis.copy(this.eye);
702
- this.rotationAngle = this.pointEnd.angleTo(this.pointStart);
703
-
704
- this._startNorm.copy(this.pointStart).normalize();
705
- this._endNorm.copy(this.pointEnd).normalize();
706
-
707
- this.rotationAngle *= (this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1);
708
-
709
- } else if (axis === 'XYZE') {
710
-
711
- this.rotationAxis.copy(this._offset).cross(this.eye).normalize();
712
- this.rotationAngle = this._offset.dot(scratch_vector.copy(this.rotationAxis).cross(this.eye)) * speed;
713
-
714
- } else if (axis === 'X' || axis === 'Y' || axis === 'Z') {
715
-
716
- this.rotationAxis.copy(UNIT[axis]);
717
-
718
- scratch_vector.copy(UNIT[axis]);
719
-
720
- if (space === 'local') {
721
-
722
- scratch_vector.applyQuaternion(this.worldQuaternion);
723
-
724
- }
725
-
726
- this.rotationAngle = this._offset.dot(scratch_vector.cross(this.eye).normalize()) * speed;
727
-
728
- }
729
-
730
- // Apply rotation snap
731
-
732
- if (this.rotationSnap) this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap;
733
-
734
- // Apply rotate
735
- if (space === 'local' && axis !== 'E' && axis !== 'XYZE') {
736
-
737
- _tempTransform.rotation.copy(this._quaternionStart);
738
- _tempTransform.rotation.multiply(
739
- scratch_quaternion.fromAxisAngle(this.rotationAxis, this.rotationAngle)
740
- ).normalize();
741
-
742
- } else {
743
-
744
- _tempTransform.rotation.copy(
745
- scratch_quaternion.fromAxisAngle(this.rotationAxis, this.rotationAngle)
746
- );
747
- _tempTransform.rotation.multiply(this._quaternionStart);
748
- _tempTransform.rotation.normalize();
749
-
750
- }
751
-
752
- object_transform.rotation.copy(_tempTransform.rotation);
753
- }
754
-
755
- this.dispatchEvent(_changeEvent);
756
- this.dispatchEvent(_objectChangeEvent);
757
-
758
- }
759
-
760
- pointerUp(pointer) {
761
-
762
- if (pointer.button !== 0) return;
763
-
764
- if (this.dragging && (this.axis !== null)) {
765
-
766
- _mouseUpEvent.mode = this.mode;
767
- this.dispatchEvent(_mouseUpEvent);
768
-
769
- }
770
-
771
- this.dragging = false;
772
- this.axis = null;
773
-
774
- }
775
-
776
- dispose() {
777
-
778
- this.domElement.removeEventListener('pointerdown', this._onPointerDown);
779
- this.domElement.removeEventListener('pointermove', this._onPointerHover);
780
- this.domElement.removeEventListener('pointermove', this._onPointerMove);
781
- this.domElement.removeEventListener('pointerup', this._onPointerUp);
782
-
783
- this.graphics.on.preRender.remove(this.#draw);
784
-
785
- }
786
-
787
- /**
788
- * Set current object
789
- * @param {number} entity
790
- * @returns {TransformControls}
791
- */
792
- attach(entity) {
793
- assert.isNonNegativeInteger(entity, 'entity');
794
-
795
- this.object = entity;
796
-
797
- this.visible = true;
798
-
799
- return this;
800
-
801
- }
802
-
803
- /**
804
- *
805
- * @returns {Transform|undefined}
806
- */
807
- get object_transform() {
808
- const ecd = this.entity.dataset;
809
-
810
- return ecd.getComponent(this.object, Transform);
811
- }
812
-
813
- // Detatch from object
814
- detach() {
815
-
816
- this.object = -1;
817
-
818
- this.visible = false;
819
- this.axis = null;
820
-
821
- // a drag in flight has no target anymore
822
- this.dragging = false;
823
-
824
- return this;
825
-
826
- }
827
-
828
- reset() {
829
-
830
- if (!this.enabled) return;
831
-
832
- if (this.dragging) {
833
-
834
- this.object_transform.position.copy(this._positionStart);
835
- this.object_transform.rotation.copy(this._quaternionStart);
836
- this.object_transform.scale.copy(this._scaleStart);
837
-
838
- this.dispatchEvent(_changeEvent);
839
- this.dispatchEvent(_objectChangeEvent);
840
-
841
- this.pointStart.copy(this.pointEnd);
842
-
843
- }
844
-
845
- }
846
-
847
- // TODO: deprecate
848
-
849
- getMode() {
850
-
851
- return this.mode;
852
-
853
- }
854
-
855
- setMode(mode) {
856
-
857
- this.mode = mode;
858
-
859
- }
860
-
861
- setTranslationSnap(translationSnap) {
862
-
863
- this.translationSnap = translationSnap;
864
-
865
- }
866
-
867
- setRotationSnap(rotationSnap) {
868
-
869
- this.rotationSnap = rotationSnap;
870
-
871
- }
872
-
873
- setScaleSnap(scaleSnap) {
874
-
875
- this.scaleSnap = scaleSnap;
876
-
877
- }
878
-
879
- setSize(size) {
880
-
881
- this.size = size;
882
-
883
- }
884
-
885
- setSpace(space) {
886
-
887
- this.space = space;
888
-
889
- }
890
-
891
- }
892
-
893
- // mouse / touch event handlers
894
-
895
- function getPointer(event) {
896
-
897
- if (this.domElement.ownerDocument.pointerLockElement) {
898
-
899
- return {
900
- x: 0,
901
- y: 0,
902
- button: event.button
903
- };
904
-
905
- } else {
906
-
907
- const rect = this.domElement.getBoundingClientRect();
908
-
909
- return {
910
- x: (event.clientX - rect.left) / rect.width * 2 - 1,
911
- y: -(event.clientY - rect.top) / rect.height * 2 + 1,
912
- button: event.button
913
- };
914
-
915
- }
916
-
917
- }
918
-
919
- function onPointerHover(event) {
920
-
921
- if (!this.enabled) return;
922
-
923
- switch (event.pointerType) {
924
-
925
- case 'mouse':
926
- case 'pen':
927
- this.pointerHover(this._getPointer(event));
928
- break;
929
-
930
- }
931
-
932
- }
933
-
934
- function onPointerDown(event) {
935
-
936
- if (!this.enabled) return;
937
-
938
- if (!document.pointerLockElement) {
939
-
940
- this.domElement.setPointerCapture(event.pointerId);
941
-
942
- }
943
-
944
- this.domElement.addEventListener('pointermove', this._onPointerMove);
945
-
946
- this.pointerHover(this._getPointer(event));
947
- this.pointerDown(this._getPointer(event));
948
-
949
- }
950
-
951
- function onPointerMove(event) {
952
-
953
- if (!this.enabled) return;
954
-
955
- this.pointerMove(this._getPointer(event));
956
-
957
- }
958
-
959
- function onPointerUp(event) {
960
-
961
- if (!this.enabled) return;
962
-
963
- this.domElement.releasePointerCapture(event.pointerId);
964
-
965
- this.domElement.removeEventListener('pointermove', this._onPointerMove);
966
-
967
- this.pointerUp(this._getPointer(event));
968
-
969
- }
970
-
971
- export { TransformControls };
1
+ import { assert } from "../../../src/core/assert.js";
2
+ import Quaternion from "../../../src/core/geom/Quaternion.js";
3
+ import Vector3 from "../../../src/core/geom/Vector3.js";
4
+ import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
5
+ import { FrameRunner } from "../../../src/engine/graphics/FrameRunner.js";
6
+ import { GizmoNode } from "./GizmoNode.js";
7
+ import { gizmo_drag_plane_normal, gizmo_ray_plane_point } from "./handle/gizmo_drag_plane.js";
8
+ import { gizmo_draw } from "./handle/gizmo_draw.js";
9
+ import { gizmo_handles_of_mode, gizmo_pick_handle } from "./handle/gizmo_handles.js";
10
+ import { TransformMode } from "./TransformMode.js";
11
+
12
+ /**
13
+ * @type {Object<string, Vector3>}
14
+ */
15
+ const UNIT = {
16
+ X: new Vector3(1, 0, 0),
17
+ Y: new Vector3(0, 1, 0),
18
+ Z: new Vector3(0, 0, 1)
19
+ };
20
+
21
+ /**
22
+ * How fast a free rotation follows the pointer, in radians per world unit at one unit from the
23
+ * camera. Carried over from the three gizmo unchanged, because it is a feel and not a derivation.
24
+ *
25
+ * @type {number}
26
+ */
27
+ const ROTATION_SPEED = 20;
28
+
29
+ /**
30
+ * The largest the gizmo is allowed to grow relative to its distance, which caps how big a very wide
31
+ * field of view can make it. three's number, kept for the same reason.
32
+ *
33
+ * @type {number}
34
+ */
35
+ const SIZE_CLAMP = 7;
36
+
37
+ const _changeEvent = { type: 'change' };
38
+ const _mouseDownEvent = { type: 'mouseDown', mode: null };
39
+ const _mouseUpEvent = { type: 'mouseUp', mode: null };
40
+ const _objectChangeEvent = { type: 'objectChange' };
41
+
42
+ /**
43
+ * @type {Vector3}
44
+ */
45
+ const ray_origin = new Vector3();
46
+
47
+ /**
48
+ * @type {Vector3}
49
+ */
50
+ const ray_direction = new Vector3();
51
+
52
+ /**
53
+ * @type {Vector3}
54
+ */
55
+ const scratch_point = new Vector3();
56
+
57
+ /**
58
+ * @type {Vector3}
59
+ */
60
+ const scratch_vector = new Vector3();
61
+
62
+ /**
63
+ * @type {Vector3}
64
+ */
65
+ const scratch_vector_2 = new Vector3();
66
+
67
+ /**
68
+ * @type {Quaternion}
69
+ */
70
+ const scratch_quaternion = new Quaternion();
71
+
72
+ /**
73
+ * @readonly
74
+ * @type {Transform}
75
+ */
76
+ const _tempTransform = new Transform();
77
+
78
+ /**
79
+ * The transform gizmo.
80
+ *
81
+ * **What it controls is an entity, and what it needs from a renderer is one ray.** Both of those are
82
+ * why this can be renderer-neutral at all: `Transform` is world-space by contract, so there is no
83
+ * scene graph to walk, and `viewportProjectionRay` is on both graphics engines and answers in world
84
+ * space. Everything else — which handle the pointer is on, what surface a drag is measured on, where
85
+ * the handles are drawn — is arithmetic, and lives in `handle/`.
86
+ *
87
+ * The three version answered the first two questions by building meshes and raycasting them: an
88
+ * invisible cone per arm, an invisible 100000-unit `PlaneGeometry` per drag. That is why it needed
89
+ * a three camera object on the component. It needs none now:
90
+ * the ray through the middle of the viewport starts at the eye and points where the camera looks,
91
+ * and the ray through the top edge gives the field of view the gizmo is sized against.
92
+ *
93
+ * The **drag maths is the three version's**, ported to meep `Vector3`/`Quaternion` — this is the
94
+ * feel of a tool people have used, not something to redesign. Two things did change:
95
+ *
96
+ * - the parent transform is gone. It was set to the identity on every update and multiplied through
97
+ * the whole of `pointerMove`, because `Transform` is world-space and there is no parent to
98
+ * compose with.
99
+ * - a drag no longer starts when the drag plane is edge-on to the pointer. three started one anyway,
100
+ * from whatever `pointStart` the previous drag left behind.
101
+ *
102
+ * The three gizmo's `showX`/`showY`/`showZ` are gone with the meshes they hid; nothing in the tree
103
+ * set them.
104
+ */
105
+ class TransformControls extends GizmoNode {
106
+ /**
107
+ * Entity ID that we are controlling. -1 indicates no entity
108
+ * @type {number}
109
+ */
110
+ object = -1;
111
+
112
+ isTransformControls = true;
113
+
114
+ /**
115
+ * @type {boolean}
116
+ */
117
+ enabled = true;
118
+
119
+ /**
120
+ * The handle under the pointer, or the one being dragged. One of the names in
121
+ * {@link gizmo_handles_of_mode}, or `null`.
122
+ *
123
+ * @type {string|null}
124
+ */
125
+ axis = null;
126
+
127
+ /**
128
+ * @type {string} one of {@link TransformMode}
129
+ */
130
+ mode = TransformMode.Translate;
131
+
132
+ /**
133
+ * @type {string} `'world'` or `'local'`
134
+ */
135
+ space = 'world';
136
+
137
+ /**
138
+ * How big the gizmo is drawn, as a multiple of its default screen size.
139
+ *
140
+ * @type {number}
141
+ */
142
+ size = 1;
143
+
144
+ /**
145
+ * @type {boolean}
146
+ */
147
+ dragging = false;
148
+
149
+ /**
150
+ * World units per step, or `null` for none.
151
+ *
152
+ * @type {number|null}
153
+ */
154
+ translationSnap = null;
155
+
156
+ /**
157
+ * Radians per step, or `null` for none.
158
+ *
159
+ * @type {number|null}
160
+ */
161
+ rotationSnap = null;
162
+
163
+ /**
164
+ * @type {number|null}
165
+ */
166
+ scaleSnap = null;
167
+
168
+ /**
169
+ * @type {Vector3}
170
+ */
171
+ worldPosition = new Vector3();
172
+
173
+ /**
174
+ * @type {Quaternion}
175
+ */
176
+ worldQuaternion = new Quaternion();
177
+
178
+ /**
179
+ * Where the controlled entity was when the drag started. The tool reads these to build its undo
180
+ * state, because by the time it looks the entity has already moved.
181
+ *
182
+ * @type {Vector3}
183
+ */
184
+ worldPositionStart = new Vector3();
185
+
186
+ /**
187
+ * @type {Quaternion}
188
+ */
189
+ worldQuaternionStart = new Quaternion();
190
+
191
+ /**
192
+ * @type {Vector3}
193
+ */
194
+ _worldScaleStart = new Vector3(1, 1, 1);
195
+
196
+ /**
197
+ * @type {Vector3}
198
+ */
199
+ _worldScale = new Vector3(1, 1, 1);
200
+
201
+ /**
202
+ * @type {Quaternion}
203
+ */
204
+ _worldQuaternionInv = new Quaternion();
205
+
206
+ /**
207
+ * @type {Vector3}
208
+ */
209
+ _positionStart = new Vector3();
210
+
211
+ /**
212
+ * @type {Quaternion}
213
+ */
214
+ _quaternionStart = new Quaternion();
215
+
216
+ /**
217
+ * @type {Vector3}
218
+ */
219
+ _scaleStart = new Vector3(1, 1, 1);
220
+
221
+ /**
222
+ * Where the pointer met the drag plane when the drag started, relative to the gizmo.
223
+ *
224
+ * @type {Vector3}
225
+ */
226
+ pointStart = new Vector3();
227
+
228
+ /**
229
+ * @type {Vector3}
230
+ */
231
+ pointEnd = new Vector3();
232
+
233
+ /**
234
+ * @type {Vector3}
235
+ */
236
+ _offset = new Vector3();
237
+
238
+ /**
239
+ * @type {Vector3}
240
+ */
241
+ _startNorm = new Vector3();
242
+
243
+ /**
244
+ * @type {Vector3}
245
+ */
246
+ _endNorm = new Vector3();
247
+
248
+ /**
249
+ * @type {Vector3}
250
+ */
251
+ rotationAxis = new Vector3();
252
+
253
+ /**
254
+ * @type {number}
255
+ */
256
+ rotationAngle = 0;
257
+
258
+ /**
259
+ * Where the camera is, and a unit vector from the gizmo towards it.
260
+ *
261
+ * @type {Vector3}
262
+ */
263
+ cameraPosition = new Vector3();
264
+
265
+ /**
266
+ * @type {Vector3}
267
+ */
268
+ eye = new Vector3(0, 0, 1);
269
+
270
+ /**
271
+ * The direction the camera looks along.
272
+ *
273
+ * @type {Vector3}
274
+ */
275
+ #camera_forward = new Vector3(0, 0, -1);
276
+
277
+ /**
278
+ * A ray through the top edge of the viewport, which is half a field of view away from
279
+ * {@link #camera_forward}.
280
+ *
281
+ * @type {Vector3}
282
+ */
283
+ #camera_edge = new Vector3(0, 0, -1);
284
+
285
+ /**
286
+ * The surface a drag is measured on, rebuilt every update from the current mode, axis, space and
287
+ * eye.
288
+ *
289
+ * A drag measures a delta between two points on this surface, so it would matter if the surface
290
+ * moved mid-drag — and it cannot. An arm's plane is built from the part of the eye perpendicular
291
+ * to that arm, and moving the object along the arm changes only the part parallel to it; a tile's
292
+ * is a basis vector; a free drag's and a rotation's is the view direction. Nothing a drag does to
293
+ * the object it is dragging can change any of them.
294
+ *
295
+ * @type {Vector3}
296
+ */
297
+ #plane_normal = new Vector3(0, 0, 1);
298
+
299
+ /**
300
+ * How the handles are turned: the identity in world space, the object's own rotation in local
301
+ * space and always in scale mode.
302
+ *
303
+ * @type {Quaternion}
304
+ */
305
+ #handle_rotation = new Quaternion();
306
+
307
+ /**
308
+ * How big the gizmo is in world units, one gizmo unit each.
309
+ *
310
+ * @type {number}
311
+ */
312
+ #handle_size = 1;
313
+
314
+ /**
315
+ * @type {function}
316
+ */
317
+ #draw;
318
+
319
+ /**
320
+ * @param {GraphicsEngine|GraphicsEngine} graphics the only thing a renderer is asked for is
321
+ * {@link GraphicsEngine#viewportProjectionRay} and the `preRender` signal to draw on
322
+ * @param {HTMLElement} domElement
323
+ * @param {boolean} [autoUpdate] update on a frame loop of its own, rather than being driven
324
+ */
325
+ constructor(graphics, domElement, autoUpdate = true) {
326
+ super();
327
+
328
+ assert.defined(graphics, 'graphics');
329
+ assert.defined(domElement, 'domElement');
330
+
331
+ this.graphics = graphics;
332
+ this.domElement = domElement;
333
+
334
+ this.domElement.style.touchAction = 'none'; // disable touch scroll
335
+
336
+ this.visible = false;
337
+
338
+ this._getPointer = getPointer.bind(this);
339
+ this._onPointerDown = onPointerDown.bind(this);
340
+ this._onPointerHover = onPointerHover.bind(this);
341
+ this._onPointerMove = onPointerMove.bind(this);
342
+ this._onPointerUp = onPointerUp.bind(this);
343
+
344
+ this.domElement.addEventListener('pointerdown', this._onPointerDown);
345
+ this.domElement.addEventListener('pointermove', this._onPointerHover);
346
+ this.domElement.addEventListener('pointerup', this._onPointerUp);
347
+
348
+ this.#draw = () => this.#record();
349
+
350
+ if (autoUpdate) {
351
+ const fr = new FrameRunner(this.update.bind(this));
352
+ this.on.built.add(fr.startup, fr);
353
+ this.on.destroyed.add(fr.shutdown, fr);
354
+ }
355
+ }
356
+
357
+ /**
358
+ * @param {EntityComponentDataset} ecd
359
+ */
360
+ build(ecd) {
361
+ super.build(ecd);
362
+
363
+ this.graphics.on.preRender.add(this.#draw);
364
+ }
365
+
366
+ /**
367
+ * How big one gizmo unit is in world units.
368
+ *
369
+ * The gizmo is a fixed size on screen, so its world size is the distance to it times the tangent
370
+ * of half the vertical field of view — and that tangent comes from the angle between the ray
371
+ * through the middle of the viewport and the ray through its top edge, which is the same
372
+ * measurement on either renderer and needs no camera object.
373
+ *
374
+ * A parallel projection has no such angle and would size the gizmo to nothing;
375
+ * `viewportProjectionRay` does not describe one on either engine, so nothing here branches on it.
376
+ *
377
+ * @returns {number}
378
+ */
379
+ #size_in_world() {
380
+ const cos = this.#camera_forward.dot(this.#camera_edge);
381
+
382
+ const tan = Math.sqrt(1 - cos * cos) / cos;
383
+
384
+ const distance = this.cameraPosition.distanceTo(this.worldPosition);
385
+
386
+ return distance * Math.min(1.9 * tan, SIZE_CLAMP) * this.size / 4;
387
+ }
388
+
389
+ /**
390
+ * Key transformation variables, and the drag surface, for this frame.
391
+ */
392
+ update() {
393
+ const graphics = this.graphics;
394
+
395
+ // both camera facts come out of the projection itself: the ray through the middle of the
396
+ // viewport starts at the eye and points where the camera looks
397
+ graphics.viewportProjectionRay(0, 0, this.cameraPosition, this.#camera_forward);
398
+ graphics.viewportProjectionRay(0, 1, scratch_point, this.#camera_edge);
399
+
400
+ if (this.object !== -1) {
401
+
402
+ const object_transform = this.object_transform;
403
+
404
+ this.worldPosition.copy(object_transform.position);
405
+ this.worldQuaternion.copy(object_transform.rotation);
406
+ this._worldScale.copy(object_transform.scale);
407
+
408
+ this._worldQuaternionInv.copy(this.worldQuaternion).invert();
409
+
410
+ }
411
+
412
+ this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize();
413
+
414
+ const local = this.mode === TransformMode.Scale || this.space === 'local';
415
+
416
+ if (local) {
417
+ this.#handle_rotation.copy(this.worldQuaternion);
418
+ } else {
419
+ this.#handle_rotation.set(0, 0, 0, 1);
420
+ }
421
+
422
+ this.#handle_size = this.#size_in_world();
423
+
424
+ if (this.axis !== null) {
425
+ gizmo_drag_plane_normal(
426
+ this.#plane_normal,
427
+ this.mode, this.axis, this.space,
428
+ this.worldQuaternion,
429
+ this.eye, this.#camera_forward
430
+ );
431
+ }
432
+
433
+ super.update();
434
+ }
435
+
436
+ /**
437
+ * One frame of the gizmo, onto the debug-draw pass.
438
+ */
439
+ #record() {
440
+ if (!this.visible || this.object === -1) {
441
+ return;
442
+ }
443
+
444
+ gizmo_draw(
445
+ this.mode,
446
+ this.worldPosition,
447
+ this.#handle_rotation,
448
+ this.#handle_size,
449
+ this.axis,
450
+ this.#camera_forward
451
+ );
452
+ }
453
+
454
+ /**
455
+ * The world ray under a pointer, into the module's own scratch.
456
+ *
457
+ * @param {{x:number, y:number}} pointer clip space
458
+ */
459
+ #pointer_ray(pointer) {
460
+ this.graphics.viewportProjectionRay(pointer.x, pointer.y, ray_origin, ray_direction);
461
+ }
462
+
463
+ pointerHover(pointer) {
464
+
465
+ if (this.object === -1 || this.dragging === true) return;
466
+
467
+ this.#pointer_ray(pointer);
468
+
469
+ this.axis = gizmo_pick_handle(
470
+ gizmo_handles_of_mode(this.mode),
471
+ ray_origin, ray_direction,
472
+ this.worldPosition, this.#handle_rotation, this.#handle_size
473
+ );
474
+
475
+ }
476
+
477
+ pointerDown(pointer) {
478
+
479
+ if (this.object === -1 || this.dragging === true || pointer.button !== 0) return;
480
+
481
+ if (this.axis === null) return;
482
+
483
+ const ot = this.object_transform;
484
+
485
+ this.#pointer_ray(pointer);
486
+
487
+ gizmo_drag_plane_normal(
488
+ this.#plane_normal,
489
+ this.mode, this.axis, this.space,
490
+ ot.rotation,
491
+ this.eye, this.#camera_forward
492
+ );
493
+
494
+ if (!gizmo_ray_plane_point(
495
+ scratch_point, ray_origin, ray_direction, ot.position, this.#plane_normal
496
+ )) {
497
+ // the drag surface is edge-on to the pointer, so there is no point on it to drag from
498
+ return;
499
+ }
500
+
501
+ this._positionStart.copy(ot.position);
502
+ this._quaternionStart.copy(ot.rotation);
503
+ this._scaleStart.copy(ot.scale);
504
+
505
+ this.worldPositionStart.copy(ot.position);
506
+ this.worldQuaternionStart.copy(ot.rotation);
507
+ this._worldScaleStart.copy(ot.scale);
508
+
509
+ this.pointStart.copy(scratch_point).sub(this.worldPositionStart);
510
+
511
+ this.dragging = true;
512
+
513
+ _mouseDownEvent.mode = this.mode;
514
+ this.dispatchEvent(_mouseDownEvent);
515
+
516
+ }
517
+
518
+ /**
519
+ *
520
+ * @param {{type:string}} event
521
+ */
522
+ dispatchEvent(event) {
523
+ this.entity.sendEvent(event.type, event);
524
+ }
525
+
526
+ pointerMove(pointer) {
527
+
528
+ const axis = this.axis;
529
+ const mode = this.mode;
530
+ const object = this.object;
531
+
532
+ let space = this.space;
533
+
534
+ if (mode === TransformMode.Scale) {
535
+
536
+ space = 'local';
537
+
538
+ } else if (axis === 'E' || axis === 'XYZE' || axis === 'XYZ') {
539
+
540
+ space = 'world';
541
+
542
+ }
543
+
544
+ if (object === -1 || axis === null || this.dragging === false || pointer.button !== -1) return;
545
+
546
+ const object_transform = this.object_transform;
547
+
548
+ this.#pointer_ray(pointer);
549
+
550
+ if (!gizmo_ray_plane_point(
551
+ scratch_point, ray_origin, ray_direction, this.worldPositionStart, this.#plane_normal
552
+ )) {
553
+ return;
554
+ }
555
+
556
+ this.pointEnd.copy(scratch_point).sub(this.worldPositionStart);
557
+
558
+ if (mode === TransformMode.Translate) {
559
+
560
+ // Apply translate
561
+
562
+ this._offset.copy(this.pointEnd).sub(this.pointStart);
563
+
564
+ if (space === 'local' && axis !== 'XYZ') {
565
+
566
+ this._offset.applyQuaternion(this._worldQuaternionInv);
567
+
568
+ }
569
+
570
+ if (axis.indexOf('X') === -1) this._offset.x = 0;
571
+ if (axis.indexOf('Y') === -1) this._offset.y = 0;
572
+ if (axis.indexOf('Z') === -1) this._offset.z = 0;
573
+
574
+ if (space === 'local' && axis !== 'XYZ') {
575
+
576
+ this._offset.applyQuaternion(this._quaternionStart);
577
+
578
+ }
579
+
580
+ _tempTransform.position.copy(this._offset);
581
+ _tempTransform.position.add(this._positionStart);
582
+
583
+ // Apply translation snap; snapping operates on the candidate position — the
584
+ // controlled object is an entity id, Transforms are world-space by contract
585
+ if (this.translationSnap) {
586
+
587
+ if (space === 'local') {
588
+
589
+ _tempTransform.position.applyQuaternion(
590
+ scratch_quaternion.copy(this._quaternionStart).invert()
591
+ );
592
+
593
+ }
594
+
595
+ if (axis.search('X') !== -1) {
596
+
597
+ _tempTransform.position.setX(Math.round(_tempTransform.position.x / this.translationSnap) * this.translationSnap);
598
+
599
+ }
600
+
601
+ if (axis.search('Y') !== -1) {
602
+
603
+ _tempTransform.position.setY(Math.round(_tempTransform.position.y / this.translationSnap) * this.translationSnap);
604
+
605
+ }
606
+
607
+ if (axis.search('Z') !== -1) {
608
+
609
+ _tempTransform.position.setZ(Math.round(_tempTransform.position.z / this.translationSnap) * this.translationSnap);
610
+
611
+ }
612
+
613
+ if (space === 'local') {
614
+
615
+ _tempTransform.position.applyQuaternion(this._quaternionStart);
616
+
617
+ }
618
+
619
+ }
620
+
621
+ // write
622
+ object_transform.position.copy(_tempTransform.position);
623
+
624
+ } else if (mode === TransformMode.Scale) {
625
+
626
+ if (axis.search('XYZ') !== -1) {
627
+
628
+ let d = this.pointEnd.length() / this.pointStart.length();
629
+
630
+ if (this.pointEnd.dot(this.pointStart) < 0) d *= -1;
631
+
632
+ scratch_vector_2.set(d, d, d);
633
+
634
+ } else {
635
+
636
+ scratch_vector.copy(this.pointStart);
637
+ scratch_vector_2.copy(this.pointEnd);
638
+
639
+ scratch_vector.applyQuaternion(this._worldQuaternionInv);
640
+ scratch_vector_2.applyQuaternion(this._worldQuaternionInv);
641
+
642
+ scratch_vector_2.divide(scratch_vector);
643
+
644
+ if (axis.search('X') === -1) {
645
+
646
+ scratch_vector_2.x = 1;
647
+
648
+ }
649
+
650
+ if (axis.search('Y') === -1) {
651
+
652
+ scratch_vector_2.y = 1;
653
+
654
+ }
655
+
656
+ if (axis.search('Z') === -1) {
657
+
658
+ scratch_vector_2.z = 1;
659
+
660
+ }
661
+
662
+ }
663
+
664
+ // Apply scale
665
+
666
+ _tempTransform.scale.copy(this._scaleStart);
667
+ _tempTransform.scale.multiply(scratch_vector_2);
668
+
669
+ if (this.scaleSnap) {
670
+
671
+ if (axis.search('X') !== -1) {
672
+
673
+ _tempTransform.scale.setX(Math.round(_tempTransform.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap);
674
+
675
+ }
676
+
677
+ if (axis.search('Y') !== -1) {
678
+
679
+ _tempTransform.scale.setY(Math.round(_tempTransform.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap);
680
+
681
+ }
682
+
683
+ if (axis.search('Z') !== -1) {
684
+
685
+ _tempTransform.scale.setZ(Math.round(_tempTransform.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap);
686
+
687
+ }
688
+
689
+ }
690
+
691
+ object_transform.scale.copy(_tempTransform.scale);
692
+
693
+ } else if (mode === TransformMode.Rotate) {
694
+
695
+ this._offset.copy(this.pointEnd).sub(this.pointStart);
696
+
697
+ const speed = ROTATION_SPEED / this.worldPosition.distanceTo(this.cameraPosition);
698
+
699
+ if (axis === 'E') {
700
+
701
+ this.rotationAxis.copy(this.eye);
702
+ this.rotationAngle = this.pointEnd.angleTo(this.pointStart);
703
+
704
+ this._startNorm.copy(this.pointStart).normalize();
705
+ this._endNorm.copy(this.pointEnd).normalize();
706
+
707
+ this.rotationAngle *= (this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1);
708
+
709
+ } else if (axis === 'XYZE') {
710
+
711
+ this.rotationAxis.copy(this._offset).cross(this.eye).normalize();
712
+ this.rotationAngle = this._offset.dot(scratch_vector.copy(this.rotationAxis).cross(this.eye)) * speed;
713
+
714
+ } else if (axis === 'X' || axis === 'Y' || axis === 'Z') {
715
+
716
+ this.rotationAxis.copy(UNIT[axis]);
717
+
718
+ scratch_vector.copy(UNIT[axis]);
719
+
720
+ if (space === 'local') {
721
+
722
+ scratch_vector.applyQuaternion(this.worldQuaternion);
723
+
724
+ }
725
+
726
+ this.rotationAngle = this._offset.dot(scratch_vector.cross(this.eye).normalize()) * speed;
727
+
728
+ }
729
+
730
+ // Apply rotation snap
731
+
732
+ if (this.rotationSnap) this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap;
733
+
734
+ // Apply rotate
735
+ if (space === 'local' && axis !== 'E' && axis !== 'XYZE') {
736
+
737
+ _tempTransform.rotation.copy(this._quaternionStart);
738
+ _tempTransform.rotation.multiply(
739
+ scratch_quaternion.fromAxisAngle(this.rotationAxis, this.rotationAngle)
740
+ ).normalize();
741
+
742
+ } else {
743
+
744
+ _tempTransform.rotation.copy(
745
+ scratch_quaternion.fromAxisAngle(this.rotationAxis, this.rotationAngle)
746
+ );
747
+ _tempTransform.rotation.multiply(this._quaternionStart);
748
+ _tempTransform.rotation.normalize();
749
+
750
+ }
751
+
752
+ object_transform.rotation.copy(_tempTransform.rotation);
753
+ }
754
+
755
+ this.dispatchEvent(_changeEvent);
756
+ this.dispatchEvent(_objectChangeEvent);
757
+
758
+ }
759
+
760
+ pointerUp(pointer) {
761
+
762
+ if (pointer.button !== 0) return;
763
+
764
+ if (this.dragging && (this.axis !== null)) {
765
+
766
+ _mouseUpEvent.mode = this.mode;
767
+ this.dispatchEvent(_mouseUpEvent);
768
+
769
+ }
770
+
771
+ this.dragging = false;
772
+ this.axis = null;
773
+
774
+ }
775
+
776
+ dispose() {
777
+
778
+ this.domElement.removeEventListener('pointerdown', this._onPointerDown);
779
+ this.domElement.removeEventListener('pointermove', this._onPointerHover);
780
+ this.domElement.removeEventListener('pointermove', this._onPointerMove);
781
+ this.domElement.removeEventListener('pointerup', this._onPointerUp);
782
+
783
+ this.graphics.on.preRender.remove(this.#draw);
784
+
785
+ }
786
+
787
+ /**
788
+ * Set current object
789
+ * @param {number} entity
790
+ * @returns {TransformControls}
791
+ */
792
+ attach(entity) {
793
+ assert.isNonNegativeInteger(entity, 'entity');
794
+
795
+ this.object = entity;
796
+
797
+ this.visible = true;
798
+
799
+ return this;
800
+
801
+ }
802
+
803
+ /**
804
+ *
805
+ * @returns {Transform|undefined}
806
+ */
807
+ get object_transform() {
808
+ const ecd = this.entity.dataset;
809
+
810
+ return ecd.getComponent(this.object, Transform);
811
+ }
812
+
813
+ // Detatch from object
814
+ detach() {
815
+
816
+ this.object = -1;
817
+
818
+ this.visible = false;
819
+ this.axis = null;
820
+
821
+ // a drag in flight has no target anymore
822
+ this.dragging = false;
823
+
824
+ return this;
825
+
826
+ }
827
+
828
+ reset() {
829
+
830
+ if (!this.enabled) return;
831
+
832
+ if (this.dragging) {
833
+
834
+ this.object_transform.position.copy(this._positionStart);
835
+ this.object_transform.rotation.copy(this._quaternionStart);
836
+ this.object_transform.scale.copy(this._scaleStart);
837
+
838
+ this.dispatchEvent(_changeEvent);
839
+ this.dispatchEvent(_objectChangeEvent);
840
+
841
+ this.pointStart.copy(this.pointEnd);
842
+
843
+ }
844
+
845
+ }
846
+
847
+ // TODO: deprecate
848
+
849
+ getMode() {
850
+
851
+ return this.mode;
852
+
853
+ }
854
+
855
+ setMode(mode) {
856
+
857
+ this.mode = mode;
858
+
859
+ }
860
+
861
+ setTranslationSnap(translationSnap) {
862
+
863
+ this.translationSnap = translationSnap;
864
+
865
+ }
866
+
867
+ setRotationSnap(rotationSnap) {
868
+
869
+ this.rotationSnap = rotationSnap;
870
+
871
+ }
872
+
873
+ setScaleSnap(scaleSnap) {
874
+
875
+ this.scaleSnap = scaleSnap;
876
+
877
+ }
878
+
879
+ setSize(size) {
880
+
881
+ this.size = size;
882
+
883
+ }
884
+
885
+ setSpace(space) {
886
+
887
+ this.space = space;
888
+
889
+ }
890
+
891
+ }
892
+
893
+ // mouse / touch event handlers
894
+
895
+ function getPointer(event) {
896
+
897
+ if (this.domElement.ownerDocument.pointerLockElement) {
898
+
899
+ return {
900
+ x: 0,
901
+ y: 0,
902
+ button: event.button
903
+ };
904
+
905
+ } else {
906
+
907
+ const rect = this.domElement.getBoundingClientRect();
908
+
909
+ return {
910
+ x: (event.clientX - rect.left) / rect.width * 2 - 1,
911
+ y: -(event.clientY - rect.top) / rect.height * 2 + 1,
912
+ button: event.button
913
+ };
914
+
915
+ }
916
+
917
+ }
918
+
919
+ function onPointerHover(event) {
920
+
921
+ if (!this.enabled) return;
922
+
923
+ switch (event.pointerType) {
924
+
925
+ case 'mouse':
926
+ case 'pen':
927
+ this.pointerHover(this._getPointer(event));
928
+ break;
929
+
930
+ }
931
+
932
+ }
933
+
934
+ function onPointerDown(event) {
935
+
936
+ if (!this.enabled) return;
937
+
938
+ if (!document.pointerLockElement) {
939
+
940
+ this.domElement.setPointerCapture(event.pointerId);
941
+
942
+ }
943
+
944
+ this.domElement.addEventListener('pointermove', this._onPointerMove);
945
+
946
+ this.pointerHover(this._getPointer(event));
947
+ this.pointerDown(this._getPointer(event));
948
+
949
+ }
950
+
951
+ function onPointerMove(event) {
952
+
953
+ if (!this.enabled) return;
954
+
955
+ this.pointerMove(this._getPointer(event));
956
+
957
+ }
958
+
959
+ function onPointerUp(event) {
960
+
961
+ if (!this.enabled) return;
962
+
963
+ this.domElement.releasePointerCapture(event.pointerId);
964
+
965
+ this.domElement.removeEventListener('pointermove', this._onPointerMove);
966
+
967
+ this.pointerUp(this._getPointer(event));
968
+
969
+ }
970
+
971
+ export { TransformControls };