@woosh/meep-engine 2.164.0 → 2.165.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 (256) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/binary/BitImage2.d.ts +91 -0
  4. package/src/core/binary/BitImage2.d.ts.map +1 -0
  5. package/src/core/binary/BitImage2.js +242 -0
  6. package/src/core/geom/2d/oriented-box/min_area_rect_2d.d.ts +22 -0
  7. package/src/core/geom/2d/oriented-box/min_area_rect_2d.d.ts.map +1 -0
  8. package/src/core/geom/2d/oriented-box/min_area_rect_2d.js +69 -0
  9. package/src/core/geom/2d/packing/skyline.d.ts +116 -0
  10. package/src/core/geom/2d/packing/skyline.d.ts.map +1 -0
  11. package/src/core/geom/2d/packing/skyline.js +258 -0
  12. package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts +18 -0
  13. package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts.map +1 -0
  14. package/src/core/geom/2d/triangle/tri2_rasterize_conservative.js +86 -0
  15. package/src/core/geom/3d/atlas/ATLAS_PORT_PLAN.md +486 -0
  16. package/src/core/geom/3d/atlas/BFF_PLAN.md +174 -0
  17. package/src/core/geom/3d/atlas/Chart.d.ts +58 -0
  18. package/src/core/geom/3d/atlas/Chart.d.ts.map +1 -0
  19. package/src/core/geom/3d/atlas/Chart.js +77 -0
  20. package/src/core/geom/3d/atlas/REVIEW_02.md +392 -0
  21. package/src/core/geom/3d/atlas/atlas_bench_lib.d.ts +73 -0
  22. package/src/core/geom/3d/atlas/atlas_bench_lib.d.ts.map +1 -0
  23. package/src/core/geom/3d/atlas/atlas_bench_lib.js +315 -0
  24. package/src/core/geom/3d/atlas/atlas_chart_type.d.ts +17 -0
  25. package/src/core/geom/3d/atlas/atlas_chart_type.d.ts.map +1 -0
  26. package/src/core/geom/3d/atlas/atlas_chart_type.js +16 -0
  27. package/src/core/geom/3d/atlas/atlas_compute_charts.d.ts +25 -0
  28. package/src/core/geom/3d/atlas/atlas_compute_charts.d.ts.map +1 -0
  29. package/src/core/geom/3d/atlas/atlas_compute_charts.js +188 -0
  30. package/src/core/geom/3d/atlas/atlas_extract_chart.d.ts +17 -0
  31. package/src/core/geom/3d/atlas/atlas_extract_chart.d.ts.map +1 -0
  32. package/src/core/geom/3d/atlas/atlas_extract_chart.js +107 -0
  33. package/src/core/geom/3d/atlas/atlas_generate.d.ts +39 -0
  34. package/src/core/geom/3d/atlas/atlas_generate.d.ts.map +1 -0
  35. package/src/core/geom/3d/atlas/atlas_generate.js +43 -0
  36. package/src/core/geom/3d/atlas/atlas_test_fixtures.d.ts +84 -0
  37. package/src/core/geom/3d/atlas/atlas_test_fixtures.d.ts.map +1 -0
  38. package/src/core/geom/3d/atlas/atlas_test_fixtures.js +266 -0
  39. package/src/core/geom/3d/atlas/atlas_write_chart_uvs.d.ts +25 -0
  40. package/src/core/geom/3d/atlas/atlas_write_chart_uvs.d.ts.map +1 -0
  41. package/src/core/geom/3d/atlas/atlas_write_chart_uvs.js +36 -0
  42. package/src/core/geom/3d/atlas/data/atlas_build_edge_dihedrals.d.ts +22 -0
  43. package/src/core/geom/3d/atlas/data/atlas_build_edge_dihedrals.d.ts.map +1 -0
  44. package/src/core/geom/3d/atlas/data/atlas_build_edge_dihedrals.js +62 -0
  45. package/src/core/geom/3d/atlas/data/atlas_build_edge_lengths.d.ts +9 -0
  46. package/src/core/geom/3d/atlas/data/atlas_build_edge_lengths.d.ts.map +1 -0
  47. package/src/core/geom/3d/atlas/data/atlas_build_edge_lengths.js +33 -0
  48. package/src/core/geom/3d/atlas/data/atlas_build_face_areas.d.ts +9 -0
  49. package/src/core/geom/3d/atlas/data/atlas_build_face_areas.d.ts.map +1 -0
  50. package/src/core/geom/3d/atlas/data/atlas_build_face_areas.js +50 -0
  51. package/src/core/geom/3d/atlas/io/atlas_mesh_weld_colocals.d.ts +27 -0
  52. package/src/core/geom/3d/atlas/io/atlas_mesh_weld_colocals.d.ts.map +1 -0
  53. package/src/core/geom/3d/atlas/io/atlas_mesh_weld_colocals.js +39 -0
  54. package/src/core/geom/3d/atlas/io/bt_loop_uv.d.ts +22 -0
  55. package/src/core/geom/3d/atlas/io/bt_loop_uv.d.ts.map +1 -0
  56. package/src/core/geom/3d/atlas/io/bt_loop_uv.js +57 -0
  57. package/src/core/geom/3d/atlas/pack/ChartPlacement.d.ts +36 -0
  58. package/src/core/geom/3d/atlas/pack/ChartPlacement.d.ts.map +1 -0
  59. package/src/core/geom/3d/atlas/pack/ChartPlacement.js +46 -0
  60. package/src/core/geom/3d/atlas/pack/atlas_pack_charts.d.ts +62 -0
  61. package/src/core/geom/3d/atlas/pack/atlas_pack_charts.d.ts.map +1 -0
  62. package/src/core/geom/3d/atlas/pack/atlas_pack_charts.js +551 -0
  63. package/src/core/geom/3d/atlas/param/atlas_chart_param_validity.d.ts +22 -0
  64. package/src/core/geom/3d/atlas/param/atlas_chart_param_validity.d.ts.map +1 -0
  65. package/src/core/geom/3d/atlas/param/atlas_chart_param_validity.js +73 -0
  66. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_bff.d.ts +37 -0
  67. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_bff.d.ts.map +1 -0
  68. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_bff.js +270 -0
  69. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_lscm.d.ts +23 -0
  70. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_lscm.d.ts.map +1 -0
  71. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_lscm.js +224 -0
  72. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_ortho.d.ts +14 -0
  73. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_ortho.d.ts.map +1 -0
  74. package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_ortho.js +38 -0
  75. package/src/core/geom/3d/atlas/param/atlas_chart_stretch_metric.d.ts +22 -0
  76. package/src/core/geom/3d/atlas/param/atlas_chart_stretch_metric.d.ts.map +1 -0
  77. package/src/core/geom/3d/atlas/param/atlas_chart_stretch_metric.js +86 -0
  78. package/src/core/geom/3d/atlas/param/atlas_piecewise_resegment.d.ts +20 -0
  79. package/src/core/geom/3d/atlas/param/atlas_piecewise_resegment.d.ts.map +1 -0
  80. package/src/core/geom/3d/atlas/param/atlas_piecewise_resegment.js +183 -0
  81. package/src/core/geom/3d/atlas/param/fit_plane_basis.d.ts +27 -0
  82. package/src/core/geom/3d/atlas/param/fit_plane_basis.d.ts.map +1 -0
  83. package/src/core/geom/3d/atlas/param/fit_plane_basis.js +66 -0
  84. package/src/core/geom/3d/atlas/segment/RegionGraph.d.ts +31 -0
  85. package/src/core/geom/3d/atlas/segment/RegionGraph.d.ts.map +1 -0
  86. package/src/core/geom/3d/atlas/segment/RegionGraph.js +40 -0
  87. package/src/core/geom/3d/atlas/segment/atlas_build_region_graph.d.ts +23 -0
  88. package/src/core/geom/3d/atlas/segment/atlas_build_region_graph.d.ts.map +1 -0
  89. package/src/core/geom/3d/atlas/segment/atlas_build_region_graph.js +136 -0
  90. package/src/core/geom/3d/atlas/segment/atlas_compute_planar_regions.d.ts +24 -0
  91. package/src/core/geom/3d/atlas/segment/atlas_compute_planar_regions.d.ts.map +1 -0
  92. package/src/core/geom/3d/atlas/segment/atlas_compute_planar_regions.js +77 -0
  93. package/src/core/geom/3d/atlas/segment/atlas_merge_charts.d.ts +27 -0
  94. package/src/core/geom/3d/atlas/segment/atlas_merge_charts.d.ts.map +1 -0
  95. package/src/core/geom/3d/atlas/segment/atlas_merge_charts.js +113 -0
  96. package/src/core/geom/3d/atlas/segment/atlas_segment_charts.d.ts +44 -0
  97. package/src/core/geom/3d/atlas/segment/atlas_segment_charts.d.ts.map +1 -0
  98. package/src/core/geom/3d/atlas/segment/atlas_segment_charts.js +275 -0
  99. package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.d.ts +22 -0
  100. package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.d.ts.map +1 -0
  101. package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.js +199 -0
  102. package/src/core/geom/3d/line/line3_compute_point_segment_point_distance_unfolded.d.ts +32 -0
  103. package/src/core/geom/3d/line/line3_compute_point_segment_point_distance_unfolded.d.ts.map +1 -0
  104. package/src/core/geom/3d/line/line3_compute_point_segment_point_distance_unfolded.js +64 -0
  105. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.d.ts +20 -0
  106. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.d.ts.map +1 -0
  107. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.js +66 -0
  108. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
  109. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +13 -11
  110. package/src/core/geom/3d/sphere/sphere_compute_bounding_of_2_spheres.d.ts.map +1 -1
  111. package/src/core/geom/3d/sphere/sphere_compute_bounding_of_2_spheres.js +4 -3
  112. package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.d.ts.map +1 -1
  113. package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +4 -3
  114. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.d.ts.map +1 -1
  115. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.js +4 -3
  116. package/src/core/geom/3d/topology/simplify/quadratic/apply_border_penalty_to_vertex_quadrics.d.ts.map +1 -1
  117. package/src/core/geom/3d/topology/simplify/quadratic/apply_border_penalty_to_vertex_quadrics.js +10 -6
  118. package/src/core/geom/3d/topology/struct/TopoMesh.js +2 -2
  119. package/src/core/geom/3d/topology/struct/TopoTriangle.d.ts +0 -2
  120. package/src/core/geom/3d/topology/struct/TopoTriangle.d.ts.map +1 -1
  121. package/src/core/geom/3d/topology/struct/TopoTriangle.js +2 -2
  122. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.d.ts.map +1 -1
  123. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.js +8 -27
  124. package/src/core/geom/vec3/v3_cotangent.d.ts +20 -0
  125. package/src/core/geom/vec3/v3_cotangent.d.ts.map +1 -0
  126. package/src/core/geom/vec3/v3_cotangent.js +29 -0
  127. package/src/core/geom/vec3/v3_matrix3_multiply.d.ts +19 -0
  128. package/src/core/geom/vec3/v3_matrix3_multiply.d.ts.map +1 -0
  129. package/src/core/geom/vec3/v3_matrix3_multiply.js +30 -0
  130. package/src/core/geom/vec3/v3_multiply.d.ts +16 -0
  131. package/src/core/geom/vec3/v3_multiply.d.ts.map +1 -0
  132. package/src/core/geom/vec3/v3_multiply.js +19 -0
  133. package/src/core/math/linalg/cg/cg_solve.d.ts +24 -0
  134. package/src/core/math/linalg/cg/cg_solve.d.ts.map +1 -0
  135. package/src/core/math/linalg/cg/cg_solve.js +106 -0
  136. package/src/core/math/linalg/cg/cg_solve_normal_equations.d.ts +21 -0
  137. package/src/core/math/linalg/cg/cg_solve_normal_equations.d.ts.map +1 -0
  138. package/src/core/math/linalg/cg/cg_solve_normal_equations.js +59 -0
  139. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts +19 -0
  140. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts.map +1 -0
  141. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.js +117 -0
  142. package/src/core/math/linalg/sparse/SparseMatrixCSR.d.ts +50 -0
  143. package/src/core/math/linalg/sparse/SparseMatrixCSR.d.ts.map +1 -0
  144. package/src/core/math/linalg/sparse/SparseMatrixCSR.js +88 -0
  145. package/src/core/math/linalg/sparse/spm_matvec.d.ts +9 -0
  146. package/src/core/math/linalg/sparse/spm_matvec.d.ts.map +1 -0
  147. package/src/core/math/linalg/sparse/spm_matvec.js +22 -0
  148. package/src/core/math/linalg/sparse/spm_matvec_transpose.d.ts +12 -0
  149. package/src/core/math/linalg/sparse/spm_matvec_transpose.d.ts.map +1 -0
  150. package/src/core/math/linalg/sparse/spm_matvec_transpose.js +29 -0
  151. package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.d.ts +39 -0
  152. package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.js +22 -1
  153. package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.d.ts.map +1 -1
  154. package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.js +32 -9
  155. package/src/core/math/physics/mie/compute_mie_phase.d.ts +2 -3
  156. package/src/core/math/physics/mie/compute_mie_phase.d.ts.map +1 -1
  157. package/src/core/math/physics/mie/compute_mie_phase.js +1 -3
  158. package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts +0 -1
  159. package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts.map +1 -1
  160. package/src/core/math/physics/mie/lorenz_mie_coefs.js +0 -7
  161. package/src/engine/ecs/attachment/TransformAttachmentBinding.js +3 -3
  162. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -2
  163. package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
  164. package/src/engine/ecs/terrain/ecs/Terrain.js +4 -3
  165. package/src/engine/ecs/terrain/tiles/TerrainTile.js +2 -2
  166. package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
  167. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +9 -8
  168. package/src/engine/graphics/GraphicsEngine.d.ts.map +1 -1
  169. package/src/engine/graphics/GraphicsEngine.js +2 -1
  170. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -2
  171. package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +2 -2
  172. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +2 -2
  173. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts.map +1 -1
  174. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +0 -1
  175. package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.d.ts.map +1 -1
  176. package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +8 -7
  177. package/src/engine/graphics/geometry/MikkT/AvgTSpace.d.ts.map +1 -1
  178. package/src/engine/graphics/geometry/MikkT/AvgTSpace.js +11 -6
  179. package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.d.ts.map +1 -1
  180. package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.js +2 -3
  181. package/src/engine/graphics/geometry/MikkT/CalcTexArea.d.ts.map +1 -1
  182. package/src/engine/graphics/geometry/MikkT/CalcTexArea.js +3 -4
  183. package/src/engine/graphics/geometry/MikkT/DegenEpilogue.js +4 -4
  184. package/src/engine/graphics/geometry/MikkT/EvalTspace.d.ts.map +1 -1
  185. package/src/engine/graphics/geometry/MikkT/EvalTspace.js +11 -8
  186. package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.d.ts.map +1 -1
  187. package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js +7 -8
  188. package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +8 -8
  189. package/src/engine/graphics/geometry/MikkT/InitTriInfo.d.ts.map +1 -1
  190. package/src/engine/graphics/geometry/MikkT/InitTriInfo.js +30 -25
  191. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +7 -7
  192. package/src/engine/graphics/geometry/MikkT/NormalizeSafe.d.ts +0 -1
  193. package/src/engine/graphics/geometry/MikkT/NormalizeSafe.d.ts.map +1 -1
  194. package/src/engine/graphics/geometry/MikkT/NormalizeSafe.js +6 -4
  195. package/src/engine/graphics/geometry/MikkT/STSpace.d.ts +0 -2
  196. package/src/engine/graphics/geometry/MikkT/STSpace.d.ts.map +1 -1
  197. package/src/engine/graphics/geometry/MikkT/STSpace.js +3 -3
  198. package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.d.ts +0 -2
  199. package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.d.ts.map +1 -1
  200. package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js +0 -1
  201. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts +0 -2
  202. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
  203. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +4 -3
  204. package/src/engine/graphics/impostors/octahedral/grid/HemiOctahedralUvEncoder.js +2 -2
  205. package/src/engine/graphics/impostors/octahedral/grid/UvEncoder.d.ts +17 -7
  206. package/src/engine/graphics/impostors/voxel/VoxelImpostorBaker.js +2 -2
  207. package/src/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +3 -3
  208. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +4 -3
  209. package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
  210. package/src/engine/graphics/render/forward_plus/model/Decal.d.ts +0 -2
  211. package/src/engine/graphics/render/forward_plus/model/Decal.d.ts.map +1 -1
  212. package/src/engine/graphics/render/forward_plus/model/Decal.js +3 -3
  213. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +4 -3
  214. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +6 -4
  215. package/src/engine/graphics/sh3/lightmap/ARTIFACTS_PLAN.md +146 -0
  216. package/src/engine/graphics/sh3/lightmap/CODE_REVIEW.md +121 -0
  217. package/src/engine/graphics/sh3/lightmap/LIGHTMAPPER_REVIEW.md +183 -0
  218. package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.d.ts +90 -0
  219. package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.d.ts.map +1 -0
  220. package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.js +678 -0
  221. package/src/engine/graphics/sh3/lightmap/lightmap_build_geometry.d.ts +32 -0
  222. package/src/engine/graphics/sh3/lightmap/lightmap_build_geometry.d.ts.map +1 -0
  223. package/src/engine/graphics/sh3/lightmap/lightmap_build_geometry.js +155 -0
  224. package/src/engine/graphics/sh3/lightmap/lightmap_denoise.d.ts +49 -0
  225. package/src/engine/graphics/sh3/lightmap/lightmap_denoise.d.ts.map +1 -0
  226. package/src/engine/graphics/sh3/lightmap/lightmap_denoise.js +136 -0
  227. package/src/engine/graphics/sh3/lightmap/lightmap_dilate.d.ts +19 -0
  228. package/src/engine/graphics/sh3/lightmap/lightmap_dilate.d.ts.map +1 -0
  229. package/src/engine/graphics/sh3/lightmap/lightmap_dilate.js +89 -0
  230. package/src/engine/graphics/sh3/lightmap/lightmap_gather.d.ts +54 -0
  231. package/src/engine/graphics/sh3/lightmap/lightmap_gather.d.ts.map +1 -0
  232. package/src/engine/graphics/sh3/lightmap/lightmap_gather.js +168 -0
  233. package/src/engine/graphics/sh3/lightmap/lightmap_rasterize_triangle.d.ts +30 -0
  234. package/src/engine/graphics/sh3/lightmap/lightmap_rasterize_triangle.d.ts.map +1 -0
  235. package/src/engine/graphics/sh3/lightmap/lightmap_rasterize_triangle.js +145 -0
  236. package/src/engine/graphics/sh3/lightmap/lightmap_seam_fix.d.ts +38 -0
  237. package/src/engine/graphics/sh3/lightmap/lightmap_seam_fix.d.ts.map +1 -0
  238. package/src/engine/graphics/sh3/lightmap/lightmap_seam_fix.js +152 -0
  239. package/src/engine/graphics/sh3/lightmap/prototypeLightmapBaker.d.ts +2 -0
  240. package/src/engine/graphics/sh3/lightmap/prototypeLightmapBaker.d.ts.map +1 -0
  241. package/src/engine/graphics/sh3/lightmap/prototypeLightmapBaker.js +186 -0
  242. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
  243. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +2 -2
  244. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
  245. package/src/engine/graphics/sh3/path_tracer/prepare_scene_gltf.d.ts.map +1 -1
  246. package/src/engine/graphics/sh3/path_tracer/prepare_scene_gltf.js +6 -4
  247. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +3 -3
  248. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -1
  249. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +5 -4
  250. package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.js +2 -2
  251. package/src/engine/input/devices/KeyboardDevice.d.ts +61 -14
  252. package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
  253. package/src/engine/input/devices/KeyboardDevice.js +41 -15
  254. package/src/engine/input/devices/isHTMLElementFocusable.d.ts.map +1 -1
  255. package/src/engine/input/devices/isHTMLElementFocusable.js +2 -9
  256. package/src/engine/sound/simulation/prototypeAcousticSolver.js +261 -143
@@ -0,0 +1,174 @@
1
+ # Plan: fix LSCM self-intersection (shape-aware boundary → BFF)
2
+
3
+ Status: **planning** (2026-06-26). No build started. Goal: rescue the LSCM
4
+ boundary-self-intersection charts that currently explode into piecewise
5
+ sub-charts, **with low distortion** — the one lever the metrics validated
6
+ ([REVIEW_02.md §5.0](REVIEW_02.md), [atlas_metrics.bench.spec.js](atlas_metrics.bench.spec.js)).
7
+
8
+ ## 0. Problem recap (measured, not assumed)
9
+
10
+ On the decimated-terrain bench: 970 charts, of which 31 LSCM charts fail
11
+ bijectivity, **all 31 on boundary self-intersection** (free-boundary conformal
12
+ LSCM has no injectivity guarantee → the patch curls so its UV outline overlaps).
13
+ Each explodes into ~4 ortho piecewise pieces (+96 charts).
14
+
15
+ The convex-boundary rescue (`atlas_chart_parameterize_tutte.js`, built then removed —
16
+ see §5) eliminated the explosion (−96 charts, util 71.9 %→86.3 %,
17
+ **guaranteed bijective**) **but at catastrophic distortion** (mean stretch 2.55→70.9,
18
+ p99 4.27→2467). Confirmed **boundary-dominated**: uniform→mean-value interior
19
+ weights changed nothing (70.82→70.88). The charts are thin/curled, so a *circle*
20
+ is the wrong target. We need a **low-distortion boundary** that is still safe.
21
+
22
+ ## 1. Reuse inventory (what already exists in meep)
23
+
24
+ **Directly reusable — no rebuild:**
25
+
26
+ | Need | Reuse |
27
+ |---|---|
28
+ | Cotangent edge weight (Laplacian core) | `core/geom/vec3/v3_cotangent.js` |
29
+ | Sparse assembly + matvec | `core/math/linalg/sparse/SparseMatrixCSR.js` (`from_triplets`), `spm_matvec`, `spm_matvec_transpose` |
30
+ | SPD / least-squares iterative solve | `core/math/linalg/cg/cg_solve.js`, `cg_solve_normal_equations.js` (used by LSCM + BFF) |
31
+ | Boundary-loop trace, disk detection, interior/boundary re-index, UV write-back | (prototyped in the now-removed Tutte module; carried into `param/atlas_chart_parameterize_bff.js`) |
32
+ | Pipeline slot: cascade + `param.*` option + bijectivity gate + new `CHART_TYPE` | `atlas_compute_charts.js`, `atlas_chart_type.js` |
33
+ | **Acceptance harness**: metrics + A/B + failure-reason diagnostic + the Tutte A/B (mirror it) | `atlas_bench_lib.js`, `atlas_metrics.bench.spec.js` |
34
+
35
+ **Must build new (no existing primitive):**
36
+
37
+ - Cotangent-**Laplacian assembly** (chart-local → `SparseMatrixCSR` via `v3_cotangent`). Small.
38
+ - Interior **angle-defect** (Gaussian curvature) + boundary **exterior/geodesic angle**. From triangle geometry.
39
+ - **Obtuse-triangle handling**: cotangent weights go negative on obtuse triangles → the Laplacian can be indefinite (CG divergence / interior flips). v1: **clamp negative weights to 0** (simple, slight bias); intrinsic-Delaunay flips are the better-but-heavier option, deferred.
40
+ - (BFF only) **DtN / Schur boundary operator**, the discrete-Yamabe **scale-factor solve**, boundary-**curve integration** (cumulative turning angles → 2D), and the **conformal interior extension** (harmonic + conjugate/Hilbert).
41
+
42
+ There is **no** existing discrete Laplacian, curvature, or conjugate operator in meep (the `harmonic`/`geodesic` hits are spherical-harmonics and pathfinding). The reusable scaffolding is the Tutte module + the linalg/cotangent primitives.
43
+
44
+ ## 2. Staged plan — cheap variant first, BFF only if it fails the gate
45
+
46
+ ### Phase A — shape-aware **convex** boundary (cheap; ~all reuse) — TRIED, FAILED ❌
47
+
48
+ Mapped the boundary to an aspect-matched convex **ellipse** (aspect from the prior
49
+ LSCM-layout PCA) instead of a circle; still convex ⇒ still guaranteed-injective.
50
+ **Measured: no improvement** — decimated terrain mean stretch **71.67 vs the
51
+ circle's 70.9** (and util 86.9 % vs 86.3 %). Reverted.
52
+
53
+ Root cause — a **catch-22**: a curled chart's LSCM layout curls into a roughly
54
+ *round* blob, so its PCA aspect ≈ 1 (the ellipse collapses back to a circle); and
55
+ 3D PCA is no better (a curled strip is 3D-compact). **You cannot estimate the
56
+ flattened aspect of a curled chart without first flattening it.** No *pre-guessed*
57
+ convex boundary escapes this. The whole convex-boundary family is now ruled out by
58
+ measurement: circle 70.9, aspect-ellipse 71.67, mean-value-weights 70.88 — all
59
+ catastrophic. **The boundary MUST be derived from the chart's intrinsic geometry
60
+ (curvature), which is exactly what BFF does and nothing cheaper can.** Proceed to
61
+ Phase B.
62
+
63
+ ### Phase B — full **BFF** (only if Phase A insufficient)
64
+
65
+ Boundary First Flattening computes a *minimal-distortion, non-convex* boundary
66
+ (not a forced convex shape) and a conformal interior, so it is the only method
67
+ that can be both low-distortion AND (in practice) non-self-intersecting. Staged so
68
+ each sub-phase is independently testable:
69
+
70
+ - **B1 — analytic infra (de-risk first).** Cotangent-Laplacian assembly + interior
71
+ angle-defect + boundary geodesic curvature + obtuse clamping. *Test:* the
72
+ Laplacian reproduces a known harmonic field on a flat grid; angle defects sum to
73
+ 2πχ (Gauss–Bonnet). Reuses `v3_cotangent` + `SparseMatrixCSR` + `cg_solve`.
74
+ - **B2 — BFF boundary.** Discrete-Yamabe scale-factor solve (interior flat,
75
+ least-area-distortion boundary via the Neumann↔Dirichlet relation on the
76
+ boundary; small dense system → `lu_factor`/`lu_solve`), then integrate scaled
77
+ boundary edge lengths + target turning angles into a 2D boundary curve. *Test:* a
78
+ developable patch (cone/cylinder) flattens to ~zero stretch; boundary curve
79
+ closes up.
80
+ - **B3 — conformal interior extension** (the riskiest). Harmonic extension of the
81
+ boundary curve + the conjugate (discrete Hilbert) recovery, via two Laplace
82
+ solves (`cg_solve`). *Test:* on a disk, stretch ≪ Tutte; bijective. If the
83
+ conjugate step proves too costly/risky, fall back to plain harmonic extension
84
+ (loses the guarantee) + the validity gate + piecewise as last resort.
85
+ - **B4 — wire in.** New `CHART_TYPE.BFF`, behind `param.bff`, inserted in the
86
+ cascade before piecewise (ortho → LSCM → BFF → piecewise); accept only if it
87
+ comes out bijective, else piecewise. Mirror the Tutte A/B test.
88
+
89
+ *Effort: substantial. B3 is the principal risk. BFF does not *strictly* guarantee
90
+ non-self-intersection, so any chart it can't flatten validly still falls to
91
+ piecewise — never worse than today.*
92
+
93
+ ## 3. Acceptance gate (the candidate must beat BOTH baselines)
94
+
95
+ Measured via the existing A/B harness on the **decimated terrain** plus a second
96
+ curved fixture (e.g. a noisy sphere), candidate (`param.{tutteShaped|bff}=true`)
97
+ vs the piecewise baseline (`tutte=false`):
98
+
99
+ 1. **Fewer charts** — `cand.chart_count < base.chart_count` (eliminates the
100
+ piecewise explosion). *Tutte already passes this.*
101
+ 2. **Distortion not worse than piecewise** — `cand.mean_stretch ≤ base.mean_stretch`
102
+ (≈ 2.55) **and** `cand.p99_stretch ≤ ~2× base.p99_stretch`. **This is the gate
103
+ Tutte fails (70.9 vs 2.55) — the whole point.** A candidate that cuts charts but
104
+ balloons distortion does not ship default-on.
105
+ 3. **Bijective** — every rescued chart: no flips, no self-intersection, no
106
+ zero-area (`atlas_chart_param_validity`).
107
+ 4. **Deterministic** — bit-identical UVs across reruns.
108
+ 5. **No regression on clean fixtures** — cube / plane / uv-sphere / cylinder / cone
109
+ unchanged (the rescue triggers only on LSCM-self-intersecting disk charts).
110
+ 6. **Bounded cost** — per-chart solve only on the self-intersecting charts; no
111
+ global slowdown on clean meshes.
112
+
113
+ **Ship rules:**
114
+ - Pass **1 + 2 + 3** → **default-on** (a genuine quality win over both piecewise and Tutte).
115
+ - Pass **1 + 3** but fail **2** → **off-by-default** opt-in knob (chart-count vs distortion trade-off), like Tutte.
116
+ - Fail **3** → **reject**.
117
+
118
+ ## 4. Risks & mitigations
119
+
120
+ | Risk | Mitigation |
121
+ |---|---|
122
+ | Obtuse triangles → indefinite cot-Laplacian (CG divergence / interior flips) | Clamp negative cotangents to 0 (v1); intrinsic-Delaunay flips deferred. Phase A's convex boundary keeps injectivity regardless of clamping. |
123
+ | BFF conjugate/Hilbert step (B3) too costly/subtle | Fall back to harmonic extension + validity gate; worst case piecewise (no regression). |
124
+ | BFF boundary may still self-intersect on pathological charts | Accept only if bijective; else piecewise — strictly ≤ today's chart count. |
125
+ | Effort for a ~10 % over-segmentation win on curved/decimated assets only | Phase A is cheap and may suffice; only escalate to BFF if the metric demands it. Clean assets are unaffected either way. |
126
+
127
+ ## 5. Status / next action
128
+
129
+ > **FINAL STATE (2026-06-26).** BFF is built ([atlas_chart_parameterize_bff.js](param/atlas_chart_parameterize_bff.js),
130
+ > `CHART_TYPE.BFF`) with the intrinsic boundary + DtN-optimal curvature + conformal
131
+ > interior, and is **folded into the single always-on cascade** (ortho → LSCM → BFF →
132
+ > piecewise, no flags) — free (compute Δ ~−0.3 %, runs only post-LSCM-failure) and
133
+ > strictly Pareto-safe (accepts only bijective + near-isometric whole charts). The
134
+ > **Tutte convex-boundary path was removed** (dominated). Net effect on the
135
+ > decimated terrain: 970 → 964 charts, mean stretch 2.553 → 2.508. The history below
136
+ > records how each variant was measured and ruled in/out.
137
+
138
+ - **Phase A — done, failed the gate (§2).** Reverted. Convex-boundary family ruled
139
+ out by measurement (catch-22 on the aspect estimate).
140
+ - **Phase B v1 — done, built + measured ([atlas_chart_parameterize_bff.js](param/atlas_chart_parameterize_bff.js),
141
+ `CHART_TYPE.BFF`, `param.bff`, default off).** Intrinsic boundary (uniform
142
+ curvature redistribution) + **conformal** pinned-boundary interior (harmonic was
143
+ tried first and flipped 26/31; conformal is far less flip-prone). **Clears the
144
+ gate** (decimated terrain: −4 charts, mean stretch 2.553 → 2.509 *better*, all
145
+ BFF charts bijective, no clean-fixture regression — a Pareto-safe win, unlike
146
+ Tutte's 70×) **but at tiny magnitude: only 1 of 31** self-intersecting charts is
147
+ rescued. Diagnosed: the other 30 fail because the v1 **uniform** curvature
148
+ redistribution leaves the boundary too contorted (25 flip the conformal interior,
149
+ 5 self-intersect at the boundary).
150
+ - **Phase B v2 — DtN boundary, done + measured.** Replaced the uniform
151
+ redistribution with the optimal Dirichlet-to-Neumann curvature (fix boundary
152
+ scale 0, solve interior Poisson `L_II u = Ω_I` via `cg_solve`, `k̃_b = (π−θ_b) −
153
+ (L u)_b`; ∑ k̃ = 2π keeps it closed). **The DtN boundary fixed the interior**
154
+ (conformal-interior flips 25 → 2). Still Pareto-safe (−6 charts, mean 2.553 →
155
+ 2.508, p99 4.27 → 3.99, bijective, torus unchanged) **but still only ~2 of 31
156
+ rescued — the flattened BOUNDARY now self-intersects on ~27/31.**
157
+
158
+ - **CONCLUSION: these charts are intrinsically un-flattenable-whole.** The boundary
159
+ self-intersection is **fundamental, not an implementation gap** — true unclamped
160
+ cotangents made it *worse* (1 rescue, 30 self-intersections). A high-curvature
161
+ decimated chart cannot be *developed* to a SIMPLE planar boundary while
162
+ preserving edge lengths (the curvature forces the flat boundary to overlap
163
+ itself), so **cutting (piecewise) is the correct injective answer** for them; BFF
164
+ rescues only the ~2 low-curvature ones. BFF is the right tool and is kept
165
+ off-by-default (correct, tested, Pareto-safe), but it does NOT unlock the
166
+ majority. The metrics conclusively show the **piecewise explosion is largely
167
+ correct behavior** for decimated/high-curvature assets.
168
+
169
+ - **If a future need demands keeping these whole:** the only remaining option is a
170
+ method that allows the *boundary to be cut* as part of the optimization
171
+ (OptCuts-style joint cut+flatten) or a guaranteed-injective nonlinear map with a
172
+ scaffold (SLIM + boundary-band scaffold). Both are large, separate builds, and
173
+ the metrics say the payoff (~29 hard charts on decimated assets) is modest. Not
174
+ recommended unless the asset mix shifts toward heavily-decimated content.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * One UV chart: a connected patch of the source mesh extracted into a
3
+ * self-contained, indexable structure for parameterization and packing
4
+ * (xatlas `Chart`).
5
+ *
6
+ * A chart-local ("unified") vertex is a distinct source mesh vertex used by the
7
+ * chart's faces — one geometric vertex shared by several faces of the chart maps
8
+ * to ONE chart vertex (and one UV), while the same geometric vertex in another
9
+ * chart is a separate chart vertex, which is how a seam arises. Triangle corners
10
+ * carry their source loop ids so solved UVs can be written back to the per-corner
11
+ * loop_data channel.
12
+ *
13
+ * Built by {@link atlas_extract_chart} (and the piecewise re-segmenter);
14
+ * parameterization fills {@link uv}/{@link type}; packing fills the `atlas_*`
15
+ * fields and rewrites {@link uv} into atlas space.
16
+ *
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export class Chart {
21
+ /** Number of chart-local (unified) vertices. @type {number} */
22
+ vertex_count: number;
23
+ /** Chart-local vertex id -> source mesh vertex id. @type {Uint32Array} */
24
+ vertex_of_local: Uint32Array;
25
+ /** Flat xyz per chart-local vertex (length 3 * vertex_count). @type {Float64Array} */
26
+ positions: Float64Array;
27
+ /** Triangle count. @type {number} */
28
+ triangle_count: number;
29
+ /** 3 chart-local vertex ids per triangle. @type {Uint32Array} */
30
+ tri_local: Uint32Array;
31
+ /** 3 source mesh loop ids per triangle (per-corner UV write-back). @type {Uint32Array} */
32
+ tri_loops: Uint32Array;
33
+ /** Source mesh face id per triangle. @type {Uint32Array} */
34
+ tri_face: Uint32Array;
35
+ /** Flat pairs of chart-local vertex ids forming the chart outline. @type {Uint32Array} */
36
+ boundary_edges: Uint32Array;
37
+ /**
38
+ * (u, v) per chart-local vertex — local during parameterization, atlas-space
39
+ * (normalized to its page) after packing.
40
+ * @type {Float64Array}
41
+ */
42
+ uv: Float64Array;
43
+ /** How the UVs were produced — a {@link CHART_TYPE} value. @type {number} */
44
+ type: number;
45
+ /** Total 3D surface area. @type {number} */
46
+ surface_area: number;
47
+ /** Total UV (parametric) area. @type {number} */
48
+ parametric_area: number;
49
+ /** Atlas page the chart was packed onto. @type {number} */
50
+ atlas_page: number;
51
+ /** Chart placement x within its page (texels). @type {number} */
52
+ atlas_x: number;
53
+ /** Chart placement y within its page (texels). @type {number} */
54
+ atlas_y: number;
55
+ /** Whether the chart was placed 90-degrees rotated during packing. @type {boolean} */
56
+ atlas_rotated: boolean;
57
+ }
58
+ //# sourceMappingURL=Chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/atlas/Chart.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IACI,+DAA+D;IAC/D,cADqD,MAAM,CAC1C;IAEjB,0EAA0E;IAC1E,iBAD2D,WAAW,CAC1C;IAE5B,sFAAsF;IACtF,WADsE,YAAY,CAC5D;IAEtB,qCAAqC;IACrC,gBAD2B,MAAM,CACd;IAEnB,iEAAiE;IACjE,WADkD,WAAW,CACvC;IAEtB,0FAA0F;IAC1F,WAD2E,WAAW,CAChE;IAEtB,4DAA4D;IAC5D,UAD6C,WAAW,CACnC;IAErB,0FAA0F;IAC1F,gBAD2E,WAAW,CAC3D;IAE3B;;;;OAIG;IACH,IAFU,YAAY,CAEP;IAEf,6EAA6E;IAC7E,MADmE,MAAM,CACjD;IAExB,4CAA4C;IAC5C,cADkC,MAAM,CACvB;IAEjB,iDAAiD;IACjD,iBADuC,MAAM,CACzB;IAEpB,2DAA2D;IAC3D,YADiD,MAAM,CACxC;IAEf,iEAAiE;IACjE,SADuD,MAAM,CACjD;IAEZ,iEAAiE;IACjE,SADuD,MAAM,CACjD;IAEZ,sFAAsF;IACtF,eAD2E,OAAO,CAC5D;CACzB"}
@@ -0,0 +1,77 @@
1
+ import { CHART_TYPE } from "./atlas_chart_type.js";
2
+
3
+ const EMPTY_U32 = new Uint32Array(0);
4
+ const EMPTY_F64 = new Float64Array(0);
5
+
6
+ /**
7
+ * One UV chart: a connected patch of the source mesh extracted into a
8
+ * self-contained, indexable structure for parameterization and packing
9
+ * (xatlas `Chart`).
10
+ *
11
+ * A chart-local ("unified") vertex is a distinct source mesh vertex used by the
12
+ * chart's faces — one geometric vertex shared by several faces of the chart maps
13
+ * to ONE chart vertex (and one UV), while the same geometric vertex in another
14
+ * chart is a separate chart vertex, which is how a seam arises. Triangle corners
15
+ * carry their source loop ids so solved UVs can be written back to the per-corner
16
+ * loop_data channel.
17
+ *
18
+ * Built by {@link atlas_extract_chart} (and the piecewise re-segmenter);
19
+ * parameterization fills {@link uv}/{@link type}; packing fills the `atlas_*`
20
+ * fields and rewrites {@link uv} into atlas space.
21
+ *
22
+ * @author Alex Goldring
23
+ * @copyright Company Named Limited (c) 2026
24
+ */
25
+ export class Chart {
26
+ /** Number of chart-local (unified) vertices. @type {number} */
27
+ vertex_count = 0;
28
+
29
+ /** Chart-local vertex id -> source mesh vertex id. @type {Uint32Array} */
30
+ vertex_of_local = EMPTY_U32;
31
+
32
+ /** Flat xyz per chart-local vertex (length 3 * vertex_count). @type {Float64Array} */
33
+ positions = EMPTY_F64;
34
+
35
+ /** Triangle count. @type {number} */
36
+ triangle_count = 0;
37
+
38
+ /** 3 chart-local vertex ids per triangle. @type {Uint32Array} */
39
+ tri_local = EMPTY_U32;
40
+
41
+ /** 3 source mesh loop ids per triangle (per-corner UV write-back). @type {Uint32Array} */
42
+ tri_loops = EMPTY_U32;
43
+
44
+ /** Source mesh face id per triangle. @type {Uint32Array} */
45
+ tri_face = EMPTY_U32;
46
+
47
+ /** Flat pairs of chart-local vertex ids forming the chart outline. @type {Uint32Array} */
48
+ boundary_edges = EMPTY_U32;
49
+
50
+ /**
51
+ * (u, v) per chart-local vertex — local during parameterization, atlas-space
52
+ * (normalized to its page) after packing.
53
+ * @type {Float64Array}
54
+ */
55
+ uv = EMPTY_F64;
56
+
57
+ /** How the UVs were produced — a {@link CHART_TYPE} value. @type {number} */
58
+ type = CHART_TYPE.ORTHO;
59
+
60
+ /** Total 3D surface area. @type {number} */
61
+ surface_area = 0;
62
+
63
+ /** Total UV (parametric) area. @type {number} */
64
+ parametric_area = 0;
65
+
66
+ /** Atlas page the chart was packed onto. @type {number} */
67
+ atlas_page = 0;
68
+
69
+ /** Chart placement x within its page (texels). @type {number} */
70
+ atlas_x = 0;
71
+
72
+ /** Chart placement y within its page (texels). @type {number} */
73
+ atlas_y = 0;
74
+
75
+ /** Whether the chart was placed 90-degrees rotated during packing. @type {boolean} */
76
+ atlas_rotated = false;
77
+ }