@woosh/meep-engine 2.109.1 → 2.109.2

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 (258) hide show
  1. package/build/meep.cjs +122 -186
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +122 -186
  4. package/package.json +1 -1
  5. package/src/core/binary/ctz32.d.ts.map +1 -1
  6. package/src/core/binary/ctz32.js +12 -11
  7. package/src/core/binary/reinterpret_int32_as_float32.d.ts +7 -0
  8. package/src/core/binary/reinterpret_int32_as_float32.d.ts.map +1 -0
  9. package/src/core/binary/reinterpret_int32_as_float32.js +14 -0
  10. package/src/core/binary/reverse_bits_uint32.d.ts +8 -0
  11. package/src/core/binary/reverse_bits_uint32.d.ts.map +1 -0
  12. package/src/core/binary/reverse_bits_uint32.js +17 -0
  13. package/src/core/binary/reverse_bits_uint32.spec.d.ts +2 -0
  14. package/src/core/binary/reverse_bits_uint32.spec.d.ts.map +1 -0
  15. package/src/core/binary/reverse_bits_uint32.spec.js +18 -0
  16. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  17. package/src/core/bvh2/bvh3/BVH.js +13 -18
  18. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.d.ts.map +1 -1
  19. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +3 -1
  20. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  21. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +6 -7
  22. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
  23. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +4 -0
  24. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts +16 -0
  25. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts.map +1 -0
  26. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.js +130 -0
  27. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts +2 -0
  28. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts.map +1 -0
  29. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.js +1 -0
  30. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts +9 -0
  31. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts.map +1 -0
  32. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.js +31 -0
  33. package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts +9 -0
  34. package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts.map +1 -0
  35. package/src/core/collection/array/array_quick_sort_by_lookup_map.js +79 -0
  36. package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts +8 -0
  37. package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts.map +1 -0
  38. package/src/core/collection/array/{array_quick_sort_by_lookup.js → array_quick_sort_by_lookup_uint.js} +1 -1
  39. package/src/core/collection/array/array_shuffle.js +1 -1
  40. package/src/core/collection/array/array_swap_one.d.ts.map +1 -1
  41. package/src/core/collection/array/array_swap_one.js +6 -0
  42. package/src/core/events/signal/Signal.d.ts.map +1 -1
  43. package/src/core/events/signal/Signal.js +10 -10
  44. package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
  45. package/src/core/geom/2d/compute_triangle_area_2d.js +5 -3
  46. package/src/core/geom/3d/Ray3.d.ts +6 -0
  47. package/src/core/geom/3d/Ray3.d.ts.map +1 -1
  48. package/src/core/geom/3d/Ray3.js +24 -0
  49. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts +16 -0
  50. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts.map +1 -0
  51. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js +29 -0
  52. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts +2 -2
  53. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts.map +1 -1
  54. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js +6 -6
  55. package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.d.ts +11 -0
  56. package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.d.ts.map +1 -0
  57. package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.js +61 -0
  58. package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts +2 -2
  59. package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts.map +1 -1
  60. package/src/core/geom/3d/eulerAnglesFromMatrix.js +28 -25
  61. package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts +2 -2
  62. package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts.map +1 -1
  63. package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +1 -1
  64. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +2 -2
  65. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
  66. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +1 -1
  67. package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.js +2 -2
  68. package/src/core/geom/3d/sphere/sphere_intersects_ray.js +1 -1
  69. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -1
  70. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js +24 -188
  71. package/src/core/geom/3d/tetrahedra/triangle/prototype.js +1 -1
  72. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts +11 -0
  73. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts.map +1 -0
  74. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.js +42 -0
  75. package/src/core/geom/3d/topology/samples/sampleFloodFill.js +2 -2
  76. package/src/core/geom/3d/topology/tm_face_area.js +2 -2
  77. package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.d.ts → compute_triangle_area_3d.d.ts} +2 -2
  78. package/src/core/geom/3d/triangle/compute_triangle_area_3d.d.ts.map +1 -0
  79. package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.js → compute_triangle_area_3d.js} +2 -4
  80. package/src/core/geom/Quaternion.d.ts.map +1 -1
  81. package/src/core/geom/Quaternion.js +13 -102
  82. package/src/core/geom/Quaternion.spec.js +2 -2
  83. package/src/core/geom/Vector1.d.ts.map +1 -1
  84. package/src/core/geom/Vector1.js +14 -6
  85. package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts +14 -0
  86. package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts.map +1 -0
  87. package/src/core/geom/vec3/{v3_shift_along_direction.js → v3_array_displace_in_direction.js} +1 -1
  88. package/src/core/geom/vec3/v3_displace_in_direction.d.ts +7 -7
  89. package/src/core/geom/vec3/v3_displace_in_direction.d.ts.map +1 -1
  90. package/src/core/geom/vec3/v3_displace_in_direction.js +20 -17
  91. package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts +2 -0
  92. package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts.map +1 -0
  93. package/src/core/geom/vec3/v3_displace_in_direction.spec.js +80 -0
  94. package/src/core/geom/vec4/v4_length.d.ts +10 -0
  95. package/src/core/geom/vec4/v4_length.d.ts.map +1 -0
  96. package/src/core/geom/vec4/v4_length.js +13 -0
  97. package/src/core/geom/vec4/v4_length_sqr.js +2 -1
  98. package/src/core/graph/eigen/matrix_eigenvalues_in_place.spec.js +31 -1
  99. package/src/core/math/FLT_EPSILON_64.d.ts +6 -0
  100. package/src/core/math/FLT_EPSILON_64.d.ts.map +1 -0
  101. package/src/core/math/FLT_EPSILON_64.js +5 -0
  102. package/src/core/math/gaussian.d.ts +2 -2
  103. package/src/core/math/gaussian.js +2 -2
  104. package/src/core/math/linalg/README.md +1 -0
  105. package/src/core/math/linalg/lu_factor_linear_system.d.ts +13 -0
  106. package/src/core/math/linalg/lu_factor_linear_system.d.ts.map +1 -0
  107. package/src/core/math/linalg/lu_factor_linear_system.js +112 -0
  108. package/src/core/math/linalg/lu_solve_linear_system.d.ts +14 -0
  109. package/src/core/math/linalg/lu_solve_linear_system.d.ts.map +1 -0
  110. package/src/core/math/linalg/lu_solve_linear_system.js +51 -0
  111. package/src/core/math/linalg/solve_linear_system.d.ts +14 -0
  112. package/src/core/math/linalg/solve_linear_system.d.ts.map +1 -0
  113. package/src/core/math/linalg/solve_linear_system.js +52 -0
  114. package/src/core/math/linalg/solve_linear_system.spec.d.ts +2 -0
  115. package/src/core/math/linalg/solve_linear_system.spec.d.ts.map +1 -0
  116. package/src/core/math/linalg/solve_linear_system.spec.js +70 -0
  117. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +10 -0
  118. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts.map +1 -0
  119. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +91 -0
  120. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  121. package/src/core/math/solveQuadratic.js +2 -0
  122. package/src/core/math/statistics/gaussian_amplitude.d.ts +8 -0
  123. package/src/core/math/statistics/gaussian_amplitude.d.ts.map +1 -0
  124. package/src/core/math/statistics/gaussian_amplitude.js +13 -0
  125. package/src/core/math/statistics/halton_sequence.js +3 -3
  126. package/src/core/math/statistics/halton_sequence.spec.js +18 -0
  127. package/src/core/math/statistics/hammersley_sequence.d.ts +9 -0
  128. package/src/core/math/statistics/hammersley_sequence.d.ts.map +1 -0
  129. package/src/core/math/statistics/hammersley_sequence.js +25 -0
  130. package/src/core/math/statistics/hammersley_sequence_2d.d.ts +9 -0
  131. package/src/core/math/statistics/hammersley_sequence_2d.d.ts.map +1 -0
  132. package/src/core/math/statistics/hammersley_sequence_2d.js +17 -0
  133. package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts +8 -0
  134. package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts.map +1 -0
  135. package/src/core/math/statistics/radical_inverse_VdC_base_2.js +15 -0
  136. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts +2 -0
  137. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts.map +1 -0
  138. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.js +9 -0
  139. package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
  140. package/src/core/model/node-graph/node/NodeInstance.js +26 -12
  141. package/src/core/model/node-graph/node/NodeInstance.spec.d.ts +2 -0
  142. package/src/core/model/node-graph/node/NodeInstance.spec.d.ts.map +1 -0
  143. package/src/core/model/node-graph/node/NodeInstance.spec.js +82 -0
  144. package/src/core/model/node-graph/node/NodeInstancePortReference.d.ts.map +1 -1
  145. package/src/core/model/node-graph/node/NodeInstancePortReference.js +9 -0
  146. package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +20 -0
  147. package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
  148. package/src/core/model/node-graph/node/Port.js +5 -12
  149. package/src/core/model/node-graph/node/PortDirection.d.ts.map +1 -1
  150. package/src/core/model/node-graph/node/PortDirection.js +7 -1
  151. package/src/engine/asset/CORS/CrossOriginConfig.d.ts.map +1 -1
  152. package/src/engine/asset/CORS/CrossOriginConfig.js +6 -4
  153. package/src/engine/graphics/geometry/computeMeshSurfaceArea.js +2 -2
  154. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.d.ts.map +1 -1
  155. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +33 -3
  156. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +9 -7
  157. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts +6 -0
  158. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts.map +1 -0
  159. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.js +18 -0
  160. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts +6 -0
  161. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts.map +1 -0
  162. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.js +266 -0
  163. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts +7 -0
  164. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts.map +1 -0
  165. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.js +19 -0
  166. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -9
  167. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  168. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +0 -2
  169. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +4 -27
  170. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  171. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +36 -158
  172. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts +13 -0
  173. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -0
  174. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +63 -0
  175. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +1 -0
  176. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  177. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +25 -1
  178. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  179. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +4 -29
  180. package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.d.ts → serialization/LightProbeVolumeSerializationAdapter.d.ts} +2 -2
  181. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
  182. package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.js → serialization/LightProbeVolumeSerializationAdapter.js} +2 -2
  183. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts +13 -0
  184. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +1 -0
  185. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.js +71 -0
  186. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts +2 -0
  187. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts.map +1 -0
  188. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.js +38 -0
  189. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +1 -7
  190. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  191. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +58 -147
  192. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts +13 -9
  193. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
  194. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +74 -54
  195. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +23 -5
  196. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  197. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +211 -59
  198. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  199. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts +15 -0
  200. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  201. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.js +46 -0
  202. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts +14 -0
  203. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  204. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.js +43 -0
  205. package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.d.ts.map +1 -0
  206. package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.js → geometry/compute_triangle_group_aabb3.js} +2 -2
  207. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts +12 -0
  208. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts.map +1 -0
  209. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.js +72 -0
  210. package/src/engine/graphics/sh3/path_tracer/geometry/sample_triangle_attribute.d.ts.map +1 -0
  211. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts +13 -0
  212. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts.map +1 -0
  213. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.js +48 -0
  214. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts +1 -0
  215. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts.map +1 -1
  216. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.js +4 -0
  217. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts +1 -0
  218. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts.map +1 -1
  219. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.js +8 -5
  220. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +24 -18
  221. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts +2 -2
  222. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts.map +1 -1
  223. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +1 -1
  224. package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.d.ts.map +1 -0
  225. package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.js → sampling/getBiasedNormalSample.js} +1 -1
  226. package/src/engine/graphics/sh3/path_tracer/sampling/random_in_hemisphere.d.ts.map +1 -0
  227. package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.js → sampling/random_in_hemisphere.js} +1 -1
  228. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts +12 -0
  229. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  230. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.js +46 -0
  231. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +2 -2
  232. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts +7 -0
  233. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts.map +1 -0
  234. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.js +69 -0
  235. package/src/engine/graphics/sh3/prototypeSH3Probe.js +29 -7
  236. package/src/engine/graphics/texture/formatToChannelCount.d.ts.map +1 -1
  237. package/src/engine/graphics/texture/formatToChannelCount.js +14 -1
  238. package/src/engine/graphics/three/three_object_replace_materials.d.ts +7 -0
  239. package/src/engine/graphics/three/three_object_replace_materials.d.ts.map +1 -0
  240. package/src/engine/graphics/three/three_object_replace_materials.js +13 -0
  241. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +0 -8
  242. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +0 -1
  243. package/src/core/geom/3d/triangle/computeTriangleSurfaceArea.d.ts.map +0 -1
  244. package/src/core/geom/vec3/v3_shift_along_direction.d.ts +0 -14
  245. package/src/core/geom/vec3/v3_shift_along_direction.d.ts.map +0 -1
  246. package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts +0 -2
  247. package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts.map +0 -1
  248. package/src/engine/graphics/filter/FlipArrayViaCanvas.js +0 -13
  249. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +0 -1
  250. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +0 -1
  251. package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts.map +0 -1
  252. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +0 -1
  253. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +0 -1
  254. /package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.d.ts → geometry/compute_triangle_group_aabb3.d.ts} +0 -0
  255. /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.d.ts → geometry/sample_triangle_attribute.d.ts} +0 -0
  256. /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.js → geometry/sample_triangle_attribute.js} +0 -0
  257. /package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.d.ts → sampling/getBiasedNormalSample.d.ts} +0 -0
  258. /package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.d.ts → sampling/random_in_hemisphere.d.ts} +0 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Distance of the nearest point along the plane normal from the plane
3
+ * @param {number} plane_normal_x
4
+ * @param {number} plane_normal_y
5
+ * @param {number} plane_normal_z
6
+ * @param {number} plane_constant
7
+ * @param {number} _x0
8
+ * @param {number} _y0
9
+ * @param {number} _z0
10
+ * @param {number} _x1
11
+ * @param {number} _y1
12
+ * @param {number} _z1
13
+ * @returns {number}
14
+ */
15
+ export function aabb3_compute_distance_above_plane_min(plane_normal_x: number, plane_normal_y: number, plane_normal_z: number, plane_constant: number, _x0: number, _y0: number, _z0: number, _x1: number, _y1: number, _z1: number): number;
16
+ //# sourceMappingURL=aabb3_compute_distance_above_plane_min.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb3_compute_distance_above_plane_min.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,uEAZW,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,GACJ,MAAM,CAelB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Distance of the nearest point along the plane normal from the plane
3
+ * @param {number} plane_normal_x
4
+ * @param {number} plane_normal_y
5
+ * @param {number} plane_normal_z
6
+ * @param {number} plane_constant
7
+ * @param {number} _x0
8
+ * @param {number} _y0
9
+ * @param {number} _z0
10
+ * @param {number} _x1
11
+ * @param {number} _y1
12
+ * @param {number} _z1
13
+ * @returns {number}
14
+ */
15
+ export function aabb3_compute_distance_above_plane_min(
16
+ plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
17
+ _x0, _y0, _z0,
18
+ _x1, _y1, _z1
19
+ ) {
20
+
21
+ // pick a corner point that is the closest along the plane normal
22
+ const px = plane_normal_x > 0 ? _x0 : _x1;
23
+ const py = plane_normal_y > 0 ? _y0 : _y1;
24
+ const pz = plane_normal_z > 0 ? _z0 : _z1;
25
+
26
+ // dot(v4,v4) inlined for speed
27
+ return plane_constant + plane_normal_x * px + plane_normal_y * py + plane_normal_z * pz;
28
+ }
29
+
@@ -3,7 +3,7 @@
3
3
  * @param {AABB3} result
4
4
  * @param {number[]|ArrayLike<number>} input
5
5
  * @param {number} input_length
6
- * @param {ArrayLike<number>|number[]|Float32Array} e 4x4 transformation matrix
6
+ * @param {ArrayLike<number>|number[]|Float32Array} matrix 4x4 transformation matrix
7
7
  */
8
- export function aabb3_from_v3_array_transformed(result: AABB3, input: number[] | ArrayLike<number>, input_length: number, e: ArrayLike<number> | number[] | Float32Array): void;
8
+ export function aabb3_from_v3_array_transformed(result: AABB3, input: number[] | ArrayLike<number>, input_length: number, matrix: ArrayLike<number> | number[] | Float32Array): void;
9
9
  //# sourceMappingURL=aabb3_from_v3_array_transformed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aabb3_from_v3_array_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,sEAJW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,KACN,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QA8BjD"}
1
+ {"version":3,"file":"aabb3_from_v3_array_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,sEAJW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,UACN,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QA8BjD"}
@@ -1,14 +1,14 @@
1
- import { min2 } from "../../../math/min2.js";
2
1
  import { max2 } from "../../../math/max2.js";
2
+ import { min2 } from "../../../math/min2.js";
3
3
 
4
4
  /**
5
5
  *
6
6
  * @param {AABB3} result
7
7
  * @param {number[]|ArrayLike<number>} input
8
8
  * @param {number} input_length
9
- * @param {ArrayLike<number>|number[]|Float32Array} e 4x4 transformation matrix
9
+ * @param {ArrayLike<number>|number[]|Float32Array} matrix 4x4 transformation matrix
10
10
  */
11
- export function aabb3_from_v3_array_transformed(result, input, input_length, e) {
11
+ export function aabb3_from_v3_array_transformed(result, input, input_length, matrix) {
12
12
  let x0 = Infinity;
13
13
  let y0 = Infinity;
14
14
  let z0 = Infinity;
@@ -22,9 +22,9 @@ export function aabb3_from_v3_array_transformed(result, input, input_length, e)
22
22
  const y = input[i + 1];
23
23
  const z = input[i + 2];
24
24
 
25
- const _x = e[0] * x + e[4] * y + e[8] * z + e[12];
26
- const _y = e[1] * x + e[5] * y + e[9] * z + e[13];
27
- const _z = e[2] * x + e[6] * y + e[10] * z + e[14];
25
+ const _x = matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12];
26
+ const _y = matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13];
27
+ const _z = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
28
28
 
29
29
  x0 = min2(_x, x0);
30
30
  y0 = min2(_y, y0);
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @param {number[]} aabb
4
+ * @param {number} aabb_offset
5
+ * @param {number[]} ray
6
+ * @param {number} min_distance
7
+ * @param {number} max_distance
8
+ * @returns {boolean}
9
+ */
10
+ export function aabb3_overlaps_ray_segment(aabb: number[], aabb_offset: number, ray: number[], min_distance: number, max_distance: number): boolean;
11
+ //# sourceMappingURL=aabb3_overlaps_ray_segment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb3_overlaps_ray_segment.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,iDAPW,MAAM,EAAE,eACR,MAAM,OACN,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACJ,OAAO,CAmDnB"}
@@ -0,0 +1,61 @@
1
+ import { v3_dot } from "../../vec3/v3_dot.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number[]} aabb
6
+ * @param {number} aabb_offset
7
+ * @param {number[]} ray
8
+ * @param {number} min_distance
9
+ * @param {number} max_distance
10
+ * @returns {boolean}
11
+ */
12
+ export function aabb3_overlaps_ray_segment(
13
+ aabb, aabb_offset, ray,
14
+ min_distance, max_distance
15
+ ) {
16
+
17
+ const dir_x = ray[3];
18
+ const dir_y = ray[4];
19
+ const dir_z = ray[5];
20
+
21
+ const plane_offset = v3_dot(
22
+ ray[0], ray[1], ray[2],
23
+ dir_x, dir_y, dir_z
24
+ );
25
+
26
+ let x0, y0, z0, x1, y1, z1;
27
+
28
+ if (dir_x > 0) {
29
+ x0 = aabb[0];
30
+ x1 = aabb[3];
31
+ } else {
32
+ x1 = aabb[0];
33
+ x0 = aabb[3];
34
+ }
35
+
36
+ if (dir_y > 0) {
37
+ y0 = aabb[1];
38
+ y1 = aabb[4];
39
+ } else {
40
+ y1 = aabb[1];
41
+ y0 = aabb[4];
42
+ }
43
+
44
+ if (dir_z > 0) {
45
+ z0 = aabb[2];
46
+ z1 = aabb[5];
47
+ } else {
48
+ z1 = aabb[2];
49
+ z0 = aabb[5];
50
+ }
51
+
52
+ const min = plane_offset + dir_x * x0 + dir_y * y0 + dir_z * z0;
53
+
54
+ if (min >= max_distance) {
55
+ return false;
56
+ }
57
+
58
+ const max = plane_offset + dir_x * x1 + dir_y * y1 + dir_z * z1;
59
+
60
+ return max > min_distance;
61
+ }
@@ -21,8 +21,8 @@
21
21
  * @param {number[]} res
22
22
  * @param {number[]|Float32Array|mat4} m4
23
23
  * @param {number} a0 axis index
24
- * @param {number} a1
25
- * @param {number} a2
24
+ * @param {number} a1 axis index
25
+ * @param {number} a2 axis index
26
26
  */
27
27
  export function eulerAnglesFromMatrix(res: number[], m4: number[] | Float32Array | mat4, a0: number, a1: number, a2: number): void;
28
28
  //# sourceMappingURL=eulerAnglesFromMatrix.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eulerAnglesFromMatrix.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/eulerAnglesFromMatrix.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,2CANW,MAAM,EAAE,MACR,MAAM,EAAE,GAAC,YAAY,OAAK,MAC1B,MAAM,MACN,MAAM,MACN,MAAM,QA6DhB"}
1
+ {"version":3,"file":"eulerAnglesFromMatrix.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/eulerAnglesFromMatrix.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,2CANW,MAAM,EAAE,MACR,MAAM,EAAE,GAAC,YAAY,OAAK,MAC1B,MAAM,MACN,MAAM,MACN,MAAM,QA2EhB"}
@@ -1,10 +1,5 @@
1
- //
2
-
3
1
  import { v2_magnitude } from "../vec2/v2_magnitude.js";
4
2
 
5
- function atan2(a, b) {
6
- return Math.atan2(a, b);
7
- }
8
3
 
9
4
  /**
10
5
  *
@@ -17,15 +12,9 @@ function coeff(mat4, row_index, column_index) {
17
12
  return mat4[row_index + column_index * 4];
18
13
  }
19
14
 
20
- function sin(a) {
21
- return Math.sin(a);
22
- }
23
-
24
- function cos(a) {
25
- return Math.cos(a);
26
- }
27
-
28
- const EIGEN_PI = Math.PI;
15
+ const sin = Math.sin;
16
+ const cos = Math.cos;
17
+ const atan2 = Math.atan2;
29
18
 
30
19
  /**
31
20
  *
@@ -50,10 +39,14 @@ const EIGEN_PI = Math.PI;
50
39
  * @param {number[]} res
51
40
  * @param {number[]|Float32Array|mat4} m4
52
41
  * @param {number} a0 axis index
53
- * @param {number} a1
54
- * @param {number} a2
42
+ * @param {number} a1 axis index
43
+ * @param {number} a2 axis index
55
44
  */
56
- export function eulerAnglesFromMatrix(res, m4, a0, a1, a2) {
45
+ export function eulerAnglesFromMatrix(
46
+ res, m4,
47
+ a0, a1, a2
48
+ ) {
49
+
57
50
  const odd = ((a0 + 1) % 3 === a1) ? 0 : 1;
58
51
 
59
52
  const i = a0;
@@ -62,11 +55,12 @@ export function eulerAnglesFromMatrix(res, m4, a0, a1, a2) {
62
55
 
63
56
  if (a0 === a2) {
64
57
  res[0] = atan2(coeff(m4, j, i), coeff(m4, k, i));
65
- if ((odd && res[0] < 0) || ((!odd) && res[0] > 0)) {
58
+
59
+ if ((odd && res[0] < 0) || ((~odd) && res[0] > 0)) {
66
60
  if (res[0] > 0) {
67
- res[0] -= EIGEN_PI;
61
+ res[0] -= Math.PI;
68
62
  } else {
69
- res[0] += EIGEN_PI;
63
+ res[0] += Math.PI;
70
64
  }
71
65
  const s2 = v2_magnitude(coeff(m4, j, i), coeff(m4, k, i));
72
66
  res[1] = -atan2(s2, coeff(m4, i, i));
@@ -87,25 +81,34 @@ export function eulerAnglesFromMatrix(res, m4, a0, a1, a2) {
87
81
 
88
82
  const s1 = sin(res[0]);
89
83
  const c1 = cos(res[0]);
84
+
90
85
  res[2] = atan2(c1 * coeff(m4, j, k) - s1 * coeff(m4, k, k), c1 * coeff(m4, j, j) - s1 * coeff(m4, k, j));
86
+
91
87
  } else {
88
+
92
89
  res[0] = atan2(coeff(m4, j, k), coeff(m4, k, k));
90
+
93
91
  const c2 = v2_magnitude(coeff(m4, i, i), coeff(m4, i, j));
94
- if ((odd && res[0] < 0) || ((!odd) && res[0] > 0)) {
92
+
93
+ if ((odd && res[0] < 0) || ((~odd) && res[0] > 0)) {
95
94
  if (res[0] > 0) {
96
- res[0] -= EIGEN_PI;
95
+ res[0] -= Math.PI;
97
96
  } else {
98
- res[0] += EIGEN_PI;
97
+ res[0] += Math.PI;
99
98
  }
100
99
  res[1] = atan2(-coeff(m4, i, k), -c2);
101
- } else
100
+ } else {
102
101
  res[1] = atan2(-coeff(m4, i, k), c2);
102
+ }
103
+
103
104
  const s1 = sin(res[0]);
104
105
  const c1 = cos(res[0]);
106
+
105
107
  res[2] = atan2(s1 * coeff(m4, k, i) - c1 * coeff(m4, j, i), c1 * coeff(m4, j, j) - s1 * coeff(m4, k, j));
108
+
106
109
  }
107
110
 
108
- if (!odd) {
111
+ if (odd === 0) {
109
112
  // invert result
110
113
  res[0] = -res[0];
111
114
  res[1] = -res[1];
@@ -2,8 +2,8 @@
2
2
  * @param {number} x
3
3
  * @param {number} y
4
4
  * @param {number} z
5
- * @param {number[]} bounds
5
+ * @param {number[]|AABB3} bounds
6
6
  * @returns {number}
7
7
  */
8
- export function v3_morton_encode_bounded(x: number, y: number, z: number, bounds: number[]): number;
8
+ export function v3_morton_encode_bounded(x: number, y: number, z: number, bounds: number[] | AABB3): number;
9
9
  //# sourceMappingURL=v3_morton_encode_bounded.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v3_morton_encode_bounded.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_bounded.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GACN,MAAM,CA0BlB"}
1
+ {"version":3,"file":"v3_morton_encode_bounded.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_bounded.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,QAAM,GACZ,MAAM,CA0BlB"}
@@ -4,7 +4,7 @@ import { mortonEncode_magicbits } from "./mortonEncode_magicbits.js";
4
4
  * @param {number} x
5
5
  * @param {number} y
6
6
  * @param {number} z
7
- * @param {number[]} bounds
7
+ * @param {number[]|AABB3} bounds
8
8
  * @returns {number}
9
9
  */
10
10
  export function v3_morton_encode_bounded(x, y, z, bounds) {
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @see A Survey of Efficient Representations for Independent Unit Vectors (Journal of Computer Graphics Techniques Vol. 3, No. 2, 2014) - page 13
3
3
  * @see https://gamedev.stackexchange.com/questions/169508/octahedral-impostors-octahedral-mapping
4
- * @param {number[]} output
4
+ * @param {number[]|Vector3} output
5
5
  * @param {number} output_offset
6
6
  * @param {number} x range [0,1]
7
7
  * @param {number} y range [0,1]
8
8
  */
9
- export function decode_octahedron_to_unit(output: number[], output_offset: number, x: number, y: number): void;
9
+ export function decode_octahedron_to_unit(output: number[] | Vector3, output_offset: number, x: number, y: number): void;
10
10
  //# sourceMappingURL=decode_octahedron_to_unit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,kDALW,MAAM,EAAE,iBACR,MAAM,KACN,MAAM,KACN,MAAM,QAsBhB"}
1
+ {"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,kDALW,MAAM,EAAE,UAAQ,iBAChB,MAAM,KACN,MAAM,KACN,MAAM,QAsBhB"}
@@ -3,7 +3,7 @@ import { sign_not_zero } from "../../../../math/sign_not_zero.js";
3
3
  /**
4
4
  * @see A Survey of Efficient Representations for Independent Unit Vectors (Journal of Computer Graphics Techniques Vol. 3, No. 2, 2014) - page 13
5
5
  * @see https://gamedev.stackexchange.com/questions/169508/octahedral-impostors-octahedral-mapping
6
- * @param {number[]} output
6
+ * @param {number[]|Vector3} output
7
7
  * @param {number} output_offset
8
8
  * @param {number} x range [0,1]
9
9
  * @param {number} y range [0,1]
@@ -1,4 +1,4 @@
1
- import { v3_shift_along_direction } from "../../vec3/v3_shift_along_direction.js";
1
+ import { v3_array_displace_in_direction } from "../../vec3/v3_array_displace_in_direction.js";
2
2
 
3
3
  /**
4
4
  *
@@ -21,7 +21,7 @@ export function ray3_shift_origin_along_direction(
21
21
  const direction_y = input[input_offset + 4];
22
22
  const direction_z = input[input_offset + 5];
23
23
 
24
- v3_shift_along_direction(
24
+ v3_array_displace_in_direction(
25
25
  output, 0,
26
26
  origin_x, origin_y, origin_z,
27
27
  direction_x, direction_y, direction_z,
@@ -48,4 +48,4 @@ export function sphere_intersects_ray(
48
48
  }
49
49
 
50
50
  return true;
51
- }
51
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"tetrahedron_compute_circumsphere.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,yDAPW,MAAM,EAAE,UACR,MAAM,EAAE,KACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QA+EhB"}
1
+ {"version":3,"file":"tetrahedron_compute_circumsphere.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,yDAPW,MAAM,EAAE,UACR,MAAM,EAAE,KACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QA2EhB"}
@@ -1,9 +1,20 @@
1
1
  import { array_copy } from "../../../collection/array/array_copy.js";
2
+ import { solve_linear_system } from "../../../math/linalg/solve_linear_system.js";
2
3
  import { v3_dot } from "../../vec3/v3_dot.js";
3
4
 
4
5
  const MAX_FLOAT32 = 3.4028234663852886e+38;
5
- const SMALL_NUMBER = 1e-12;
6
- const VTK_MAX_WARNS = 3;
6
+
7
+ const n12 = new Float64Array(3);
8
+ const n13 = new Float64Array(3);
9
+ const n14 = new Float64Array(3);
10
+
11
+ const x12 = new Float64Array(3);
12
+ const x13 = new Float64Array(3);
13
+ const x14 = new Float64Array(3);
14
+
15
+ const A = new Float64Array(9);
16
+
17
+ const rhs = new Float64Array(3);
7
18
 
8
19
  /**
9
20
  * Compute the circumcenter (center[3]) and radius squared (method return value) of a tetrahedron defined by the four points x1, x2, x3, and x4.
@@ -21,23 +32,16 @@ export function tetrahedron_compute_circumsphere(
21
32
  points,
22
33
  a, b, c, d
23
34
  ) {
24
- const n12 = [];
25
- const n13 = [];
26
- const n14 = [];
27
35
 
28
- const x12 = [];
29
- const x13 = [];
30
- const x14 = [];
31
-
32
- // calculate normals and intersection points of bisecting planes.
36
+ // calculate normals and intersection points of bisecting planes.
33
37
  for (let i = 0; i < 3; i++) {
34
38
  const v_a = points[a * 3 + i];
35
-
36
39
  const v_b = points[b * 3 + i];
37
- n12[i] = v_b - v_a;
38
40
  const v_c = points[c * 3 + i];
39
- n13[i] = v_c - v_a;
40
41
  const v_d = points[d * 3 + i];
42
+
43
+ n12[i] = v_b - v_a;
44
+ n13[i] = v_c - v_a;
41
45
  n14[i] = v_d - v_a;
42
46
 
43
47
  x12[i] = (v_b + v_a) * 0.5;
@@ -45,28 +49,28 @@ export function tetrahedron_compute_circumsphere(
45
49
  x14[i] = (v_d + v_a) * 0.5;
46
50
  }
47
51
 
48
- const A = [];
49
-
50
52
  array_copy(n12, 0, A, 0, 3);
51
53
  array_copy(n13, 0, A, 3, 3);
52
54
  array_copy(n14, 0, A, 6, 3);
53
55
 
54
- const rhs = [];
55
-
56
56
  rhs[0] = v3_dot(n12[0], n12[1], n12[2], x12[0], x12[1], x12[2]);
57
57
  rhs[1] = v3_dot(n13[0], n13[1], n13[2], x13[0], x13[1], x13[2]);
58
58
  rhs[2] = v3_dot(n14[0], n14[1], n14[2], x14[0], x14[1], x14[2]);
59
59
 
60
60
  // Solve system of equations
61
61
  if (solve_linear_system(A, rhs, 3) === false) {
62
+
62
63
  // failed to solve, fall-back to infinitely-sized sphere centered around origin
63
64
  result[0] = result[1] = result[2] = 0;
64
65
  result[3] = MAX_FLOAT32;
65
66
  return;
67
+
66
68
  } else {
69
+
67
70
  result[0] = rhs[0];
68
71
  result[1] = rhs[1];
69
72
  result[2] = rhs[2];
73
+
70
74
  }
71
75
 
72
76
  let sum = 0;
@@ -77,10 +81,13 @@ export function tetrahedron_compute_circumsphere(
77
81
 
78
82
  diff = points[a * 3 + i] - rhs_offset;
79
83
  sum += diff * diff;
84
+
80
85
  diff = points[b * 3 + i] - rhs_offset;
81
86
  sum += diff * diff;
87
+
82
88
  diff = points[c * 3 + i] - rhs_offset;
83
89
  sum += diff * diff;
90
+
84
91
  diff = points[d * 3 + i] - rhs_offset;
85
92
  sum += diff * diff;
86
93
  }
@@ -95,175 +102,4 @@ export function tetrahedron_compute_circumsphere(
95
102
  }
96
103
  }
97
104
 
98
- /**
99
- * Solve linear equations Ax = b using Crout's method. Input is square matrix A
100
- * and load vector b. Solution x is written over load vector. The dimension of
101
- * the matrix is specified in size. If error is found, method returns a 0.
102
- *
103
- * @see https://github.com/Kitware/VTK/blob/af928016f4041ad8a6a193d032355b909721fc95/Common/Core/vtkMath.cxx
104
- *
105
- * @param {number[]} A
106
- * @param {number[]} x
107
- * @param {number} size
108
- * @returns {boolean}
109
- */
110
- function solve_linear_system(A, x, size) {
111
- const index = [];
112
-
113
- if (luf_factor_linear_system(A, index, size) === 0) {
114
- return false;
115
- }
116
-
117
- luf_solve_linear_system(A, index, x, size);
118
-
119
- return true;
120
- }
121
-
122
-
123
- /**
124
- * Factor linear equations Ax = b using LU decomposition A = LU where L is
125
- * lower triangular matrix and U is upper triangular matrix. Input is
126
- * square matrix A, integer array of pivot indices index[0->n-1], and size
127
- * of square matrix n. Output factorization LU is in matrix A. If error is
128
- * found, method returns 0.
129
- * @param {number[]} A
130
- * @param {number[]} index
131
- * @param {number} size
132
- */
133
- function luf_factor_linear_system(A, index, size) {
134
- const scale = [];
135
-
136
- // double scratch[10];
137
- // double* scale = (size < 10 ? scratch : new double[size]);
138
- //
139
- // int i, j, k;
140
- // int maxI = 0;
141
- // double largest, temp1, temp2, sum;
142
- //
143
- // // Manage number of output warnings
144
- // static int numWarns = 0;
145
- //
146
- // //
147
-
148
- let numWarns = 0;
149
- let i, j, k;
150
- let maxI = 0;
151
- let largest, temp1, temp2, sum;
152
- // Loop over rows to get implicit scaling information
153
- //
154
- for (i = 0; i < size; ++i) {
155
- for (largest = 0.0, j = 0; j < size; ++j) {
156
- if ((temp2 = Math.abs(A[i * size + j])) > largest) {
157
- largest = temp2;
158
- }
159
- }
160
-
161
- if (largest === 0.0 && numWarns++ < VTK_MAX_WARNS) {
162
- // vtkGenericWarningMacro(<< "Unable to factor linear system");
163
- return 0;
164
- }
165
- scale[i] = 1.0 / largest;
166
- }
167
- //
168
- // Loop over all columns using Crout's method
169
- //
170
- for (j = 0; j < size; ++j) {
171
- for (i = 0; i < j; ++i) {
172
- sum = A[i * size + j];
173
- for (k = 0; k < i; ++k) {
174
- sum -= A[i * size + k] * A[k * size + j];
175
- }
176
- A[i * size + j] = sum;
177
- }
178
- //
179
- // Begin search for largest pivot element
180
- //
181
- for (largest = 0.0, i = j; i < size; ++i) {
182
- sum = A[i * size + j];
183
- for (k = 0; k < j; ++k) {
184
- sum -= A[i * size + k] * A[k * size + j];
185
- }
186
- A[i * size + j] = sum;
187
-
188
- if ((temp1 = scale[i] * Math.abs(sum)) >= largest) {
189
- largest = temp1;
190
- maxI = i;
191
- }
192
- }
193
- //
194
- // Check for row interchange
195
- //
196
- if (j !== maxI) {
197
- for (k = 0; k < size; ++k) {
198
- temp1 = A[maxI * size + k];
199
- A[maxI * size + k] = A[j * size + k];
200
- A[j * size + k] = temp1;
201
- }
202
- scale[maxI] = scale[j];
203
- }
204
- //
205
- // Divide by pivot element and perform elimination
206
- //
207
- index[j] = maxI;
208
105
 
209
- if (Math.abs(A[j * size + j]) <= SMALL_NUMBER && numWarns++ < VTK_MAX_WARNS) {
210
- //vtkGenericWarningMacro(<< "Unable to factor linear system");
211
- return 0;
212
- }
213
-
214
- if (j !== (size - 1)) {
215
- temp1 = 1.0 / A[j * size + j];
216
- for (i = j + 1; i < size; ++i) {
217
- A[i * size + j] *= temp1;
218
- }
219
- }
220
- }
221
-
222
- return 1;
223
- }
224
-
225
- /**
226
- * Solve linear equations Ax = b using LU decomposition A = LU where L is
227
- * lower triangular matrix and U is upper triangular matrix. Input is
228
- * factored matrix A=LU, integer array of pivot indices index[0->n-1],
229
- * load vector x[0->n-1], and size of square matrix n. Note that A=LU and
230
- * index[] are generated from method LUFactorLinearSystem). Also, solution
231
- * vector is written directly over input load vector.
232
- * @param {number[]} A
233
- * @param {number[]} index
234
- * @param {number[]} x
235
- * @param {number} size
236
- */
237
- function luf_solve_linear_system(A, index, x, size) {
238
- let i, j, ii, idx;
239
- let sum;
240
- //
241
- // Proceed with forward and backsubstitution for L and U
242
- // matrices. First, forward substitution.
243
- //
244
- for (ii = -1, i = 0; i < size; ++i) {
245
- idx = index[i];
246
- sum = x[idx];
247
- x[idx] = x[i];
248
-
249
- if (ii >= 0) {
250
- for (j = ii; j <= (i - 1); ++j) {
251
- sum -= A[i * size + j] * x[j];
252
- }
253
- } else if (sum !== 0.0) {
254
- ii = i;
255
- }
256
-
257
- x[i] = sum;
258
- }
259
- //
260
- // Now, back substitution
261
- //
262
- for (i = size - 1; i >= 0; i--) {
263
- sum = x[i];
264
- for (j = i + 1; j < size; ++j) {
265
- sum -= A[i * size + j] * x[j];
266
- }
267
- x[i] = sum / A[i * size + i];
268
- }
269
- }
@@ -54,7 +54,7 @@ async function main() {
54
54
 
55
55
  transform.scale.setScalar(1.5);
56
56
 
57
- scene.addMesh(
57
+ scene.createMesh(
58
58
  new BoxBufferGeometry(),
59
59
  new MeshStandardMaterial(),
60
60
  transform.matrix