@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
@@ -1,4 +1,4 @@
1
- import { vec3 } from "gl-matrix";
1
+ import { v3_equals_array } from "../../../../core/geom/vec3/v3_equals_array.js";
2
2
  import { v3_allocate } from "../../../../core/geom/vec3/v3_allocate.js";
3
3
  import { DEG_TO_RAD } from "../../../../core/math/DEG_TO_RAD.js";
4
4
  import { Build4RuleGroups } from "./Build4RuleGroups.js";
@@ -194,9 +194,9 @@ export function genTangSpace(pContext, fAngularThreshold = 180) {
194
194
  const iTotTris = iNrTrianglesIn;
195
195
  let iDegenTriangles = 0;
196
196
 
197
- const p0 = vec3.create();
198
- const p1 = vec3.create();
199
- const p2 = vec3.create();
197
+ const p0 = new Float32Array(3);
198
+ const p1 = new Float32Array(3);
199
+ const p2 = new Float32Array(3);
200
200
 
201
201
  for (let t = 0; t < iTotTris; t++) {
202
202
 
@@ -211,9 +211,9 @@ export function genTangSpace(pContext, fAngularThreshold = 180) {
211
211
  GetPosition(p2, 0, pContext, i2);
212
212
 
213
213
  if (
214
- vec3.exactEquals(p0, p1) ||
215
- vec3.exactEquals(p0, p2) ||
216
- vec3.exactEquals(p1, p2)
214
+ v3_equals_array(p0, 0, p1, 0) ||
215
+ v3_equals_array(p0, 0, p2, 0) ||
216
+ v3_equals_array(p1, 0, p2, 0)
217
217
  ) {
218
218
  // degenerate
219
219
  pTriInfos[t].iFlag |= MARK_DEGENERATE;
@@ -4,5 +4,4 @@
4
4
  * @param {vec3} input
5
5
  */
6
6
  export function NormalizeSafe(out: vec3, input: vec3): void;
7
- import { vec3 } from "gl-matrix";
8
7
  //# sourceMappingURL=NormalizeSafe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizeSafe.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/NormalizeSafe.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,mCAHW,IAAI,SACJ,IAAI,QAcd;qBAnBoB,WAAW"}
1
+ {"version":3,"file":"NormalizeSafe.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/NormalizeSafe.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,4DAYC"}
@@ -1,4 +1,6 @@
1
- import { vec3 } from "gl-matrix";
1
+ import { v3_length } from "../../../../core/geom/vec3/v3_length.js";
2
+ import { v3_scale } from "../../../../core/geom/vec3/v3_scale.js";
3
+ import { v3_copy_array } from "../../../../core/geom/vec3/v3_copy_array.js";
2
4
 
3
5
  /**
4
6
  *
@@ -7,14 +9,14 @@ import { vec3 } from "gl-matrix";
7
9
  */
8
10
  export function NormalizeSafe(out, input) {
9
11
 
10
- const len = vec3.length(input);
12
+ const len = v3_length(input[0], input[1], input[2]);
11
13
 
12
14
  if (len !== 0) {
13
15
  const m = 1 / len;
14
16
 
15
- vec3.scale(out, input, m)
17
+ v3_scale(out, 0, input[0], input[1], input[2], m);
16
18
 
17
19
  } else {
18
- vec3.copy(out, input);
20
+ v3_copy_array(out, 0, input, 0);
19
21
  }
20
22
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="gl-matrix/index.js" />
2
1
  export class STSpace {
3
2
  /**
4
3
  *
@@ -20,5 +19,4 @@ export class STSpace {
20
19
  */
21
20
  copy(other: STSpace): void;
22
21
  }
23
- import { vec3 } from "gl-matrix";
24
22
  //# sourceMappingURL=STSpace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"STSpace.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/STSpace.js"],"names":[],"mappings":";AAGA;IACI;;;OAGG;IACH,KAFU,IAAI,GAAC,YAAY,CAEP;IACpB;;;OAGG;IACH,KAFU,IAAI,GAAC,YAAY,CAEP;IAEpB,cAAU;IACV,cAAU;IAEV,iBAAa;IACb,iBAAgB;IAEhB;;;OAGG;IACH,YAFW,OAAO,QASjB;CACJ;qBAjCoB,WAAW"}
1
+ {"version":3,"file":"STSpace.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/STSpace.js"],"names":[],"mappings":"AAGA;IACI;;;OAGG;IACH,KAFU,OAAK,YAAY,CAEP;IACpB;;;OAGG;IACH,KAFU,OAAK,YAAY,CAEP;IAEpB,cAAU;IACV,cAAU;IAEV,iBAAa;IACb,iBAAgB;IAEhB;;;OAGG;IACH,YAFW,OAAO,QASjB;CACJ"}
@@ -1,5 +1,5 @@
1
- import { vec3 } from "gl-matrix";
2
1
  import { v3_allocate } from "../../../../core/geom/vec3/v3_allocate.js";
2
+ import { v3_copy_array } from "../../../../core/geom/vec3/v3_copy_array.js";
3
3
 
4
4
  export class STSpace {
5
5
  /**
@@ -24,9 +24,9 @@ export class STSpace {
24
24
  * @param {STSpace} other
25
25
  */
26
26
  copy(other) {
27
- vec3.copy(this.vOs, other.vOs);
27
+ v3_copy_array(this.vOs, 0, other.vOs, 0);
28
28
  this.fMagS = other.fMagS;
29
- vec3.copy(this.vOt, other.vOt);
29
+ v3_copy_array(this.vOt, 0, other.vOt, 0);
30
30
  this.fMagT = other.fMagT;
31
31
  this.iCounter = other.iCounter;
32
32
  this.bOrient = other.bOrient;
@@ -1,4 +1,3 @@
1
- /// <reference types="gl-matrix/index.js" />
2
1
  /**
3
2
  * executes following formula: v1 - v0*( dot(v0,v1) )
4
3
  * @param {vec3} out
@@ -6,5 +5,4 @@
6
5
  * @param {vec3} v1
7
6
  */
8
7
  export function v3_scale_dot_sub_normalize(out: vec3, v0: vec3, v1: vec3): void;
9
- import { vec3 } from "gl-matrix";
10
8
  //# sourceMappingURL=v3_scale_dot_sub_normalize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v3_scale_dot_sub_normalize.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js"],"names":[],"mappings":";AAIA;;;;;GAKG;AACH,gDAJW,IAAI,MACJ,IAAI,MACJ,IAAI,QA2Cd;qBAnDoB,WAAW"}
1
+ {"version":3,"file":"v3_scale_dot_sub_normalize.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,gFAyCC"}
@@ -1,4 +1,3 @@
1
- import { vec3 } from "gl-matrix";
2
1
  import { v3_length } from "../../../../core/geom/vec3/v3_length.js";
3
2
  import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
4
3
 
@@ -1,4 +1,3 @@
1
- /// <reference types="gl-matrix/index.js" />
2
1
  export class ImpostorBaker {
3
2
  /**
4
3
  *
@@ -34,5 +33,4 @@ export class ImpostorBaker {
34
33
  }[]): ImpostorDescription;
35
34
  }
36
35
  import { ImpostorDescription } from "./ImpostorDescription.js";
37
- import { mat4 } from "gl-matrix";
38
36
  //# sourceMappingURL=ImpostorBaker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImpostorBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorBaker.js"],"names":[],"mappings":";AAqBA;IAEI;;;;OAIG;IACH,kBAAiB;IAEjB;;;OAGG;IACH,iDAEC;IAGD;;;;;;;OAOG;IACH,yEANW,MAAM,EAAE,OAAK,uBAgPvB;IAED;;;;;;;OAOG;IACH,4CANW;QAAC,IAAI,iBAAgB;QAAC,SAAS,EAAC,IAAI,CAAA;KAAC,EAAE,GAIrC,mBAAmB,CA4E/B;CACJ;oCA7VmC,0BAA0B;qBAjBnC,WAAW"}
1
+ {"version":3,"file":"ImpostorBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorBaker.js"],"names":[],"mappings":"AAsBA;IAEI;;;;OAIG;IACH,kBAAiB;IAEjB;;;OAGG;IACH,iDAEC;IAGD;;;;;;;OAOG;IACH,yEANW,MAAM,EAAE,OAAK,uBAgPvB;IAED;;;;;;;OAOG;IACH,4CANW;QAAC,IAAI,iBAAgB;QAAC,SAAS,OAAK;KAAC,EAAE,GAIrC,mBAAmB,CA4E/B;CACJ;oCA7VmC,0BAA0B"}
@@ -1,5 +1,6 @@
1
- import { mat4, vec3 } from "gl-matrix";
2
1
  import { Mesh, OrthographicCamera, Scene, Vector4, WebGLMultipleRenderTargets } from "three";
2
+ import { v3_copy_array } from "../../../../core/geom/vec3/v3_copy_array.js";
3
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
3
4
  import { assert } from "../../../../core/assert.js";
4
5
  import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
5
6
  import { HashMap } from "../../../../core/collection/map/HashMap.js";
@@ -170,7 +171,7 @@ export class ImpostorBaker {
170
171
  mesh.matrixWorldNeedsUpdate = false;
171
172
  mesh.frustumCulled = false;
172
173
 
173
- mat4.copy(mesh.matrixWorld.elements, object.transform);
174
+ array_copy(object.transform, 0, mesh.matrixWorld.elements, 0, 16);
174
175
 
175
176
  scene.add(mesh);
176
177
 
@@ -276,7 +277,7 @@ export class ImpostorBaker {
276
277
 
277
278
 
278
279
  id.sphere_radius = bounding_sphere[3];
279
- vec3.copy(id.offset, bounding_sphere);
280
+ v3_copy_array(id.offset, 0, bounding_sphere, 0);
280
281
 
281
282
  return id;
282
283
  }
@@ -1,5 +1,5 @@
1
1
  import { UvEncoder } from "./UvEncoder.js";
2
- import { vec3 } from "gl-matrix";
2
+ import { v3_normalize_array } from "../../../../../core/geom/vec3/v3_normalize_array.js";
3
3
 
4
4
  export class HemiOctahedralUvEncoder extends UvEncoder {
5
5
  uv_to_unit(output, input) {
@@ -15,6 +15,6 @@ export class HemiOctahedralUvEncoder extends UvEncoder {
15
15
  output[1] = r_y;
16
16
  output[2] = pz;
17
17
 
18
- vec3.normalize(output, output);
18
+ v3_normalize_array(output, 0, output, 0);
19
19
  }
20
20
  }
@@ -1,7 +1,17 @@
1
- import {vec2, vec3} from "gl-matrix";
2
-
3
- export declare class UvEncoder {
4
- uv_to_unit(output: vec3, input: vec2): void
5
-
6
- unit_to_uv(output: vec2, inout: vec3): void
7
- }
1
+ export class UvEncoder {
2
+ /**
3
+ *
4
+ * @param {number[]|vec3} output
5
+ * @param {number[]|vec2} input
6
+ * @returns {void}
7
+ */
8
+ uv_to_unit(output: number[] | vec3, input: number[] | vec2): void;
9
+ /**
10
+ *
11
+ * @param {number[]|vec2} output
12
+ * @param {number[]|vec3} input
13
+ * @returns {void}
14
+ */
15
+ unit_to_uv(output: number[] | vec2, input: number[] | vec3): void;
16
+ }
17
+ //# sourceMappingURL=UvEncoder.d.ts.map
@@ -1,4 +1,4 @@
1
- import { vec3 } from "gl-matrix";
1
+ import { v3_copy_array } from "../../../../core/geom/vec3/v3_copy_array.js";
2
2
  import { assert } from "../../../../core/assert.js";
3
3
  import { ImpostorBaker } from "../octahedral/ImpostorBaker.js";
4
4
  import { ImpostorCaptureType } from "../octahedral/ImpostorCaptureType.js";
@@ -349,7 +349,7 @@ export class VoxelImpostorBaker {
349
349
 
350
350
  result.capture_type = capture_type;
351
351
  result.sphere_radius = bake_result.sphere_radius;
352
- vec3.copy(result.offset, bake_result.offset);
352
+ v3_copy_array(result.offset, 0, bake_result.offset, 0);
353
353
 
354
354
  result.points = bake_result.voxelised.points;
355
355
  result.point_count = bake_result.voxelised.point_count;
@@ -6,7 +6,7 @@ import Quaternion from "../../../../../../../core/geom/Quaternion.js";
6
6
  import { ParticleEmitter } from "../../emitter/ParticleEmitter.js";
7
7
  import { Transform } from "../../../../../../ecs/transform/Transform.js";
8
8
  import Entity from "../../../../../../ecs/Entity.js";
9
- import { vec3 } from "gl-matrix";
9
+ import { v3_matrix4_multiply } from "../../../../../../../core/geom/vec3/v3_matrix4_multiply.js";
10
10
  import { AttributeValue } from "./AttributeValue.js";
11
11
  import { PARTICULAR_PARTICLE_SPECIFICATION } from "../../emitter/PARTICULAR_PARTICLE_SPECIFICATION.js";
12
12
  import { SerializationMetadata } from "../../../../../../ecs/components/SerializationMetadata.js";
@@ -443,7 +443,7 @@ export class ParticleVolume {
443
443
 
444
444
  if (ts.contains_point(v3_position)) {
445
445
 
446
- vec3.transformMat4(v3_position, v3_position, matrix_elements);
446
+ v3_matrix4_multiply(v3_position, 0, v3_position, 0, matrix_elements);
447
447
 
448
448
  particles.writeAttributeVector3(particle_index, PARTICLE_ATTRIBUTE_POSITION, v3_position[0], v3_position[1], v3_position[2]);
449
449
 
@@ -521,7 +521,7 @@ export class ParticleVolume {
521
521
  for (let i = 0; i < particle_count; i++) {
522
522
  shape.sample_random_point_in_volume(v3_position, 0, random);
523
523
 
524
- vec3.transformMat4(v3_position, v3_position, matrix_elements);
524
+ v3_matrix4_multiply(v3_position, 0, v3_position, 0, matrix_elements);
525
525
 
526
526
  particles.writeAttributeVector3(i, PARTICLE_ATTRIBUTE_POSITION, v3_position[0], v3_position[1], v3_position[2]);
527
527
  }
@@ -1,4 +1,5 @@
1
- import { mat4 } from "gl-matrix";
1
+ import { m4_allocate } from "../../../../../../../core/geom/3d/mat4/m4_allocate.js";
2
+ import { m4_from_rotation_translation_scale } from "../../../../../../../core/geom/3d/mat4/m4_from_rotation_translation_scale.js";
2
3
  import { LineBasicMaterial } from "three";
3
4
  import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
4
5
  import { makeEngineOptionsModel } from "../../../../../../../../../model/game/options/makeEngineOptionsModel.js";
@@ -243,9 +244,9 @@ function make_shape_vis_toggle(engine) {
243
244
  }
244
245
 
245
246
  function mat_from_aabb3(aabb3) {
246
- const m4 = mat4.create();
247
+ const m4 = m4_allocate();
247
248
 
248
- mat4.fromRotationTranslationScale(m4, [0, 0, 0, 1], [(aabb3.x0 + aabb3.x1) / 2, (aabb3.y0 + aabb3.y1) / 2, (aabb3.z0 + aabb3.z1) / 2], [aabb3.getExtentsX(), aabb3.getExtentsY(), aabb3.getExtentsZ()]);
249
+ m4_from_rotation_translation_scale(m4, [0, 0, 0, 1], [(aabb3.x0 + aabb3.x1) / 2, (aabb3.y0 + aabb3.y1) / 2, (aabb3.z0 + aabb3.z1) / 2], [aabb3.getExtentsX(), aabb3.getExtentsY(), aabb3.getExtentsZ()]);
249
250
 
250
251
  return m4;
251
252
  }
@@ -1,4 +1,4 @@
1
- import { mat4 } from "gl-matrix";
1
+ import { m4_multiply } from "../../../../core/geom/3d/mat4/m4_multiply.js";
2
2
  import {
3
3
  ClampToEdgeWrapping,
4
4
  DataTexture,
@@ -1079,7 +1079,7 @@ export class LightManager {
1079
1079
  camera.matrixWorldInverse.invert();
1080
1080
 
1081
1081
  // this.__projection_matrix.set(camera.matrixWorldInverse.elements);
1082
- mat4.multiply(this.__projection_matrix, camera.projectionMatrix.elements, camera.matrixWorldInverse.elements);
1082
+ m4_multiply(this.__projection_matrix, camera.projectionMatrix.elements, camera.matrixWorldInverse.elements);
1083
1083
 
1084
1084
  // console.time('__build_view_frustum');
1085
1085
  this.__build_view_frustum(camera);
@@ -1,4 +1,3 @@
1
- /// <reference types="gl-matrix/index.js" />
2
1
  export class Decal extends AbstractLight {
3
2
  /**
4
3
  * Transform matrix, initial volume is a unit cube
@@ -41,6 +40,5 @@ export class Decal extends AbstractLight {
41
40
  ENCODED_SLOT_COUNT: number;
42
41
  }
43
42
  import { AbstractLight } from "./AbstractLight.js";
44
- import { mat4 } from "gl-matrix";
45
43
  import Signal from "../../../../../core/events/signal/Signal.js";
46
44
  //# sourceMappingURL=Decal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Decal.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/render/forward_plus/model/Decal.js"],"names":[],"mappings":";AASA;IAIQ;;;OAGG;IACH,WAFU,MAAM,EAAE,GAAC,YAAY,GAAC,IAAI,EAAE,CAED;IACrC,gCAA6C;IAC7C,iBAA6B;IAE7B,oBAAgC;IAKhC;;;OAGG;IACH,2BAA2B;IAE3B;;;;OAIG;IACH,eAFU,MAAM,CAEM;IAEtB,0EAA6C;IAGjD;;;OAGG;IACH,gBAFW,MAAM,EAAE,GAAC,YAAY,GAAC,UAAU,MAAM,CAAC,QAOjD;IAED,6CAGC;IAED,yCAGC;IAED,4BAUC;IAED,+CAGC;IAED,gDAGC;IAED,6BAKC;IAED,2BAIC;IAED,gDAcC;IAGL;;;OAGG;IACH,kBAFU,OAAO,CAEM;IAEvB,2BAAkC;CARjC;8BAjH6B,oBAAoB;qBAI7B,WAAW;mBACb,6CAA6C"}
1
+ {"version":3,"file":"Decal.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/render/forward_plus/model/Decal.js"],"names":[],"mappings":"AASA;IAIQ;;;OAGG;IACH,WAFU,MAAM,EAAE,GAAC,YAAY,GAAC,MAAM,CAED;IACrC,gCAA6C;IAC7C,iBAA6B;IAE7B,oBAAgC;IAKhC;;;OAGG;IACH,2BAA2B;IAE3B;;;;OAIG;IACH,eAFU,MAAM,CAEM;IAEtB,0EAA6C;IAGjD;;;OAGG;IACH,gBAFW,MAAM,EAAE,GAAC,YAAY,GAAC,UAAU,MAAM,CAAC,QAOjD;IAED,6CAGC;IAED,yCAGC;IAED,4BAUC;IAED,+CAGC;IAED,gDAGC;IAED,6BAKC;IAED,2BAIC;IAED,gDAcC;IAGL;;;OAGG;IACH,kBAFU,OAAO,CAEM;IAEvB,2BAAkC;CARjC;8BAjH6B,oBAAoB;mBAK/B,6CAA6C"}
@@ -2,7 +2,7 @@ import { AbstractLight } from "./AbstractLight.js";
2
2
  import { aabb3_matrix4_project_by_corners } from "../../../../../core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js";
3
3
  import { aabb3_build_corners } from "../../../../../core/geom/3d/aabb/aabb3_build_corners.js";
4
4
  import { array_copy } from "../../../../../core/collection/array/array_copy.js";
5
- import { mat4 } from "gl-matrix";
5
+ import { m4_invert } from "../../../../../core/geom/3d/mat4/m4_invert.js";
6
6
  import Signal from "../../../../../core/events/signal/Signal.js";
7
7
 
8
8
  const corners = [];
@@ -45,8 +45,8 @@ export class Decal extends AbstractLight {
45
45
  * @param {number[]|Float32Array|ArrayLike<number>} m
46
46
  */
47
47
  setTransform(m) {
48
- mat4.copy(this.transform, m);
49
- mat4.invert(this.transform_inverse, this.transform);
48
+ array_copy(m, 0, this.transform, 0, 16);
49
+ m4_invert(this.transform_inverse, this.transform);
50
50
 
51
51
  this.__signal_transfom_changed.send0();
52
52
  }
@@ -1,4 +1,5 @@
1
- import { mat4 } from "gl-matrix";
1
+ import { m4_from_rotation_translation_scale } from "../../../../../core/geom/3d/mat4/m4_from_rotation_translation_scale.js";
2
+ import { m4_invert } from "../../../../../core/geom/3d/mat4/m4_invert.js";
2
3
  import SimplexNoise from "simplex-noise";
3
4
  import {
4
5
  AmbientLight,
@@ -388,8 +389,8 @@ function addDecal({
388
389
  }) {
389
390
  const decal = new Decal();
390
391
 
391
- mat4.fromRotationTranslationScale(decal.transform, rotation, position, scale);
392
- mat4.invert(decal.transform_inverse, decal.transform);
392
+ m4_from_rotation_translation_scale(decal.transform, rotation, position, scale);
393
+ m4_invert(decal.transform_inverse, decal.transform);
393
394
 
394
395
  decal.texture_diffuse = sampler;
395
396
 
@@ -1,4 +1,6 @@
1
- import { mat4 } from "gl-matrix";
1
+ import { m4_allocate } from "../../../../../core/geom/3d/mat4/m4_allocate.js";
2
+ import { m4_multiply } from "../../../../../core/geom/3d/mat4/m4_multiply.js";
3
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
2
4
  import FacingDirectionSystem from "../../../../../../../model/game/ecs/system/FacingDirectionSystem.js";
3
5
  import { initializeEditor } from "../../../../../../../model/game/initializeEditor.js";
4
6
  import { makeEngineOptionsModel } from "../../../../../../../model/game/options/makeEngineOptionsModel.js";
@@ -208,12 +210,12 @@ function prepare_query_test(hiz, graphics, ecd) {
208
210
 
209
211
  const camera = graphics.camera;
210
212
 
211
- const projection = mat4.create();
213
+ const projection = m4_allocate();
212
214
  const world_inverse = camera.matrixWorldInverse.elements;
213
215
  const camera_projection = camera.projectionMatrix.elements;
214
216
 
215
- mat4.copy(projection, world_inverse);
216
- mat4.multiply(projection, camera_projection, projection);
217
+ array_copy(world_inverse, 0, projection, 0, 16);
218
+ m4_multiply(projection, camera_projection, projection);
217
219
  const aabb = new AABB3();
218
220
 
219
221
  const query_size = query.getSize();
@@ -0,0 +1,146 @@
1
+ # Plan: fixing seams & contact leaks
2
+
3
+ Driven by two observed artifacts plus the Bakery author's article
4
+ "Baking artifact-free lightmaps" (https://ndotl.wordpress.com/2018/08/29/baking-artifact-free-lightmaps/).
5
+
6
+ ## Status (2026-06): implemented
7
+
8
+ - **P0 carry original normals** — `lightmap_build_geometry.js` now accumulates the SOURCE
9
+ mesh's per-corner normals via `tri_face` (continuous across seams, hard edges preserved),
10
+ falling back to the geometric recompute. Fixes sphere faceting. ✅
11
+ - **P0 sample-position push** — `lightmap_push_sample.js`; the bake relocates contact/buried
12
+ samples (tangential backface probe → push out) instead of discarding. Fixes the contact
13
+ black line. ✅
14
+ - **P1 supersampling** — `lightmap_gather.js` jitters each ray ORIGIN within the texel
15
+ footprint (`supersample` option), antialiasing contacts/silhouettes; directions stay
16
+ independent per texel. ✅
17
+ - **P1 graded adaptive sampling** — smooth interior texels take a reduced *real* sample count
18
+ (`min_sample_fraction`, default 0.25) instead of a pure lerp (which is now opt-in via
19
+ `min_sample_fraction = 0`). Edges still full-sampled. ✅
20
+ - **P1 UV seam stitching** — `lightmap_seam_fix.js` pairs chart boundary edges by source vertex
21
+ and blends both atlas sides; runs after dilation (`seam_fix_iterations`). ✅
22
+ - Post order now: bake (push + supersample) → variance denoise → dilate → seam-fix.
23
+ - Specs: +`lightmap_push_sample.spec.js`, +`lightmap_seam_fix.spec.js`, +carry-normals case;
24
+ 24 tests across 8 suites green; webpack build clean.
25
+
26
+ ### P2 bicubic — SKIPPED for now (user decision)
27
+ The lightmap is sampled inside three's unexpanded `#include <lights_fragment_maps>`, so a clean
28
+ 4-tap bicubic needs either a global `THREE.ShaderChunk.lights_fragment_maps` override (affects
29
+ every lit material) or hard-coding three's chunk text in a per-material `onBeforeCompile`
30
+ (brittle across three versions), and it must compose with the FP+ fragment rebuild. It's
31
+ cosmetic polish (masks low resolution) on top of fixes that already address the root artifacts,
32
+ so it was deliberately skipped. Revisit only if the lightmap still reads low-res after the P0/P1
33
+ fixes; the two viable approaches are recorded above.
34
+
35
+ ---
36
+
37
+ ## Original analysis
38
+
39
+ ## The two artifacts, diagnosed against our code
40
+
41
+ ### A. Seams on the smooth sphere
42
+ Two independent causes stack here:
43
+
44
+ 1. **Shading faceting (the dominant one).** `lightmap_build_geometry.js` *recomputes* normals
45
+ per concatenated chart (`geometry_compute_vertex_normals_indexed`). A seam vertex is
46
+ duplicated per chart and not shared, so each side averages only its own chart's triangles →
47
+ the shading normal is **discontinuous at every chart boundary** → hard facets on a surface
48
+ that should be smooth. This is a regression we flagged ("normals recomputed, not original").
49
+
50
+ 2. **Lighting value step across the UV seam.** The two sides of a seam are the same 3D edge but
51
+ live in different atlas locations, sampled independently → slightly different indirect values →
52
+ a faint step. Denoise/dilate never bridge it (the two sides are far apart in the atlas).
53
+
54
+ ### B. Black line where the box meets the floor (contact leak)
55
+ The contact texels — floor texels whose footprint straddles the box base, and the box's
56
+ bottom-edge texels — are getting near-zero indirect. Likely contributors:
57
+ - Our **confidence mask discards** over-occluded contact texels (`coverage = 0`) and lets
58
+ dilation fill them — but dilation pulls from the *adjacent dark contact texels*, so the line
59
+ stays dark instead of getting a proper value.
60
+ - **No spatial anti-aliasing**: every sample for a texel originates from the *same* texel-center
61
+ point, so a texel half in shadow / half lit resolves to one hard value → a one-texel hard line
62
+ rather than a soft gradient.
63
+ - Bilinear reaching toward the chart silhouette / gutter at the contact.
64
+
65
+ ## Bakery techniques and how they map to us
66
+
67
+ | Bakery technique | Our adaptation |
68
+ |---|---|
69
+ | **Shadow-leak prevention**: trace 4+ **tangential** rays of length `0.5 × worldTexelSize`; if one hits a **backface**, *push* the sample out (`pos += rayDir·hitDist + faceNormal·bias`) | Replace our *discard-on-low-confidence* with **relocate**: keep the texel, move its sample to a valid spot. Directly targets artifact B. |
70
+ | **Supersampling**: 25 sub-texel UV taps | **Jitter the ray ORIGIN within the texel footprint** (surface tangent plane), not just the direction. Antialiases the contact line and silhouettes (artifact B). |
71
+ | **Seam fixing**: detect seam edge pairs (same pos+normal, different UV), draw lines blending both sides until they match (iterative, ping-pong) | CPU equivalent: pair `chart.boundary_edges` across charts by original vertex id, walk both sides in atlas space, average a few iterations. Targets artifact A.2. |
72
+ | **Dilation** (8-neighbour fill) | We have `lightmap_dilate`. Keep; fix ordering. |
73
+ | **Bicubic read-time filtering** ("0 reasons not to") | Optional three.js lightmap shader patch — hides low-res, softens lines. Bigger lift (custom material). |
74
+ | **Phong-tessellated smooth sample position** (shadow terminator on low-poly) | Defer — our content is either smooth-normalled (sphere) or genuinely flat (boxes). |
75
+ | Post order: bake-push → dilate → denoise → seam-fix | Adopt: currently denoise → dilate, no seam-fix. |
76
+
77
+ Note: the Bakery seam detection uses pos<ε, normal<ε, **uv>ε** — exactly the seam definition we
78
+ can derive from `vertex_of_local` + `chart.uv`.
79
+
80
+ ## Prioritized next steps
81
+
82
+ ### P0 — Carry original smooth normals (fixes sphere faceting, A.1)
83
+ - `lightmap_build_geometry.js`: take the source geometry's `normal` attribute; set each
84
+ chart-local vertex normal to `original_normal[chart.vertex_of_local[lv]]` instead of
85
+ recomputing. For a smooth mesh welding is a no-op, so this reproduces the original normals
86
+ exactly; for welded hard edges it's the representative's normal (fine — those are hard anyway).
87
+ Fall back to the current recompute when `vertex_of_local[lv] >= original_vertex_count`
88
+ (T-junction-added vertices) or the geometry has no normals.
89
+ - `bake_lightmap_for_scene.js`: pass `geometry.getAttribute('normal')?.array` (captured before
90
+ the geometry is swapped) into `lightmap_build_geometry`.
91
+ - Smallest change, biggest visible win on the sphere.
92
+
93
+ ### P0 — Sample-position PUSH instead of discard (fixes contact black line, B)
94
+ - New `lightmap_push_sample.js`: given world pos + normal + tangent basis + `texel_world_size`,
95
+ trace 4 tangential rays (length `0.5 × texel_world_size`); if any hits a backface, push the
96
+ origin out (`pos += rayDir·hitDist + hitFaceNormal·bias`); repeat until clear or a cap.
97
+ - `bake_lightmap_for_scene.js` `prepare()`: run the push when generating each job; store the
98
+ corrected position. Drop the confidence-discard path in `lightmap_gather` (keep a cheap
99
+ "still buried after push" → mark hole only as a last resort).
100
+ - Reuses `scene.trace` (already used by the confidence probe).
101
+
102
+ ### P1 — Supersampling: jitter the ray origin in the texel footprint (antialias B, general AA)
103
+ - `lightmap_gather.js`: build a tangent basis from the normal; offset each sample's origin by a
104
+ random sub-texel amount (`±0.5 × texel_world_size`) in the tangent plane (keep directions
105
+ independent per sample — no shared set). A contact texel then averages lit/shadowed
106
+ sub-positions → soft edge instead of a hard line.
107
+ - Pass `texel_world_size` (already available) + reuse `v3_orthonormal_matrix_from_normal`.
108
+
109
+ ### P1 — Graded adaptive sampling (your note: CPU isn't all-or-nothing)
110
+ - `bake_lightmap_for_scene.js`: replace the binary interpolate-vs-full fine path with a
111
+ **floor of samples** on "smooth" texels: take e.g. `max(samples/4, k)` rays and blend with the
112
+ bilinear prediction (or accept the samples if they deviate from the prediction beyond
113
+ `interpolation_threshold`). Keeps a real estimate everywhere — pure lerp can erase small
114
+ features — while still cutting cost on flats. `adaptive_step`/threshold stay the controls.
115
+
116
+ ### P1 — UV seam stitching (residual sphere value step, A.2)
117
+ - New `lightmap_seam_fix.js`: from each entry's charts, pair `boundary_edges` across charts by
118
+ `vertex_of_local` (same original edge, different `uv`); for each pair, walk both atlas-space
119
+ edges and average the texels over a few iterations (Bakery's line-blend, done on the CPU
120
+ buffer). Run after dilation.
121
+ - Most involved item; do it only if P0-normals + AA leave a visible step.
122
+
123
+ ### P2 — Bicubic lightmap sampling at read time (optional, global softening)
124
+ - Patch the forward-plus lightmap sampling to 4-tap bicubic (`vUv2`). Hides low resolution and
125
+ softens any remaining jagged lines. Larger change (touches the material/shader); evaluate after
126
+ the above.
127
+
128
+ ### Post-process order to converge on
129
+ `bake (with push + supersample)` → `variance denoise` → `dilate` → `seam-fix`.
130
+
131
+ ## Verification
132
+ - Sphere: after P0-normals, no facet creases across chart boundaries; after seam-fix, no value
133
+ step. Add a spec asserting `lightmap_build_geometry` reproduces input normals for a smooth mesh
134
+ (sphere) within tolerance.
135
+ - Contact: after push + supersample, the box/floor contact is a soft darkening, not a black line.
136
+ Add a gather/push spec: a texel wedged at a contact gets relocated to a non-buried position
137
+ (its post-push confidence is high) and bakes > 0.
138
+ - Keep the existing 18 specs green; re-run the webpack build.
139
+
140
+ ## Effort / impact summary
141
+ 1. P0 original normals — small, high impact (sphere). **Do first.**
142
+ 2. P0 sample push — medium, high impact (contact). **Do first.**
143
+ 3. P1 supersample — small/medium, high impact (contact softness + AA).
144
+ 4. P1 graded adaptive — small, quality/robustness.
145
+ 5. P1 seam stitching — larger, medium impact (only if needed after 1).
146
+ 6. P2 bicubic — larger, polish.