@woosh/meep-engine 2.168.0 → 2.169.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 (295) hide show
  1. package/README.md +2 -2
  2. package/build/bundle-worker-image-decoder.js +1 -1
  3. package/package.json +1 -1
  4. package/src/REVIEW_2026_08_06/adv-core.md +511 -0
  5. package/src/REVIEW_2026_08_06/adv-gfx.md +480 -0
  6. package/src/REVIEW_2026_08_06/adv-view.md +446 -0
  7. package/src/REVIEW_2026_08_06/api-core.md +296 -0
  8. package/src/REVIEW_2026_08_06/api-engine.md +195 -0
  9. package/src/REVIEW_2026_08_06/bvh-phys-sound-net.md +507 -0
  10. package/src/REVIEW_2026_08_06/core-binary.md +348 -0
  11. package/src/REVIEW_2026_08_06/core-collection.md +376 -0
  12. package/src/REVIEW_2026_08_06/core-math.md +221 -0
  13. package/src/REVIEW_2026_08_06/core-process.md +266 -0
  14. package/src/REVIEW_2026_08_06/core-science.md +223 -0
  15. package/src/REVIEW_2026_08_06/engine-ai-nav.md +279 -0
  16. package/src/REVIEW_2026_08_06/engine-animation.md +167 -0
  17. package/src/REVIEW_2026_08_06/engine-asset.md +166 -0
  18. package/src/REVIEW_2026_08_06/engine-ecs.md +920 -0
  19. package/src/REVIEW_2026_08_06/engine-input.md +197 -0
  20. package/src/REVIEW_2026_08_06/engine-misc.md +248 -0
  21. package/src/REVIEW_2026_08_06/engine-terrain.md +52 -0
  22. package/src/REVIEW_2026_08_06/generation.md +176 -0
  23. package/src/REVIEW_2026_08_06/geom-2d.md +434 -0
  24. package/src/REVIEW_2026_08_06/geom-3d.md +117 -0
  25. package/src/REVIEW_2026_08_06/gfx-gi.md +143 -0
  26. package/src/REVIEW_2026_08_06/gfx-render.md +740 -0
  27. package/src/REVIEW_2026_08_06/gfx-texture.md +690 -0
  28. package/src/REVIEW_2026_08_06/prior-criticals.md +49 -0
  29. package/src/REVIEW_2026_08_06/prior-highs.md +138 -0
  30. package/src/REVIEW_2026_08_06/test-gaps.md +364 -0
  31. package/src/REVIEW_2026_08_06/view.md +667 -0
  32. package/src/REVIEW_2026_08_06.md +571 -0
  33. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  34. package/src/core/binary/BinaryBuffer.js +12 -1
  35. package/src/core/binary/BitImage2.d.ts +5 -1
  36. package/src/core/binary/BitImage2.d.ts.map +1 -1
  37. package/src/core/binary/BitImage2.js +5 -1
  38. package/src/core/bvh8/build/NodeProxy.d.ts.map +1 -1
  39. package/src/core/bvh8/build/NodeProxy.js +314 -308
  40. package/src/core/collection/list/List.d.ts +15 -0
  41. package/src/core/collection/list/List.d.ts.map +1 -1
  42. package/src/core/collection/list/List.js +34 -0
  43. package/src/core/collection/list/SortedListProjection.d.ts.map +1 -1
  44. package/src/core/collection/list/SortedListProjection.js +4 -1
  45. package/src/core/collection/map/BiMap.d.ts +25 -2
  46. package/src/core/collection/map/BiMap.d.ts.map +1 -1
  47. package/src/core/collection/map/BiMap.js +57 -3
  48. package/src/core/debug/matchers/IsAnything.d.ts.map +1 -1
  49. package/src/core/debug/matchers/IsAnything.js +5 -1
  50. package/src/core/events/signal/Signal.d.ts.map +1 -1
  51. package/src/core/events/signal/Signal.js +3 -1
  52. package/src/core/geom/2d/polygon/TRIANGULATION_DESIGN.md +433 -0
  53. package/src/core/geom/2d/polygon/polygon2_is_counter_clockwise.d.ts +31 -0
  54. package/src/core/geom/2d/polygon/polygon2_is_counter_clockwise.d.ts.map +1 -0
  55. package/src/core/geom/2d/polygon/polygon2_is_counter_clockwise.js +84 -0
  56. package/src/core/geom/2d/polygon/polygon2_signed_area.d.ts +24 -2
  57. package/src/core/geom/2d/polygon/polygon2_signed_area.d.ts.map +1 -1
  58. package/src/core/geom/2d/polygon/polygon2_signed_area.js +52 -34
  59. package/src/core/geom/2d/polygon/polygon2_triangulate.corpus.d.ts +28 -0
  60. package/src/core/geom/2d/polygon/polygon2_triangulate.corpus.d.ts.map +1 -0
  61. package/src/core/geom/2d/polygon/polygon2_triangulate.corpus.js +86 -0
  62. package/src/core/geom/2d/polygon/polygon2_triangulate.d.ts +40 -0
  63. package/src/core/geom/2d/polygon/polygon2_triangulate.d.ts.map +1 -0
  64. package/src/core/geom/2d/polygon/polygon2_triangulate.js +1280 -0
  65. package/src/core/geom/2d/polygon/polygon2_triangulation_deviation.d.ts +28 -0
  66. package/src/core/geom/2d/polygon/polygon2_triangulation_deviation.d.ts.map +1 -0
  67. package/src/core/geom/2d/polygon/polygon2_triangulation_deviation.js +77 -0
  68. package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts +6 -3
  69. package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts.map +1 -1
  70. package/src/core/geom/2d/triangle/tri2_rasterize_conservative.js +26 -13
  71. package/src/core/geom/2d/triangle/tri2_signed_area.d.ts +17 -1
  72. package/src/core/geom/2d/triangle/tri2_signed_area.d.ts.map +1 -1
  73. package/src/core/geom/2d/triangle/tri2_signed_area.js +35 -23
  74. package/src/core/geom/2d/v2_morton_encode.d.ts +20 -0
  75. package/src/core/geom/2d/v2_morton_encode.d.ts.map +1 -0
  76. package/src/core/geom/2d/v2_morton_encode.js +23 -0
  77. package/src/core/geom/3d/atlas/segment/atlas_merge_charts.d.ts.map +1 -1
  78. package/src/core/geom/3d/atlas/segment/atlas_merge_charts.js +4 -1
  79. package/src/core/geom/3d/polygon/polygon3_compute_normal.d.ts +27 -0
  80. package/src/core/geom/3d/polygon/polygon3_compute_normal.d.ts.map +1 -0
  81. package/src/core/geom/3d/polygon/polygon3_compute_normal.js +60 -0
  82. package/src/core/geom/3d/polygon/polygon3_triangulate.d.ts +34 -0
  83. package/src/core/geom/3d/polygon/polygon3_triangulate.d.ts.map +1 -0
  84. package/src/core/geom/3d/polygon/polygon3_triangulate.js +94 -0
  85. package/src/core/geom/3d/quaternion/quat3_multiply.d.ts +8 -2
  86. package/src/core/geom/3d/quaternion/quat3_multiply.d.ts.map +1 -1
  87. package/src/core/geom/3d/quaternion/quat3_multiply.js +8 -2
  88. package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -1
  89. package/src/core/geom/3d/shape/ConvexHullShape3D.js +32 -2
  90. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.d.ts +23 -6
  91. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.d.ts.map +1 -1
  92. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.js +268 -124
  93. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_assert_valid.d.ts +17 -0
  94. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_assert_valid.d.ts.map +1 -0
  95. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_assert_valid.js +44 -0
  96. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_count_edge_faces.d.ts +20 -0
  97. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_count_edge_faces.d.ts.map +1 -0
  98. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_count_edge_faces.js +40 -0
  99. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_closed.d.ts +19 -0
  100. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_closed.d.ts.map +1 -0
  101. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_closed.js +34 -0
  102. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_manifold.d.ts +22 -0
  103. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_manifold.d.ts.map +1 -0
  104. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_manifold.js +37 -0
  105. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_validate.d.ts +87 -0
  106. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_validate.d.ts.map +1 -0
  107. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_validate.js +599 -0
  108. package/src/core/geom/3d/triangle/tri3_compute_signed_volume.d.ts +32 -0
  109. package/src/core/geom/3d/triangle/tri3_compute_signed_volume.d.ts.map +1 -1
  110. package/src/core/geom/3d/triangle/tri3_compute_signed_volume.js +66 -7
  111. package/src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.d.ts +22 -1
  112. package/src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.d.ts.map +1 -1
  113. package/src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.js +83 -38
  114. package/src/core/geom/MANIFOLD_COMPARISON_2026_08_01.md +554 -0
  115. package/src/core/geom/vec3/v3_cotangent.d.ts +6 -2
  116. package/src/core/geom/vec3/v3_cotangent.d.ts.map +1 -1
  117. package/src/core/geom/vec3/v3_cotangent.js +6 -2
  118. package/src/core/geom/vec3/v3_cross.d.ts +6 -2
  119. package/src/core/geom/vec3/v3_cross.d.ts.map +1 -1
  120. package/src/core/geom/vec3/v3_cross.js +6 -2
  121. package/src/core/geom/vec3/v3_multiply.d.ts +6 -2
  122. package/src/core/geom/vec3/v3_multiply.d.ts.map +1 -1
  123. package/src/core/geom/vec3/v3_multiply.js +6 -2
  124. package/src/core/geom/vec3/v3_subtract.d.ts +6 -2
  125. package/src/core/geom/vec3/v3_subtract.d.ts.map +1 -1
  126. package/src/core/geom/vec3/v3_subtract.js +6 -2
  127. package/src/core/localization/Localization.js +1 -1
  128. package/src/core/math/random/randomSeed.d.ts +13 -0
  129. package/src/core/math/random/randomSeed.d.ts.map +1 -0
  130. package/src/core/math/random/randomSeed.js +16 -0
  131. package/src/core/math/spline/spline3_hermite_apply_transform.d.ts +50 -0
  132. package/src/core/math/spline/spline3_hermite_apply_transform.d.ts.map +1 -0
  133. package/src/core/math/spline/spline3_hermite_apply_transform.js +107 -0
  134. package/src/core/math/spline/spline3_hermite_reverse.d.ts +34 -0
  135. package/src/core/math/spline/spline3_hermite_reverse.d.ts.map +1 -0
  136. package/src/core/math/spline/spline3_hermite_reverse.js +49 -0
  137. package/src/core/math/statistics/hammersley_sequence.d.ts +17 -4
  138. package/src/core/math/statistics/hammersley_sequence.d.ts.map +1 -1
  139. package/src/core/math/statistics/hammersley_sequence.js +25 -16
  140. package/src/core/process/Future.d.ts.map +1 -1
  141. package/src/core/process/Future.js +12 -0
  142. package/src/core/process/PromiseWatcher.d.ts.map +1 -1
  143. package/src/core/process/PromiseWatcher.js +9 -2
  144. package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
  145. package/src/core/process/executor/ConcurrentExecutor.js +12 -2
  146. package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
  147. package/src/core/process/worker/WorkerProxy.js +5 -2
  148. package/src/core/process/worker/extractTransferables.d.ts.map +1 -1
  149. package/src/core/process/worker/extractTransferables.js +4 -1
  150. package/src/engine/Engine.d.ts +12 -12
  151. package/src/engine/Engine.d.ts.map +1 -1
  152. package/src/engine/Engine.js +149 -10
  153. package/src/engine/EngineHarness.d.ts.map +1 -1
  154. package/src/engine/EngineHarness.js +4 -1
  155. package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
  156. package/src/engine/asset/loaders/ArrayBufferLoader.js +7 -0
  157. package/src/engine/ecs/speaker/lines/sets/LineSetDescription.d.ts.map +1 -1
  158. package/src/engine/ecs/speaker/lines/sets/LineSetDescription.js +3 -1
  159. package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
  160. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +4 -1
  161. package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts +29 -0
  162. package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
  163. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +84 -23
  164. package/src/engine/graphics/CONTEXT_LOSS_RECOVERY_PLAN.md +446 -0
  165. package/src/engine/graphics/GraphicsEngine.d.ts +56 -7
  166. package/src/engine/graphics/GraphicsEngine.d.ts.map +1 -1
  167. package/src/engine/graphics/GraphicsEngine.js +196 -24
  168. package/src/engine/graphics/context/WebGLContextFailureReason.d.ts +9 -0
  169. package/src/engine/graphics/context/WebGLContextFailureReason.d.ts.map +1 -0
  170. package/src/engine/graphics/context/WebGLContextFailureReason.js +17 -0
  171. package/src/engine/graphics/context/WebGLContextMonitor.d.ts +106 -0
  172. package/src/engine/graphics/context/WebGLContextMonitor.d.ts.map +1 -0
  173. package/src/engine/graphics/context/WebGLContextMonitor.js +341 -0
  174. package/src/engine/graphics/context/WebGLContextState.d.ts +14 -0
  175. package/src/engine/graphics/context/WebGLContextState.d.ts.map +1 -0
  176. package/src/engine/graphics/context/WebGLContextState.js +24 -0
  177. package/src/engine/graphics/context/testWebGLContextLoss.d.ts +2 -0
  178. package/src/engine/graphics/context/testWebGLContextLoss.d.ts.map +1 -0
  179. package/src/engine/graphics/context/testWebGLContextLoss.js +696 -0
  180. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.d.ts.map +1 -1
  181. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +68 -32
  182. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationUpgrader_0_1.d.ts +14 -0
  183. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationUpgrader_0_1.d.ts.map +1 -0
  184. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationUpgrader_0_1.js +41 -0
  185. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +1 -1
  186. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts.map +1 -1
  187. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +5 -0
  188. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts +5 -1
  189. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts.map +1 -1
  190. package/src/engine/graphics/ecs/trail2d/Trail2D.js +15 -0
  191. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +1 -1
  192. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts.map +1 -1
  193. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +2 -1
  194. package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts +4 -1
  195. package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts.map +1 -1
  196. package/src/engine/graphics/ecs/trail3d/Trail3D.js +488 -476
  197. package/src/engine/graphics/ecs/trail3d/Trail3DSystem.d.ts +1 -1
  198. package/src/engine/graphics/ecs/trail3d/Trail3DSystem.d.ts.map +1 -1
  199. package/src/engine/graphics/ecs/trail3d/Trail3DSystem.js +280 -253
  200. package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.d.ts.map +1 -1
  201. package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.js +3 -2
  202. package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.d.ts.map +1 -1
  203. package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js +3 -1
  204. package/src/engine/graphics/geometry/computeMeshSurfaceArea.js +1 -1
  205. package/src/engine/graphics/load_and_set_cubemap_v0.d.ts +5 -0
  206. package/src/engine/graphics/load_and_set_cubemap_v0.d.ts.map +1 -1
  207. package/src/engine/graphics/load_and_set_cubemap_v0.js +26 -21
  208. package/src/engine/graphics/particles/particular/group/ParticleGroup.d.ts.map +1 -1
  209. package/src/engine/graphics/particles/particular/group/ParticleGroup.js +19 -8
  210. package/src/engine/graphics/particles/particular/group/optimizeCommandQueue.js +1 -1
  211. package/src/engine/graphics/texture/atlas/AtlasLookupTexture.d.ts.map +1 -1
  212. package/src/engine/graphics/texture/atlas/AtlasLookupTexture.js +10 -3
  213. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  214. package/src/engine/graphics/texture/atlas/TextureAtlas.js +4 -1
  215. package/src/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.d.ts.map +1 -1
  216. package/src/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.js +11 -0
  217. package/src/engine/graphics/texture/cubemap/load_environment_map.d.ts.map +1 -1
  218. package/src/engine/graphics/texture/cubemap/load_environment_map.js +5 -2
  219. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.d.ts.map +1 -1
  220. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +26 -18
  221. package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts +15 -2
  222. package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts.map +1 -1
  223. package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js +29 -3
  224. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.d.ts +11 -1
  225. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.d.ts.map +1 -1
  226. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.js +158 -171
  227. package/src/engine/graphics/texture/sampler/sampler2d_paint.js +1 -1
  228. package/src/engine/graphics/texture/sampler/util/bitSet2Sampler2D.js +2 -2
  229. package/src/engine/input/ecs/util/TopDownCameraControllerHelper.d.ts.map +1 -1
  230. package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +10 -3
  231. package/src/engine/navigation/ecs/components/PathSerializationUpgrader_2_3.d.ts +14 -0
  232. package/src/engine/navigation/ecs/components/PathSerializationUpgrader_2_3.d.ts.map +1 -0
  233. package/src/engine/navigation/ecs/components/PathSerializationUpgrader_2_3.js +38 -0
  234. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
  235. package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +433 -425
  236. package/src/engine/physics/constraint/solve_constraints.d.ts +4 -1
  237. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
  238. package/src/engine/physics/constraint/solve_constraints.js +38 -13
  239. package/src/engine/physics/contact/ManifoldStore.d.ts +15 -3
  240. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
  241. package/src/engine/physics/contact/ManifoldStore.js +15 -3
  242. package/src/engine/physics/ecs/Joint.d.ts +7 -4
  243. package/src/engine/physics/ecs/Joint.d.ts.map +1 -1
  244. package/src/engine/physics/ecs/Joint.js +7 -4
  245. package/src/engine/physics/ecs/PhysicsSystem.d.ts +14 -0
  246. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  247. package/src/engine/physics/ecs/PhysicsSystem.js +16 -0
  248. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  249. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
  250. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts +15 -7
  251. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -1
  252. package/src/engine/physics/narrowphase/convex_convex_manifold.js +33 -10
  253. package/src/engine/physics/narrowphase/refine_ray_concave.d.ts +6 -2
  254. package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
  255. package/src/engine/physics/narrowphase/refine_ray_concave.js +6 -2
  256. package/src/engine/physics/narrowphase/refine_ray_hit.d.ts +6 -2
  257. package/src/engine/physics/narrowphase/refine_ray_hit.d.ts.map +1 -1
  258. package/src/engine/physics/narrowphase/refine_ray_hit.js +6 -2
  259. package/src/engine/physics/queries/raycast.d.ts.map +1 -1
  260. package/src/engine/physics/queries/raycast.js +11 -4
  261. package/src/engine/save/storage/IndexedDBStorage.d.ts.map +1 -1
  262. package/src/engine/save/storage/IndexedDBStorage.js +21 -3
  263. package/src/engine/simulation/Ticker.d.ts +12 -0
  264. package/src/engine/simulation/Ticker.d.ts.map +1 -1
  265. package/src/engine/simulation/Ticker.js +18 -0
  266. package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
  267. package/src/engine/sound/simulation/AcousticSimulator.js +9 -1
  268. package/src/engine/sound/simulation/core/VolumeField.d.ts +6 -2
  269. package/src/engine/sound/simulation/core/VolumeField.d.ts.map +1 -1
  270. package/src/engine/sound/simulation/core/VolumeField.js +6 -2
  271. package/src/engine/sound/simulation/probe/AcousticProbeField.d.ts +6 -2
  272. package/src/engine/sound/simulation/probe/AcousticProbeField.d.ts.map +1 -1
  273. package/src/engine/sound/simulation/probe/AcousticProbeField.js +6 -2
  274. package/src/engine/sound/simulation/probe/acoustic_probe_transfer.d.ts +6 -2
  275. package/src/engine/sound/simulation/probe/acoustic_probe_transfer.d.ts.map +1 -1
  276. package/src/engine/sound/simulation/probe/acoustic_probe_transfer.js +6 -2
  277. package/src/engine/sound/simulation/probe/bakeProbeReflectors.d.ts +3 -1
  278. package/src/engine/sound/simulation/probe/bakeProbeReflectors.d.ts.map +1 -1
  279. package/src/engine/sound/simulation/probe/bakeProbeReflectors.js +3 -1
  280. package/src/engine/ui/GUIEngine.d.ts.map +1 -1
  281. package/src/engine/ui/GUIEngine.js +8 -1
  282. package/src/generation/theme/TerrainTheme.d.ts.map +1 -1
  283. package/src/generation/theme/TerrainTheme.js +2 -1
  284. package/src/generation/theme/ThemeEngine.d.ts.map +1 -1
  285. package/src/generation/theme/ThemeEngine.js +6 -5
  286. package/src/view/ViewGroup.d.ts.map +1 -1
  287. package/src/view/ViewGroup.js +9 -7
  288. package/src/view/graphics/WebGLContextFailureView.d.ts +19 -0
  289. package/src/view/graphics/WebGLContextFailureView.d.ts.map +1 -0
  290. package/src/view/graphics/WebGLContextFailureView.js +76 -0
  291. package/src/view/minimap/Minimap.d.ts +8 -0
  292. package/src/view/minimap/Minimap.d.ts.map +1 -1
  293. package/src/view/minimap/Minimap.js +16 -3
  294. package/src/view/minimap/dom/MinimapMarkerView.d.ts.map +1 -1
  295. package/src/view/minimap/dom/MinimapMarkerView.js +3 -1
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Relative area error of a triangulation produced by {@link polygon2_triangulate}
3
+ * for the same `points` / `contour_ends` / `contour_count`.
4
+ *
5
+ * `0` means the triangles cover exactly the polygon's area. A positive value is
6
+ * the fraction of the polygon that is missing (or, for a self-intersecting input,
7
+ * double-covered). This is the cheap, total-order way to ask "did that work?"
8
+ * without pairwise triangle comparisons -- it is the primary invariant the specs
9
+ * assert, and it is available to callers that need to validate untrusted input at
10
+ * runtime.
11
+ *
12
+ * A degenerate polygon (zero total area) reports `0` when the triangulation is
13
+ * also empty, and `Infinity` when it is not -- there is no meaningful ratio to a
14
+ * zero reference, and silently reporting `0` would call a wrong answer perfect.
15
+ *
16
+ * @param {ArrayLike<number>} result triangle indices as written by {@link polygon2_triangulate}
17
+ * @param {number} result_offset first index of the triangulation within `result`
18
+ * @param {number} triangle_count as returned by {@link polygon2_triangulate}
19
+ * @param {ArrayLike<number>} points flat (x, y) pairs, stride 2
20
+ * @param {ArrayLike<number>} contour_ends exclusive end vertex index per contour
21
+ * @param {number} contour_count
22
+ * @returns {number} relative area error, `0` for an exact triangulation
23
+ *
24
+ * @author Alex Goldring
25
+ * @copyright Company Named Limited (c) 2026
26
+ */
27
+ export function polygon2_triangulation_deviation(result: ArrayLike<number>, result_offset: number, triangle_count: number, points: ArrayLike<number>, contour_ends: ArrayLike<number>, contour_count: number): number;
28
+ //# sourceMappingURL=polygon2_triangulation_deviation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polygon2_triangulation_deviation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/polygon/polygon2_triangulation_deviation.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,yDAXW,UAAU,MAAM,CAAC,iBACjB,MAAM,kBACN,MAAM,UACN,UAAU,MAAM,CAAC,gBACjB,UAAU,MAAM,CAAC,iBACjB,MAAM,GACJ,MAAM,CAoDlB"}
@@ -0,0 +1,77 @@
1
+ import { tri2_signed_area } from "../triangle/tri2_signed_area.js";
2
+ import { polygon2_signed_area } from "./polygon2_signed_area.js";
3
+
4
+ /**
5
+ * Relative area error of a triangulation produced by {@link polygon2_triangulate}
6
+ * for the same `points` / `contour_ends` / `contour_count`.
7
+ *
8
+ * `0` means the triangles cover exactly the polygon's area. A positive value is
9
+ * the fraction of the polygon that is missing (or, for a self-intersecting input,
10
+ * double-covered). This is the cheap, total-order way to ask "did that work?"
11
+ * without pairwise triangle comparisons -- it is the primary invariant the specs
12
+ * assert, and it is available to callers that need to validate untrusted input at
13
+ * runtime.
14
+ *
15
+ * A degenerate polygon (zero total area) reports `0` when the triangulation is
16
+ * also empty, and `Infinity` when it is not -- there is no meaningful ratio to a
17
+ * zero reference, and silently reporting `0` would call a wrong answer perfect.
18
+ *
19
+ * @param {ArrayLike<number>} result triangle indices as written by {@link polygon2_triangulate}
20
+ * @param {number} result_offset first index of the triangulation within `result`
21
+ * @param {number} triangle_count as returned by {@link polygon2_triangulate}
22
+ * @param {ArrayLike<number>} points flat (x, y) pairs, stride 2
23
+ * @param {ArrayLike<number>} contour_ends exclusive end vertex index per contour
24
+ * @param {number} contour_count
25
+ * @returns {number} relative area error, `0` for an exact triangulation
26
+ *
27
+ * @author Alex Goldring
28
+ * @copyright Company Named Limited (c) 2026
29
+ */
30
+ export function polygon2_triangulation_deviation(
31
+ result, result_offset, triangle_count,
32
+ points, contour_ends, contour_count
33
+ ) {
34
+ // Outer contour area, minus every hole's.
35
+ let polygon_area = 0;
36
+
37
+ for (let c = 0; c < contour_count; c++) {
38
+ const from = c === 0 ? 0 : contour_ends[c - 1];
39
+ const to = contour_ends[c];
40
+
41
+ const count = to - from;
42
+
43
+ if (count < 3) {
44
+ continue;
45
+ }
46
+
47
+ const slice = from === 0
48
+ ? points
49
+ : (typeof points.subarray === "function" ? points.subarray(from * 2) : points.slice(from * 2));
50
+
51
+ const area = Math.abs(polygon2_signed_area(slice, count));
52
+
53
+ polygon_area += c === 0 ? area : -area;
54
+ }
55
+
56
+ let triangles_area = 0;
57
+
58
+ for (let t = 0; t < triangle_count; t++) {
59
+ const o = result_offset + t * 3;
60
+
61
+ const a = result[o] * 2;
62
+ const b = result[o + 1] * 2;
63
+ const c = result[o + 2] * 2;
64
+
65
+ triangles_area += Math.abs(tri2_signed_area(
66
+ points[a], points[a + 1],
67
+ points[b], points[b + 1],
68
+ points[c], points[c + 1]
69
+ ));
70
+ }
71
+
72
+ if (polygon_area === 0) {
73
+ return triangles_area === 0 ? 0 : Infinity;
74
+ }
75
+
76
+ return Math.abs(triangles_area - polygon_area) / Math.abs(polygon_area);
77
+ }
@@ -6,9 +6,12 @@
6
6
  * candidate cell square.
7
7
  *
8
8
  * @param {{width:number, height:number, set:(x:number,y:number)=>void}} image
9
- * @param {number} x0 @param {number} y0
10
- * @param {number} x1 @param {number} y1
11
- * @param {number} x2 @param {number} y2
9
+ * @param {number} x0
10
+ * @param {number} y0
11
+ * @param {number} x1
12
+ * @param {number} y1
13
+ * @param {number} x2
14
+ * @param {number} y2
12
15
  */
13
16
  export function tri2_rasterize_conservative(image: {
14
17
  width: number;
@@ -1 +1 @@
1
- {"version":3,"file":"tri2_rasterize_conservative.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/triangle/tri2_rasterize_conservative.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH;WALkB,MAAM;YAAS,MAAM;aAAS,MAAM,KAAG,MAAM,KAAG,IAAI;OAC3D,MAAM,MAAa,MAAM,MACzB,MAAM,MAAa,MAAM,MACzB,MAAM,MAAa,MAAM,QAoBnC"}
1
+ {"version":3,"file":"tri2_rasterize_conservative.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/triangle/tri2_rasterize_conservative.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH;WARkB,MAAM;YAAS,MAAM;aAAS,MAAM,KAAG,MAAM,KAAG,IAAI;OAC3D,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAoBhB"}
@@ -6,9 +6,12 @@
6
6
  * candidate cell square.
7
7
  *
8
8
  * @param {{width:number, height:number, set:(x:number,y:number)=>void}} image
9
- * @param {number} x0 @param {number} y0
10
- * @param {number} x1 @param {number} y1
11
- * @param {number} x2 @param {number} y2
9
+ * @param {number} x0
10
+ * @param {number} y0
11
+ * @param {number} x1
12
+ * @param {number} y1
13
+ * @param {number} x2
14
+ * @param {number} y2
12
15
  */
13
16
  export function tri2_rasterize_conservative(image, x0, y0, x1, y1, x2, y2) {
14
17
  let min_x = Math.floor(Math.min(x0, x1, x2));
@@ -33,11 +36,16 @@ export function tri2_rasterize_conservative(image, x0, y0, x1, y1, x2, y2) {
33
36
  /**
34
37
  * Separating-axis overlap test between a triangle and an axis-aligned box.
35
38
  *
36
- * @param {number} ax @param {number} ay first triangle vertex
37
- * @param {number} bx @param {number} by second triangle vertex
38
- * @param {number} cx @param {number} cy third triangle vertex
39
- * @param {number} bminx @param {number} bminy box minimum corner
40
- * @param {number} bmaxx @param {number} bmaxy box maximum corner
39
+ * @param {number} ax first triangle vertex x
40
+ * @param {number} ay first triangle vertex y
41
+ * @param {number} bx second triangle vertex x
42
+ * @param {number} by second triangle vertex y
43
+ * @param {number} cx third triangle vertex x
44
+ * @param {number} cy third triangle vertex y
45
+ * @param {number} bminx box minimum corner x
46
+ * @param {number} bminy box minimum corner y
47
+ * @param {number} bmaxx box maximum corner x
48
+ * @param {number} bmaxy box maximum corner y
41
49
  * @returns {boolean} true if the triangle and box overlap
42
50
  */
43
51
  function tri_box_overlap(ax, ay, bx, by, cx, cy, bminx, bminy, bmaxx, bmaxy) {
@@ -57,11 +65,16 @@ function tri_box_overlap(ax, ay, bx, by, cx, cy, bminx, bminy, bmaxx, bmaxy) {
57
65
  * Does the outward normal of edge (p->q) separate the box from the triangle?
58
66
  * `r` is the triangle's third vertex (to orient the normal inward).
59
67
  *
60
- * @param {number} px @param {number} py edge start vertex
61
- * @param {number} qx @param {number} qy edge end vertex
62
- * @param {number} rx @param {number} ry triangle's third vertex
63
- * @param {number} bminx @param {number} bminy box minimum corner
64
- * @param {number} bmaxx @param {number} bmaxy box maximum corner
68
+ * @param {number} px edge start vertex x
69
+ * @param {number} py edge start vertex y
70
+ * @param {number} qx edge end vertex x
71
+ * @param {number} qy edge end vertex y
72
+ * @param {number} rx triangle's third vertex x
73
+ * @param {number} ry triangle's third vertex y
74
+ * @param {number} bminx box minimum corner x
75
+ * @param {number} bminy box minimum corner y
76
+ * @param {number} bmaxx box maximum corner x
77
+ * @param {number} bmaxy box maximum corner y
65
78
  * @returns {boolean} true if this edge's axis separates the box from the triangle
66
79
  */
67
80
  function edge_separates(px, py, qx, qy, rx, ry, bminx, bminy, bmaxx, bmaxy) {
@@ -1,5 +1,21 @@
1
1
  /**
2
- * Uses Green's Theorem to compute area of a 2d triangle
2
+ * Signed area of a 2D triangle. Positive for counter-clockwise winding, negative
3
+ * for clockwise, zero when the three points are collinear.
4
+ *
5
+ * The edge vectors are formed FIRST and only then crossed. The algebraically
6
+ * identical expanded form -- `(x0*y1 - y0*x1) + (x1*y2 - y1*x2) + (x2*y0 - y2*x0)`,
7
+ * which this used to compute -- sums three products of ABSOLUTE coordinates, each
8
+ * `O(|p|^2)`, to reach an answer that is only the area. Those terms then cancel,
9
+ * and for a small triangle, or one far from the origin, the computed value -- and
10
+ * worse, its SIGN -- is rounding noise. A 1e-9-sided triangle at (1, 1) has a true
11
+ * area of ~5e-19 against per-term rounding of ~1e-16; the expanded form returns
12
+ * exactly 0. The callers most exposed were the ones that only want the sign: the
13
+ * Polyanya funnel and the atlas parameterisation validity check.
14
+ *
15
+ * This form's error is proportional to the area rather than to the coordinates'
16
+ * magnitude. It is still floating point: for a decision that must be exact
17
+ * regardless of magnitude, use `orient2d_indexed`, which is adaptive-exact.
18
+ *
3
19
  * @param {number} x0
4
20
  * @param {number} y0
5
21
  * @param {number} x1
@@ -1 +1 @@
1
- {"version":3,"file":"tri2_signed_area.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/triangle/tri2_signed_area.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,qCARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAclB"}
1
+ {"version":3,"file":"tri2_signed_area.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/triangle/tri2_signed_area.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qCARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAUlB"}
@@ -1,23 +1,35 @@
1
- /**
2
- * Uses Green's Theorem to compute area of a 2d triangle
3
- * @param {number} x0
4
- * @param {number} y0
5
- * @param {number} x1
6
- * @param {number} y1
7
- * @param {number} x2
8
- * @param {number} y2
9
- * @returns {number}
10
- */
11
- export function tri2_signed_area(
12
- x0, y0,
13
- x1, y1,
14
- x2, y2
15
- ) {
16
-
17
- return (
18
- (x0 * y1 - y0 * x1)
19
- + (x1 * y2 - y1 * x2)
20
- + (x2 * y0 - y2 * x0)
21
- ) * 0.5;
22
-
23
- }
1
+ /**
2
+ * Signed area of a 2D triangle. Positive for counter-clockwise winding, negative
3
+ * for clockwise, zero when the three points are collinear.
4
+ *
5
+ * The edge vectors are formed FIRST and only then crossed. The algebraically
6
+ * identical expanded form -- `(x0*y1 - y0*x1) + (x1*y2 - y1*x2) + (x2*y0 - y2*x0)`,
7
+ * which this used to compute -- sums three products of ABSOLUTE coordinates, each
8
+ * `O(|p|^2)`, to reach an answer that is only the area. Those terms then cancel,
9
+ * and for a small triangle, or one far from the origin, the computed value -- and
10
+ * worse, its SIGN -- is rounding noise. A 1e-9-sided triangle at (1, 1) has a true
11
+ * area of ~5e-19 against per-term rounding of ~1e-16; the expanded form returns
12
+ * exactly 0. The callers most exposed were the ones that only want the sign: the
13
+ * Polyanya funnel and the atlas parameterisation validity check.
14
+ *
15
+ * This form's error is proportional to the area rather than to the coordinates'
16
+ * magnitude. It is still floating point: for a decision that must be exact
17
+ * regardless of magnitude, use `orient2d_indexed`, which is adaptive-exact.
18
+ *
19
+ * @param {number} x0
20
+ * @param {number} y0
21
+ * @param {number} x1
22
+ * @param {number} y1
23
+ * @param {number} x2
24
+ * @param {number} y2
25
+ * @returns {number}
26
+ */
27
+ export function tri2_signed_area(
28
+ x0, y0,
29
+ x1, y1,
30
+ x2, y2
31
+ ) {
32
+
33
+ return ((x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0)) * 0.5;
34
+
35
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Interleave two 16-bit integer coordinates into a 32-bit Morton (Z-order) code.
3
+ *
4
+ * The 2D counterpart of the {@link v3_morton_encode} family. Inputs above 16 bits
5
+ * are silently truncated by {@link split_by_2}'s masking, which is the same
6
+ * contract the 3D encoders carry: callers quantise into range first.
7
+ *
8
+ * Points close in Z-order are close in space, which is what makes a Z-sorted
9
+ * sequence usable as a cheap 1D proxy for a 2D range query -- the acceleration
10
+ * {@link polygon2_triangulate} uses to keep its point-in-ear test local.
11
+ *
12
+ * @param {number} x integer in [0, 65535]
13
+ * @param {number} y integer in [0, 65535]
14
+ * @returns {number} unsigned 32-bit Morton code
15
+ *
16
+ * @author Alex Goldring
17
+ * @copyright Company Named Limited (c) 2026
18
+ */
19
+ export function v2_morton_encode(x: number, y: number): number;
20
+ //# sourceMappingURL=v2_morton_encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2_morton_encode.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/v2_morton_encode.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,oCAPW,MAAM,KACN,MAAM,GACJ,MAAM,CAOlB"}
@@ -0,0 +1,23 @@
1
+ import { split_by_2 } from "../../binary/split_by_2.js";
2
+
3
+ /**
4
+ * Interleave two 16-bit integer coordinates into a 32-bit Morton (Z-order) code.
5
+ *
6
+ * The 2D counterpart of the {@link v3_morton_encode} family. Inputs above 16 bits
7
+ * are silently truncated by {@link split_by_2}'s masking, which is the same
8
+ * contract the 3D encoders carry: callers quantise into range first.
9
+ *
10
+ * Points close in Z-order are close in space, which is what makes a Z-sorted
11
+ * sequence usable as a cheap 1D proxy for a 2D range query -- the acceleration
12
+ * {@link polygon2_triangulate} uses to keep its point-in-ear test local.
13
+ *
14
+ * @param {number} x integer in [0, 65535]
15
+ * @param {number} y integer in [0, 65535]
16
+ * @returns {number} unsigned 32-bit Morton code
17
+ *
18
+ * @author Alex Goldring
19
+ * @copyright Company Named Limited (c) 2026
20
+ */
21
+ export function v2_morton_encode(x, y) {
22
+ return (split_by_2(x) | (split_by_2(y) << 1)) >>> 0;
23
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"atlas_merge_charts.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/atlas/segment/atlas_merge_charts.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qEAPW,UAAU,eACV,MAAM,cACN,YAAY;IAEK,WAAW,GAA5B,MAAM;IACJ;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,CAkFzD"}
1
+ {"version":3,"file":"atlas_merge_charts.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/atlas/segment/atlas_merge_charts.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qEAPW,UAAU,eACV,MAAM,cACN,YAAY;IAEK,WAAW,GAA5B,MAAM;IACJ;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,CAqFzD"}
@@ -52,7 +52,10 @@ export function atlas_merge_charts(mesh, face_chart, chart_count, face_areas, op
52
52
  const parent = new Int32Array(chart_count);
53
53
  for (let c = 0; c < chart_count; c++) parent[c] = c;
54
54
 
55
- /** @param {number} x @returns {number} root with path compression */
55
+ /**
56
+ * @param {number} x
57
+ * @returns {number} root with path compression
58
+ */
56
59
  function find(x) {
57
60
  while (parent[x] !== x) {
58
61
  parent[x] = parent[parent[x]];
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Newell's method: the area-weighted normal of an arbitrary 3D polygon, written
3
+ * to `result` at `result_offset` as a unit vector.
4
+ *
5
+ * Unlike taking the cross product of the first three vertices
6
+ * (what {@link bt_mesh_compute_face_normals} does, correctly, for triangles),
7
+ * this is defined for any vertex count, is immune to a collinear or coincident
8
+ * leading triple, and for a non-planar polygon returns the normal of its
9
+ * best-fit plane rather than of one arbitrary corner. That is exactly what
10
+ * projecting an n-gon down to 2D needs.
11
+ *
12
+ * A polygon with no area -- fewer than three vertices, all collinear, or all
13
+ * coincident -- has no normal; `result` is then written as `(0, 0, 0)`, which
14
+ * callers can test with a length check. That is a real outcome of real data, not
15
+ * an error.
16
+ *
17
+ * @param {ArrayLike<number>} result
18
+ * @param {number} result_offset
19
+ * @param {ArrayLike<number>} points flat (x, y, z) triples, stride 3
20
+ * @param {number} from first vertex index of the contour
21
+ * @param {number} count number of vertices in the contour
22
+ *
23
+ * @author Alex Goldring
24
+ * @copyright Company Named Limited (c) 2026
25
+ */
26
+ export function polygon3_compute_normal(result: ArrayLike<number>, result_offset: number, points: ArrayLike<number>, from: number, count: number): void;
27
+ //# sourceMappingURL=polygon3_compute_normal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polygon3_compute_normal.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/polygon/polygon3_compute_normal.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,gDATW,UAAU,MAAM,CAAC,iBACjB,MAAM,UACN,UAAU,MAAM,CAAC,QACjB,MAAM,SACN,MAAM,QAuChB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Newell's method: the area-weighted normal of an arbitrary 3D polygon, written
3
+ * to `result` at `result_offset` as a unit vector.
4
+ *
5
+ * Unlike taking the cross product of the first three vertices
6
+ * (what {@link bt_mesh_compute_face_normals} does, correctly, for triangles),
7
+ * this is defined for any vertex count, is immune to a collinear or coincident
8
+ * leading triple, and for a non-planar polygon returns the normal of its
9
+ * best-fit plane rather than of one arbitrary corner. That is exactly what
10
+ * projecting an n-gon down to 2D needs.
11
+ *
12
+ * A polygon with no area -- fewer than three vertices, all collinear, or all
13
+ * coincident -- has no normal; `result` is then written as `(0, 0, 0)`, which
14
+ * callers can test with a length check. That is a real outcome of real data, not
15
+ * an error.
16
+ *
17
+ * @param {ArrayLike<number>} result
18
+ * @param {number} result_offset
19
+ * @param {ArrayLike<number>} points flat (x, y, z) triples, stride 3
20
+ * @param {number} from first vertex index of the contour
21
+ * @param {number} count number of vertices in the contour
22
+ *
23
+ * @author Alex Goldring
24
+ * @copyright Company Named Limited (c) 2026
25
+ */
26
+ export function polygon3_compute_normal(result, result_offset, points, from, count) {
27
+ let nx = 0;
28
+ let ny = 0;
29
+ let nz = 0;
30
+
31
+ const to = from + count;
32
+
33
+ for (let i = from; i < to; i++) {
34
+ const j = (i + 1 === to) ? from : i + 1;
35
+
36
+ const i3 = i * 3;
37
+ const j3 = j * 3;
38
+
39
+ const ax = points[i3], ay = points[i3 + 1], az = points[i3 + 2];
40
+ const bx = points[j3], by = points[j3 + 1], bz = points[j3 + 2];
41
+
42
+ nx += (ay - by) * (az + bz);
43
+ ny += (az - bz) * (ax + bx);
44
+ nz += (ax - bx) * (ay + by);
45
+ }
46
+
47
+ const length = Math.sqrt(nx * nx + ny * ny + nz * nz);
48
+
49
+ if (length === 0) {
50
+ result[result_offset] = 0;
51
+ result[result_offset + 1] = 0;
52
+ result[result_offset + 2] = 0;
53
+
54
+ return;
55
+ }
56
+
57
+ result[result_offset] = nx / length;
58
+ result[result_offset + 1] = ny / length;
59
+ result[result_offset + 2] = nz / length;
60
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Triangulate a planar 3D polygon with holes, viewed along `-normal`.
3
+ *
4
+ * The polygon is projected to 2D by **dropping the axis the normal points most
5
+ * strongly along** and keeping the other two verbatim, swapped when that
6
+ * component is negative so the projection stays counter-clockwise as seen from
7
+ * `+normal`. Nothing is rotated and no coordinate is recomputed, which is the
8
+ * whole point: {@link polygon2_triangulate} decides exactly, and it can only do
9
+ * that on coordinates that are exactly the input's. A rotation into a fitted
10
+ * plane basis would round every vertex first and hand the exact predicate
11
+ * approximate data.
12
+ *
13
+ * `normal` need not be normalised, but it must not be zero. Derive it with
14
+ * {@link polygon3_compute_normal} when the caller has no authoritative one.
15
+ *
16
+ * Output indices address `points3` -- the same vertices the caller passed in --
17
+ * and each triangle is counter-clockwise when viewed from `+normal`.
18
+ *
19
+ * @param {Uint32Array} result receives 3 point indices per triangle
20
+ * @param {number} result_offset first index written in `result`
21
+ * @param {ArrayLike<number>} points3 flat (x, y, z) triples, stride 3
22
+ * @param {ArrayLike<number>} contour_ends exclusive end vertex index per contour
23
+ * @param {number} contour_count number of contours; contour 0 is the outer boundary
24
+ * @param {number} nx
25
+ * @param {number} ny
26
+ * @param {number} nz polygon normal, need not be unit length
27
+ * @returns {number} number of triangles written; see {@link polygon2_triangulate}
28
+ * for what a short count means
29
+ *
30
+ * @author Alex Goldring
31
+ * @copyright Company Named Limited (c) 2026
32
+ */
33
+ export function polygon3_triangulate(result: Uint32Array, result_offset: number, points3: ArrayLike<number>, contour_ends: ArrayLike<number>, contour_count: number, nx: number, ny: number, nz: number): number;
34
+ //# sourceMappingURL=polygon3_triangulate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polygon3_triangulate.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/polygon/polygon3_triangulate.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,6CAdW,WAAW,iBACX,MAAM,WACN,UAAU,MAAM,CAAC,gBACjB,UAAU,MAAM,CAAC,iBACjB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAwDlB"}
@@ -0,0 +1,94 @@
1
+ import { assert } from "../../../assert.js";
2
+ import { polygon2_triangulate } from "../../2d/polygon/polygon2_triangulate.js";
3
+
4
+ /**
5
+ * Projected (u, v) per vertex for the current call. Module-static and grown on
6
+ * demand, matching {@link polygon2_triangulate}'s own storage -- and, like it,
7
+ * this function is therefore not re-entrant.
8
+ * @type {Float64Array}
9
+ */
10
+ let _projected = new Float64Array(0);
11
+
12
+ /**
13
+ * Triangulate a planar 3D polygon with holes, viewed along `-normal`.
14
+ *
15
+ * The polygon is projected to 2D by **dropping the axis the normal points most
16
+ * strongly along** and keeping the other two verbatim, swapped when that
17
+ * component is negative so the projection stays counter-clockwise as seen from
18
+ * `+normal`. Nothing is rotated and no coordinate is recomputed, which is the
19
+ * whole point: {@link polygon2_triangulate} decides exactly, and it can only do
20
+ * that on coordinates that are exactly the input's. A rotation into a fitted
21
+ * plane basis would round every vertex first and hand the exact predicate
22
+ * approximate data.
23
+ *
24
+ * `normal` need not be normalised, but it must not be zero. Derive it with
25
+ * {@link polygon3_compute_normal} when the caller has no authoritative one.
26
+ *
27
+ * Output indices address `points3` -- the same vertices the caller passed in --
28
+ * and each triangle is counter-clockwise when viewed from `+normal`.
29
+ *
30
+ * @param {Uint32Array} result receives 3 point indices per triangle
31
+ * @param {number} result_offset first index written in `result`
32
+ * @param {ArrayLike<number>} points3 flat (x, y, z) triples, stride 3
33
+ * @param {ArrayLike<number>} contour_ends exclusive end vertex index per contour
34
+ * @param {number} contour_count number of contours; contour 0 is the outer boundary
35
+ * @param {number} nx
36
+ * @param {number} ny
37
+ * @param {number} nz polygon normal, need not be unit length
38
+ * @returns {number} number of triangles written; see {@link polygon2_triangulate}
39
+ * for what a short count means
40
+ *
41
+ * @author Alex Goldring
42
+ * @copyright Company Named Limited (c) 2026
43
+ */
44
+ export function polygon3_triangulate(
45
+ result, result_offset,
46
+ points3, contour_ends, contour_count,
47
+ nx, ny, nz
48
+ ) {
49
+ assert.isArrayLike(points3, "points3");
50
+ assert.isPositiveInteger(contour_count, "contour_count");
51
+ assert.ok(nx !== 0 || ny !== 0 || nz !== 0, "polygon normal must not be zero");
52
+
53
+ const vertex_count = contour_ends[contour_count - 1];
54
+
55
+ if (vertex_count < 3) {
56
+ return 0;
57
+ }
58
+
59
+ if (_projected.length < vertex_count * 2) {
60
+ _projected = new Float64Array(vertex_count * 2);
61
+ }
62
+
63
+ const ax = Math.abs(nx);
64
+ const ay = Math.abs(ny);
65
+ const az = Math.abs(nz);
66
+
67
+ // Component offsets of the two axes kept, in the order that preserves
68
+ // counter-clockwise winding seen from +normal:
69
+ // +x -> (y, z) -x -> (z, y)
70
+ // +y -> (z, x) -y -> (x, z)
71
+ // +z -> (x, y) -z -> (y, x)
72
+ let u_axis;
73
+ let v_axis;
74
+
75
+ if (ax >= ay && ax >= az) {
76
+ u_axis = nx > 0 ? 1 : 2;
77
+ v_axis = nx > 0 ? 2 : 1;
78
+ } else if (ay >= az) {
79
+ u_axis = ny > 0 ? 2 : 0;
80
+ v_axis = ny > 0 ? 0 : 2;
81
+ } else {
82
+ u_axis = nz > 0 ? 0 : 1;
83
+ v_axis = nz > 0 ? 1 : 0;
84
+ }
85
+
86
+ for (let i = 0; i < vertex_count; i++) {
87
+ const i3 = i * 3;
88
+
89
+ _projected[i * 2] = points3[i3 + u_axis];
90
+ _projected[i * 2 + 1] = points3[i3 + v_axis];
91
+ }
92
+
93
+ return polygon2_triangulate(result, result_offset, _projected, contour_ends, contour_count);
94
+ }
@@ -14,8 +14,14 @@
14
14
  *
15
15
  * @param {number[]|Float32Array|Float64Array} out
16
16
  * @param {number} out_offset offset into `out`; receives 4 floats (x, y, z, w)
17
- * @param {number} ax @param {number} ay @param {number} az @param {number} aw
18
- * @param {number} bx @param {number} by @param {number} bz @param {number} bw
17
+ * @param {number} ax
18
+ * @param {number} ay
19
+ * @param {number} az
20
+ * @param {number} aw
21
+ * @param {number} bx
22
+ * @param {number} by
23
+ * @param {number} bz
24
+ * @param {number} bw
19
25
  */
20
26
  export function quat3_multiply(out: number[] | Float32Array | Float64Array, out_offset: number, ax: number, ay: number, az: number, aw: number, bx: number, by: number, bz: number, bw: number): void;
21
27
  //# sourceMappingURL=quat3_multiply.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quat3_multiply.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/quaternion/quat3_multiply.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,oCALW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,cAClC,MAAM,MACN,MAAM,MAAa,MAAM,MAAa,MAAM,MAAa,MAAM,MAC/D,MAAM,MAAa,MAAM,MAAa,MAAM,MAAa,MAAM,QAOzE"}
1
+ {"version":3,"file":"quat3_multiply.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/quaternion/quat3_multiply.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,oCAXW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,cAClC,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAOhB"}
@@ -14,8 +14,14 @@
14
14
  *
15
15
  * @param {number[]|Float32Array|Float64Array} out
16
16
  * @param {number} out_offset offset into `out`; receives 4 floats (x, y, z, w)
17
- * @param {number} ax @param {number} ay @param {number} az @param {number} aw
18
- * @param {number} bx @param {number} by @param {number} bz @param {number} bw
17
+ * @param {number} ax
18
+ * @param {number} ay
19
+ * @param {number} az
20
+ * @param {number} aw
21
+ * @param {number} bx
22
+ * @param {number} by
23
+ * @param {number} bz
24
+ * @param {number} bw
19
25
  */
20
26
  export function quat3_multiply(out, out_offset, ax, ay, az, aw, bx, by, bz, bw) {
21
27
  out[out_offset] = aw * bx + ax * bw + ay * bz - az * by;
@@ -1 +1 @@
1
- {"version":3,"file":"ConvexHullShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/ConvexHullShape3D.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;IA+CI;;;;;;;OAOG;IACH,sBAJW,YAAY,WACZ,WAAW,GACT,iBAAiB,CAQ7B;IAxDG;;;;OAIG;IACH,UAFU,YAAY,CAEa;IAEnC;;;;OAIG;IACH,SAFU,WAAW,CAEY;IAEjC;;;;;;OAMG;IACH,cAFU,WAAW,CAEiB;IACtC,0BAA0B;IAC1B,YADW,WAAW,CACc;IAEpC;;;;;;OAMG;IACH,iBAAmC;IAEnC,oCAAoC;IACpC,eAAiC;IACjC,8BAA8B;IAC9B,iBAAiB;IACjB,8BAA8B;IAC9B,uBAAuB;IAmB3B;;;OAGG;IACH,kBAmDC;IAKD,wCAIC;IAED;;;;;OAKG;IACH,qGAgBC;IAED;;;OAGG;IACH,oCAgBC;IAED;;;OAGG;IACH,6CAwBC;IAED,mEAEC;IAED,4DAwBC;IAED,kFAmBC;IAED;;;OAGG;IACH,cAHW,iBAAiB,GACf,OAAO,CAanB;IAcL;;;;OAIG;IACH,8BAFU,OAAO,CAE8B;CAP9C;gCAxT+B,sBAAsB"}
1
+ {"version":3,"file":"ConvexHullShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/ConvexHullShape3D.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;IA+CI;;;;;;;OAOG;IACH,sBAJW,YAAY,WACZ,WAAW,GACT,iBAAiB,CAQ7B;IAxDG;;;;OAIG;IACH,UAFU,YAAY,CAEa;IAEnC;;;;OAIG;IACH,SAFU,WAAW,CAEY;IAEjC;;;;;;OAMG;IACH,cAFU,WAAW,CAEiB;IACtC,0BAA0B;IAC1B,YADW,WAAW,CACc;IAEpC;;;;;;OAMG;IACH,iBAAmC;IAEnC,oCAAoC;IACpC,eAAiC;IACjC,8BAA8B;IAC9B,iBAAiB;IACjB,8BAA8B;IAC9B,uBAAuB;IAmB3B;;;OAGG;IACH,kBAiFC;IAKD,wCAIC;IAED;;;;;OAKG;IACH,qGAgBC;IAED;;;OAGG;IACH,oCAgBC;IAED;;;OAGG;IACH,6CAwBC;IAED,mEAEC;IAED,4DAwBC;IAED,kFAmBC;IAED;;;OAGG;IACH,cAHW,iBAAiB,GACf,OAAO,CAanB;IAcL;;;;OAIG;IACH,8BAFU,OAAO,CAE8B;CAP9C;gCAtV+B,sBAAsB"}