@woosh/meep-engine 2.138.17 → 2.138.19

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 (449) hide show
  1. package/README.md +2 -2
  2. package/build/bundle-worker-image-decoder.js +1 -1
  3. package/editor/actions/concrete/ActionUpdateTexture.d.ts +12 -0
  4. package/editor/actions/concrete/ActionUpdateTexture.d.ts.map +1 -0
  5. package/editor/actions/concrete/ArrayCopyAction.d.ts +20 -0
  6. package/editor/actions/concrete/ArrayCopyAction.d.ts.map +1 -0
  7. package/editor/actions/concrete/ComponentRemoveAction.d.ts +11 -0
  8. package/editor/actions/concrete/ComponentRemoveAction.d.ts.map +1 -0
  9. package/editor/actions/concrete/ModifyPatchSampler2DAction.d.ts +47 -0
  10. package/editor/actions/concrete/ModifyPatchSampler2DAction.d.ts.map +1 -0
  11. package/editor/actions/concrete/ModifyPatchTextureArray2DAction.d.ts +38 -0
  12. package/editor/actions/concrete/ModifyPatchTextureArray2DAction.d.ts.map +1 -0
  13. package/editor/actions/concrete/PaintTerrainOverlayAction.d.ts +23 -0
  14. package/editor/actions/concrete/PaintTerrainOverlayAction.d.ts.map +1 -0
  15. package/editor/actions/concrete/PatchTerrainHeightAction.d.ts +19 -0
  16. package/editor/actions/concrete/PatchTerrainHeightAction.d.ts.map +1 -0
  17. package/editor/actions/concrete/SelectionRemoveAction.d.ts +10 -0
  18. package/editor/actions/concrete/SelectionRemoveAction.d.ts.map +1 -0
  19. package/editor/actions/concrete/WriteGridValueAction.d.ts +15 -0
  20. package/editor/actions/concrete/WriteGridValueAction.d.ts.map +1 -0
  21. package/editor/ecs/component/FieldDescriptor.d.ts +27 -0
  22. package/editor/ecs/component/FieldDescriptor.d.ts.map +1 -0
  23. package/editor/ecs/component/FieldValueAdapter.d.ts +7 -0
  24. package/editor/ecs/component/FieldValueAdapter.d.ts.map +1 -0
  25. package/editor/ecs/component/createFieldEditor.d.ts +9 -0
  26. package/editor/ecs/component/createFieldEditor.d.ts.map +1 -0
  27. package/editor/ecs/component/createObjectEditor.d.ts +14 -0
  28. package/editor/ecs/component/createObjectEditor.d.ts.map +1 -0
  29. package/editor/ecs/component/editors/geom/QuaternionEditor.d.ts.map +1 -1
  30. package/editor/ecs/component/findNearestRegisteredType.d.ts +8 -0
  31. package/editor/ecs/component/findNearestRegisteredType.d.ts.map +1 -0
  32. package/editor/process/ObstacleGridDisplayProcess.d.ts.map +1 -1
  33. package/editor/process/symbolic/makeGridPositionSymbolDisplay.d.ts.map +1 -1
  34. package/editor/tools/GridPaintTool.d.ts +17 -0
  35. package/editor/tools/GridPaintTool.d.ts.map +1 -0
  36. package/editor/tools/SelectionTool.d.ts +27 -0
  37. package/editor/tools/SelectionTool.d.ts.map +1 -0
  38. package/editor/tools/TopDownCameraControlTool.d.ts +13 -0
  39. package/editor/tools/TopDownCameraControlTool.d.ts.map +1 -0
  40. package/editor/view/ecs/ComponentControlFactory.d.ts.map +1 -0
  41. package/editor/view/ecs/ComponentControlView.d.ts.map +1 -1
  42. package/editor/view/ecs/EntityEditor.d.ts.map +1 -0
  43. package/editor/view/ecs/EntityList.d.ts.map +1 -0
  44. package/editor/view/ecs/HierarchicalEntityListView.d.ts.map +1 -0
  45. package/editor/view/node-graph/NodeGraphEditorView.d.ts.map +1 -1
  46. package/editor/view/node-graph/NodeGraphView.d.ts.map +1 -1
  47. package/editor/view/node-graph/NodeView.d.ts.map +1 -1
  48. package/editor/view/node-graph/PortView.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/core/binary/BinaryBuffer.d.ts +1 -1
  51. package/src/core/binary/BinaryBuffer.js +1 -1
  52. package/src/core/binary/BitSet.d.ts +1 -1
  53. package/src/core/binary/BitSet.js +1 -1
  54. package/src/core/cache/Cache.js +1 -1
  55. package/src/core/cache/LoadingCache.js +1 -1
  56. package/src/core/collection/list/List.js +1 -1
  57. package/src/core/collection/map/HashMap.js +1 -1
  58. package/src/core/collection/table/RowFirstTable.d.ts +1 -1
  59. package/src/core/collection/table/RowFirstTable.js +1 -1
  60. package/src/core/collection/table/RowFirstTableSpec.d.ts +1 -1
  61. package/src/core/collection/table/RowFirstTableSpec.js +1 -1
  62. package/src/core/color/oklab/compute_max_saturation.d.ts +1 -1
  63. package/src/core/color/oklab/compute_max_saturation.js +1 -1
  64. package/src/core/color/oklab/find_cusp.d.ts +1 -1
  65. package/src/core/color/oklab/find_cusp.js +1 -1
  66. package/src/core/color/oklab/find_gamut_intersection.d.ts +1 -1
  67. package/src/core/color/oklab/find_gamut_intersection.js +1 -1
  68. package/src/core/color/oklab/okhsv_to_linear_srgb.d.ts +1 -1
  69. package/src/core/color/oklab/okhsv_to_linear_srgb.js +1 -1
  70. package/src/core/color/oklab/oklab_to_linear_srgb.d.ts +1 -1
  71. package/src/core/color/oklab/oklab_to_linear_srgb.js +1 -1
  72. package/src/core/color/oklab/oklab_to_xyz.d.ts +1 -1
  73. package/src/core/color/oklab/oklab_to_xyz.js +1 -1
  74. package/src/core/color/oklab/xyz_to_oklab.d.ts +1 -1
  75. package/src/core/color/oklab/xyz_to_oklab.js +1 -1
  76. package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.d.ts +1 -1
  77. package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -1
  78. package/src/core/geom/3d/aabb/aabb3_nearest_point_on_surface.d.ts.map +1 -1
  79. package/src/core/geom/3d/aabb/aabb3_nearest_point_on_surface.js +57 -65
  80. package/src/core/geom/3d/octahedra/octahedral_uv_wrap.d.ts +1 -1
  81. package/src/core/geom/3d/octahedra/octahedral_uv_wrap.js +1 -1
  82. package/src/core/geom/3d/quaternion/quat_decode_from_uint32.d.ts +1 -1
  83. package/src/core/geom/3d/quaternion/quat_decode_from_uint32.js +1 -1
  84. package/src/core/geom/3d/quaternion/quat_encode_to_uint32.d.ts +1 -1
  85. package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +1 -1
  86. package/src/core/geom/3d/shape/AbstractShape3D.d.ts +74 -3
  87. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +37 -0
  88. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -0
  89. package/src/core/geom/3d/shape/CapsuleShape3D.js +210 -0
  90. package/src/core/geom/3d/shape/PointShape3D.d.ts +5 -0
  91. package/src/core/geom/3d/shape/PointShape3D.d.ts.map +1 -1
  92. package/src/core/geom/3d/shape/PointShape3D.js +52 -14
  93. package/src/core/geom/3d/shape/TransformedShape3D.d.ts +75 -12
  94. package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
  95. package/src/core/geom/3d/shape/TransformedShape3D.js +12 -3
  96. package/src/core/geom/3d/shape/UnionShape3D.d.ts +47 -5
  97. package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
  98. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts +12 -5
  99. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  100. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts +17 -5
  101. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  102. package/src/core/geom/3d/shape/json/shape_to_type.d.ts.map +1 -1
  103. package/src/core/geom/3d/shape/json/shape_to_type.js +4 -1
  104. package/src/core/geom/3d/shape/json/type_adapters.d.ts +17 -2
  105. package/src/core/geom/3d/shape/json/type_adapters.d.ts.map +1 -1
  106. package/src/core/geom/3d/shape/json/type_adapters.js +18 -2
  107. package/src/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.d.ts.map +1 -1
  108. package/src/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +51 -48
  109. package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.d.ts +1 -1
  110. package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +1 -1
  111. package/src/core/geom/ConicRay.d.ts +1 -1
  112. package/src/core/geom/ConicRay.js +1 -1
  113. package/src/core/geom/Quaternion.d.ts +2 -2
  114. package/src/core/geom/Quaternion.js +2 -2
  115. package/src/core/geom/Vector1.d.ts +1 -1
  116. package/src/core/geom/Vector1.js +1 -1
  117. package/src/core/geom/Vector2.d.ts +1 -1
  118. package/src/core/geom/Vector2.js +1 -1
  119. package/src/core/geom/Vector3.d.ts +1 -1
  120. package/src/core/geom/Vector3.js +1 -1
  121. package/src/core/geom/packing/miniball/Miniball.d.ts +1 -1
  122. package/src/core/geom/packing/miniball/Miniball.js +1 -1
  123. package/src/core/geom/vec3/serialization/v3_binary_equality_decode.d.ts +1 -1
  124. package/src/core/geom/vec3/serialization/v3_binary_equality_decode.js +1 -1
  125. package/src/core/geom/vec3/serialization/v3_binary_equality_encode.d.ts +1 -1
  126. package/src/core/geom/vec3/serialization/v3_binary_equality_encode.js +1 -1
  127. package/src/core/math/spline/spline3_hermite.d.ts +1 -1
  128. package/src/core/math/spline/spline3_hermite.js +1 -1
  129. package/src/core/math/spline/spline3_hermite_bounds.d.ts +1 -1
  130. package/src/core/math/spline/spline3_hermite_bounds.js +1 -1
  131. package/src/core/math/spline/spline3_hermite_bounds_t.d.ts +1 -1
  132. package/src/core/math/spline/spline3_hermite_bounds_t.js +1 -1
  133. package/src/core/math/spline/spline3_hermite_to_monomial.d.ts +1 -1
  134. package/src/core/math/spline/spline3_hermite_to_monomial.js +1 -1
  135. package/src/core/model/ObservedBoolean.d.ts +1 -1
  136. package/src/core/model/ObservedBoolean.js +1 -1
  137. package/src/core/model/ObservedString.d.ts +1 -1
  138. package/src/core/model/ObservedString.js +1 -1
  139. package/src/core/process/undo/Action.js +1 -1
  140. package/src/core/process/undo/ActionProcessor.js +1 -1
  141. package/src/engine/animation/curve/AnimationCurve.d.ts +1 -1
  142. package/src/engine/animation/curve/AnimationCurve.js +1 -1
  143. package/src/engine/animation/curve/Keyframe.d.ts +1 -1
  144. package/src/engine/animation/curve/Keyframe.js +1 -1
  145. package/src/engine/animation/curve/animation_curve_compute_aabb.d.ts +1 -1
  146. package/src/engine/animation/curve/animation_curve_compute_aabb.js +1 -1
  147. package/src/engine/animation/curve/animation_curve_optimize.d.ts +1 -1
  148. package/src/engine/animation/curve/animation_curve_optimize.js +2 -2
  149. package/src/engine/asset/loaders/image/jpeg/JpegImage.js +1 -1
  150. package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
  151. package/src/engine/asset/loaders/image/png/PNGReader.js +27 -7
  152. package/src/engine/asset/loaders/image/png/crc32.d.ts +1 -1
  153. package/src/engine/asset/loaders/image/png/crc32.js +1 -1
  154. package/src/engine/control/first-person/DESIGN.md +616 -0
  155. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +229 -0
  156. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -0
  157. package/src/engine/control/first-person/FirstPersonPlayerController.js +176 -0
  158. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +251 -0
  159. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -0
  160. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +205 -0
  161. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +151 -0
  162. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -0
  163. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +799 -0
  164. package/src/engine/control/first-person/math/computeJumpFromApex.d.ts +23 -0
  165. package/src/engine/control/first-person/math/computeJumpFromApex.d.ts.map +1 -0
  166. package/src/engine/control/first-person/math/computeJumpFromApex.js +23 -0
  167. package/src/engine/control/first-person/math/criticallyDampedSpring.d.ts +23 -0
  168. package/src/engine/control/first-person/math/criticallyDampedSpring.d.ts.map +1 -0
  169. package/src/engine/control/first-person/math/criticallyDampedSpring.js +34 -0
  170. package/src/engine/control/first-person/math/dampedSpringStep.d.ts +23 -0
  171. package/src/engine/control/first-person/math/dampedSpringStep.d.ts.map +1 -0
  172. package/src/engine/control/first-person/math/dampedSpringStep.js +72 -0
  173. package/src/engine/control/first-person/math/stepTowards.d.ts +12 -0
  174. package/src/engine/control/first-person/math/stepTowards.d.ts.map +1 -0
  175. package/src/engine/control/first-person/math/stepTowards.js +20 -0
  176. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts +69 -0
  177. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts.map +1 -0
  178. package/src/engine/control/first-person/pose/FirstPersonPose.js +91 -0
  179. package/src/engine/control/first-person/prototype_first_person_controller.d.ts +2 -0
  180. package/src/engine/control/first-person/prototype_first_person_controller.d.ts.map +1 -0
  181. package/src/engine/control/first-person/prototype_first_person_controller.js +314 -0
  182. package/src/engine/ecs/Entity.js +1 -1
  183. package/src/engine/ecs/EntityComponentDataset.js +1 -1
  184. package/src/engine/ecs/EntityManager.d.ts +1 -1
  185. package/src/engine/ecs/EntityManager.js +1 -1
  186. package/src/engine/ecs/EntityObserver.js +1 -1
  187. package/src/engine/ecs/EntityReference.d.ts +1 -1
  188. package/src/engine/ecs/EntityReference.js +1 -1
  189. package/src/engine/ecs/System.js +1 -1
  190. package/src/engine/ecs/attachment/AttachmentSystem.d.ts +2 -2
  191. package/src/engine/ecs/attachment/AttachmentSystem.d.ts.map +1 -1
  192. package/src/engine/ecs/grid/HeightMap2AOMap.d.ts.map +1 -1
  193. package/src/engine/ecs/grid/HeightMap2AOMap.js +3 -2
  194. package/src/engine/ecs/guid/UUID.d.ts +1 -1
  195. package/src/engine/ecs/guid/UUID.js +1 -1
  196. package/src/engine/ecs/name/Name.d.ts +1 -1
  197. package/src/engine/ecs/name/Name.js +1 -1
  198. package/src/engine/ecs/parent/ParentEntity.js +1 -1
  199. package/src/engine/ecs/storage/BinaryBufferDeSerializer.d.ts +1 -1
  200. package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +1 -1
  201. package/src/engine/ecs/storage/BinaryBufferSerializer.d.ts +1 -1
  202. package/src/engine/ecs/storage/BinaryBufferSerializer.js +1 -1
  203. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.js +1 -1
  204. package/src/engine/ecs/storage/binary/BinarySerializationRegistry.d.ts +1 -1
  205. package/src/engine/ecs/storage/binary/BinarySerializationRegistry.js +1 -1
  206. package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.d.ts +1 -1
  207. package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +1 -1
  208. package/src/engine/ecs/transform/Transform.d.ts +1 -1
  209. package/src/engine/ecs/transform/Transform.js +1 -1
  210. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
  211. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
  212. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +10 -1
  213. package/src/engine/graphics/impostors/voxel/README.md +149 -0
  214. package/src/engine/graphics/impostors/voxel/VoxelImpostorBaker.d.ts +91 -0
  215. package/src/engine/graphics/impostors/voxel/VoxelImpostorBaker.d.ts.map +1 -0
  216. package/src/engine/graphics/impostors/voxel/VoxelImpostorBaker.js +376 -0
  217. package/src/engine/graphics/impostors/voxel/VoxelImpostorDescription.d.ts +128 -0
  218. package/src/engine/graphics/impostors/voxel/VoxelImpostorDescription.d.ts.map +1 -0
  219. package/src/engine/graphics/impostors/voxel/VoxelImpostorDescription.js +141 -0
  220. package/src/engine/graphics/impostors/voxel/bake/read_atlas_to_samples.d.ts +38 -0
  221. package/src/engine/graphics/impostors/voxel/bake/read_atlas_to_samples.d.ts.map +1 -0
  222. package/src/engine/graphics/impostors/voxel/bake/read_atlas_to_samples.js +338 -0
  223. package/src/engine/graphics/impostors/voxel/bake/voxelize_samples.d.ts +43 -0
  224. package/src/engine/graphics/impostors/voxel/bake/voxelize_samples.d.ts.map +1 -0
  225. package/src/engine/graphics/impostors/voxel/bake/voxelize_samples.js +192 -0
  226. package/src/engine/graphics/impostors/voxel/prototype_voxel_impostors.d.ts +2 -0
  227. package/src/engine/graphics/impostors/voxel/prototype_voxel_impostors.d.ts.map +1 -0
  228. package/src/engine/graphics/impostors/voxel/prototype_voxel_impostors.js +343 -0
  229. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderDepthV0.d.ts +13 -0
  230. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderDepthV0.d.ts.map +1 -0
  231. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderDepthV0.js +99 -0
  232. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderLitV0.d.ts +19 -0
  233. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderLitV0.d.ts.map +1 -0
  234. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderLitV0.js +231 -0
  235. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderNormalsV0.d.ts +5 -0
  236. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderNormalsV0.d.ts.map +1 -0
  237. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderNormalsV0.js +70 -0
  238. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderV0.d.ts +13 -0
  239. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderV0.d.ts.map +1 -0
  240. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderV0.js +127 -0
  241. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderViewportDepthV0.d.ts +5 -0
  242. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderViewportDepthV0.d.ts.map +1 -0
  243. package/src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderViewportDepthV0.js +68 -0
  244. package/src/engine/graphics/impostors/voxel/util/make_voxel_impostor_geometry.d.ts +27 -0
  245. package/src/engine/graphics/impostors/voxel/util/make_voxel_impostor_geometry.d.ts.map +1 -0
  246. package/src/engine/graphics/impostors/voxel/util/make_voxel_impostor_geometry.js +96 -0
  247. package/src/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +113 -29
  248. package/src/engine/graphics/render/forward_plus/SPECIFICATION.md +1 -1
  249. package/src/engine/graphics/shaders/AmbientOcclusionShader.d.ts.map +1 -1
  250. package/src/engine/graphics/shaders/AmbientOcclusionShader.js +20 -5
  251. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts +1 -1
  252. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  253. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.d.ts +1 -1
  254. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +1 -1
  255. package/src/engine/graphics/util/build_max_height_pyramid.d.ts +21 -14
  256. package/src/engine/graphics/util/build_max_height_pyramid.d.ts.map +1 -1
  257. package/src/engine/graphics/util/build_max_height_pyramid.js +107 -70
  258. package/src/engine/input/devices/InputDeviceSwitch.js +1 -1
  259. package/src/engine/input/devices/KeyboardDevice.js +1 -1
  260. package/src/engine/input/devices/PointerDevice.js +1 -1
  261. package/src/engine/intelligence/behavior/Behavior.js +1 -1
  262. package/src/engine/intelligence/behavior/SelectorBehavior.d.ts +1 -1
  263. package/src/engine/intelligence/behavior/SelectorBehavior.js +1 -1
  264. package/src/engine/intelligence/behavior/behavior_to_dot.d.ts +1 -1
  265. package/src/engine/intelligence/behavior/behavior_to_dot.js +1 -1
  266. package/src/engine/intelligence/behavior/composite/CompositeBehavior.d.ts +1 -1
  267. package/src/engine/intelligence/behavior/composite/CompositeBehavior.js +1 -1
  268. package/src/engine/intelligence/behavior/composite/ParallelBehavior.d.ts +1 -1
  269. package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +1 -1
  270. package/src/engine/intelligence/behavior/composite/SequenceBehavior.d.ts +1 -1
  271. package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +1 -1
  272. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.d.ts +1 -1
  273. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +1 -1
  274. package/src/engine/intelligence/behavior/decorator/IgnoreFailureBehavior.d.ts +1 -1
  275. package/src/engine/intelligence/behavior/decorator/IgnoreFailureBehavior.js +1 -1
  276. package/src/engine/intelligence/behavior/decorator/InvertStatusBehavior.d.ts +1 -1
  277. package/src/engine/intelligence/behavior/decorator/InvertStatusBehavior.js +1 -1
  278. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.d.ts +1 -1
  279. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.js +1 -1
  280. package/src/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.d.ts +1 -1
  281. package/src/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.js +1 -1
  282. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.d.ts +1 -1
  283. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.js +1 -1
  284. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts +1 -1
  285. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.js +1 -1
  286. package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts +1 -1
  287. package/src/engine/intelligence/behavior/ecs/DieBehavior.js +1 -1
  288. package/src/engine/intelligence/behavior/ecs/EntityBehavior.d.ts +1 -1
  289. package/src/engine/intelligence/behavior/ecs/EntityBehavior.js +1 -1
  290. package/src/engine/intelligence/behavior/ecs/KillBehavior.d.ts +1 -1
  291. package/src/engine/intelligence/behavior/ecs/KillBehavior.js +1 -1
  292. package/src/engine/intelligence/behavior/ecs/SendEventBehavior.d.ts +1 -1
  293. package/src/engine/intelligence/behavior/ecs/SendEventBehavior.js +1 -1
  294. package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.d.ts +1 -1
  295. package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +1 -1
  296. package/src/engine/intelligence/behavior/primitive/ActionBehavior.d.ts +1 -1
  297. package/src/engine/intelligence/behavior/primitive/ActionBehavior.js +1 -1
  298. package/src/engine/intelligence/behavior/primitive/FailingBehavior.d.ts +1 -1
  299. package/src/engine/intelligence/behavior/primitive/FailingBehavior.js +1 -1
  300. package/src/engine/intelligence/behavior/primitive/PromiseBehavior.d.ts +1 -1
  301. package/src/engine/intelligence/behavior/primitive/PromiseBehavior.js +1 -1
  302. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.d.ts +1 -1
  303. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +1 -1
  304. package/src/engine/intelligence/behavior/selector/WeightedElement.d.ts +1 -1
  305. package/src/engine/intelligence/behavior/selector/WeightedElement.js +1 -1
  306. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.d.ts +1 -1
  307. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.js +1 -1
  308. package/src/engine/intelligence/behavior/util/BranchBehavior.d.ts +1 -1
  309. package/src/engine/intelligence/behavior/util/BranchBehavior.js +1 -1
  310. package/src/engine/intelligence/behavior/util/DelayBehavior.d.ts +1 -1
  311. package/src/engine/intelligence/behavior/util/DelayBehavior.js +1 -1
  312. package/src/engine/intelligence/behavior/util/LogMessageBehavior.d.ts +1 -1
  313. package/src/engine/intelligence/behavior/util/LogMessageBehavior.js +1 -1
  314. package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts +1 -1
  315. package/src/engine/intelligence/behavior/util/RandomDelayBehavior.js +1 -1
  316. package/src/engine/intelligence/blackboard/Blackboard.js +1 -1
  317. package/src/engine/intelligence/mcts/MonteCarlo.d.ts +1 -1
  318. package/src/engine/intelligence/mcts/MonteCarlo.js +1 -1
  319. package/src/engine/intelligence/mcts/MoveEdge.d.ts +1 -1
  320. package/src/engine/intelligence/mcts/MoveEdge.js +1 -1
  321. package/src/engine/intelligence/mcts/StateNode.d.ts +1 -1
  322. package/src/engine/intelligence/mcts/StateNode.js +1 -1
  323. package/src/engine/intelligence/resource/ActionSequence.d.ts +1 -1
  324. package/src/engine/intelligence/resource/ActionSequence.js +1 -1
  325. package/src/engine/intelligence/resource/Resource.d.ts +1 -1
  326. package/src/engine/intelligence/resource/Resource.js +1 -1
  327. package/src/engine/intelligence/resource/ResourceAllocation.d.ts +1 -1
  328. package/src/engine/intelligence/resource/ResourceAllocation.js +1 -1
  329. package/src/engine/intelligence/resource/ResourceAllocationBid.d.ts +1 -1
  330. package/src/engine/intelligence/resource/ResourceAllocationBid.js +1 -1
  331. package/src/engine/intelligence/resource/ResourceAllocationSolver.d.ts +1 -1
  332. package/src/engine/intelligence/resource/ResourceAllocationSolver.js +1 -1
  333. package/src/engine/intelligence/resource/StrategicResourceAllocator.d.ts +1 -1
  334. package/src/engine/intelligence/resource/StrategicResourceAllocator.js +1 -1
  335. package/src/engine/intelligence/resource/TacticalModule.d.ts +1 -1
  336. package/src/engine/intelligence/resource/TacticalModule.js +1 -1
  337. package/src/engine/network/NetworkSession.d.ts +1 -1
  338. package/src/engine/network/NetworkSession.js +1 -1
  339. package/src/engine/network/adapters/QuaternionInterpolationAdapter.d.ts +1 -1
  340. package/src/engine/network/adapters/QuaternionInterpolationAdapter.js +1 -1
  341. package/src/engine/network/adapters/TransformInterpolationAdapter.d.ts +1 -1
  342. package/src/engine/network/adapters/TransformInterpolationAdapter.js +1 -1
  343. package/src/engine/network/adapters/TransformReplicationAdapter.d.ts +1 -1
  344. package/src/engine/network/adapters/TransformReplicationAdapter.js +1 -1
  345. package/src/engine/network/adapters/Vector3InterpolationAdapter.d.ts +1 -1
  346. package/src/engine/network/adapters/Vector3InterpolationAdapter.js +1 -1
  347. package/src/engine/network/core/quantize/quantize_float.d.ts +1 -1
  348. package/src/engine/network/core/quantize/quantize_float.js +1 -1
  349. package/src/engine/network/core/quantize/quantize_position.d.ts +1 -1
  350. package/src/engine/network/core/quantize/quantize_position.js +1 -1
  351. package/src/engine/network/core/sequence/ack_bitfield.d.ts +1 -1
  352. package/src/engine/network/core/sequence/ack_bitfield.js +1 -1
  353. package/src/engine/network/core/sequence/seq16.d.ts +1 -1
  354. package/src/engine/network/core/sequence/seq16.js +1 -1
  355. package/src/engine/network/core/sequence/seq32.d.ts +1 -1
  356. package/src/engine/network/core/sequence/seq32.js +1 -1
  357. package/src/engine/network/diagnostics/BandwidthMeter.d.ts +1 -1
  358. package/src/engine/network/diagnostics/BandwidthMeter.js +1 -1
  359. package/src/engine/network/diagnostics/ReplayLog.d.ts +1 -1
  360. package/src/engine/network/diagnostics/ReplayLog.js +1 -1
  361. package/src/engine/network/diagnostics/SyncTest.d.ts +1 -1
  362. package/src/engine/network/diagnostics/SyncTest.js +1 -1
  363. package/src/engine/network/ecs/NetworkSystem.d.ts +1 -1
  364. package/src/engine/network/ecs/NetworkSystem.js +1 -1
  365. package/src/engine/network/ecs/components/NetworkIdentity.d.ts +1 -1
  366. package/src/engine/network/ecs/components/NetworkIdentity.js +1 -1
  367. package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.d.ts +1 -1
  368. package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.js +1 -1
  369. package/src/engine/network/orchestrator/NetworkPeer.d.ts +1 -1
  370. package/src/engine/network/orchestrator/NetworkPeer.js +1 -1
  371. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts +1 -1
  372. package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +1 -1
  373. package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts +1 -1
  374. package/src/engine/network/orchestrator/ServerAuthoritativeServer.js +1 -1
  375. package/src/engine/network/replication/Replicator.d.ts +1 -1
  376. package/src/engine/network/replication/Replicator.js +1 -1
  377. package/src/engine/network/replication/ScopeFilter.d.ts +2 -2
  378. package/src/engine/network/replication/ScopeFilter.js +2 -2
  379. package/src/engine/network/sim/ActionLog.d.ts +1 -1
  380. package/src/engine/network/sim/ActionLog.js +1 -1
  381. package/src/engine/network/sim/BinaryInterpolationAdapter.d.ts +1 -1
  382. package/src/engine/network/sim/BinaryInterpolationAdapter.js +1 -1
  383. package/src/engine/network/sim/InterpolationLog.d.ts +1 -1
  384. package/src/engine/network/sim/InterpolationLog.js +1 -1
  385. package/src/engine/network/sim/ReplicatedComponentRegistry.d.ts +1 -1
  386. package/src/engine/network/sim/ReplicatedComponentRegistry.js +1 -1
  387. package/src/engine/network/sim/RewindEngine.d.ts +1 -1
  388. package/src/engine/network/sim/RewindEngine.js +1 -1
  389. package/src/engine/network/sim/SimAction.d.ts +1 -1
  390. package/src/engine/network/sim/SimAction.js +1 -1
  391. package/src/engine/network/sim/SimActionExecutor.d.ts +1 -1
  392. package/src/engine/network/sim/SimActionExecutor.js +1 -1
  393. package/src/engine/network/sim/SimActionRegistry.d.ts +1 -1
  394. package/src/engine/network/sim/SimActionRegistry.js +1 -1
  395. package/src/engine/network/sim/SmoothingState.js +1 -1
  396. package/src/engine/network/sim/Snapshotter.d.ts +1 -1
  397. package/src/engine/network/sim/Snapshotter.js +1 -1
  398. package/src/engine/network/sim/SpeculationLog.d.ts +1 -1
  399. package/src/engine/network/sim/SpeculationLog.js +1 -1
  400. package/src/engine/network/state/Baseline.d.ts +1 -1
  401. package/src/engine/network/state/Baseline.js +1 -1
  402. package/src/engine/network/state/ChangedEntitySet.d.ts +1 -1
  403. package/src/engine/network/state/ChangedEntitySet.js +1 -1
  404. package/src/engine/network/state/InputRing.d.ts +1 -1
  405. package/src/engine/network/state/InputRing.js +1 -1
  406. package/src/engine/network/state/MutationLedger.d.ts +1 -1
  407. package/src/engine/network/state/MutationLedger.js +1 -1
  408. package/src/engine/network/state/PriorityAccumulator.d.ts +1 -1
  409. package/src/engine/network/state/PriorityAccumulator.js +1 -1
  410. package/src/engine/network/state/ReplicationSlotTable.d.ts +1 -1
  411. package/src/engine/network/state/ReplicationSlotTable.js +1 -1
  412. package/src/engine/network/time/AdaptiveRenderDelay.d.ts +1 -1
  413. package/src/engine/network/time/AdaptiveRenderDelay.js +1 -1
  414. package/src/engine/network/time/JitterBuffer.d.ts +1 -1
  415. package/src/engine/network/time/JitterBuffer.js +1 -1
  416. package/src/engine/network/time/TimeDilation.d.ts +1 -1
  417. package/src/engine/network/time/TimeDilation.js +1 -1
  418. package/src/engine/network/time/TimeSync.d.ts +1 -1
  419. package/src/engine/network/time/TimeSync.js +1 -1
  420. package/src/engine/network/transport/Channel.d.ts.map +1 -1
  421. package/src/engine/network/transport/Channel.js +3 -6
  422. package/src/engine/network/transport/LoopbackTransport.d.ts +1 -1
  423. package/src/engine/network/transport/LoopbackTransport.js +1 -1
  424. package/src/engine/network/transport/ReliableCommandPipeline.d.ts +1 -1
  425. package/src/engine/network/transport/ReliableCommandPipeline.js +1 -1
  426. package/src/engine/network/transport/Transport.d.ts +1 -1
  427. package/src/engine/network/transport/Transport.js +1 -1
  428. package/src/engine/network/transport/adapters/NodeUDPTransport.d.ts +1 -1
  429. package/src/engine/network/transport/adapters/NodeUDPTransport.js +2 -2
  430. package/src/engine/network/transport/adapters/SimulatedTransport.d.ts +1 -1
  431. package/src/engine/network/transport/adapters/SimulatedTransport.js +1 -1
  432. package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.d.ts +1 -1
  433. package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.js +1 -1
  434. package/src/engine/network/transport/adapters/WebSocketTransport.d.ts +1 -1
  435. package/src/engine/network/transport/adapters/WebSocketTransport.js +1 -1
  436. package/src/engine/network/transport/adapters/WebTransportTransport.d.ts +1 -1
  437. package/src/engine/network/transport/adapters/WebTransportTransport.js +1 -1
  438. package/src/engine/network/transport/fragments/FragmentAssembler.d.ts +1 -1
  439. package/src/engine/network/transport/fragments/FragmentAssembler.js +1 -1
  440. package/src/engine/network/transport/fragments/FragmentRetention.d.ts +1 -1
  441. package/src/engine/network/transport/fragments/FragmentRetention.js +1 -1
  442. package/src/engine/network/transport/fragments/packet_size.d.ts +1 -1
  443. package/src/engine/network/transport/fragments/packet_size.js +1 -1
  444. package/src/engine/simulation/Ticker.d.ts +1 -1
  445. package/src/engine/simulation/Ticker.js +1 -1
  446. package/src/engine/sound/SoundEngine.js +1 -1
  447. package/src/engine/ui/DraggableAspect.d.ts +1 -1
  448. package/src/engine/ui/DraggableAspect.js +1 -1
  449. package/src/view/View.js +1 -1
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Bin every CPU sample produced by {@link read_atlas_to_samples} into a
3
+ * sparse uniform voxel grid, accumulating position / normal / albedo /
4
+ * ORM weighted by sample count. Empty cells are dropped, so the output
5
+ * size scales with surface coverage, not with grid_resolution^3.
6
+ *
7
+ * Accumulation rules:
8
+ * - position: simple mean of sample positions in the cell (gives a
9
+ * slight bias inwards on slanted surfaces but is C0 across cells)
10
+ * - normal: vector sum, normalised at output time (handles
11
+ * multiple-orientation surfaces inside one cell — surfels with
12
+ * opposing normals cancel, which is what voxel-LOD wants)
13
+ * - albedo: simple mean
14
+ * - ORM: simple mean per channel
15
+ *
16
+ * Voxel size is computed from the bounding box and the requested grid
17
+ * resolution along the longest axis. Cells are addressed by integer
18
+ * (ix, iy, iz) so two samples in the same cell hash identically.
19
+ *
20
+ * @param {object} params
21
+ * @param {Float32Array} params.samples interleaved [pos, normal, albedo, orm]
22
+ * @param {number} params.sample_count number of valid samples in `samples`
23
+ * @param {number[]} params.bounds_min [x, y, z]
24
+ * @param {number[]} params.bounds_max [x, y, z]
25
+ * @param {number} params.grid_resolution cells along the longest axis
26
+ * @returns {{
27
+ * points: Float32Array,
28
+ * point_count: number,
29
+ * voxel_size: number
30
+ * }}
31
+ */
32
+ export function voxelize_samples({ samples, sample_count, bounds_min, bounds_max, grid_resolution }: {
33
+ samples: Float32Array;
34
+ sample_count: number;
35
+ bounds_min: number[];
36
+ bounds_max: number[];
37
+ grid_resolution: number;
38
+ }): {
39
+ points: Float32Array;
40
+ point_count: number;
41
+ voxel_size: number;
42
+ };
43
+ //# sourceMappingURL=voxelize_samples.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voxelize_samples.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/voxel/bake/voxelize_samples.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH;IAXgC,OAAO,EAA5B,YAAY;IACG,YAAY,EAA3B,MAAM;IACW,UAAU,EAA3B,MAAM,EAAE;IACS,UAAU,EAA3B,MAAM,EAAE;IACO,eAAe,EAA9B,MAAM;;YAEF,YAAY;iBACP,MAAM;gBACP,MAAM;EAwJxB"}
@@ -0,0 +1,192 @@
1
+ import { convert_channel_linear_to_sRGB } from "../../../../../core/color/sRGB/linear_to_sRGB.js";
2
+ import {
3
+ VOXEL_POINT_OFFSET_ALBEDO,
4
+ VOXEL_POINT_OFFSET_NORMAL,
5
+ VOXEL_POINT_OFFSET_ORM,
6
+ VOXEL_POINT_OFFSET_POSITION,
7
+ VOXEL_POINT_STRIDE
8
+ } from "../VoxelImpostorDescription.js";
9
+ import { ATLAS_SAMPLE_STRIDE } from "./read_atlas_to_samples.js";
10
+
11
+
12
+ /**
13
+ * Bin every CPU sample produced by {@link read_atlas_to_samples} into a
14
+ * sparse uniform voxel grid, accumulating position / normal / albedo /
15
+ * ORM weighted by sample count. Empty cells are dropped, so the output
16
+ * size scales with surface coverage, not with grid_resolution^3.
17
+ *
18
+ * Accumulation rules:
19
+ * - position: simple mean of sample positions in the cell (gives a
20
+ * slight bias inwards on slanted surfaces but is C0 across cells)
21
+ * - normal: vector sum, normalised at output time (handles
22
+ * multiple-orientation surfaces inside one cell — surfels with
23
+ * opposing normals cancel, which is what voxel-LOD wants)
24
+ * - albedo: simple mean
25
+ * - ORM: simple mean per channel
26
+ *
27
+ * Voxel size is computed from the bounding box and the requested grid
28
+ * resolution along the longest axis. Cells are addressed by integer
29
+ * (ix, iy, iz) so two samples in the same cell hash identically.
30
+ *
31
+ * @param {object} params
32
+ * @param {Float32Array} params.samples interleaved [pos, normal, albedo, orm]
33
+ * @param {number} params.sample_count number of valid samples in `samples`
34
+ * @param {number[]} params.bounds_min [x, y, z]
35
+ * @param {number[]} params.bounds_max [x, y, z]
36
+ * @param {number} params.grid_resolution cells along the longest axis
37
+ * @returns {{
38
+ * points: Float32Array,
39
+ * point_count: number,
40
+ * voxel_size: number
41
+ * }}
42
+ */
43
+ export function voxelize_samples({
44
+ samples,
45
+ sample_count,
46
+ bounds_min,
47
+ bounds_max,
48
+ grid_resolution
49
+ }) {
50
+
51
+ // 1. Voxel cell size = longest axis / grid_resolution. Keeps cells
52
+ // isotropic; the grid extents on the shorter axes round up to
53
+ // cover the bounds.
54
+ const extent_x = bounds_max[0] - bounds_min[0];
55
+ const extent_y = bounds_max[1] - bounds_min[1];
56
+ const extent_z = bounds_max[2] - bounds_min[2];
57
+ const max_extent = Math.max(extent_x, extent_y, Math.max(extent_z, 1e-6));
58
+
59
+ const voxel_size = max_extent / grid_resolution;
60
+ const inv_voxel_size = 1 / voxel_size;
61
+
62
+ // Per-axis cell counts after isotropic cell sizing — used to pack
63
+ // (ix, iy, iz) into a single integer key without collisions inside
64
+ // the bounding region.
65
+ const cells_x = Math.max(1, Math.ceil(extent_x * inv_voxel_size) + 1);
66
+ const cells_y = Math.max(1, Math.ceil(extent_y * inv_voxel_size) + 1);
67
+ const cells_z = Math.max(1, Math.ceil(extent_z * inv_voxel_size) + 1);
68
+
69
+ // 2. Sparse accumulator keyed on a packed cell index. Each value is
70
+ // a 13-float record: [px, py, pz, nx, ny, nz, ar, ag, ab, o, r, m, count].
71
+ // Using a flat Float32Array inside the map keeps allocation
72
+ // pressure low for big sample sets.
73
+ /** @type {Map<number, Float32Array>} */
74
+ const cell_map = new Map();
75
+
76
+ const CELL_STRIDE = 13;
77
+
78
+ for (let i = 0; i < sample_count; i++) {
79
+ const src = i * ATLAS_SAMPLE_STRIDE;
80
+
81
+ const sx = samples[src];
82
+ const sy = samples[src + 1];
83
+ const sz = samples[src + 2];
84
+
85
+ // Skip samples that fell outside the captured bounds (can happen
86
+ // with depth quantisation at the very edge of the bounding sphere).
87
+ if (sx < bounds_min[0] || sx > bounds_max[0]) continue;
88
+ if (sy < bounds_min[1] || sy > bounds_max[1]) continue;
89
+ if (sz < bounds_min[2] || sz > bounds_max[2]) continue;
90
+
91
+ const ix = Math.floor((sx - bounds_min[0]) * inv_voxel_size);
92
+ const iy = Math.floor((sy - bounds_min[1]) * inv_voxel_size);
93
+ const iz = Math.floor((sz - bounds_min[2]) * inv_voxel_size);
94
+
95
+ // Key needs ~10 bits per axis for typical grids (1024^3 max);
96
+ // bit-packing keeps us under JS's safe integer range easily.
97
+ const key = ix + iy * cells_x + iz * cells_x * cells_y;
98
+
99
+ let acc = cell_map.get(key);
100
+ if (acc === undefined) {
101
+ acc = new Float32Array(CELL_STRIDE);
102
+ cell_map.set(key, acc);
103
+ }
104
+
105
+ acc[0] += sx;
106
+ acc[1] += sy;
107
+ acc[2] += sz;
108
+
109
+ acc[3] += samples[src + 3];
110
+ acc[4] += samples[src + 4];
111
+ acc[5] += samples[src + 5];
112
+
113
+ acc[6] += samples[src + 6];
114
+ acc[7] += samples[src + 7];
115
+ acc[8] += samples[src + 8];
116
+
117
+ acc[9] += samples[src + 9];
118
+ acc[10] += samples[src + 10];
119
+ acc[11] += samples[src + 11];
120
+
121
+ acc[12] += 1;
122
+ }
123
+
124
+ // 3. Pack the surviving cells into the final interleaved point
125
+ // buffer. Cell ordering is whatever Map iteration gives us; the
126
+ // runtime renderer doesn't care because each instance is
127
+ // self-contained.
128
+ //
129
+ // Position-finding: arithmetic mean of sample positions —
130
+ // the centroid, which sits roughly on the original mesh
131
+ // surface. The silhouette-tightening inward-shift is applied
132
+ // at render time (see VoxelImpostorShaderV0 etc.) rather than
133
+ // baked in, because the shift amount depends on the splat
134
+ // diameter the renderer chooses — keeping the bake output
135
+ // representation-neutral lets a renderer override the
136
+ // description's recommended diameter (eg for tighter fit /
137
+ // bigger overlap) without re-baking.
138
+ const point_count = cell_map.size;
139
+ const points = new Float32Array(point_count * VOXEL_POINT_STRIDE);
140
+
141
+ let dst = 0;
142
+ for (const acc of cell_map.values()) {
143
+ const count = acc[12];
144
+ const inv_count = 1 / count;
145
+
146
+ // normal: normalise the vector sum so cells that saw conflicting
147
+ // orientations (eg both sides of a thin wall) end up with a
148
+ // length-shorter normal — the lit shader can renormalise but it
149
+ // never sees a 'wrong' average orientation.
150
+ let nx = acc[3];
151
+ let ny = acc[4];
152
+ let nz = acc[5];
153
+ const nlen = Math.sqrt(nx * nx + ny * ny + nz * nz);
154
+ if (nlen > 1e-6) {
155
+ nx /= nlen;
156
+ ny /= nlen;
157
+ nz /= nlen;
158
+ }
159
+ points[dst + VOXEL_POINT_OFFSET_NORMAL] = nx;
160
+ points[dst + VOXEL_POINT_OFFSET_NORMAL + 1] = ny;
161
+ points[dst + VOXEL_POINT_OFFSET_NORMAL + 2] = nz;
162
+
163
+ // position: centroid of samples (raw surface position).
164
+ points[dst + VOXEL_POINT_OFFSET_POSITION] = acc[0] * inv_count;
165
+ points[dst + VOXEL_POINT_OFFSET_POSITION + 1] = acc[1] * inv_count;
166
+ points[dst + VOXEL_POINT_OFFSET_POSITION + 2] = acc[2] * inv_count;
167
+
168
+ // albedo: arithmetic mean (samples were linearised in
169
+ // read_atlas_to_samples so this average is physically
170
+ // correct), then re-encode to sRGB so the runtime shaders see
171
+ // the same "sRGB bytes labelled linear" format the octahedral
172
+ // path uses. Lit shader's sRGBToLinear() decodes back to
173
+ // linear for PBR; unlit shader writes the sRGB-encoded bytes
174
+ // through to the framebuffer.
175
+ points[dst + VOXEL_POINT_OFFSET_ALBEDO] = convert_channel_linear_to_sRGB(acc[6] * inv_count);
176
+ points[dst + VOXEL_POINT_OFFSET_ALBEDO + 1] = convert_channel_linear_to_sRGB(acc[7] * inv_count);
177
+ points[dst + VOXEL_POINT_OFFSET_ALBEDO + 2] = convert_channel_linear_to_sRGB(acc[8] * inv_count);
178
+
179
+ // orm: arithmetic mean (each channel independent)
180
+ points[dst + VOXEL_POINT_OFFSET_ORM] = acc[9] * inv_count;
181
+ points[dst + VOXEL_POINT_OFFSET_ORM + 1] = acc[10] * inv_count;
182
+ points[dst + VOXEL_POINT_OFFSET_ORM + 2] = acc[11] * inv_count;
183
+
184
+ dst += VOXEL_POINT_STRIDE;
185
+ }
186
+
187
+ return {
188
+ points,
189
+ point_count,
190
+ voxel_size
191
+ };
192
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prototype_voxel_impostors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype_voxel_impostors.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/voxel/prototype_voxel_impostors.js"],"names":[],"mappings":""}
@@ -0,0 +1,343 @@
1
+ import Quaternion from "../../../../core/geom/Quaternion.js";
2
+ import Vector2 from "../../../../core/geom/Vector2.js";
3
+ import Vector3 from "../../../../core/geom/Vector3.js";
4
+ import { DEG_TO_RAD } from "../../../../core/math/DEG_TO_RAD.js";
5
+ import { GameAssetType } from "../../../asset/GameAssetType.js";
6
+ import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
7
+ import Entity from "../../../ecs/Entity.js";
8
+ import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
9
+ import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
10
+ import { TransformAttachmentSystem } from "../../../ecs/transform-attachment/TransformAttachmentSystem.js";
11
+ import { Transform } from "../../../ecs/transform/Transform.js";
12
+ import { EngineHarness } from "../../../EngineHarness.js";
13
+ import { BehaviorComponent } from "../../../intelligence/behavior/ecs/BehaviorComponent.js";
14
+ import { BehaviorSystem } from "../../../intelligence/behavior/ecs/BehaviorSystem.js";
15
+ import { RotationBehavior } from "../../../intelligence/behavior/util/RotationBehavior.js";
16
+ import { SGMesh } from "../../ecs/mesh-v2/aggregate/SGMesh.js";
17
+ import { SGMeshSystem } from "../../ecs/mesh-v2/aggregate/SGMeshSystem.js";
18
+ import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
19
+ import { ShadedGeometryFlags } from "../../ecs/mesh-v2/ShadedGeometryFlags.js";
20
+ import { ShadedGeometrySystem } from "../../ecs/mesh-v2/ShadedGeometrySystem.js";
21
+ import { ImpostorCaptureType } from "../octahedral/ImpostorCaptureType.js";
22
+ import { load_mesh_for_bake } from "../octahedral/util/load_mesh_for_bake.js";
23
+ import { VoxelImpostorShaderDepthV0 } from "./shader/VoxelImpostorShaderDepthV0.js";
24
+ import { VoxelImpostorShaderLitV0 } from "./shader/VoxelImpostorShaderLitV0.js";
25
+ import { VoxelImpostorShaderNormalsV0 } from "./shader/VoxelImpostorShaderNormalsV0.js";
26
+ import { VoxelImpostorShaderV0 } from "./shader/VoxelImpostorShaderV0.js";
27
+ import { VoxelImpostorShaderViewportDepthV0 } from "./shader/VoxelImpostorShaderViewportDepthV0.js";
28
+ import { make_voxel_impostor_geometry } from "./util/make_voxel_impostor_geometry.js";
29
+ import { VoxelImpostorBaker } from "./VoxelImpostorBaker.js";
30
+
31
+
32
+ /**
33
+ * Prototype harness for the voxel impostor system. Mirrors the
34
+ * structure of the octahedral system's prototypeBaker.js — load a GLTF
35
+ * mesh, bake it through {@link VoxelImpostorBaker}, then lay out a
36
+ * lineup of variants side-by-side so visual differences are easy to
37
+ * compare against the truth mesh.
38
+ *
39
+ * Slot layout (along +X from x=10 to x=25):
40
+ * 0 : V0 unlit (square splats)
41
+ * 1 : V0 unlit with disc mask (shows splat shape clearly)
42
+ * 2 : Lit V0 — only one that receives shadows
43
+ * 3 : Normals viz (debug pair for the lit variant)
44
+ * 4 : Viewport-depth viz
45
+ * 5 : True mesh (ground-truth reference)
46
+ *
47
+ * @param {Engine} engine
48
+ * @return {Promise<void>}
49
+ */
50
+ async function main(engine) {
51
+ await EngineHarness.buildBasics({
52
+ engine,
53
+ enableWater: false,
54
+ cameraFieldOfView: 45,
55
+ showFps: false,
56
+ enableLights: true,
57
+ enableShadows: true,
58
+ cameraAutoClip: true,
59
+ // Mirror the octahedral prototype's terrain layout so the same
60
+ // EngineHarness defaults give us a sensible camera framing.
61
+ terrainSize: new Vector2(18, 12),
62
+ focus: new Vector3(17, 0, 10),
63
+ });
64
+
65
+ const ecd = engine.entityManager.dataset;
66
+
67
+ const baker = new VoxelImpostorBaker();
68
+ const renderer = engine.graphics.renderer;
69
+ baker.renderer = renderer;
70
+
71
+ // const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
72
+ // const path = 'data/models/samples/textured_unit_cube.gltf';
73
+ // const path = 'data/models/samples/teapot.gltf';
74
+ // const path = 'data/models/LowPolyTownshipSet/Barrel/model.gltf';
75
+ // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
76
+ // const path = 'data/models/MOBA and Tower Defense/Tree_01.gltf';
77
+ const path = 'data/models/samples/just_a_girl/scene.gltf';
78
+ // const path = 'data/models/road_bike/road_bike.gltf'; //large CAD-type model
79
+
80
+ const objects = await load_mesh_for_bake(engine, path);
81
+
82
+ const id = baker.bake({
83
+ objects,
84
+ point_budget: 4096,
85
+ // Atlas frame/resolution are conservative defaults — they
86
+ // control how dense the SAMPLE cloud is, not the OUTPUT point
87
+ // count. The budget is what caps the output. Tweak `frames`
88
+ // up for hard-to-cover shapes (think: deep concavities) and
89
+ // `resolution` up if voxels look noisy in their averaged colour.
90
+ frames: 16,
91
+ resolution: 1024,
92
+ capture_type: ImpostorCaptureType.FullSphere
93
+ });
94
+
95
+ console.log(id);
96
+
97
+ const t0 = Transform.fromJSON({
98
+ position: { x: 10, y: 0.5, z: 10 },
99
+ scale: 3,
100
+ rotation: Quaternion.fromEulerAngles(0, 90 * DEG_TO_RAD, 0)
101
+ });
102
+
103
+ // Match the octahedral prototype's sizing: 3 world units across the
104
+ // bounding sphere diameter. The voxel point cloud occupies the
105
+ // same volume as the source mesh (each splat is sized in world
106
+ // space — see the shaders' uPointDiameter doc — and the bounding
107
+ // sphere comes straight from the bake), so the same Transform
108
+ // scale that fits the octahedral card here also fits the voxel
109
+ // cloud.
110
+ t0.scale.setScalar(3 / (id.sphere_radius * 2));
111
+
112
+ // Splat diameter in OBJECT space, auto-tuned by the baker —
113
+ // sqrt(2) * voxel_size, which covers worst-case oblique
114
+ // projections of each voxel cell. The shaders apply a render-time
115
+ // inward-shift of half this value along the surface normal, so
116
+ // even with the overlap the silhouette stays tight against the
117
+ // original mesh outline. Override here for tighter (= voxel_size)
118
+ // or looser (~ 1.5+ * voxel_size) fits per asset.
119
+ const point_diameter_OS = id.point_diameter;
120
+
121
+ // Slot 0: V0 unlit, square splats.
122
+ make_voxel_entity({ id, t: t0, point_diameter: point_diameter_OS }).build(ecd);
123
+
124
+ // Slot 1: V0 unlit with disc mask — shows splat shape directly,
125
+ // useful for seeing the underlying point distribution.
126
+ const t_disc = new Transform();
127
+ t_disc.copy(t0);
128
+ t_disc.position._add(3, 0, 0);
129
+ make_voxel_entity({ id, t: t_disc, disc_mask: true, point_diameter: point_diameter_OS }).build(ecd);
130
+
131
+ // Slot 2: lit variant — only one that receives shadows.
132
+ const t_lit = new Transform();
133
+ t_lit.copy(t0);
134
+ t_lit.position._add(6, 0, 0);
135
+ make_voxel_lit_entity({ id, t: t_lit, point_diameter: point_diameter_OS }).build(ecd);
136
+
137
+ // Slot 3: world-space-normal viz — diagnostics for the lit shader.
138
+ const t_normals = new Transform();
139
+ t_normals.copy(t0);
140
+ t_normals.position._add(9, 0, 0);
141
+ make_voxel_normals_entity({ id, t: t_normals, point_diameter: point_diameter_OS }).build(ecd);
142
+
143
+ // Slot 4: viewport-depth viz — diagnostics for the depth caster.
144
+ const t_depth = new Transform();
145
+ t_depth.copy(t0);
146
+ t_depth.position._add(12, 0, 0);
147
+ make_voxel_viewport_depth_entity({ id, t: t_depth, point_diameter: point_diameter_OS }).build(ecd);
148
+
149
+ // Slot 5: true mesh ground truth.
150
+ const t_truth = new Transform();
151
+ t_truth.copy(t0);
152
+ t_truth.position._add(15, 0, 0);
153
+
154
+ const sg_mesh = SGMesh.fromURL(path);
155
+ sg_mesh.castShadow = true;
156
+ sg_mesh.receiveShadow = true;
157
+
158
+ new Entity()
159
+ .add(sg_mesh)
160
+ .add(t_truth)
161
+ .build(ecd);
162
+
163
+ // [entity_impostor].forEach(e => make_spin(e));
164
+ }
165
+
166
+
167
+ /**
168
+ * Apply a rotation behavior to an entity — useful for visually
169
+ * confirming the impostor stays consistent under rotation. Off by
170
+ * default, see the line at the end of main().
171
+ *
172
+ * @param {Entity} entity
173
+ * @param {number} [speed]
174
+ * @param {Vector3} [axis]
175
+ */
176
+ function make_spin(entity, speed = 1, axis = Vector3.up) {
177
+ /**
178
+ * @type {Transform}
179
+ */
180
+ const t = entity.getComponent(Transform);
181
+
182
+ if (t === null) {
183
+ return;
184
+ }
185
+
186
+ entity.add(BehaviorComponent.from(RotationBehavior.fromJSON({
187
+ axis, speed
188
+ })));
189
+ }
190
+
191
+
192
+ /**
193
+ * Build a paired depth material whose point diameter and disc mask
194
+ * agree with the colour material. ShadedGeometry uses depth_material
195
+ * for the shadow pass, so this keeps the cast silhouette aligned
196
+ * with the visible one.
197
+ *
198
+ * @param {number} point_diameter object-space splat diameter
199
+ * @param {boolean} disc_mask
200
+ */
201
+ function make_voxel_depth_material(point_diameter, disc_mask) {
202
+ const m = new VoxelImpostorShaderDepthV0();
203
+ m.uniforms.uPointDiameter.value = point_diameter;
204
+ m.uniforms.uDiscMask.value = disc_mask;
205
+ return m;
206
+ }
207
+
208
+
209
+ /**
210
+ * Slot 0/1 factory: unlit voxel splats. Each instance is a
211
+ * world-space-sized camera-facing billboard; the depth-caster
212
+ * mirrors the same world size so the shadow silhouette agrees.
213
+ *
214
+ * @param {object} params
215
+ * @param {VoxelImpostorDescription} params.id
216
+ * @param {Transform} [params.t]
217
+ * @param {boolean} [params.disc_mask]
218
+ * @param {number} params.point_diameter object-space splat diameter
219
+ * @returns {Entity}
220
+ */
221
+ function make_voxel_entity({ id, t = new Transform(), disc_mask = false, point_diameter }) {
222
+ const mat = new VoxelImpostorShaderV0();
223
+ mat.uniforms.uPointDiameter.value = point_diameter;
224
+ mat.uniforms.uDiscMask.value = disc_mask;
225
+
226
+ const transform = new Transform();
227
+ transform.copy(t);
228
+
229
+ const sg = ShadedGeometry.from(make_voxel_impostor_geometry(id), mat);
230
+ sg.depth_material = make_voxel_depth_material(point_diameter, disc_mask);
231
+ // Unlit splats don't receive shadow, same convention as the
232
+ // octahedral V0 (its lit shader is the only receiver).
233
+ sg.clearFlag(ShadedGeometryFlags.ReceiveShadow);
234
+
235
+ return new Entity()
236
+ .add(transform)
237
+ .add(sg);
238
+ }
239
+
240
+
241
+ /**
242
+ * Slot 2 factory: lit voxel splats. Casts AND receives shadows. The
243
+ * lighting equations consume the per-instance baked normal directly,
244
+ * so each splat's shading follows the surface orientation at the
245
+ * sampled voxel.
246
+ *
247
+ * @param {object} params
248
+ * @param {VoxelImpostorDescription} params.id
249
+ * @param {Transform} [params.t]
250
+ * @param {number} params.point_diameter
251
+ * @returns {Entity}
252
+ */
253
+ function make_voxel_lit_entity({ id, t = new Transform(), point_diameter }) {
254
+ const mat = new VoxelImpostorShaderLitV0();
255
+ mat.uniforms.uPointDiameter.value = point_diameter;
256
+
257
+ const transform = new Transform();
258
+ transform.copy(t);
259
+
260
+ const sg = ShadedGeometry.from(make_voxel_impostor_geometry(id), mat);
261
+ sg.depth_material = make_voxel_depth_material(point_diameter, false);
262
+ // CastShadow + ReceiveShadow on by default.
263
+
264
+ return new Entity()
265
+ .add(transform)
266
+ .add(sg);
267
+ }
268
+
269
+
270
+ /**
271
+ * Slot 3 factory: per-voxel normal as RGB. Reads the same iNormal
272
+ * attribute the lit shader feeds its lighting equations.
273
+ *
274
+ * @param {object} params
275
+ * @param {VoxelImpostorDescription} params.id
276
+ * @param {Transform} [params.t]
277
+ * @param {number} params.point_diameter
278
+ * @returns {Entity}
279
+ */
280
+ function make_voxel_normals_entity({ id, t = new Transform(), point_diameter }) {
281
+ const mat = new VoxelImpostorShaderNormalsV0();
282
+ mat.uniforms.uPointDiameter.value = point_diameter;
283
+
284
+ const transform = new Transform();
285
+ transform.copy(t);
286
+
287
+ const sg = ShadedGeometry.from(make_voxel_impostor_geometry(id), mat);
288
+ sg.depth_material = make_voxel_depth_material(point_diameter, false);
289
+ // Viz pass: don't participate in shadow casting/receiving, same as
290
+ // the octahedral normals viz — keeps it from influencing neighbours.
291
+ sg.clearFlag(ShadedGeometryFlags.CastShadow);
292
+ sg.clearFlag(ShadedGeometryFlags.ReceiveShadow);
293
+
294
+ return new Entity()
295
+ .add(transform)
296
+ .add(sg);
297
+ }
298
+
299
+
300
+ /**
301
+ * Slot 4 factory: viewport-depth viz. Helpful for verifying the splat
302
+ * cloud's depth matches the truth mesh (eg before bumping into a
303
+ * receiving wall).
304
+ *
305
+ * @param {object} params
306
+ * @param {VoxelImpostorDescription} params.id
307
+ * @param {Transform} [params.t]
308
+ * @param {number} params.point_diameter
309
+ * @returns {Entity}
310
+ */
311
+ function make_voxel_viewport_depth_entity({ id, t = new Transform(), point_diameter }) {
312
+ const mat = new VoxelImpostorShaderViewportDepthV0();
313
+ mat.uniforms.uPointDiameter.value = point_diameter;
314
+
315
+ const transform = new Transform();
316
+ transform.copy(t);
317
+
318
+ const sg = ShadedGeometry.from(make_voxel_impostor_geometry(id), mat);
319
+ sg.depth_material = make_voxel_depth_material(point_diameter, false);
320
+ sg.clearFlag(ShadedGeometryFlags.CastShadow);
321
+ sg.clearFlag(ShadedGeometryFlags.ReceiveShadow);
322
+
323
+ return new Entity()
324
+ .add(transform)
325
+ .add(sg);
326
+ }
327
+
328
+
329
+ new EngineHarness().initialize({
330
+ configuration(config, engine) {
331
+ config.addSystem(new GUIElementSystem(engine.gui.view, engine));
332
+ config.addSystem(new ViewportPositionSystem(engine.graphics.viewport.size));
333
+ config.addSystem(new ShadedGeometrySystem(engine));
334
+ config.addSystem(new SGMeshSystem(engine));
335
+ config.addSystem(new TransformAttachmentSystem());
336
+ config.addSystem(new BehaviorSystem(engine));
337
+
338
+ const gltfAssetLoader = new GLTFAssetLoader();
339
+
340
+ config.addLoader(GameAssetType.ModelGLTF, gltfAssetLoader);
341
+ config.addLoader(GameAssetType.ModelGLTF_JSON, gltfAssetLoader);
342
+ }
343
+ }).then(main);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Depth-pass companion to {@link VoxelImpostorShaderLitV0}. Wire as
3
+ * ShadedGeometry.depth_material so the impostor casts a shadow whose
4
+ * silhouette matches the visible splat cloud (modulo the half-splat
5
+ * normal bias the lit shader applies on the receiver side).
6
+ *
7
+ * Keep `uPointDiameter` and `uDiscMask` aligned with the colour pass.
8
+ */
9
+ export class VoxelImpostorShaderDepthV0 extends RawShaderMaterial {
10
+ constructor();
11
+ }
12
+ import { RawShaderMaterial } from "three";
13
+ //# sourceMappingURL=VoxelImpostorShaderDepthV0.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoxelImpostorShaderDepthV0.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/voxel/shader/VoxelImpostorShaderDepthV0.js"],"names":[],"mappings":"AA4EA;;;;;;;GAOG;AACH;IACI,cAYC;CACJ;kCAlGoD,OAAO"}