@woosh/meep-engine 3.29.0 → 3.30.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 (226) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/package.json +1 -1
  4. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  5. package/src/core/binary/BinaryBuffer.js +14 -2
  6. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  7. package/src/core/bvh2/bvh3/BVH.js +14 -1
  8. package/src/core/cache/FrequencySketch.d.ts +3 -1
  9. package/src/core/cache/FrequencySketch.d.ts.map +1 -1
  10. package/src/core/cache/FrequencySketch.js +10 -4
  11. package/src/core/cache/wtinylfu/CacheWTinylfu.d.ts.map +1 -1
  12. package/src/core/cache/wtinylfu/CacheWTinylfu.js +24 -2
  13. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.d.ts +20 -0
  14. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.d.ts.map +1 -1
  15. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.js +69 -4
  16. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts +48 -18
  17. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
  18. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +262 -70
  19. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_fold_limit.d.ts +25 -0
  20. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_fold_limit.d.ts.map +1 -0
  21. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_fold_limit.js +228 -0
  22. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_would_fold.d.ts +13 -0
  23. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_would_fold.d.ts.map +1 -1
  24. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_would_fold.js +10 -128
  25. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_face_bvh.d.ts.map +1 -1
  26. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_face_bvh.js +11 -1
  27. package/src/core/graph/mn_graph_collapse_weighted_edge.js +6 -6
  28. package/src/core/math/lookup/ParameterLookupTable.d.ts.map +1 -1
  29. package/src/core/math/lookup/ParameterLookupTable.js +10 -5
  30. package/src/core/math/noise/sdnoise.d.ts.map +1 -1
  31. package/src/core/math/noise/sdnoise.js +16 -10
  32. package/src/core/model/object/ImmutableObjectPool.d.ts.map +1 -1
  33. package/src/core/model/object/ImmutableObjectPool.js +17 -7
  34. package/src/core/process/executor/ConcurrentExecutor.d.ts +1 -5
  35. package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
  36. package/src/core/process/executor/ConcurrentExecutor.js +95 -1
  37. package/src/core/process/task/task_find_dependency_cycle.d.ts +17 -0
  38. package/src/core/process/task/task_find_dependency_cycle.d.ts.map +1 -0
  39. package/src/core/process/task/task_find_dependency_cycle.js +81 -0
  40. package/src/core/wfc/WFCCellChoice.d.ts +17 -0
  41. package/src/core/wfc/WFCCellChoice.d.ts.map +1 -0
  42. package/src/core/wfc/WFCCellChoice.js +36 -0
  43. package/src/core/wfc/WFCLattice.d.ts +105 -0
  44. package/src/core/wfc/WFCLattice.d.ts.map +1 -0
  45. package/src/core/wfc/WFCLattice.js +235 -0
  46. package/src/core/wfc/WFCRuleTable.d.ts +172 -0
  47. package/src/core/wfc/WFCRuleTable.d.ts.map +1 -0
  48. package/src/core/wfc/WFCRuleTable.js +334 -0
  49. package/src/core/wfc/WFCState.d.ts +273 -0
  50. package/src/core/wfc/WFCState.d.ts.map +1 -0
  51. package/src/core/wfc/WFCState.js +552 -0
  52. package/src/core/wfc/WFCStatus.d.ts +11 -0
  53. package/src/core/wfc/WFCStatus.d.ts.map +1 -0
  54. package/src/core/wfc/WFCStatus.js +28 -0
  55. package/src/core/wfc/WFCTileWeights.d.ts +48 -0
  56. package/src/core/wfc/WFCTileWeights.d.ts.map +1 -0
  57. package/src/core/wfc/WFCTileWeights.js +86 -0
  58. package/src/core/wfc/WFC_UNRESOLVED.d.ts +12 -0
  59. package/src/core/wfc/WFC_UNRESOLVED.d.ts.map +1 -0
  60. package/src/core/wfc/WFC_UNRESOLVED.js +11 -0
  61. package/src/core/wfc/wfc_estimate_bytes.d.ts +24 -0
  62. package/src/core/wfc/wfc_estimate_bytes.d.ts.map +1 -0
  63. package/src/core/wfc/wfc_estimate_bytes.js +47 -0
  64. package/src/core/wfc/wfc_rule_table_tile_components.d.ts +27 -0
  65. package/src/core/wfc/wfc_rule_table_tile_components.d.ts.map +1 -0
  66. package/src/core/wfc/wfc_rule_table_tile_components.js +80 -0
  67. package/src/core/wfc/wfc_solve.d.ts +21 -0
  68. package/src/core/wfc/wfc_solve.d.ts.map +1 -0
  69. package/src/core/wfc/wfc_solve.js +154 -0
  70. package/src/core/wfc/wfc_state_apply_boundary.d.ts +18 -0
  71. package/src/core/wfc/wfc_state_apply_boundary.d.ts.map +1 -0
  72. package/src/core/wfc/wfc_state_apply_boundary.js +61 -0
  73. package/src/core/wfc/wfc_state_assign.d.ts +11 -0
  74. package/src/core/wfc/wfc_state_assign.d.ts.map +1 -0
  75. package/src/core/wfc/wfc_state_assign.js +36 -0
  76. package/src/core/wfc/wfc_state_ban_bits.d.ts +17 -0
  77. package/src/core/wfc/wfc_state_ban_bits.d.ts.map +1 -0
  78. package/src/core/wfc/wfc_state_ban_bits.js +81 -0
  79. package/src/core/wfc/wfc_state_collapse.d.ts +12 -0
  80. package/src/core/wfc/wfc_state_collapse.d.ts.map +1 -0
  81. package/src/core/wfc/wfc_state_collapse.js +73 -0
  82. package/src/core/wfc/wfc_state_flush_dirty.d.ts +12 -0
  83. package/src/core/wfc/wfc_state_flush_dirty.d.ts.map +1 -0
  84. package/src/core/wfc/wfc_state_flush_dirty.js +39 -0
  85. package/src/core/wfc/wfc_state_propagate.d.ts +14 -0
  86. package/src/core/wfc/wfc_state_propagate.d.ts.map +1 -0
  87. package/src/core/wfc/wfc_state_propagate.js +155 -0
  88. package/src/core/wfc/wfc_state_read.d.ts +11 -0
  89. package/src/core/wfc/wfc_state_read.d.ts.map +1 -0
  90. package/src/core/wfc/wfc_state_read.js +38 -0
  91. package/src/core/wfc/wfc_state_restrict.d.ts +18 -0
  92. package/src/core/wfc/wfc_state_restrict.d.ts.map +1 -0
  93. package/src/core/wfc/wfc_state_restrict.js +39 -0
  94. package/src/core/wfc/wfc_state_set_eligible.d.ts +24 -0
  95. package/src/core/wfc/wfc_state_set_eligible.d.ts.map +1 -0
  96. package/src/core/wfc/wfc_state_set_eligible.js +49 -0
  97. package/src/core/wfc/wfc_state_undo_to.d.ts +13 -0
  98. package/src/core/wfc/wfc_state_undo_to.d.ts.map +1 -0
  99. package/src/core/wfc/wfc_state_undo_to.js +84 -0
  100. package/src/core/wfc/wfc_words_per_cell.d.ts +11 -0
  101. package/src/core/wfc/wfc_words_per_cell.d.ts.map +1 -0
  102. package/src/core/wfc/wfc_words_per_cell.js +16 -0
  103. package/src/engine/ecs/EntityComponentDataset.d.ts +8 -0
  104. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  105. package/src/engine/ecs/EntityComponentDataset.js +37 -14
  106. package/src/engine/ecs/fow/FogOfWarRevealerSystem.d.ts +8 -1
  107. package/src/engine/ecs/fow/FogOfWarRevealerSystem.d.ts.map +1 -1
  108. package/src/engine/ecs/fow/FogOfWarRevealerSystem.js +37 -2
  109. package/src/engine/ecs/guid/UUID.d.ts.map +1 -1
  110. package/src/engine/ecs/guid/UUID.js +45 -17
  111. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.d.ts.map +1 -1
  112. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +3 -1
  113. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
  114. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +366 -360
  115. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.d.ts.map +1 -1
  116. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.js +24 -10
  117. package/src/engine/grid/grid2transform/GridPosition2TransformSystem.d.ts.map +1 -1
  118. package/src/engine/grid/grid2transform/GridPosition2TransformSystem.js +24 -5
  119. package/src/engine/interpolation/Interpoland.d.ts +7 -1
  120. package/src/engine/interpolation/Interpoland.d.ts.map +1 -1
  121. package/src/engine/interpolation/Interpoland.js +8 -1
  122. package/src/engine/interpolation/InterpolationSystem.d.ts.map +1 -1
  123. package/src/engine/interpolation/InterpolationSystem.js +3 -0
  124. package/src/engine/interpolation/TransformPoseSerializationAdapter.d.ts +5 -3
  125. package/src/engine/interpolation/TransformPoseSerializationAdapter.d.ts.map +1 -1
  126. package/src/engine/interpolation/TransformPoseSerializationAdapter.js +14 -3
  127. package/src/engine/interpolation/pose_interpoland.d.ts.map +1 -1
  128. package/src/engine/interpolation/pose_interpoland.js +2 -0
  129. package/src/engine/network/orchestrator/NetworkPeer.d.ts.map +1 -1
  130. package/src/engine/network/orchestrator/NetworkPeer.js +15 -10
  131. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  132. package/src/engine/physics/cloth/ecs/ClothWorld.js +17 -0
  133. package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
  134. package/src/engine/physics/mls-mpm/MLS_MPM.js +14 -0
  135. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts +2 -1
  136. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts.map +1 -1
  137. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +1 -1
  138. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts +1 -0
  139. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts.map +1 -1
  140. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts +1 -0
  141. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts.map +1 -1
  142. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts +2 -1
  143. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts.map +1 -1
  144. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +12 -3
  145. package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts +1 -0
  146. package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts.map +1 -1
  147. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +1 -0
  148. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -1
  149. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  150. package/src/engine/sound/sopra/runtime/EventInstance.js +4 -1
  151. package/src/format/image/avif/av1/decode/decode_coefficients.d.ts.map +1 -1
  152. package/src/format/image/avif/av1/decode/decode_coefficients.js +248 -259
  153. package/src/format/image/avif/av1/decode/read_golomb.d.ts +21 -0
  154. package/src/format/image/avif/av1/decode/read_golomb.d.ts.map +1 -0
  155. package/src/format/image/avif/av1/decode/read_golomb.js +49 -0
  156. package/src/format/image/avif/av1/filter/loop_restoration.js +461 -451
  157. package/src/format/image/avif/av1/util/round2.d.ts +19 -2
  158. package/src/format/image/avif/av1/util/round2.d.ts.map +1 -1
  159. package/src/format/image/avif/av1/util/round2.js +51 -27
  160. package/src/format/image/avif/heif/parse_avif_file.js +24 -0
  161. package/src/shade/renderer/buffer/table/GPUTypedTable.d.ts.map +1 -1
  162. package/src/shade/renderer/buffer/table/GPUTypedTable.js +14 -0
  163. package/src/shade/renderer/geometry/virtual/VIRTUAL_GEOMETRY_DESIGN.md +46 -3
  164. package/src/shade/renderer/geometry/virtual/WEDGE_PLAN_2026_09_18.md +91 -1
  165. package/src/shade/renderer/geometry/virtual/build/VGeoBuildOptions.d.ts +0 -13
  166. package/src/shade/renderer/geometry/virtual/build/VGeoBuildOptions.d.ts.map +1 -1
  167. package/src/shade/renderer/geometry/virtual/build/VGeoBuildOptions.js +0 -15
  168. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +5 -5
  169. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_DEFAULT_ATTRIBUTE_WEIGHT_RATIOS.d.ts +11 -1
  170. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_DEFAULT_ATTRIBUTE_WEIGHT_RATIOS.d.ts.map +1 -1
  171. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_DEFAULT_ATTRIBUTE_WEIGHT_RATIOS.js +11 -1
  172. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_compute_vertex_normals.d.ts +18 -9
  173. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_compute_vertex_normals.d.ts.map +1 -1
  174. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_compute_vertex_normals.js +20 -26
  175. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_normalize_source.d.ts +1 -3
  176. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_normalize_source.d.ts.map +1 -1
  177. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_normalize_source.js +2 -5
  178. package/src/shade/renderer/geometry/virtual/build/vgeo_build.js +1 -1
  179. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.d.ts.map +1 -1
  180. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.js +14 -1
  181. package/src/shade/renderer/global_illumination/probe/octahedral/GPUProbeAtlas.d.ts.map +1 -1
  182. package/src/shade/renderer/global_illumination/probe/octahedral/GPUProbeAtlas.js +12 -3
  183. package/src/shade/renderer/light/environment/rgbe/RGBE_ReadPixels_RLE.d.ts.map +1 -1
  184. package/src/shade/renderer/light/environment/rgbe/RGBE_ReadPixels_RLE.js +7 -1
  185. package/src/shade/renderer/lightmap/GPULightMap.d.ts.map +1 -1
  186. package/src/shade/renderer/lightmap/GPULightMap.js +349 -336
  187. package/src/shade/renderer/loader/gltf/load_gltf.d.ts.map +1 -1
  188. package/src/shade/renderer/loader/gltf/load_gltf.js +1137 -1128
  189. package/src/shade/renderer/particles/DESIGN.md +14 -5
  190. package/src/shade/renderer/particles/GPUParticleSystem.d.ts +25 -10
  191. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  192. package/src/shade/renderer/particles/GPUParticleSystem.js +182 -38
  193. package/src/shade/renderer/particles/graph/groups/simplex_reference.d.ts.map +1 -1
  194. package/src/shade/renderer/particles/graph/groups/simplex_reference.js +16 -10
  195. package/src/shade/renderer/particles/graph_particles.d.ts +4 -2
  196. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  197. package/src/shade/renderer/particles/graph_particles.js +8 -2
  198. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
  199. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +8 -2
  200. package/src/shade/renderer/particles/optimizer/pass_fold_constants.d.ts.map +1 -1
  201. package/src/shade/renderer/particles/optimizer/pass_fold_constants.js +10 -4
  202. package/src/shade/renderer/particles/shaders/shader_particle_init_free_list.d.ts +31 -0
  203. package/src/shade/renderer/particles/shaders/shader_particle_init_free_list.d.ts.map +1 -0
  204. package/src/shade/renderer/particles/shaders/shader_particle_init_free_list.js +62 -0
  205. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +13 -0
  206. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
  207. package/src/shade/renderer/particles/vm/ParticleVMReference.js +95 -17
  208. package/src/shade/renderer/rasterize/bucket/rasterization_has_opaque_bucket.d.ts +21 -0
  209. package/src/shade/renderer/rasterize/bucket/rasterization_has_opaque_bucket.d.ts.map +1 -0
  210. package/src/shade/renderer/rasterize/bucket/rasterization_has_opaque_bucket.js +28 -0
  211. package/src/shade/renderer/rasterize/fast/graph_rasterize_scene_fast.d.ts.map +1 -1
  212. package/src/shade/renderer/rasterize/fast/graph_rasterize_scene_fast.js +19 -2
  213. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.d.ts.map +1 -1
  214. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.js +19 -2
  215. package/src/shade/renderer/shader/type/WebGPUStruct.d.ts.map +1 -1
  216. package/src/shade/renderer/shader/type/WebGPUStruct.js +12 -0
  217. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts +8 -2
  218. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
  219. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +41 -6
  220. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +2383 -2356
  221. package/src/view/tooltip/DomTooltipManager.d.ts +7 -0
  222. package/src/view/tooltip/DomTooltipManager.d.ts.map +1 -1
  223. package/src/view/tooltip/DomTooltipManager.js +22 -0
  224. package/src/view/tooltip/DomTooltipObserver.d.ts.map +1 -1
  225. package/src/view/tooltip/DomTooltipObserver.js +13 -3
  226. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_CREASE_ANGLE.js +0 -45
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Advanced 3D game engine",
7
7
  "type": "module",
8
8
  "author": "Alexander Goldring",
9
- "version": "3.29.0",
9
+ "version": "3.30.0",
10
10
  "exports": {
11
11
  "./build/*": "./build/*",
12
12
  "./src/*": "./src/*",
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/BinaryBuffer.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAg2CI;;;;OAIG;IACH,4BAHW,UAAU,GACT,YAAY,CAUvB;IAED;;;;OAIG;IACH,0BAHW,WAAW,GACV,YAAY,CAQvB;IAED;;;;;OAKG;IACH,8BAJW,YAAY,UACZ,YAAY,GACV,MAAM,CAQlB;IAED;;;;;OAKG;IACH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IACH,mBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAgBhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAgBhB;IAED;;;;;;OAMG;IACH,oBAFW,MAAM,QAuBhB;IAED;;;OAGG;IACH,eAFa,MAAM,CAqBlB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAShB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAShB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAShB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAShB;IAED;;;;;OAKG;IACH,yBAJW,WAAW,GAAC,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,iBACtC,MAAM,UACN,MAAM,QAYhB;IAED;;;;;OAKG;IACH,kBAJW,UAAU,GAAC,iBAAiB,iBAC5B,MAAM,UACN,MAAM,QAgChB;IAED;;;;;OAKG;IACH,uBAJW,UAAU,sBACV,MAAM,UACN,MAAM,QAiBhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAgGhB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAuElB;IAED;;;;;;;;OAQG;IACH,yBAFW,MAAM,QAuBhB;IAED;;;;;;;;;OASG;IACH,4BAJW,MAAM,oBACN,OAAO,GACL,MAAM,CAoBlB;IAED;;;;OAIG;IACH,YAFY,MAAM,CAIjB;IAED;;;;;;;;;;;OAWG;IACH,eAFY,MAAM,CAcjB;IAsJL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;CANpC;2BA5hD0B,iBAAiB"}
1
+ {"version":3,"file":"BinaryBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/BinaryBuffer.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IA42CI;;;;OAIG;IACH,4BAHW,UAAU,GACT,YAAY,CAUvB;IAED;;;;OAIG;IACH,0BAHW,WAAW,GACV,YAAY,CAQvB;IAED;;;;;OAKG;IACH,8BAJW,YAAY,UACZ,YAAY,GACV,MAAM,CAQlB;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AQhB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAgBhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAgBhB;IAED;;;;;;OAMG;IACH,oBAFW,MAAM,QAmChB;IAED;;;OAGG;IACH,eAFa,MAAM,CAqBlB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAShB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAShB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAShB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAShB;IAED;;;;;OAKG;IACH,yBAJW,WAAW,GAAC,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,iBACtC,MAAM,UACN,MAAM,QAYhB;IAED;;;;;OAKG;IACH,kBAJW,UAAU,GAAC,iBAAiB,iBAC5B,MAAM,UACN,MAAM,QAgChB;IAED;;;;;OAKG;IACH,uBAJW,UAAU,sBACV,MAAM,UACN,MAAM,QAiBhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAgGhB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAuElB;IAED;;;;;;;;OAQG;IACH,yBAFW,MAAM,QAuBhB;IAED;;;;;;;;;OASG;IACH,4BAJW,MAAM,oBACN,OAAO,GACL,MAAM,CAoBlB;IAED;;;;OAIG;IACH,YAFY,MAAM,CAIjB;IAED;;;;;;;;;;;OAWG;IACH,eAFY,MAAM,CAcjB;IAsJL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;CANpC;2BAxiD0B,iBAAiB"}
@@ -974,8 +974,20 @@ export class BinaryBuffer {
974
974
  * @param {number} value must be an unsigned integer
975
975
  */
976
976
  writeUintVar(value) {
977
- assert.isNonNegativeInteger(value, 'value');
978
- assert.ok(value <= MAX_SAFE_UINT_VAR, `value=[${value}] exceeds maximum safe limit[=${MAX_SAFE_UINT_VAR}]`);
977
+ /**
978
+ * Deliberately an ordinary throw and not an `assert.*`: the accumulator below uses a signed
979
+ * `>>=`, so a value at or above 2^31 coerces to a negative int32 and `-1 >> 7 === -1` spins
980
+ * the loop forever, writing 0x80 until the heap gives out. The consumer strips asserts, so a
981
+ * strippable guard is no guard at all in the build that ships. `MAX_SAFE_UINT_VAR` is 2^31-1,
982
+ * which is also the ceiling {@link #readUintVar} can reconstruct, so this is the format's
983
+ * own limit rather than a conservative one.
984
+ *
985
+ * `(value | 0) !== value` catches non-integers, NaN and anything outside int32 in one test;
986
+ * `value < 0` takes the negative half of that range.
987
+ */
988
+ if ((value | 0) !== value || value < 0) {
989
+ throw new RangeError(`value=[${value}] must be an integer in [0, ${MAX_SAFE_UINT_VAR}]`);
990
+ }
979
991
 
980
992
  let first = true;
981
993
  let _v = value;
@@ -1 +1 @@
1
- {"version":3,"file":"BVH.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/BVH.js"],"names":[],"mappings":"AAUA;;GAEG;AACH,8BAA+B;AAC/B,+BAAgC;AAChC,+BAAgC;AAChC,8BAA+B;AAE/B;;;;;GAKG;AACH,+BAFU,MAAM,CAE+B;AAE/C;;;GAGG;AACH,wBAFU,MAAM,CAEoB;AAcpC;;;;;GAKG;AACH,iCAFU,MAAM,CAEqB;AAiBrC;;;;;;;;GAQG;AACH;IAEI;;;;OAIG;IACH,sBAAuE;IAYvE;;;;;OAKG;IACH,gCAeC;IA/BD;;;;;OAKG;IACH,+BAEC;IAyBD;;;;OAIG;IACH,uBAAsD;IAUtD;;;;OAIG;IACH,sBAAoD;IAEpD;;;;OAIG;IACH,mBAA8B;IApB9B;;;OAGG;IACH,iCAEC;IAgBD;;;;OAIG;IACH,eAAW;IAEX;;;;OAIG;IACH,eAAY;IAEZ;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,eAAmB;IAUnB;;;OAGG;IACH,oBAEC;IAdD;;;OAGG;IACH,mBAEC;IAUD;;;;OAIG;IACH,mBAEC;IAUD;;;OAGG;IACH,6BAMC;IAlBD;;;OAGG;IACH,4BAEC;IAcD,wBAgBC;IA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HW,MAAM,QACN,MAAM,EAAE,QAYlB;IAED;;;;;;;;;OASG;IACH,4BARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAmBhB;IAED;;;;OAIG;IACH,0BAHW,MAAM,GACJ,MAAM,CAoBlB;IAED;;;;;OAKG;IACH,wCAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAoClB;IAED;;;;;OAKG;IACH,oCAJW,MAAM,WACN,MAAM,WACN,MAAM,QAgBhB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,IAAI,CA0GhB;IAED;;;;;OAKG;IACH,wBAqBC;IAED;;;;OAIG;IACH,yBAkCC;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,IAAI,CA6ChB;IAED;;;;;;;;;;;OAWG;IACH,uBAoMC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,uBAqIC;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,WACN,MAAM,WACN,MAAM,QAWhB;IAED;;;;;;;OAOG;IACH,kCAJW,MAAM,WACN,MAAM,WACN,MAAM,QAmBhB;IAED;;;OAGG;IACH,oBAIC;IAED;;;;OAIG;IACH,mBAHW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,mBAiC3C;IAED;;;;;OAKG;IACH,+BAJW,MAAM,EAAE,sBACR,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;OAKG;IACH,0BA6BC;IAED;;;;;OAKG;IACH,cAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAsCnB;IAGL;;;;OAIG;IACH,gBAFU,OAAO,CAEE;CAPlB;oBA35CY,OAAO,6BAA6B,EAAE,KAAK"}
@@ -1176,7 +1176,20 @@ export class BVH {
1176
1176
  }
1177
1177
 
1178
1178
  if (best_rotation === 0) {
1179
- return iA; // no beneficial rotation
1179
+ /**
1180
+ * No swap reduces the surface area. That is the ordinary case for a well-shaped subtree,
1181
+ * but it is also what happens when the candidate boxes are identical or one contains the
1182
+ * other: every rotation then changes the area by exactly zero, `imp > best_improvement`
1183
+ * is false four times over, and nothing moves. Left there, each new leaf inserted into
1184
+ * such a cluster goes one level deeper than the last and the subtree becomes a linked
1185
+ * list — 1,500 leaves sharing one AABB gave depth 1,531 rather than ~11, which is 1,500
1186
+ * box tests on every query that reaches them and an O(N^2) insert.
1187
+ *
1188
+ * The height-AVL rotation is the tie-break. It is itself a no-op unless the subtree is
1189
+ * out of balance by more than one level, so a subtree the SAH pass is already happy with
1190
+ * is left exactly as it was.
1191
+ */
1192
+ return this.balance_height(iA);
1180
1193
  }
1181
1194
 
1182
1195
  // Apply the chosen rotation: re-wire one child↔grandchild pair, then
@@ -56,7 +56,9 @@ export class FrequencySketch<T> {
56
56
  /**
57
57
  * Initializes and increases the capacity of this <tt>FrequencySketch</tt> instance, if necessary,
58
58
  * to ensure that it can accurately estimate the popularity of elements given the maximum size of
59
- * the cache. This operation forgets all previous counts when resizing.
59
+ * the cache. This operation forgets all previous counts when resizing, so callers that care about
60
+ * the history — all of them — must size the sketch before they start counting rather than growing
61
+ * it as they go.
60
62
  *
61
63
  * @param {number} maximumSize the maximum size of the cache
62
64
  */
@@ -1 +1 @@
1
- {"version":3,"file":"FrequencySketch.d.ts","sourceRoot":"","sources":["../../../../src/core/cache/FrequencySketch.js"],"names":[],"mappings":"AAsEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;IACI;;;OAGG;IACH,YAFU,MAAM,CAED;IACf;;;OAGG;IACH,WAFU,MAAM,CAEF;IACd;;;OAGG;IACH,OAFU,WAAW,GAAC,IAAI,CAEb;IACb;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;;;;OAMG;IACH,4BAFW,MAAM,QAsBhB;IAED;;;;;OAKG;IACH,oBAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,MAAM,CAgBlB;IAED;;;;;;;OAOG;IACH,sBAFW,MAAM,QAwBhB;IAED;;OAEG;IACH,cAaC;CACJ"}
1
+ {"version":3,"file":"FrequencySketch.d.ts","sourceRoot":"","sources":["../../../../src/core/cache/FrequencySketch.js"],"names":[],"mappings":"AA0EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;IACI;;;OAGG;IACH,YAFU,MAAM,CAED;IACf;;;OAGG;IACH,WAFU,MAAM,CAEF;IACd;;;OAGG;IACH,OAFU,WAAW,GAAC,IAAI,CAEb;IACb;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;;;;;;OAQG;IACH,4BAFW,MAAM,QAsBhB;IAED;;;;;OAKG;IACH,oBAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,MAAM,CAgBlB;IAED;;;;;;;OAOG;IACH,sBAFW,MAAM,QAwBhB;IAED;;OAEG;IACH,cAaC;CACJ"}
@@ -27,8 +27,11 @@ const MAX_INT_32 = 2147483647;
27
27
  function spread(v) {
28
28
  let x = v;
29
29
 
30
- x = ((x >>> 16) ^ x) * 0x45d9f3b;
31
- x = ((x >>> 16) ^ x) * 0x45d9f3b;
30
+ //`Math.imul` and not `*`: both operands are ~2^31, and the double product lands around 2^62,
31
+ //nine orders past the exact-integer limit. The bits that get rounded away are the low ones,
32
+ //which are exactly the bits `indexOf` then masks off — see COR-002.
33
+ x = Math.imul((x >>> 16) ^ x, 0x45d9f3b);
34
+ x = Math.imul((x >>> 16) ^ x, 0x45d9f3b);
32
35
 
33
36
  return (x >>> 16) ^ x;
34
37
  }
@@ -41,7 +44,8 @@ function spread(v) {
41
44
  * @returns {number} the table index
42
45
  */
43
46
  function indexOf(item, i, tableMask) {
44
- let hash = (item + SEED[i]) * SEED[i];
47
+ //Caffeine's original is `int` arithmetic that wraps at 32 bits; `Math.imul` is what wraps here.
48
+ let hash = Math.imul(item + SEED[i], SEED[i]);
45
49
  hash += (hash >>> 16);
46
50
 
47
51
  return hash & tableMask;
@@ -127,7 +131,9 @@ export class FrequencySketch {
127
131
  /**
128
132
  * Initializes and increases the capacity of this <tt>FrequencySketch</tt> instance, if necessary,
129
133
  * to ensure that it can accurately estimate the popularity of elements given the maximum size of
130
- * the cache. This operation forgets all previous counts when resizing.
134
+ * the cache. This operation forgets all previous counts when resizing, so callers that care about
135
+ * the history — all of them — must size the sketch before they start counting rather than growing
136
+ * it as they go.
131
137
  *
132
138
  * @param {number} maximumSize the maximum size of the cache
133
139
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CacheWTinylfu.d.ts","sourceRoot":"","sources":["../../../../../src/core/cache/wtinylfu/CacheWTinylfu.js"],"names":[],"mappings":"AAiDA;IA0FI;;;;;;;;;;;OAWG;IACH;QAT4B,SAAS,GAA1B,MAAM;QACW,kBAAkB,GAAnC,MAAM;QACW,cAAc,GAA/B,MAAM;QACW,iBAAiB,GAAlC,MAAM;QACyB,UAAU,GAAzC,CAAC,GAAG,KAAK,KAAK,MAAM;QACe,YAAY,GAA/C,CAAC,KAAK,OAAO,KAAK,MAAM;QACO,eAAe,kBAAhC,MAAM;QACiB,mBAAmB,6BAArC,OAAO;OAwDpC;IA3FD;;;OAGG;IACH,OAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,WAFU,MAAM,CAES;IAEzB;;;OAGG;IACH,WAFU,MAAM,CAES;IAEzB;;;;OAIG;IACH,YAFU,MAAM,CAEU;IAsE1B;;;;OAIG;IACH,gBAGC;IAED;;;;OAIG;IACH,mBAcC;IACD;;;;OAIG;IACH,wBAsBC;IAED;;;;OAIG;IACH,0BAEC;IAED;;;;;OAKG;IACH,oBAEC;IAED;;;;;;OAMG;IACH,mCAEC;IAED;;;;;;;OAOG;IACH,wBAEC;IAED;;;;OAIG;IACH,kBAFa,OAAO,CAUnB;IAED;;;OAGG;IACH,cASC;IAED;;;;;;OAMG;IACH,+BAUC;IAED;;;;OAIG;IACH,uBAEC;IAED;;;;;;OAMG;IACH,4BAEC;IAED;;;;;;OAMG;IACH,wBAEC;IAED;;;;;;OAMG;IACH,4BAEC;IAED;;;;OAIG;IACH,wBAIC;IAED;;;;;;;OAOG;IACH,8BAmBC;IAED;;;;;;;OAOG;IACH,0BAeC;IAED;;;;;;;OAOG;IACH,2BAwBC;IAED;;;;;;OAMG;IACH,sBAkCC;IAED;;;;OAIG;IACH,sBAGC;IAED;;;;;;OAMG;IACH,gBAQC;IAED;;;;;;;OAOG;IACH,gBASC;IAoBD;;;;OAIG;IACH,mBAOC;IAED;;;;;;;OAOG;IACH,+BAgBC;IAED;;;;;OAKG;IACH,8BAMC;IAED;;;;;;;OAOG;IACH,gCAcC;IAED;;;;OAIG;IACH,2BASC;IAED;;;;;OAKG;IACH,gCAQC;IAED;;;;;OAKG;IACH,yBAmBC;IAED;;;;OAIG;IACH,kCAkBC;IAED;;;;OAIG;IACH,eAFa,QAAM,IAAI,CAWtB;IAID;;;;;OAKG;IACH,yBAFa,eAAe,GAAC,IAAI,CAKhC;IAED;;;OAGG;IACH,kBAFa;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,CAQ9D;;CACJ;uBA/vBoB,+BAA+B;gCARtB,sBAAsB"}
1
+ {"version":3,"file":"CacheWTinylfu.d.ts","sourceRoot":"","sources":["../../../../../src/core/cache/wtinylfu/CacheWTinylfu.js"],"names":[],"mappings":"AA0DA;IA0FI;;;;;;;;;;;OAWG;IACH;QAT4B,SAAS,GAA1B,MAAM;QACW,kBAAkB,GAAnC,MAAM;QACW,cAAc,GAA/B,MAAM;QACW,iBAAiB,GAAlC,MAAM;QACyB,UAAU,GAAzC,CAAC,GAAG,KAAK,KAAK,MAAM;QACe,YAAY,GAA/C,CAAC,KAAK,OAAO,KAAK,MAAM;QACO,eAAe,kBAAhC,MAAM;QACiB,mBAAmB,6BAArC,OAAO;OAqEpC;IAxGD;;;OAGG;IACH,OAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,WAFU,MAAM,CAES;IAEzB;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Equals} from "../../model/object/invokeObjectEquals.js";
39
39
  import {HashMap} from "../../collection/map/HashMap.js";
40
40
  import {mainCapacity, exceedsMainWeight, cannotFitMain, winsAdmissionDuel, shouldPromoteToProtected, classifyAdmission, AdmissionRoute} from "./wtinylfuDecisions.js";
41
41
  import {Signal} from "../../events/signal/Signal.js";
42
+ import {min2} from "../../math/min2.js";
42
43
 
43
44
  /**
44
45
  * Cap on the reuse pool of evicted element objects. Under churn the pool hovers near 1 (one evict per
@@ -47,6 +48,14 @@ import {Signal} from "../../events/signal/Signal.js";
47
48
  */
48
49
  const ELEMENT_POOL_MAX = 256;
49
50
 
51
+ /**
52
+ * Ceiling on the up-front {@link FrequencySketch} size, in counter slots. The sketch costs 4 bytes a
53
+ * slot, so this is 4 KiB; `maxWeight` is a weight budget and defaults to infinity, so it cannot be
54
+ * used to size the table unclamped.
55
+ * @type {number}
56
+ */
57
+ const SKETCH_SEED_LIMIT = 1024;
58
+
50
59
  export class CacheWTinylfu {
51
60
 
52
61
  /**
@@ -201,8 +210,21 @@ export class CacheWTinylfu {
201
210
  keyEqualityFunction
202
211
  });
203
212
 
204
- // The sketch is sized dynamically to the live element count in __admit; seed a minimal table.
205
- this.#sketch.ensureCapacity(0);
213
+ /**
214
+ * Size the sketch up front, from the cache's own budget, rather than letting `__admit` grow
215
+ * it one admission at a time. `ensureCapacity` drops every count it holds when it grows, so
216
+ * growing alongside the cache wipes the access history at each power-of-two boundary —
217
+ * exactly while the cache is filling, which is when the admission duel first starts running.
218
+ * The effect is that a long-resident hot key reads back as frequency 0 and loses its duel to
219
+ * whichever one-shot newcomer was admitted most recently.
220
+ *
221
+ * `maxWeight` is a weight budget, not an element count, and defaults to infinity, so it is
222
+ * only an element ceiling under the default unit weigher. It is clamped here so a
223
+ * byte-weighted cache does not allocate a table sized in its byte budget; a cache whose live
224
+ * set exceeds the clamp still grows (and still loses its early history once), which is a
225
+ * transient at that scale rather than the whole warm-up.
226
+ */
227
+ this.#sketch.ensureCapacity(Math.ceil(min2(maxWeight, SKETCH_SEED_LIMIT)));
206
228
  }
207
229
 
208
230
  /**
@@ -5,6 +5,26 @@
5
5
  * vertices; the corresponding quadric is then accumulated onto each of those
6
6
  * three vertices' Quadric3. Non-triangular faces are skipped.
7
7
  *
8
+ * **Each plane weighs the surface standing behind it, not one.** What a vertex reports is the mean
9
+ * over its planes ({@link Quadric3#distance}), and a mean over a count is a statement about how the
10
+ * surface was *cut* rather than about the surface: cutting one face in two along its own plane adds
11
+ * no surface and the metric hears the same plane twice, so a finely tessellated patch outvotes a
12
+ * coarse one many times its size. Weighing each plane by its triangle's area is what makes the mean
13
+ * an average over the surface, and it is what makes an in-plane subdivision — which says nothing new
14
+ * — change nothing.
15
+ *
16
+ * The weights are **areas as a multiple of this mesh's own mean triangle**, not areas. A ratio is
17
+ * what every other number here is stated against: {@link BOUNDARY_WEIGHT} is three *faces*, and the
18
+ * attribute quadric a virtual-geometry build sums with these weighs one per triangle and says so
19
+ * ({@link quadric_attribute_set_from_triangle}) — both of which are answers to "how much is a face
20
+ * worth", and neither survives the slot becoming square metres. It costs nothing that matters: a
21
+ * mean divides the weights out again, so what a vertex reports is identical either way, and
22
+ * {@link quadric3_optimize} is scale-invariant, so placement is too.
23
+ *
24
+ * A triangle with no area is skipped entirely rather than weighed at zero. It has no plane —
25
+ * {@link tri3_compute_normal} hands it an arbitrary direction — so it neither contributes one nor
26
+ * counts towards the mean it would otherwise drag down.
27
+ *
8
28
  * @param {BinaryTopology} mesh
9
29
  * @returns {Quadric3[]} Array indexed by vertex ID. Entries for unallocated
10
30
  * vertex slots are `undefined`.
@@ -1 +1 @@
1
- {"version":3,"file":"bt_mesh_compute_vertex_quadrics.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;GAUG;AACH,uEAHa,QAAQ,EAAE,CA2EtB;yBA5GwB,iCAAiC"}
1
+ {"version":3,"file":"bt_mesh_compute_vertex_quadrics.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.js"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,uEAHa,QAAQ,EAAE,CAgHtB;yBA1KwB,iCAAiC"}
@@ -1,6 +1,7 @@
1
1
  import { quadric3_set_from_plane_through_point } from "../../../../quadric/quadric3_set_from_plane_through_point.js";
2
2
  import { assert } from "../../../../../../assert.js";
3
3
  import { v3_dot } from "../../../../../vec3/v3_dot.js";
4
+ import { tri3_area } from "../../../../triangle/tri3_area.js";
4
5
  import { tri3_compute_normal } from "../../../../triangle/tri3_compute_normal.js";
5
6
  import { Quadric3 } from "../../../../quadric/Quadric3.js";
6
7
  import { NULL_POINTER } from "../BinaryTopology.js";
@@ -12,7 +13,7 @@ const scratch_normal = new Float32Array(3);
12
13
  const boundary_quadric = new Quadric3();
13
14
 
14
15
  /**
15
- * How much a boundary constraint plane weighs against one face plane.
16
+ * How much a boundary constraint plane weighs against one face plane **of the same area**.
16
17
  *
17
18
  * Three, measured. A face-plane quadric alone says nothing about a vertex sliding *within* the
18
19
  * surface, which is exactly what an open edge does when it erodes, so without this term a boundary
@@ -22,6 +23,11 @@ const boundary_quadric = new Quadric3();
22
23
  * roughly the displacement itself, while leaving the boundary free enough to erode at all — which
23
24
  * it must, or a mesh made of open shells has no coarse form and no root.
24
25
  *
26
+ * It is a ratio against a face, so it is applied on top of the face's own area weight rather than
27
+ * instead of it. Three flat is a number of square metres, which is not a ratio at all: the same
28
+ * border would weigh a millionth of its fan on a model authored in millimetres and a million times
29
+ * it on one authored in kilometres, and the measurement above would hold for neither.
30
+ *
25
31
  * @readonly
26
32
  * @type {number}
27
33
  */
@@ -34,6 +40,26 @@ const BOUNDARY_WEIGHT = 3;
34
40
  * vertices; the corresponding quadric is then accumulated onto each of those
35
41
  * three vertices' Quadric3. Non-triangular faces are skipped.
36
42
  *
43
+ * **Each plane weighs the surface standing behind it, not one.** What a vertex reports is the mean
44
+ * over its planes ({@link Quadric3#distance}), and a mean over a count is a statement about how the
45
+ * surface was *cut* rather than about the surface: cutting one face in two along its own plane adds
46
+ * no surface and the metric hears the same plane twice, so a finely tessellated patch outvotes a
47
+ * coarse one many times its size. Weighing each plane by its triangle's area is what makes the mean
48
+ * an average over the surface, and it is what makes an in-plane subdivision — which says nothing new
49
+ * — change nothing.
50
+ *
51
+ * The weights are **areas as a multiple of this mesh's own mean triangle**, not areas. A ratio is
52
+ * what every other number here is stated against: {@link BOUNDARY_WEIGHT} is three *faces*, and the
53
+ * attribute quadric a virtual-geometry build sums with these weighs one per triangle and says so
54
+ * ({@link quadric_attribute_set_from_triangle}) — both of which are answers to "how much is a face
55
+ * worth", and neither survives the slot becoming square metres. It costs nothing that matters: a
56
+ * mean divides the weights out again, so what a vertex reports is identical either way, and
57
+ * {@link quadric3_optimize} is scale-invariant, so placement is too.
58
+ *
59
+ * A triangle with no area is skipped entirely rather than weighed at zero. It has no plane —
60
+ * {@link tri3_compute_normal} hands it an arbitrary direction — so it neither contributes one nor
61
+ * counts towards the mean it would otherwise drag down.
62
+ *
37
63
  * @param {BinaryTopology} mesh
38
64
  * @returns {Quadric3[]} Array indexed by vertex ID. Entries for unallocated
39
65
  * vertex slots are `undefined`.
@@ -58,6 +84,11 @@ export function bt_mesh_compute_vertex_quadrics(mesh) {
58
84
 
59
85
  const q = new Quadric3();
60
86
 
87
+ // The mesh's own scale, for the normalization below. Accumulated as the faces go by rather than
88
+ // swept for beforehand, since the loop below already has every area it needs.
89
+ let total_area = 0;
90
+ let triangle_count = 0;
91
+
61
92
  for (let f = 0; f < face_count; f++) {
62
93
  if (!face_pool.is_allocated(f)) {
63
94
  continue;
@@ -85,6 +116,19 @@ export function bt_mesh_compute_vertex_quadrics(mesh) {
85
116
  mesh.vertex_read_coordinate(scratch_coord_b, 0, vb);
86
117
  mesh.vertex_read_coordinate(scratch_coord_c, 0, vc);
87
118
 
119
+ const area = tri3_area(
120
+ scratch_coord_a[0], scratch_coord_a[1], scratch_coord_a[2],
121
+ scratch_coord_b[0], scratch_coord_b[1], scratch_coord_b[2],
122
+ scratch_coord_c[0], scratch_coord_c[1], scratch_coord_c[2]
123
+ );
124
+
125
+ if (area === 0) {
126
+ continue;
127
+ }
128
+
129
+ total_area += area;
130
+ triangle_count++;
131
+
88
132
  tri3_compute_normal(
89
133
  scratch_normal, 0,
90
134
  scratch_coord_a[0], scratch_coord_a[1], scratch_coord_a[2],
@@ -102,11 +146,30 @@ export function bt_mesh_compute_vertex_quadrics(mesh) {
102
146
  scratch_coord_a[0], scratch_coord_a[1], scratch_coord_a[2]
103
147
  );
104
148
 
149
+ // Weight and matrix together, which is what {@link quadric3_scale} is for: the plane counts
150
+ // for its area in the sum *and* declares that it does, so the mean stays a length.
151
+ q.multiplyScalar(area);
152
+
105
153
  quadratics[va].add(q);
106
154
  quadratics[vb].add(q);
107
155
  quadratics[vc].add(q);
108
156
 
109
- add_boundary_constraints(mesh, quadratics, f, nx, ny, nz);
157
+ add_boundary_constraints(mesh, quadratics, f, nx, ny, nz, area);
158
+ }
159
+
160
+ if (triangle_count > 0) {
161
+ // Areas into multiples of the mean triangle. One pass at the end rather than a pass for the
162
+ // mean before the accumulation: scaling is linear and uniform, so dividing every quadric
163
+ // here is dividing every plane's weight there.
164
+ const of_a_mean_triangle = triangle_count / total_area;
165
+
166
+ for (let v = 0; v < vertex_count; v++) {
167
+ const quadric = quadratics[v];
168
+
169
+ if (quadric !== undefined) {
170
+ quadric.multiplyScalar(of_a_mean_triangle);
171
+ }
172
+ }
110
173
  }
111
174
 
112
175
  return quadratics;
@@ -170,8 +233,10 @@ function count_edge_faces(mesh, edge) {
170
233
  * @param {number} nx face normal, unit
171
234
  * @param {number} ny
172
235
  * @param {number} nz
236
+ * @param {number} area of the face, which the constraint carries so that it stays
237
+ * {@link BOUNDARY_WEIGHT} times a face rather than a fixed number of square metres
173
238
  */
174
- function add_boundary_constraints(mesh, quadratics, face, nx, ny, nz) {
239
+ function add_boundary_constraints(mesh, quadratics, face, nx, ny, nz, area) {
175
240
  const first = mesh.face_read_loop(face);
176
241
 
177
242
  let loop = first;
@@ -217,7 +282,7 @@ function add_boundary_constraints(mesh, quadratics, face, nx, ny, nz) {
217
282
  scratch_coord_a[0], scratch_coord_a[1], scratch_coord_a[2]
218
283
  );
219
284
 
220
- boundary_quadric.multiplyScalar(BOUNDARY_WEIGHT);
285
+ boundary_quadric.multiplyScalar(BOUNDARY_WEIGHT * area);
221
286
 
222
287
  quadratics[v1].add(boundary_quadric);
223
288
  quadratics[v2].add(boundary_quadric);
@@ -6,9 +6,24 @@
6
6
  * removed. If the target cannot be reached (e.g. too many restricted vertices),
7
7
  * simplification stops early without failing.
8
8
  *
9
- * A collapse that would turn a surviving triangle inside out is refused however cheap the quadric
10
- * says it is ({@link bt_edge_collapse_would_fold}) -- the quadric cannot see a fold, because a flat
11
- * region scores zero for every placement in its plane.
9
+ * No collapse ever turns a surviving triangle inside out, and the quadric cannot help with that: it
10
+ * cannot see a fold at all, because a flat region scores zero for every placement in its plane. So
11
+ * the placement is *constrained* rather than merely checked. Where the quadric's own answer folds,
12
+ * the collapse is re-placed at the best point that does not — see {@link constrain_placement}, and
13
+ * {@link bt_edge_collapse_fold_limit} for why that point can be found exactly instead of hunted for.
14
+ * A collapse is refused only when the pair has no such placement anywhere, which is a statement
15
+ * about the geometry rather than about the quadric's preference.
16
+ *
17
+ * Every edge is priced at the placement it would actually use, including the constrained ones, and
18
+ * the queue is ordered on that. It is the expensive way round — the constraint costs a walk of both
19
+ * the pair's fans, and pricing happens once per edge at the start and again for every neighbour of
20
+ * every collapse, which measures at 1.4x to 2.5x the build time of the alternative. The alternative
21
+ * is to order on the unconstrained price, which is a genuine lower bound ({@link placement_cost}),
22
+ * and settle only on the way out of the queue. That was built and measured, and it is not here: the
23
+ * greedy order it produces is approximate, and on a pinwheel whose whole rim is pinned it stopped at
24
+ * 28 faces against a target of 21 — which is precisely the shape a vgeo group step hands this, since
25
+ * such a step pins its entire outer boundary. A cheaper order that cannot finish a pinned
26
+ * simplification is no bargain.
12
27
  *
13
28
  * **Topology is not preserved**, and cannot be here. The other standard guard, the *link condition*
14
29
  * ({@link bt_edge_collapse_breaks_link_condition}), refuses collapses that weld together two parts
@@ -24,21 +39,36 @@
24
39
  * At the end of the call the mesh is cleaned up so that no dangling loops, edges,
25
40
  * or vertices remain in the topology.
26
41
  *
27
- * The return value is the **object-space distance** the surface moved: the largest, over every
28
- * vertex, of that vertex's accumulated quadric evaluated where the vertex ended up, normalized by
29
- * the quadric's weight. Because a survivor inherits its victim's quadric, this measures deviation
30
- * from the mesh as it stood when the call began — not merely from the step before.
31
- *
32
- * It is taken *before* faceless vertices are cleaned away, and that is not an implementation detail.
33
- * A patch that is consumed entirely leaves a vertex behind that belongs to no face; that vertex is
34
- * the only thing still holding the quadric of everything that used to be there, and reading the mesh
35
- * after cleanup would find no trace of it. A soup of separate triangles simplifies by *deleting*
36
- * them, and measuring survivors alone reports the deletion of ninety per cent of a model as costing
37
- * nothing at all.
38
- *
39
- * A caller that needs deviation from something *older* than this call's input — a mesh several
40
- * simplification passes back — supplies its own quadrics through
41
- * {@link bt_mesh_simplify_with_quadrics} and keeps them across passes.
42
+ * The return value is the **object-space distance** the surface moved: the largest reading taken at
43
+ * any collapse the call performed, a collapse being read by evaluating *each* of its two endpoints'
44
+ * accumulated quadrics at the placement the survivor is about to take, each normalized by its own
45
+ * weight. Because a survivor inherits its victim's quadric, every such reading is a deviation from
46
+ * the mesh as it stood when the call began — not merely from the step before.
47
+ *
48
+ * **At the collapses, and per endpoint, and both of those are what keep it from diluting.** The
49
+ * weight is what makes the value a length ({@link Quadric3#distance}) and it is also a divisor that
50
+ * grows every time a vertex absorbs another. A vertex that flattens a spike and then spends the rest
51
+ * of the call swallowing the plane around it ends up standing mostly for planes it sits exactly on,
52
+ * and a single reading taken at the end divides the spike it destroyed by all of them — measured on
53
+ * a unit spike at the centre of a pinned grid, the same spike came back at 0.64 on a 7-vertex grid
54
+ * and at 0.040 on a 33-vertex one, which is the reported error falling as the surface grows.
55
+ * Reading at every collapse catches the spike while the quadric is still mostly about it. Reading
56
+ * the two endpoints apart rather than summed stops a small victim's residual being averaged into a
57
+ * large survivor's untouched history, which is that same dilution one collapse at a time.
58
+ *
59
+ * Nothing is given up by no longer scanning the survivors, and it is a domination rather than a
60
+ * coincidence. What the scan would read off a survivor is its *merged* quadric at the placement its
61
+ * last collapse chose — and a merged quadric's reading is the weight-weighted mean of its two parts'
62
+ * readings at that same point, so it can never exceed the larger of the two this already took there.
63
+ * Every value the scan could report is therefore one this maximum has seen or beaten, and the
64
+ * maximum holds the earlier and sharper readings besides. A patch consumed entirely, which leaves
65
+ * behind a faceless vertex that the cleanup then sweeps, is read at the collapse that consumed it
66
+ * instead of in the window between the last collapse and the sweep.
67
+ *
68
+ * So what comes back is what *this call's* collapses cost. A caller carrying quadrics across calls
69
+ * through {@link bt_mesh_simplify_with_quadrics} carries the maximum across them too — and the
70
+ * deviation a vertex arrives already carrying is, by construction, a reading that the call which
71
+ * placed it there has already returned.
42
72
  *
43
73
  * `protected_faces` names faces that must still be there when the call returns. Pinning vertices
44
74
  * does not by itself protect the *edges* between them: a collapse elsewhere in the fan can take away
@@ -1 +1 @@
1
- {"version":3,"file":"bt_mesh_simplify.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js"],"names":[],"mappings":"AA4yBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,0EALW,MAAM,wBACN,IAAI,MAAM,CAAC,oBACX,IAAI,MAAM,CAAC,GACT,MAAM,CAwBlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,wFA/CW,MAAM,uBACN,IAAI,MAAM,CAAC,mBACX,IAAI,MAAM,CAAC,cA4BX,QAAQ,EAAE,eACV;IAAC,MAAM,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAC,GAAC,IAAI,WAS9F,aAAW,IAAI,GAKb,MAAM,CA2LlB;yBA/mCwB,iCAAiC"}
1
+ {"version":3,"file":"bt_mesh_simplify.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js"],"names":[],"mappings":"AAw9BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AACH,0EALW,MAAM,wBACN,IAAI,MAAM,CAAC,oBACX,IAAI,MAAM,CAAC,GACT,MAAM,CAwBlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,wFA/CW,MAAM,uBACN,IAAI,MAAM,CAAC,mBACX,IAAI,MAAM,CAAC,cA4BX,QAAQ,EAAE,eACV;IAAC,MAAM,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAC,GAAC,IAAI,WAS9F,aAAW,IAAI,GAKb,MAAM,CA4MlB;yBA10CwB,iCAAiC"}