@woosh/meep-engine 2.107.0 → 2.108.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 (315) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/meep.cjs +255 -172
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +255 -173
  5. package/editor/tools/paint/TerrainHeightPaintTool.js +5 -5
  6. package/package.json +1 -1
  7. package/src/core/binary/float_to_uint8.d.ts +7 -0
  8. package/src/core/binary/float_to_uint8.d.ts.map +1 -0
  9. package/src/core/binary/{float2uint8.js → float_to_uint8.js} +1 -1
  10. package/src/core/binary/int32_to_binary_string.d.ts +3 -2
  11. package/src/core/binary/int32_to_binary_string.d.ts.map +1 -1
  12. package/src/core/binary/int32_to_binary_string.js +18 -14
  13. package/src/core/binary/split_by_3.spec.d.ts +2 -0
  14. package/src/core/binary/split_by_3.spec.d.ts.map +1 -0
  15. package/src/core/binary/split_by_3.spec.js +22 -0
  16. package/src/core/binary/to_half_float_uint16.d.ts.map +1 -1
  17. package/src/core/binary/to_half_float_uint16.js +7 -5
  18. package/src/core/binary/uint8_to_float.d.ts +7 -0
  19. package/src/core/binary/uint8_to_float.d.ts.map +1 -0
  20. package/src/core/binary/{uint82float.js → uint8_to_float.js} +1 -1
  21. package/src/core/binary/uint8_to_float.spec.d.ts +2 -0
  22. package/src/core/binary/uint8_to_float.spec.d.ts.map +1 -0
  23. package/src/core/binary/uint8_to_float.spec.js +7 -0
  24. package/src/core/codegen/codeToBlob.d.ts +8 -0
  25. package/src/core/codegen/codeToBlob.d.ts.map +1 -0
  26. package/src/core/codegen/codeToBlob.js +36 -0
  27. package/src/core/codegen/codeToURL.d.ts +8 -0
  28. package/src/core/codegen/codeToURL.d.ts.map +1 -0
  29. package/src/core/codegen/codeToURL.js +22 -0
  30. package/src/core/collection/array/array_shuffle.d.ts +8 -0
  31. package/src/core/collection/array/array_shuffle.d.ts.map +1 -0
  32. package/src/core/collection/array/array_shuffle.js +22 -0
  33. package/src/core/collection/array/array_shuffle.spec.d.ts +2 -0
  34. package/src/core/collection/array/array_shuffle.spec.d.ts.map +1 -0
  35. package/src/core/collection/array/{randomizeArrayElementOrder.spec.js → array_shuffle.spec.js} +4 -4
  36. package/src/core/collection/array/isArrayEqualStrict.d.ts.map +1 -1
  37. package/src/core/collection/array/isArrayEqualStrict.js +2 -2
  38. package/src/core/collection/array/iterator/ArrayIteratorRandom.js +2 -2
  39. package/src/core/collection/array/randomMultipleFromArray.js +2 -2
  40. package/src/core/color/Color.d.ts.map +1 -1
  41. package/src/core/color/Color.js +16 -11
  42. package/src/core/color/hsv/hsv2rgb.js +4 -4
  43. package/src/core/color/hsv/rgb2hsv.d.ts +3 -3
  44. package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
  45. package/src/core/color/hsv/rgb2hsv.js +11 -18
  46. package/src/core/color/rgb2uint24.js +4 -4
  47. package/src/core/color/rgb_to_luminance.d.ts +9 -0
  48. package/src/core/color/rgb_to_luminance.d.ts.map +1 -0
  49. package/src/core/color/rgb_to_luminance.js +10 -0
  50. package/src/core/color/sRGB/linear_to_sRGB.d.ts +1 -0
  51. package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
  52. package/src/core/color/sRGB/linear_to_sRGB.js +4 -4
  53. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  54. package/src/core/geom/3d/aabb/AABB3.js +4 -1
  55. package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +3 -3
  56. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  57. package/src/core/geom/3d/shape/UnitSphereShape3D.js +14 -14
  58. package/src/core/geom/3d/sphere/harmonics/README.md +16 -2
  59. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts +6 -0
  60. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts.map +1 -0
  61. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js +17 -0
  62. package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.d.ts.map +1 -1
  63. package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.js +21 -9
  64. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts +3 -3
  65. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
  66. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +35 -206
  67. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts +8 -0
  68. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts.map +1 -0
  69. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.js +29 -0
  70. package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.js +10 -10
  71. package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts +8 -0
  72. package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts.map +1 -0
  73. package/src/core/geom/3d/sphere/harmonics/sh_index.js +9 -0
  74. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +8 -0
  75. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +1 -0
  76. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +44 -0
  77. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +8 -0
  78. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +1 -0
  79. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +86 -0
  80. package/src/core/geom/3d/sphere/in_sphere3d_robust.d.ts.map +1 -1
  81. package/src/core/geom/3d/sphere/in_sphere3d_robust.js +2 -1
  82. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +20 -1
  83. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  84. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +53 -7
  85. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.spec.js +2 -2
  86. package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts +1 -1
  87. package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts.map +1 -1
  88. package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js +12 -7
  89. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts +13 -0
  90. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts.map +1 -0
  91. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js +135 -0
  92. package/src/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +38 -24
  93. package/src/core/geom/3d/tetrahedra/{compute_circumsphere.d.ts → tetrahedron_compute_circumsphere.d.ts} +3 -5
  94. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -0
  95. package/src/core/geom/3d/tetrahedra/{compute_circumsphere.js → tetrahedron_compute_circumsphere.js} +2 -4
  96. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.d.ts.map +1 -1
  97. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js +3 -1
  98. package/src/core/geom/Vector3.d.ts.map +1 -1
  99. package/src/core/geom/Vector3.js +4 -3
  100. package/src/core/geom/mat3/m3_multiply_vec3.d.ts +8 -0
  101. package/src/core/geom/mat3/m3_multiply_vec3.d.ts.map +1 -0
  102. package/src/core/geom/mat3/m3_multiply_vec3.js +21 -0
  103. package/src/core/geom/random/randomPointInSphere.d.ts +1 -1
  104. package/src/core/geom/random/randomPointInSphere.js +2 -2
  105. package/src/core/geom/random/randomPointOnSphere.d.ts +3 -3
  106. package/src/core/geom/random/randomPointOnSphere.d.ts.map +1 -1
  107. package/src/core/geom/random/randomPointOnSphere.js +5 -9
  108. package/src/core/geom/vec2/v2_cross_product.d.ts +15 -0
  109. package/src/core/geom/vec2/v2_cross_product.d.ts.map +1 -0
  110. package/src/core/geom/vec2/v2_cross_product.js +21 -0
  111. package/src/core/geom/vec3/v3_slerp.d.ts +1 -0
  112. package/src/core/geom/vec3/v3_slerp.d.ts.map +1 -1
  113. package/src/core/geom/vec3/v3_slerp.js +1 -0
  114. package/src/core/graph/MultiNode.d.ts +1 -1
  115. package/src/core/graph/MultiNode.js +1 -1
  116. package/src/core/graph/WeightedEdge.d.ts +6 -4
  117. package/src/core/graph/WeightedEdge.d.ts.map +1 -1
  118. package/src/core/graph/WeightedEdge.js +3 -0
  119. package/src/core/graph/coloring/colorizeGraph.js +19 -19
  120. package/src/core/graph/convert_graph_to_dot_string.d.ts +1 -1
  121. package/src/core/graph/convert_graph_to_dot_string.d.ts.map +1 -1
  122. package/src/core/graph/convert_graph_to_dot_string.js +10 -6
  123. package/src/core/graph/graph_compute_adjacency_matrix.d.ts +9 -0
  124. package/src/core/graph/graph_compute_adjacency_matrix.d.ts.map +1 -0
  125. package/src/core/graph/{graph_adjacency_matrix.js → graph_compute_adjacency_matrix.js} +1 -2
  126. package/src/core/graph/graph_compute_degree_matrix.d.ts +10 -0
  127. package/src/core/graph/graph_compute_degree_matrix.d.ts.map +1 -0
  128. package/src/core/graph/graph_compute_degree_matrix.js +23 -0
  129. package/src/core/graph/graph_compute_distance_matrix.d.ts +13 -0
  130. package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -0
  131. package/src/core/graph/graph_compute_distance_matrix.js +103 -0
  132. package/src/core/graph/{graph_laplacian_matrix.d.ts → graph_compute_laplacian_matrix.d.ts} +2 -2
  133. package/src/core/graph/graph_compute_laplacian_matrix.d.ts.map +1 -0
  134. package/src/core/graph/{graph_laplacian_matrix.js → graph_compute_laplacian_matrix.js} +6 -6
  135. package/src/core/graph/graph_k_means_cluster.d.ts.map +1 -1
  136. package/src/core/graph/graph_k_means_cluster.js +4 -119
  137. package/src/core/graph/{coarsen_graph.d.ts → mn_graph_coarsen.d.ts} +2 -2
  138. package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -0
  139. package/src/core/graph/{coarsen_graph.js → mn_graph_coarsen.js} +1 -1
  140. package/src/core/graph/mn_graph_coarsen.spec.d.ts +2 -0
  141. package/src/core/graph/mn_graph_coarsen.spec.d.ts.map +1 -0
  142. package/src/core/graph/{coarsen_graph.spec.js → mn_graph_coarsen.spec.js} +4 -4
  143. package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts +1 -0
  144. package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts.map +1 -1
  145. package/src/core/graph/mn_graph_collapse_weighted_edge.js +7 -1
  146. package/src/core/math/physics/brdf/brdf_burley.d.ts.map +1 -1
  147. package/src/core/math/physics/brdf/brdf_burley.js +9 -1
  148. package/src/core/math/physics/brdf/{D_GGX.d.ts → diffuse_GGX.d.ts} +2 -2
  149. package/src/core/math/physics/brdf/diffuse_GGX.d.ts.map +1 -0
  150. package/src/core/math/physics/brdf/{D_GGX.js → diffuse_GGX.js} +1 -1
  151. package/src/core/math/physics/brdf/fresnel_Schlick.d.ts +3 -0
  152. package/src/core/math/physics/brdf/fresnel_Schlick.d.ts.map +1 -0
  153. package/src/core/math/physics/brdf/fresnel_Schlick.js +3 -0
  154. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts +9 -0
  155. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts.map +1 -0
  156. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.js +12 -0
  157. package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts +9 -0
  158. package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts.map +1 -0
  159. package/src/core/math/physics/brdf/fresnel_Schlick_original.js +10 -0
  160. package/src/core/math/physics/bsdf/bsdf_schlick.d.ts.map +1 -1
  161. package/src/core/math/physics/bsdf/bsdf_schlick.js +3 -11
  162. package/src/core/math/physics/ior_to_reflectivity.d.ts +7 -0
  163. package/src/core/math/physics/ior_to_reflectivity.d.ts.map +1 -0
  164. package/src/core/math/physics/ior_to_reflectivity.js +9 -0
  165. package/src/core/math/physics/pdf/README.md +1 -0
  166. package/src/core/math/physics/pdf/pdf_GGX.d.ts +16 -0
  167. package/src/core/math/physics/pdf/pdf_GGX.d.ts.map +1 -0
  168. package/src/core/math/physics/pdf/pdf_GGX.js +25 -0
  169. package/src/core/math/physics/reflectivity_to_ior.d.ts +7 -0
  170. package/src/core/math/physics/reflectivity_to_ior.d.ts.map +1 -0
  171. package/src/core/math/physics/reflectivity_to_ior.js +8 -0
  172. package/src/core/process/task/util/randomCountTask.js +3 -3
  173. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  174. package/src/core/process/worker/WorkerBuilder.js +5 -35
  175. package/src/engine/EngineHarness.d.ts +10 -1
  176. package/src/engine/EngineHarness.d.ts.map +1 -1
  177. package/src/engine/EngineHarness.js +22 -11
  178. package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
  179. package/src/engine/asset/loaders/ArrayBufferLoader.js +17 -10
  180. package/src/engine/asset/loaders/image/png/PNGReader.d.ts +25 -11
  181. package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
  182. package/src/engine/asset/loaders/image/png/PNGReader.js +38 -24
  183. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.d.ts.map +1 -1
  184. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +5 -0
  185. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +4 -4
  186. package/src/engine/graphics/GraphicsEngine.js +1 -1
  187. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
  188. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +4 -0
  189. package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
  190. package/src/engine/graphics/ecs/light/LightSystem.js +2 -3
  191. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts +6 -0
  192. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
  193. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +22 -11
  194. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
  195. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +7 -7
  196. package/src/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +3 -3
  197. package/src/engine/graphics/render/forward_plus/model/DirectionalLight.d.ts.map +1 -1
  198. package/src/engine/graphics/render/forward_plus/model/DirectionalLight.js +25 -25
  199. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +1 -1
  200. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -6
  201. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts +9 -0
  202. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +1 -0
  203. package/src/engine/graphics/sh3/fromCubeRenderTarget.js +145 -0
  204. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts +8 -0
  205. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts.map +1 -0
  206. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +51 -0
  207. package/src/engine/graphics/sh3/{LightProbeVolume.d.ts → lpv/LightProbeVolume.d.ts} +18 -7
  208. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -0
  209. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +340 -0
  210. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts +18 -0
  211. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
  212. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.js +44 -0
  213. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +12 -0
  214. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -0
  215. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +122 -0
  216. package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts +29 -0
  217. package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts.map +1 -0
  218. package/src/engine/graphics/sh3/lpv/ProbeRenderer.js +35 -0
  219. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts +27 -0
  220. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts.map +1 -0
  221. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.js +158 -0
  222. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +11 -0
  223. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -0
  224. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +127 -0
  225. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +12 -0
  226. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -0
  227. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +89 -0
  228. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +90 -0
  229. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -0
  230. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +352 -0
  231. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +5 -91
  232. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  233. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +41 -477
  234. package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts +1 -0
  235. package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts.map +1 -1
  236. package/src/engine/graphics/sh3/path_tracer/make_one_vector3.js +6 -3
  237. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +38 -62
  238. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +1 -1
  239. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +7 -1
  240. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
  241. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +1 -1
  242. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +1 -1
  243. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts +10 -0
  244. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts.map +1 -0
  245. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.js +20 -0
  246. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts +10 -0
  247. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts.map +1 -0
  248. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.js +31 -0
  249. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts +9 -0
  250. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts.map +1 -0
  251. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.js +21 -0
  252. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +3 -0
  253. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +1 -0
  254. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +3 -0
  255. package/src/engine/graphics/sh3/path_tracer/texture/apply_texture_clamping_to_coordinate.d.ts.map +1 -0
  256. package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.js → texture/apply_texture_clamping_to_coordinate.js} +2 -2
  257. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts +11 -0
  258. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -0
  259. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +86 -0
  260. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts +10 -0
  261. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts.map +1 -0
  262. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.js +55 -0
  263. package/src/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +4 -4
  264. package/src/engine/graphics/sh3/prototypeSH3Probe.js +145 -185
  265. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts +5 -5
  266. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts.map +1 -1
  267. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +8 -8
  268. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts +13 -0
  269. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts.map +1 -0
  270. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +54 -0
  271. package/src/engine/graphics/texture/AttributeDataTexture.d.ts +2 -2
  272. package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
  273. package/src/engine/graphics/texture/AttributeDataTexture.js +11 -11
  274. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  275. package/src/engine/graphics/texture/sampler/Sampler2D.js +2 -2
  276. package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
  277. package/src/engine/network/convertPathToURL.d.ts +3 -1
  278. package/src/engine/network/convertPathToURL.d.ts.map +1 -1
  279. package/src/engine/network/convertPathToURL.js +68 -51
  280. package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
  281. package/src/engine/physics/fluid/SliceVisualiser.js +4 -4
  282. package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
  283. package/src/generation/filtering/numeric/CellFilterCache.js +1 -0
  284. package/src/view/elements/ColorPickerView.d.ts.map +1 -1
  285. package/src/view/elements/ColorPickerView.js +7 -7
  286. package/src/core/binary/float2uint8.d.ts +0 -7
  287. package/src/core/binary/float2uint8.d.ts.map +0 -1
  288. package/src/core/binary/uint82float.d.ts +0 -7
  289. package/src/core/binary/uint82float.d.ts.map +0 -1
  290. package/src/core/binary/uint82float.spec.d.ts +0 -2
  291. package/src/core/binary/uint82float.spec.d.ts.map +0 -1
  292. package/src/core/binary/uint82float.spec.js +0 -7
  293. package/src/core/collection/array/randomizeArrayElementOrder.d.ts +0 -8
  294. package/src/core/collection/array/randomizeArrayElementOrder.d.ts.map +0 -1
  295. package/src/core/collection/array/randomizeArrayElementOrder.js +0 -24
  296. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts +0 -2
  297. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts.map +0 -1
  298. package/src/core/geom/3d/tetrahedra/compute_circumsphere.d.ts.map +0 -1
  299. package/src/core/graph/coarsen_graph.d.ts.map +0 -1
  300. package/src/core/graph/coarsen_graph.spec.d.ts +0 -2
  301. package/src/core/graph/coarsen_graph.spec.d.ts.map +0 -1
  302. package/src/core/graph/graph_adjacency_matrix.d.ts +0 -9
  303. package/src/core/graph/graph_adjacency_matrix.d.ts.map +0 -1
  304. package/src/core/graph/graph_degree_matrix.d.ts +0 -9
  305. package/src/core/graph/graph_degree_matrix.d.ts.map +0 -1
  306. package/src/core/graph/graph_degree_matrix.js +0 -18
  307. package/src/core/graph/graph_laplacian_matrix.d.ts.map +0 -1
  308. package/src/core/math/physics/brdf/D_GGX.d.ts.map +0 -1
  309. package/src/engine/graphics/sh3/LightProbeVolume.d.ts.map +0 -1
  310. package/src/engine/graphics/sh3/LightProbeVolume.js +0 -609
  311. package/src/engine/graphics/sh3/path_tracer/apply_texture_clamping_to_coordinate.d.ts.map +0 -1
  312. package/src/engine/graphics/sh3/visualise_probe.d.ts +0 -12
  313. package/src/engine/graphics/sh3/visualise_probe.d.ts.map +0 -1
  314. package/src/engine/graphics/sh3/visualise_probe.js +0 -40
  315. /package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.d.ts → texture/apply_texture_clamping_to_coordinate.d.ts} +0 -0
package/build/meep.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  /**
4
4
  *
5
- * @param {Array} a
6
- * @param {Array} b
5
+ * @param {Array|Uint8Array} a
6
+ * @param {Array|Uint8Array} b
7
7
  * @returns {boolean}
8
8
  */
9
9
  function isArrayEqualStrict(a, b) {
@@ -2049,6 +2049,7 @@ function v3_lerp(
2049
2049
 
2050
2050
  /**
2051
2051
  * Spherical linear interpolation
2052
+ * NOTE: vectors are assumed to be normalized
2052
2053
  * @see https://en.wikipedia.org/wiki/Slerp
2053
2054
  * @param {Vector3} result
2054
2055
  * @param {number} a_x
@@ -2671,6 +2672,7 @@ let Vector3$1 = class Vector3 {
2671
2672
  const y = this.y;
2672
2673
  const z = this.z;
2673
2674
 
2675
+ // This is just 3x3 matrix multiplication
2674
2676
  const _x = m4[0] * x + m4[4] * y + m4[8] * z;
2675
2677
  const _y = m4[1] * x + m4[5] * y + m4[9] * z;
2676
2678
  const _z = m4[2] * x + m4[6] * y + m4[10] * z;
@@ -2868,10 +2870,10 @@ let Vector3$1 = class Vector3 {
2868
2870
  }
2869
2871
 
2870
2872
  /**
2871
- *
2873
+ * Convert spherical coordinates to cartesian
2872
2874
  * @param {number} radius
2873
- * @param {number} phi
2874
- * @param {number} theta
2875
+ * @param {number} phi Also known as Azimuth
2876
+ * @param {number} theta Also known as Elevation
2875
2877
  */
2876
2878
  setFromSphericalCoords(radius, phi, theta) {
2877
2879
 
@@ -49538,7 +49540,7 @@ class Sampler2D {
49538
49540
  *
49539
49541
  * @param {number} u
49540
49542
  * @param {number} v
49541
- * @param {number[]} result
49543
+ * @param {number[]|Float32Array} result
49542
49544
  * @param {number} result_offset
49543
49545
  */
49544
49546
  sampleBilinearUV(u, v, result, result_offset = 0) {
@@ -49668,7 +49670,7 @@ class Sampler2D {
49668
49670
  *
49669
49671
  * @param {number} u
49670
49672
  * @param {number} v
49671
- * @param {ArrayLike<number>} result
49673
+ * @param {number[]|ArrayLike<number>} result
49672
49674
  */
49673
49675
  sampleNearestUV(u, v, result) {
49674
49676
  const w = this.width;
@@ -50288,7 +50290,7 @@ const WHITE_PIXEL_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA
50288
50290
  * @param {number} v
50289
50291
  * @returns {number}
50290
50292
  */
50291
- function float2uint8(v) {
50293
+ function float_to_uint8(v) {
50292
50294
  return Math.round(v * 255);
50293
50295
  }
50294
50296
 
@@ -50297,7 +50299,7 @@ function float2uint8(v) {
50297
50299
  * @param {number} v
50298
50300
  * @returns {number}
50299
50301
  */
50300
- function uint82float(v) {
50302
+ function uint8_to_float(v) {
50301
50303
  return v / 255;
50302
50304
  }
50303
50305
 
@@ -51696,7 +51698,7 @@ class TerrainOverlay {
51696
51698
  for (let i = 0; i < 4; i++) {
51697
51699
  const v = this.sampler.readChannel(x, y, i);
51698
51700
 
51699
- result[i] = uint82float(v);
51701
+ result[i] = uint8_to_float(v);
51700
51702
  }
51701
51703
  }
51702
51704
 
@@ -51743,7 +51745,7 @@ class TerrainOverlay {
51743
51745
  paintPoint(x, y, vec4) {
51744
51746
  for (let i = 0; i < 4; i++) {
51745
51747
 
51746
- this.sampler.writeChannel(x, y, i, float2uint8(vec4[i]));
51748
+ this.sampler.writeChannel(x, y, i, float_to_uint8(vec4[i]));
51747
51749
 
51748
51750
  }
51749
51751
 
@@ -53220,7 +53222,7 @@ function aabb3_intersects_ray(
53220
53222
  const diff_x = origin_x - center_x;
53221
53223
 
53222
53224
 
53223
- if (diff_x * direction_x >= 0.0 && abs(diff_x) > extents_x) {
53225
+ if (diff_x * direction_x >= 0 && abs(diff_x) > extents_x) {
53224
53226
  return false;
53225
53227
  }
53226
53228
 
@@ -53232,7 +53234,7 @@ function aabb3_intersects_ray(
53232
53234
  const diff_y = origin_y - center_y;
53233
53235
 
53234
53236
 
53235
- if (diff_y * direction_y >= 0.0 && abs(diff_y) > extents_y) {
53237
+ if (diff_y * direction_y >= 0 && abs(diff_y) > extents_y) {
53236
53238
  return false;
53237
53239
  }
53238
53240
 
@@ -53244,7 +53246,7 @@ function aabb3_intersects_ray(
53244
53246
  const diff_z = origin_z - center_z;
53245
53247
 
53246
53248
 
53247
- if (diff_z * direction_z >= 0.0 && abs(diff_z) > extents_z) {
53249
+ if (diff_z * direction_z >= 0 && abs(diff_z) > extents_z) {
53248
53250
  return false;
53249
53251
  }
53250
53252
 
@@ -53400,20 +53402,15 @@ function rgb2hex(r, g, b) {
53400
53402
 
53401
53403
  /**
53402
53404
  *
53403
- * @param {number} r 0 to 255
53404
- * @param {number} g 0 to 255
53405
- * @param {number} b 0 to 255
53405
+ * @param {number} r 0 to 1
53406
+ * @param {number} g 0 to 1
53407
+ * @param {number} b 0 to 1
53406
53408
  * @returns {{h: number, s: number, v: number}}
53407
53409
  */
53408
53410
  function rgb2hsv(r, g, b) {
53409
53411
 
53410
- const _r = uint82float(r);
53411
- const _g = uint82float(g);
53412
- const _b = uint82float(b);
53413
-
53414
-
53415
- const max = Math.max(_r, _g, _b);
53416
- const min = Math.min(_r, _g, _b);
53412
+ const max = Math.max(r, g, b);
53413
+ const min = Math.min(r, g, b);
53417
53414
 
53418
53415
  let h, s, v = max;
53419
53416
 
@@ -53425,14 +53422,14 @@ function rgb2hsv(r, g, b) {
53425
53422
  h = 0; // achromatic
53426
53423
  } else {
53427
53424
  switch (max) {
53428
- case _r:
53429
- h = (_g - _b) / d + (_g < _b ? 6 : 0);
53425
+ case r:
53426
+ h = (g - b) / d + (g < b ? 6 : 0);
53430
53427
  break;
53431
- case _g:
53432
- h = (_b - _r) / d + 2;
53428
+ case g:
53429
+ h = (b - r) / d + 2;
53433
53430
  break;
53434
- case _b:
53435
- h = (_r - _g) / d + 4;
53431
+ case b:
53432
+ h = (r - g) / d + 4;
53436
53433
  break;
53437
53434
  }
53438
53435
 
@@ -53529,9 +53526,9 @@ function hsv2rgb(h, s, v) {
53529
53526
  break;
53530
53527
  }
53531
53528
  return {
53532
- r: float2uint8(r),
53533
- g: float2uint8(g),
53534
- b: float2uint8(b)
53529
+ r: float_to_uint8(r),
53530
+ g: float_to_uint8(g),
53531
+ b: float_to_uint8(b)
53535
53532
  };
53536
53533
  }
53537
53534
 
@@ -53622,9 +53619,9 @@ function parse_color(c) {
53622
53619
  * @returns {number}
53623
53620
  */
53624
53621
  function rgb2uint24(r, g, b) {
53625
- const _r = float2uint8(r);
53626
- const _g = float2uint8(g);
53627
- const _b = float2uint8(b);
53622
+ const _r = float_to_uint8(r);
53623
+ const _g = float_to_uint8(g);
53624
+ const _b = float_to_uint8(b);
53628
53625
 
53629
53626
  return (_b & 0xFF)
53630
53627
  | (_g & 0xFF) << 8
@@ -53632,7 +53629,18 @@ function rgb2uint24(r, g, b) {
53632
53629
  ;
53633
53630
  }
53634
53631
 
53635
- function convert(c) {
53632
+ /**
53633
+ *
53634
+ * @param {number} r
53635
+ * @param {number} g
53636
+ * @param {number} b
53637
+ * @return {number}
53638
+ */
53639
+ function rgb_to_luminance(r, g, b) {
53640
+ return 0.299 * r + 0.587 * g + 0.114 * b;
53641
+ }
53642
+
53643
+ function convert_channel_linear_to_sRGB(c) {
53636
53644
  if (c < 0.0031308) {
53637
53645
  return c * 12.92;
53638
53646
  } else {
@@ -53655,9 +53663,9 @@ function linear_to_sRGB(
53655
53663
  const g = input[input_offset + 1];
53656
53664
  const b = input[input_offset + 2];
53657
53665
 
53658
- output[output_offset] = convert(r);
53659
- output[output_offset + 1] = convert(g);
53660
- output[output_offset + 2] = convert(b);
53666
+ output[output_offset] = convert_channel_linear_to_sRGB(r);
53667
+ output[output_offset + 1] = convert_channel_linear_to_sRGB(g);
53668
+ output[output_offset + 2] = convert_channel_linear_to_sRGB(b);
53661
53669
  }
53662
53670
 
53663
53671
  /**
@@ -53831,9 +53839,9 @@ class Color {
53831
53839
  */
53832
53840
  setRGBUint8(r, g, b) {
53833
53841
  this.setRGB(
53834
- uint82float(r),
53835
- uint82float(g),
53836
- uint82float(b),
53842
+ uint8_to_float(r),
53843
+ uint8_to_float(g),
53844
+ uint8_to_float(b),
53837
53845
  );
53838
53846
  }
53839
53847
 
@@ -54086,11 +54094,15 @@ class Color {
54086
54094
  * @return {number}
54087
54095
  */
54088
54096
  computeLuminance() {
54089
- return 0.299 * this.r + 0.587 * this.g + 0.114 * this.b;
54097
+ return rgb_to_luminance(this.r, this.g, this.b);
54090
54098
  }
54091
54099
 
54092
54100
  getHSV() {
54093
- return rgb2hsv(this.r * 255, this.g * 255, this.b * 255);
54101
+ return rgb2hsv(
54102
+ this.r,
54103
+ this.g,
54104
+ this.b
54105
+ );
54094
54106
  }
54095
54107
 
54096
54108
  /**
@@ -54122,9 +54134,9 @@ class Color {
54122
54134
  */
54123
54135
  toHex() {
54124
54136
  return '#' + rgb2hex(
54125
- float2uint8(this.r),
54126
- float2uint8(this.g),
54127
- float2uint8(this.b)
54137
+ float_to_uint8(this.r),
54138
+ float_to_uint8(this.g),
54139
+ float_to_uint8(this.b)
54128
54140
  );
54129
54141
  }
54130
54142
 
@@ -54133,7 +54145,7 @@ class Color {
54133
54145
  * @returns {string}
54134
54146
  */
54135
54147
  toCssRGBAString() {
54136
- return `rgba(${float2uint8(this.r)},${float2uint8(this.g)},${float2uint8(this.b)},${this.a})`;
54148
+ return `rgba(${float_to_uint8(this.r)},${float_to_uint8(this.g)},${float_to_uint8(this.b)},${this.a})`;
54137
54149
  }
54138
54150
 
54139
54151
  /**
@@ -56749,11 +56761,13 @@ class AABB3 {
56749
56761
  * Get center position of the box
56750
56762
  * @param {Vector3} target where to write result
56751
56763
  */
56752
- getCenter(target) {
56764
+ getCenter(target = new Vector3$1()) {
56753
56765
  const x = this.getCenterX();
56754
56766
  const y = this.getCenterY();
56755
56767
  const z = this.getCenterZ();
56756
56768
  target.set(x, y, z);
56769
+
56770
+ return target;
56757
56771
  }
56758
56772
 
56759
56773
 
@@ -63058,72 +63072,137 @@ const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
63058
63072
  * @param {string} path
63059
63073
  * @return {string}
63060
63074
  */
63061
- function convertPathToURL(path) {
63075
+ function localPathToGlobal(path) {
63076
+ /**
63077
+ * @type {Window|DedicatedWorkerGlobalScope}
63078
+ */
63079
+ let scope;
63062
63080
 
63063
- if (!isGlobalPath(path)) {
63081
+ if (ENVIRONMENT_IS_WEB) {
63082
+ scope = window;
63083
+ } else if (ENVIRONMENT_IS_WORKER) {
63084
+ scope = self;
63085
+ } else if (ENVIRONMENT_IS_NODE) {
63064
63086
 
63065
- /**
63066
- * @type {Window|DedicatedWorkerGlobalScope}
63067
- */
63068
- let scope;
63087
+ let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63069
63088
 
63070
- if (ENVIRONMENT_IS_WEB) {
63071
- scope = window;
63072
- } else if (ENVIRONMENT_IS_WORKER) {
63073
- scope = self;
63074
- } else if (ENVIRONMENT_IS_NODE) {
63089
+ // remove multiple sequential slashes
63090
+ normalized_path = normalized_path.replace(/\/+/g, '/');
63075
63091
 
63076
- let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63077
-
63078
- // remove multiple sequential slashes
63079
- normalized_path = normalized_path.replace(/\/+/g, '/');
63092
+ if (normalized_path[0] !== '/') {
63093
+ // Windows drive letter must be prefixed with a slash.
63094
+ normalized_path = `/${normalized_path}`;
63095
+ }
63080
63096
 
63081
- if (normalized_path[0] !== '/') {
63082
- // Windows drive letter must be prefixed with a slash.
63083
- normalized_path = `/${normalized_path}`;
63097
+ scope = {
63098
+ location: {
63099
+ pathname: normalized_path,
63100
+ host: '',
63101
+ protocol: 'file:'
63084
63102
  }
63103
+ };
63104
+ } else {
63105
+ throw new Error('Unknown environment');
63106
+ }
63085
63107
 
63086
- scope = {
63087
- location: {
63088
- pathname: normalized_path,
63089
- host: '',
63090
- protocol: 'file:'
63091
- }
63092
- };
63108
+ const location = scope.location;
63109
+ const pathname = location.pathname;
63110
+
63111
+ let directoryPath;
63112
+
63113
+ /*
63114
+ path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63115
+ we need to extract directory to load relative path
63116
+ */
63117
+
63118
+ if (pathname.endsWith('/')) {
63119
+ //path is to a directory, strip last slash
63120
+ directoryPath = pathname.substring(0, pathname.length - 1);
63121
+ } else {
63122
+ //path is to a file
63123
+ const i = pathname.lastIndexOf('/');
63124
+
63125
+ if (i === -1) {
63126
+ //root level file
63127
+ directoryPath = "";
63093
63128
  } else {
63094
- throw new Error('Unknown environment');
63129
+ directoryPath = pathname.substring(0, i);
63095
63130
  }
63131
+ }
63096
63132
 
63097
- const location = scope.location;
63098
- const pathname = location.pathname;
63133
+ const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63134
+ return urlBase + path;
63135
+ }
63099
63136
 
63100
- let directoryPath;
63137
+ /**
63138
+ * Given a path, which may be a local path, produce a fully qualified URL
63139
+ * @example '/path' -> 'http://example.com/path'
63140
+ * @example 'some/local/path' -> 'http://example.com/current_path/some/local/path'
63141
+ * @param {string} path
63142
+ * @return {string}
63143
+ */
63144
+ function convertPathToURL(path) {
63101
63145
 
63102
- /*
63103
- path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63104
- we need to extract directory to load relative path
63105
- */
63146
+ const is_global = isGlobalPath(path);
63106
63147
 
63107
- if (pathname.endsWith('/')) {
63108
- //path is to a directory, strip last slash
63109
- directoryPath = pathname.substring(0, pathname.length - 1);
63110
- } else {
63111
- //path is to a file
63112
- const i = pathname.lastIndexOf('/');
63148
+ let result = path;
63113
63149
 
63114
- if (i === -1) {
63115
- //root level file
63116
- directoryPath = "";
63117
- } else {
63118
- directoryPath = pathname.substring(0, i);
63119
- }
63150
+ if (!is_global) {
63151
+ result = localPathToGlobal(path);
63152
+ }
63153
+
63154
+ return result;
63155
+ }
63156
+
63157
+ /**
63158
+ *
63159
+ * @param {string} code
63160
+ * @param {string} [mime_type]
63161
+ * @return {Blob}
63162
+ */
63163
+ function codeToBlob(code, mime_type = 'application/javascript') {
63164
+
63165
+ let blob;
63166
+
63167
+ if (typeof globalThis.Blob !== "undefined") {
63168
+ blob = new Blob([code], { type: mime_type });
63169
+ } else {
63170
+ // Backwards-compatibility
63171
+ const BlobBuilder = globalThis.BlobBuilder
63172
+ || globalThis.BlobBuilder
63173
+ || globalThis.WebKitBlobBuilder
63174
+ || globalThis.MozBlobBuilder;
63175
+
63176
+ if (BlobBuilder !== undefined) {
63177
+ blob = new BlobBuilder();
63178
+ blob.append(code);
63179
+ blob = blob.getBlob();
63180
+ } else {
63181
+ throw new Error(`No BlobBuilder interface supported in current context`);
63120
63182
  }
63121
63183
 
63122
- const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63123
- path = urlBase + path;
63124
63184
  }
63125
63185
 
63126
- return path;
63186
+
63187
+ return blob;
63188
+ }
63189
+
63190
+ /**
63191
+ *
63192
+ * @param {string} code
63193
+ * @param {string} [mime_type]
63194
+ * @return {string}
63195
+ */
63196
+ function codeToURL(code, mime_type = 'application/javascript') {
63197
+
63198
+ const blob = codeToBlob(code, mime_type);
63199
+
63200
+ if (blob !== undefined && URL.createObjectURL !== undefined) {
63201
+ return URL.createObjectURL(blob);
63202
+ } else {
63203
+ // build data URL in a slowest way possible
63204
+ return `data:${mime_type},${encodeURIComponent(code)}`;
63205
+ }
63127
63206
  }
63128
63207
 
63129
63208
  class Line {
@@ -63579,6 +63658,7 @@ class WorkerProxy {
63579
63658
 
63580
63659
  const RxMatchFunctionName = /(function\s*)([a-zA-Z0-9_]+)?(\s*\([^\]]*\)\s*\{.*)/g;
63581
63660
 
63661
+
63582
63662
  class WorkerBuilder {
63583
63663
 
63584
63664
  imports = [];
@@ -63621,9 +63701,9 @@ class WorkerBuilder {
63621
63701
  * @param {string} path
63622
63702
  */
63623
63703
  importScript(path) {
63624
- path = convertPathToURL(path);
63704
+ const qualified_path = convertPathToURL(path);
63625
63705
 
63626
- this.imports.push(path);
63706
+ this.imports.push(qualified_path);
63627
63707
  }
63628
63708
 
63629
63709
  /**
@@ -63633,7 +63713,7 @@ class WorkerBuilder {
63633
63713
  build() {
63634
63714
  const codeLines = [];
63635
63715
 
63636
- codeLines.push('var globalScope = this;');
63716
+ codeLines.push('var globalScope = globalThis;');
63637
63717
 
63638
63718
  //handle imports
63639
63719
  this.imports.forEach(function (url) {
@@ -63734,37 +63814,6 @@ class WorkerBuilder {
63734
63814
 
63735
63815
  return new WorkerProxy(workerURL, this.methods);
63736
63816
  }
63737
- }
63738
- /**
63739
- *
63740
- * @param {string} code
63741
- * @return {string}
63742
- */
63743
- function codeToURL(code) {
63744
- const js_mime = 'application/javascript';
63745
-
63746
- let blob;
63747
-
63748
- if (typeof window === 'object') {
63749
- if (typeof window.Blob !== "undefined") {
63750
- blob = new Blob([code], {type: js_mime});
63751
- } else {
63752
- // Backwards-compatibility
63753
- const BlobBuilder = window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
63754
- if (BlobBuilder !== undefined) {
63755
- blob = new BlobBuilder();
63756
- blob.append(code);
63757
- blob = blob.getBlob();
63758
- }
63759
- }
63760
- }
63761
-
63762
- if (blob !== undefined && URL.createObjectURL !== undefined) {
63763
- return URL.createObjectURL(blob);
63764
- } else {
63765
- // build data URL in a slowest way possible
63766
- return `data:${js_mime},${encodeURIComponent(code)}`;
63767
- }
63768
63817
  }
63769
63818
 
63770
63819
  /**
@@ -67679,20 +67728,19 @@ class AssetLoader {
67679
67728
  function observeResponseProgress(input, progress) {
67680
67729
  let response = input;
67681
67730
 
67682
-
67683
- if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
67731
+ // Workaround: Checking if response.body === undefined for Alipay browser
67732
+ if (typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined) {
67684
67733
 
67685
67734
  return response;
67686
67735
 
67687
67736
  }
67688
67737
 
67689
- /**
67690
- * @type {ReadableStreamDefaultReader<Uint8Array>}
67691
- */
67692
- const reader = response.body.getReader();
67738
+ // Nginx needs X-File-Size check
67739
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
67740
+ const contentLength = response.headers.get('Content-Length') || response.headers.get('X-File-Size');
67693
67741
 
67694
- const contentLength = response.headers.get('Content-Length');
67695
67742
  const total = contentLength ? parseInt(contentLength) : 0;
67743
+
67696
67744
  let loaded = 0;
67697
67745
 
67698
67746
  // periodically read data into the new stream tracking while download progress
@@ -67700,6 +67748,11 @@ function observeResponseProgress(input, progress) {
67700
67748
  type: "bytes",
67701
67749
  start(controller) {
67702
67750
 
67751
+ /**
67752
+ * @type {ReadableStreamDefaultReader<Uint8Array>}
67753
+ */
67754
+ const reader = response.body.getReader();
67755
+
67703
67756
  pump();
67704
67757
 
67705
67758
  function pump() {
@@ -67717,6 +67770,7 @@ function observeResponseProgress(input, progress) {
67717
67770
  progress(loaded, total);
67718
67771
 
67719
67772
  controller.enqueue(value);
67773
+
67720
67774
  pump();
67721
67775
 
67722
67776
  });
@@ -67788,16 +67842,13 @@ class ArrayBufferLoader extends AssetLoader {
67788
67842
 
67789
67843
  let response = await fetch(request);
67790
67844
 
67791
- if (!(response.status === 200 || response.status === 0)) {
67845
+ const response_status = response.status;
67792
67846
 
67793
- throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
67847
+ if (response_status !== 200 && response_status !== 0) {
67794
67848
 
67795
- }
67849
+ throw Error(`fetch for "${response.url}" responded with ${response_status}: ${response.statusText}`);
67796
67850
 
67797
- // Some browsers return HTTP Status 0 when using non-http protocol
67798
- // e.g. 'file://' or 'data://'. Handle as success.
67799
-
67800
- if (response.status === 0) ;
67851
+ }
67801
67852
 
67802
67853
  try {
67803
67854
  response = observeResponseProgress(response, progress);
@@ -75580,6 +75631,9 @@ const TextureAttachmentsByMaterialType = {
75580
75631
  taDisplacement,
75581
75632
  taAlphaMap
75582
75633
  ],
75634
+ MeshBasicMaterial: [
75635
+ taDiffuse
75636
+ ],
75583
75637
  MeshStandardMaterial: [
75584
75638
  taDiffuse,
75585
75639
  taAlphaMap,
@@ -75665,7 +75719,9 @@ const TextureAttachmentsByMaterialType = {
75665
75719
  }
75666
75720
  })
75667
75721
  ]
75668
- };
75722
+ };
75723
+
75724
+ TextureAttachmentsByMaterialType.MeshPhysicalMaterial = TextureAttachmentsByMaterialType.MeshStandardMaterial;
75669
75725
 
75670
75726
  /**
75671
75727
  * Transfer bitmap contents to Sampler2D, effectively moving data to CPU, making it readable
@@ -90632,6 +90688,7 @@ class GraphicsEngine {
90632
90688
  const camera = this.camera;
90633
90689
 
90634
90690
  if (scene.children.indexOf(camera) < 0) {
90691
+ // console.log("added camera");
90635
90692
  scene.add(camera);
90636
90693
  }
90637
90694
 
@@ -105053,6 +105110,9 @@ class TopDownCameraController {
105053
105110
 
105054
105111
  this.distance = eye.distanceTo(target);
105055
105112
 
105113
+ // ensure we can maintain this distance
105114
+ this.distanceMax = max2(this.distance, this.distanceMax);
105115
+
105056
105116
  this.target.copy(target);
105057
105117
  }
105058
105118
 
@@ -112371,6 +112431,27 @@ function scene_object_filter(object3D) {
112371
112431
  return true;
112372
112432
  }
112373
112433
 
112434
+ /**
112435
+ *
112436
+ * @param {LightShadow} shadow
112437
+ * @param {number} resolution
112438
+ */
112439
+ function three_set_shadow_resolution(shadow, resolution) {
112440
+ const mapSize = shadow.mapSize;
112441
+
112442
+ if (mapSize.width !== resolution || mapSize.height !== resolution) {
112443
+
112444
+ mapSize.width = mapSize.height = resolution;
112445
+
112446
+ //destroy old map
112447
+ if (shadow.map !== null) {
112448
+ shadow.map.dispose(); // important
112449
+ shadow.map = null;
112450
+ }
112451
+
112452
+ }
112453
+ }
112454
+
112374
112455
  class ThreeLightBinding extends LightBinding {
112375
112456
 
112376
112457
  constructor() {
@@ -112635,17 +112716,7 @@ class ThreeLightBinding extends LightBinding {
112635
112716
  shadow.radius = 1;
112636
112717
  shadow.blurSamples = 8;
112637
112718
 
112638
- if (shadow.mapSize.width !== resolution || shadow.mapSize.height !== resolution) {
112639
-
112640
- shadow.mapSize.width = shadow.mapSize.height = resolution;
112641
-
112642
- //destroy old map
112643
- if (shadow.map !== null) {
112644
- shadow.map.dispose(); // important
112645
- shadow.map = null;
112646
- }
112647
-
112648
- }
112719
+ three_set_shadow_resolution(shadow, resolution);
112649
112720
 
112650
112721
  }
112651
112722
  }
@@ -113273,7 +113344,7 @@ class LightSystem extends AbstractContextSystem {
113273
113344
 
113274
113345
  l.castShadow = true;
113275
113346
 
113276
- updateShadowMap(this.__camera_object, l, this.__graphics);
113347
+ three_update_shadow_camera_extents(this.__camera_object, l, this.__graphics);
113277
113348
 
113278
113349
  } else {
113279
113350
 
@@ -113324,9 +113395,8 @@ const scratch_aabb3 = new AABB3();
113324
113395
  * @author Alex Goldring 02.06.2016 (Komrade)
113325
113396
  * @param {Camera} camera
113326
113397
  * @param {Light} light
113327
- * @param {GraphicsEngine} graphics
113328
113398
  */
113329
- function updateShadowMap(camera, light, graphics) {
113399
+ function three_update_shadow_camera_extents(camera, light) {
113330
113400
 
113331
113401
 
113332
113402
  // Fit shadow camera's ortho frustum to camera frustum
@@ -114548,6 +114618,8 @@ class InputControllerSystem extends System {
114548
114618
 
114549
114619
  this.devices = devices;
114550
114620
 
114621
+ // console.log("Input Controller System started. Devices: ", devices);
114622
+
114551
114623
  const self = this;
114552
114624
 
114553
114625
  this.enabled.onChanged.add(function (v) {
@@ -115577,6 +115649,12 @@ function setLocale(engine) {
115577
115649
  return engine.localization.loadLocale(locale);
115578
115650
  }
115579
115651
 
115652
+ /**
115653
+ * Equal to ~ 5500 K light color
115654
+ * @type {Readonly<Color>}
115655
+ */
115656
+ const DEFAULT_SUNLIGHT_COLOR = Object.freeze(new Color(1, 0.93, 0.87));
115657
+
115580
115658
  class EngineHarness {
115581
115659
  constructor() {
115582
115660
  /**
@@ -115844,12 +115922,21 @@ class EngineHarness {
115844
115922
  * @param {EntityComponentDataset} [param.ecd]
115845
115923
  * @param {number} [param.shadowmapResolution]
115846
115924
  * @param {boolean} [param.castShadow]
115925
+ * @param {Color} [param.sun]
115926
+ * @param {number} [param.sunIntensity]
115927
+ * @param {Color} [param.ambient]
115928
+ * @param {number} [param.ambientIntensity]
115847
115929
  */
115848
115930
  static async buildLights({
115849
115931
  engine,
115850
115932
  ecd = engine.entityManager.dataset,
115851
115933
  shadowmapResolution = 1024,
115852
- castShadow = true
115934
+ castShadow = true,
115935
+ sun = DEFAULT_SUNLIGHT_COLOR,
115936
+ sunIntensity = 0.9,
115937
+ sunDirection = new Vector3$1(0.1, -1, 0.1),
115938
+ ambient = Color.white,
115939
+ ambientIntensity = 0.1
115853
115940
  }) {
115854
115941
  const em = engine.entityManager;
115855
115942
 
@@ -115865,18 +115952,13 @@ class EngineHarness {
115865
115952
 
115866
115953
  const key = new Light();
115867
115954
  key.type.set(Light.Type.DIRECTION);
115868
- key.color.setRGB(1, 1, 1);
115869
- key.intensity.set(0.8);
115955
+ key.color.copy(sun);
115956
+ key.intensity.set(sunIntensity);
115870
115957
  key.castShadow.set(castShadow);
115871
115958
 
115872
115959
  const transform = new Transform();
115873
115960
  transform.position.set(30, 70, 30);
115874
- transform.rotation.set(
115875
- -0.18780341950959473,
115876
- 0.8049745556929917,
115877
- -0.4533975611897181,
115878
- -0.3334313787830773
115879
- );
115961
+ transform.rotation.lookRotation(sunDirection);
115880
115962
 
115881
115963
  new Entity()
115882
115964
  .add(key)
@@ -115887,8 +115969,8 @@ class EngineHarness {
115887
115969
 
115888
115970
  const fill = new Light();
115889
115971
  fill.type.set(Light.Type.AMBIENT);
115890
- fill.color.setRGB(1, 1, 1);
115891
- fill.intensity.set(0.1);
115972
+ fill.color.copy(ambient);
115973
+ fill.intensity.set(ambientIntensity);
115892
115974
 
115893
115975
 
115894
115976
  new Entity()
@@ -117692,6 +117774,7 @@ exports.findSignalHandlerIndexByHandle = findSignalHandlerIndexByHandle;
117692
117774
  exports.findSignalHandlerIndexByHandleAndContext = findSignalHandlerIndexByHandleAndContext;
117693
117775
  exports.find_path_on_grid_astar = find_path_on_grid_astar;
117694
117776
  exports.quat3_createFromAxisAngle = quat3_createFromAxisAngle;
117777
+ exports.three_update_shadow_camera_extents = three_update_shadow_camera_extents;
117695
117778
  exports.v2_angle_between = v2_angle_between;
117696
117779
  exports.v2_bearing_angle_towards = v2_bearing_angle_towards;
117697
117780
  exports.v2_distance = v2_distance;