@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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
- * @param {Array} a
4
- * @param {Array} b
3
+ * @param {Array|Uint8Array} a
4
+ * @param {Array|Uint8Array} b
5
5
  * @returns {boolean}
6
6
  */
7
7
  function isArrayEqualStrict(a, b) {
@@ -2047,6 +2047,7 @@ function v3_lerp(
2047
2047
 
2048
2048
  /**
2049
2049
  * Spherical linear interpolation
2050
+ * NOTE: vectors are assumed to be normalized
2050
2051
  * @see https://en.wikipedia.org/wiki/Slerp
2051
2052
  * @param {Vector3} result
2052
2053
  * @param {number} a_x
@@ -2669,6 +2670,7 @@ let Vector3$1 = class Vector3 {
2669
2670
  const y = this.y;
2670
2671
  const z = this.z;
2671
2672
 
2673
+ // This is just 3x3 matrix multiplication
2672
2674
  const _x = m4[0] * x + m4[4] * y + m4[8] * z;
2673
2675
  const _y = m4[1] * x + m4[5] * y + m4[9] * z;
2674
2676
  const _z = m4[2] * x + m4[6] * y + m4[10] * z;
@@ -2866,10 +2868,10 @@ let Vector3$1 = class Vector3 {
2866
2868
  }
2867
2869
 
2868
2870
  /**
2869
- *
2871
+ * Convert spherical coordinates to cartesian
2870
2872
  * @param {number} radius
2871
- * @param {number} phi
2872
- * @param {number} theta
2873
+ * @param {number} phi Also known as Azimuth
2874
+ * @param {number} theta Also known as Elevation
2873
2875
  */
2874
2876
  setFromSphericalCoords(radius, phi, theta) {
2875
2877
 
@@ -49536,7 +49538,7 @@ class Sampler2D {
49536
49538
  *
49537
49539
  * @param {number} u
49538
49540
  * @param {number} v
49539
- * @param {number[]} result
49541
+ * @param {number[]|Float32Array} result
49540
49542
  * @param {number} result_offset
49541
49543
  */
49542
49544
  sampleBilinearUV(u, v, result, result_offset = 0) {
@@ -49666,7 +49668,7 @@ class Sampler2D {
49666
49668
  *
49667
49669
  * @param {number} u
49668
49670
  * @param {number} v
49669
- * @param {ArrayLike<number>} result
49671
+ * @param {number[]|ArrayLike<number>} result
49670
49672
  */
49671
49673
  sampleNearestUV(u, v, result) {
49672
49674
  const w = this.width;
@@ -50286,7 +50288,7 @@ const WHITE_PIXEL_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA
50286
50288
  * @param {number} v
50287
50289
  * @returns {number}
50288
50290
  */
50289
- function float2uint8(v) {
50291
+ function float_to_uint8(v) {
50290
50292
  return Math.round(v * 255);
50291
50293
  }
50292
50294
 
@@ -50295,7 +50297,7 @@ function float2uint8(v) {
50295
50297
  * @param {number} v
50296
50298
  * @returns {number}
50297
50299
  */
50298
- function uint82float(v) {
50300
+ function uint8_to_float(v) {
50299
50301
  return v / 255;
50300
50302
  }
50301
50303
 
@@ -51694,7 +51696,7 @@ class TerrainOverlay {
51694
51696
  for (let i = 0; i < 4; i++) {
51695
51697
  const v = this.sampler.readChannel(x, y, i);
51696
51698
 
51697
- result[i] = uint82float(v);
51699
+ result[i] = uint8_to_float(v);
51698
51700
  }
51699
51701
  }
51700
51702
 
@@ -51741,7 +51743,7 @@ class TerrainOverlay {
51741
51743
  paintPoint(x, y, vec4) {
51742
51744
  for (let i = 0; i < 4; i++) {
51743
51745
 
51744
- this.sampler.writeChannel(x, y, i, float2uint8(vec4[i]));
51746
+ this.sampler.writeChannel(x, y, i, float_to_uint8(vec4[i]));
51745
51747
 
51746
51748
  }
51747
51749
 
@@ -53218,7 +53220,7 @@ function aabb3_intersects_ray(
53218
53220
  const diff_x = origin_x - center_x;
53219
53221
 
53220
53222
 
53221
- if (diff_x * direction_x >= 0.0 && abs(diff_x) > extents_x) {
53223
+ if (diff_x * direction_x >= 0 && abs(diff_x) > extents_x) {
53222
53224
  return false;
53223
53225
  }
53224
53226
 
@@ -53230,7 +53232,7 @@ function aabb3_intersects_ray(
53230
53232
  const diff_y = origin_y - center_y;
53231
53233
 
53232
53234
 
53233
- if (diff_y * direction_y >= 0.0 && abs(diff_y) > extents_y) {
53235
+ if (diff_y * direction_y >= 0 && abs(diff_y) > extents_y) {
53234
53236
  return false;
53235
53237
  }
53236
53238
 
@@ -53242,7 +53244,7 @@ function aabb3_intersects_ray(
53242
53244
  const diff_z = origin_z - center_z;
53243
53245
 
53244
53246
 
53245
- if (diff_z * direction_z >= 0.0 && abs(diff_z) > extents_z) {
53247
+ if (diff_z * direction_z >= 0 && abs(diff_z) > extents_z) {
53246
53248
  return false;
53247
53249
  }
53248
53250
 
@@ -53398,20 +53400,15 @@ function rgb2hex(r, g, b) {
53398
53400
 
53399
53401
  /**
53400
53402
  *
53401
- * @param {number} r 0 to 255
53402
- * @param {number} g 0 to 255
53403
- * @param {number} b 0 to 255
53403
+ * @param {number} r 0 to 1
53404
+ * @param {number} g 0 to 1
53405
+ * @param {number} b 0 to 1
53404
53406
  * @returns {{h: number, s: number, v: number}}
53405
53407
  */
53406
53408
  function rgb2hsv(r, g, b) {
53407
53409
 
53408
- const _r = uint82float(r);
53409
- const _g = uint82float(g);
53410
- const _b = uint82float(b);
53411
-
53412
-
53413
- const max = Math.max(_r, _g, _b);
53414
- const min = Math.min(_r, _g, _b);
53410
+ const max = Math.max(r, g, b);
53411
+ const min = Math.min(r, g, b);
53415
53412
 
53416
53413
  let h, s, v = max;
53417
53414
 
@@ -53423,14 +53420,14 @@ function rgb2hsv(r, g, b) {
53423
53420
  h = 0; // achromatic
53424
53421
  } else {
53425
53422
  switch (max) {
53426
- case _r:
53427
- h = (_g - _b) / d + (_g < _b ? 6 : 0);
53423
+ case r:
53424
+ h = (g - b) / d + (g < b ? 6 : 0);
53428
53425
  break;
53429
- case _g:
53430
- h = (_b - _r) / d + 2;
53426
+ case g:
53427
+ h = (b - r) / d + 2;
53431
53428
  break;
53432
- case _b:
53433
- h = (_r - _g) / d + 4;
53429
+ case b:
53430
+ h = (r - g) / d + 4;
53434
53431
  break;
53435
53432
  }
53436
53433
 
@@ -53527,9 +53524,9 @@ function hsv2rgb(h, s, v) {
53527
53524
  break;
53528
53525
  }
53529
53526
  return {
53530
- r: float2uint8(r),
53531
- g: float2uint8(g),
53532
- b: float2uint8(b)
53527
+ r: float_to_uint8(r),
53528
+ g: float_to_uint8(g),
53529
+ b: float_to_uint8(b)
53533
53530
  };
53534
53531
  }
53535
53532
 
@@ -53620,9 +53617,9 @@ function parse_color(c) {
53620
53617
  * @returns {number}
53621
53618
  */
53622
53619
  function rgb2uint24(r, g, b) {
53623
- const _r = float2uint8(r);
53624
- const _g = float2uint8(g);
53625
- const _b = float2uint8(b);
53620
+ const _r = float_to_uint8(r);
53621
+ const _g = float_to_uint8(g);
53622
+ const _b = float_to_uint8(b);
53626
53623
 
53627
53624
  return (_b & 0xFF)
53628
53625
  | (_g & 0xFF) << 8
@@ -53630,7 +53627,18 @@ function rgb2uint24(r, g, b) {
53630
53627
  ;
53631
53628
  }
53632
53629
 
53633
- function convert(c) {
53630
+ /**
53631
+ *
53632
+ * @param {number} r
53633
+ * @param {number} g
53634
+ * @param {number} b
53635
+ * @return {number}
53636
+ */
53637
+ function rgb_to_luminance(r, g, b) {
53638
+ return 0.299 * r + 0.587 * g + 0.114 * b;
53639
+ }
53640
+
53641
+ function convert_channel_linear_to_sRGB(c) {
53634
53642
  if (c < 0.0031308) {
53635
53643
  return c * 12.92;
53636
53644
  } else {
@@ -53653,9 +53661,9 @@ function linear_to_sRGB(
53653
53661
  const g = input[input_offset + 1];
53654
53662
  const b = input[input_offset + 2];
53655
53663
 
53656
- output[output_offset] = convert(r);
53657
- output[output_offset + 1] = convert(g);
53658
- output[output_offset + 2] = convert(b);
53664
+ output[output_offset] = convert_channel_linear_to_sRGB(r);
53665
+ output[output_offset + 1] = convert_channel_linear_to_sRGB(g);
53666
+ output[output_offset + 2] = convert_channel_linear_to_sRGB(b);
53659
53667
  }
53660
53668
 
53661
53669
  /**
@@ -53829,9 +53837,9 @@ class Color {
53829
53837
  */
53830
53838
  setRGBUint8(r, g, b) {
53831
53839
  this.setRGB(
53832
- uint82float(r),
53833
- uint82float(g),
53834
- uint82float(b),
53840
+ uint8_to_float(r),
53841
+ uint8_to_float(g),
53842
+ uint8_to_float(b),
53835
53843
  );
53836
53844
  }
53837
53845
 
@@ -54084,11 +54092,15 @@ class Color {
54084
54092
  * @return {number}
54085
54093
  */
54086
54094
  computeLuminance() {
54087
- return 0.299 * this.r + 0.587 * this.g + 0.114 * this.b;
54095
+ return rgb_to_luminance(this.r, this.g, this.b);
54088
54096
  }
54089
54097
 
54090
54098
  getHSV() {
54091
- return rgb2hsv(this.r * 255, this.g * 255, this.b * 255);
54099
+ return rgb2hsv(
54100
+ this.r,
54101
+ this.g,
54102
+ this.b
54103
+ );
54092
54104
  }
54093
54105
 
54094
54106
  /**
@@ -54120,9 +54132,9 @@ class Color {
54120
54132
  */
54121
54133
  toHex() {
54122
54134
  return '#' + rgb2hex(
54123
- float2uint8(this.r),
54124
- float2uint8(this.g),
54125
- float2uint8(this.b)
54135
+ float_to_uint8(this.r),
54136
+ float_to_uint8(this.g),
54137
+ float_to_uint8(this.b)
54126
54138
  );
54127
54139
  }
54128
54140
 
@@ -54131,7 +54143,7 @@ class Color {
54131
54143
  * @returns {string}
54132
54144
  */
54133
54145
  toCssRGBAString() {
54134
- return `rgba(${float2uint8(this.r)},${float2uint8(this.g)},${float2uint8(this.b)},${this.a})`;
54146
+ return `rgba(${float_to_uint8(this.r)},${float_to_uint8(this.g)},${float_to_uint8(this.b)},${this.a})`;
54135
54147
  }
54136
54148
 
54137
54149
  /**
@@ -56747,11 +56759,13 @@ class AABB3 {
56747
56759
  * Get center position of the box
56748
56760
  * @param {Vector3} target where to write result
56749
56761
  */
56750
- getCenter(target) {
56762
+ getCenter(target = new Vector3$1()) {
56751
56763
  const x = this.getCenterX();
56752
56764
  const y = this.getCenterY();
56753
56765
  const z = this.getCenterZ();
56754
56766
  target.set(x, y, z);
56767
+
56768
+ return target;
56755
56769
  }
56756
56770
 
56757
56771
 
@@ -63056,72 +63070,137 @@ const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
63056
63070
  * @param {string} path
63057
63071
  * @return {string}
63058
63072
  */
63059
- function convertPathToURL(path) {
63073
+ function localPathToGlobal(path) {
63074
+ /**
63075
+ * @type {Window|DedicatedWorkerGlobalScope}
63076
+ */
63077
+ let scope;
63060
63078
 
63061
- if (!isGlobalPath(path)) {
63079
+ if (ENVIRONMENT_IS_WEB) {
63080
+ scope = window;
63081
+ } else if (ENVIRONMENT_IS_WORKER) {
63082
+ scope = self;
63083
+ } else if (ENVIRONMENT_IS_NODE) {
63062
63084
 
63063
- /**
63064
- * @type {Window|DedicatedWorkerGlobalScope}
63065
- */
63066
- let scope;
63085
+ let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63067
63086
 
63068
- if (ENVIRONMENT_IS_WEB) {
63069
- scope = window;
63070
- } else if (ENVIRONMENT_IS_WORKER) {
63071
- scope = self;
63072
- } else if (ENVIRONMENT_IS_NODE) {
63087
+ // remove multiple sequential slashes
63088
+ normalized_path = normalized_path.replace(/\/+/g, '/');
63073
63089
 
63074
- let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63075
-
63076
- // remove multiple sequential slashes
63077
- normalized_path = normalized_path.replace(/\/+/g, '/');
63090
+ if (normalized_path[0] !== '/') {
63091
+ // Windows drive letter must be prefixed with a slash.
63092
+ normalized_path = `/${normalized_path}`;
63093
+ }
63078
63094
 
63079
- if (normalized_path[0] !== '/') {
63080
- // Windows drive letter must be prefixed with a slash.
63081
- normalized_path = `/${normalized_path}`;
63095
+ scope = {
63096
+ location: {
63097
+ pathname: normalized_path,
63098
+ host: '',
63099
+ protocol: 'file:'
63082
63100
  }
63101
+ };
63102
+ } else {
63103
+ throw new Error('Unknown environment');
63104
+ }
63083
63105
 
63084
- scope = {
63085
- location: {
63086
- pathname: normalized_path,
63087
- host: '',
63088
- protocol: 'file:'
63089
- }
63090
- };
63106
+ const location = scope.location;
63107
+ const pathname = location.pathname;
63108
+
63109
+ let directoryPath;
63110
+
63111
+ /*
63112
+ path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63113
+ we need to extract directory to load relative path
63114
+ */
63115
+
63116
+ if (pathname.endsWith('/')) {
63117
+ //path is to a directory, strip last slash
63118
+ directoryPath = pathname.substring(0, pathname.length - 1);
63119
+ } else {
63120
+ //path is to a file
63121
+ const i = pathname.lastIndexOf('/');
63122
+
63123
+ if (i === -1) {
63124
+ //root level file
63125
+ directoryPath = "";
63091
63126
  } else {
63092
- throw new Error('Unknown environment');
63127
+ directoryPath = pathname.substring(0, i);
63093
63128
  }
63129
+ }
63094
63130
 
63095
- const location = scope.location;
63096
- const pathname = location.pathname;
63131
+ const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63132
+ return urlBase + path;
63133
+ }
63097
63134
 
63098
- let directoryPath;
63135
+ /**
63136
+ * Given a path, which may be a local path, produce a fully qualified URL
63137
+ * @example '/path' -> 'http://example.com/path'
63138
+ * @example 'some/local/path' -> 'http://example.com/current_path/some/local/path'
63139
+ * @param {string} path
63140
+ * @return {string}
63141
+ */
63142
+ function convertPathToURL(path) {
63099
63143
 
63100
- /*
63101
- path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63102
- we need to extract directory to load relative path
63103
- */
63144
+ const is_global = isGlobalPath(path);
63104
63145
 
63105
- if (pathname.endsWith('/')) {
63106
- //path is to a directory, strip last slash
63107
- directoryPath = pathname.substring(0, pathname.length - 1);
63108
- } else {
63109
- //path is to a file
63110
- const i = pathname.lastIndexOf('/');
63146
+ let result = path;
63111
63147
 
63112
- if (i === -1) {
63113
- //root level file
63114
- directoryPath = "";
63115
- } else {
63116
- directoryPath = pathname.substring(0, i);
63117
- }
63148
+ if (!is_global) {
63149
+ result = localPathToGlobal(path);
63150
+ }
63151
+
63152
+ return result;
63153
+ }
63154
+
63155
+ /**
63156
+ *
63157
+ * @param {string} code
63158
+ * @param {string} [mime_type]
63159
+ * @return {Blob}
63160
+ */
63161
+ function codeToBlob(code, mime_type = 'application/javascript') {
63162
+
63163
+ let blob;
63164
+
63165
+ if (typeof globalThis.Blob !== "undefined") {
63166
+ blob = new Blob([code], { type: mime_type });
63167
+ } else {
63168
+ // Backwards-compatibility
63169
+ const BlobBuilder = globalThis.BlobBuilder
63170
+ || globalThis.BlobBuilder
63171
+ || globalThis.WebKitBlobBuilder
63172
+ || globalThis.MozBlobBuilder;
63173
+
63174
+ if (BlobBuilder !== undefined) {
63175
+ blob = new BlobBuilder();
63176
+ blob.append(code);
63177
+ blob = blob.getBlob();
63178
+ } else {
63179
+ throw new Error(`No BlobBuilder interface supported in current context`);
63118
63180
  }
63119
63181
 
63120
- const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63121
- path = urlBase + path;
63122
63182
  }
63123
63183
 
63124
- return path;
63184
+
63185
+ return blob;
63186
+ }
63187
+
63188
+ /**
63189
+ *
63190
+ * @param {string} code
63191
+ * @param {string} [mime_type]
63192
+ * @return {string}
63193
+ */
63194
+ function codeToURL(code, mime_type = 'application/javascript') {
63195
+
63196
+ const blob = codeToBlob(code, mime_type);
63197
+
63198
+ if (blob !== undefined && URL.createObjectURL !== undefined) {
63199
+ return URL.createObjectURL(blob);
63200
+ } else {
63201
+ // build data URL in a slowest way possible
63202
+ return `data:${mime_type},${encodeURIComponent(code)}`;
63203
+ }
63125
63204
  }
63126
63205
 
63127
63206
  class Line {
@@ -63577,6 +63656,7 @@ class WorkerProxy {
63577
63656
 
63578
63657
  const RxMatchFunctionName = /(function\s*)([a-zA-Z0-9_]+)?(\s*\([^\]]*\)\s*\{.*)/g;
63579
63658
 
63659
+
63580
63660
  class WorkerBuilder {
63581
63661
 
63582
63662
  imports = [];
@@ -63619,9 +63699,9 @@ class WorkerBuilder {
63619
63699
  * @param {string} path
63620
63700
  */
63621
63701
  importScript(path) {
63622
- path = convertPathToURL(path);
63702
+ const qualified_path = convertPathToURL(path);
63623
63703
 
63624
- this.imports.push(path);
63704
+ this.imports.push(qualified_path);
63625
63705
  }
63626
63706
 
63627
63707
  /**
@@ -63631,7 +63711,7 @@ class WorkerBuilder {
63631
63711
  build() {
63632
63712
  const codeLines = [];
63633
63713
 
63634
- codeLines.push('var globalScope = this;');
63714
+ codeLines.push('var globalScope = globalThis;');
63635
63715
 
63636
63716
  //handle imports
63637
63717
  this.imports.forEach(function (url) {
@@ -63732,37 +63812,6 @@ class WorkerBuilder {
63732
63812
 
63733
63813
  return new WorkerProxy(workerURL, this.methods);
63734
63814
  }
63735
- }
63736
- /**
63737
- *
63738
- * @param {string} code
63739
- * @return {string}
63740
- */
63741
- function codeToURL(code) {
63742
- const js_mime = 'application/javascript';
63743
-
63744
- let blob;
63745
-
63746
- if (typeof window === 'object') {
63747
- if (typeof window.Blob !== "undefined") {
63748
- blob = new Blob([code], {type: js_mime});
63749
- } else {
63750
- // Backwards-compatibility
63751
- const BlobBuilder = window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
63752
- if (BlobBuilder !== undefined) {
63753
- blob = new BlobBuilder();
63754
- blob.append(code);
63755
- blob = blob.getBlob();
63756
- }
63757
- }
63758
- }
63759
-
63760
- if (blob !== undefined && URL.createObjectURL !== undefined) {
63761
- return URL.createObjectURL(blob);
63762
- } else {
63763
- // build data URL in a slowest way possible
63764
- return `data:${js_mime},${encodeURIComponent(code)}`;
63765
- }
63766
63815
  }
63767
63816
 
63768
63817
  /**
@@ -67677,20 +67726,19 @@ class AssetLoader {
67677
67726
  function observeResponseProgress(input, progress) {
67678
67727
  let response = input;
67679
67728
 
67680
-
67681
- if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
67729
+ // Workaround: Checking if response.body === undefined for Alipay browser
67730
+ if (typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined) {
67682
67731
 
67683
67732
  return response;
67684
67733
 
67685
67734
  }
67686
67735
 
67687
- /**
67688
- * @type {ReadableStreamDefaultReader<Uint8Array>}
67689
- */
67690
- const reader = response.body.getReader();
67736
+ // Nginx needs X-File-Size check
67737
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
67738
+ const contentLength = response.headers.get('Content-Length') || response.headers.get('X-File-Size');
67691
67739
 
67692
- const contentLength = response.headers.get('Content-Length');
67693
67740
  const total = contentLength ? parseInt(contentLength) : 0;
67741
+
67694
67742
  let loaded = 0;
67695
67743
 
67696
67744
  // periodically read data into the new stream tracking while download progress
@@ -67698,6 +67746,11 @@ function observeResponseProgress(input, progress) {
67698
67746
  type: "bytes",
67699
67747
  start(controller) {
67700
67748
 
67749
+ /**
67750
+ * @type {ReadableStreamDefaultReader<Uint8Array>}
67751
+ */
67752
+ const reader = response.body.getReader();
67753
+
67701
67754
  pump();
67702
67755
 
67703
67756
  function pump() {
@@ -67715,6 +67768,7 @@ function observeResponseProgress(input, progress) {
67715
67768
  progress(loaded, total);
67716
67769
 
67717
67770
  controller.enqueue(value);
67771
+
67718
67772
  pump();
67719
67773
 
67720
67774
  });
@@ -67786,16 +67840,13 @@ class ArrayBufferLoader extends AssetLoader {
67786
67840
 
67787
67841
  let response = await fetch(request);
67788
67842
 
67789
- if (!(response.status === 200 || response.status === 0)) {
67843
+ const response_status = response.status;
67790
67844
 
67791
- throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
67845
+ if (response_status !== 200 && response_status !== 0) {
67792
67846
 
67793
- }
67847
+ throw Error(`fetch for "${response.url}" responded with ${response_status}: ${response.statusText}`);
67794
67848
 
67795
- // Some browsers return HTTP Status 0 when using non-http protocol
67796
- // e.g. 'file://' or 'data://'. Handle as success.
67797
-
67798
- if (response.status === 0) ;
67849
+ }
67799
67850
 
67800
67851
  try {
67801
67852
  response = observeResponseProgress(response, progress);
@@ -75578,6 +75629,9 @@ const TextureAttachmentsByMaterialType = {
75578
75629
  taDisplacement,
75579
75630
  taAlphaMap
75580
75631
  ],
75632
+ MeshBasicMaterial: [
75633
+ taDiffuse
75634
+ ],
75581
75635
  MeshStandardMaterial: [
75582
75636
  taDiffuse,
75583
75637
  taAlphaMap,
@@ -75663,7 +75717,9 @@ const TextureAttachmentsByMaterialType = {
75663
75717
  }
75664
75718
  })
75665
75719
  ]
75666
- };
75720
+ };
75721
+
75722
+ TextureAttachmentsByMaterialType.MeshPhysicalMaterial = TextureAttachmentsByMaterialType.MeshStandardMaterial;
75667
75723
 
75668
75724
  /**
75669
75725
  * Transfer bitmap contents to Sampler2D, effectively moving data to CPU, making it readable
@@ -90630,6 +90686,7 @@ class GraphicsEngine {
90630
90686
  const camera = this.camera;
90631
90687
 
90632
90688
  if (scene.children.indexOf(camera) < 0) {
90689
+ // console.log("added camera");
90633
90690
  scene.add(camera);
90634
90691
  }
90635
90692
 
@@ -105051,6 +105108,9 @@ class TopDownCameraController {
105051
105108
 
105052
105109
  this.distance = eye.distanceTo(target);
105053
105110
 
105111
+ // ensure we can maintain this distance
105112
+ this.distanceMax = max2(this.distance, this.distanceMax);
105113
+
105054
105114
  this.target.copy(target);
105055
105115
  }
105056
105116
 
@@ -112369,6 +112429,27 @@ function scene_object_filter(object3D) {
112369
112429
  return true;
112370
112430
  }
112371
112431
 
112432
+ /**
112433
+ *
112434
+ * @param {LightShadow} shadow
112435
+ * @param {number} resolution
112436
+ */
112437
+ function three_set_shadow_resolution(shadow, resolution) {
112438
+ const mapSize = shadow.mapSize;
112439
+
112440
+ if (mapSize.width !== resolution || mapSize.height !== resolution) {
112441
+
112442
+ mapSize.width = mapSize.height = resolution;
112443
+
112444
+ //destroy old map
112445
+ if (shadow.map !== null) {
112446
+ shadow.map.dispose(); // important
112447
+ shadow.map = null;
112448
+ }
112449
+
112450
+ }
112451
+ }
112452
+
112372
112453
  class ThreeLightBinding extends LightBinding {
112373
112454
 
112374
112455
  constructor() {
@@ -112633,17 +112714,7 @@ class ThreeLightBinding extends LightBinding {
112633
112714
  shadow.radius = 1;
112634
112715
  shadow.blurSamples = 8;
112635
112716
 
112636
- if (shadow.mapSize.width !== resolution || shadow.mapSize.height !== resolution) {
112637
-
112638
- shadow.mapSize.width = shadow.mapSize.height = resolution;
112639
-
112640
- //destroy old map
112641
- if (shadow.map !== null) {
112642
- shadow.map.dispose(); // important
112643
- shadow.map = null;
112644
- }
112645
-
112646
- }
112717
+ three_set_shadow_resolution(shadow, resolution);
112647
112718
 
112648
112719
  }
112649
112720
  }
@@ -113271,7 +113342,7 @@ class LightSystem extends AbstractContextSystem {
113271
113342
 
113272
113343
  l.castShadow = true;
113273
113344
 
113274
- updateShadowMap(this.__camera_object, l, this.__graphics);
113345
+ three_update_shadow_camera_extents(this.__camera_object, l, this.__graphics);
113275
113346
 
113276
113347
  } else {
113277
113348
 
@@ -113322,9 +113393,8 @@ const scratch_aabb3 = new AABB3();
113322
113393
  * @author Alex Goldring 02.06.2016 (Komrade)
113323
113394
  * @param {Camera} camera
113324
113395
  * @param {Light} light
113325
- * @param {GraphicsEngine} graphics
113326
113396
  */
113327
- function updateShadowMap(camera, light, graphics) {
113397
+ function three_update_shadow_camera_extents(camera, light) {
113328
113398
 
113329
113399
 
113330
113400
  // Fit shadow camera's ortho frustum to camera frustum
@@ -114546,6 +114616,8 @@ class InputControllerSystem extends System {
114546
114616
 
114547
114617
  this.devices = devices;
114548
114618
 
114619
+ // console.log("Input Controller System started. Devices: ", devices);
114620
+
114549
114621
  const self = this;
114550
114622
 
114551
114623
  this.enabled.onChanged.add(function (v) {
@@ -115575,6 +115647,12 @@ function setLocale(engine) {
115575
115647
  return engine.localization.loadLocale(locale);
115576
115648
  }
115577
115649
 
115650
+ /**
115651
+ * Equal to ~ 5500 K light color
115652
+ * @type {Readonly<Color>}
115653
+ */
115654
+ const DEFAULT_SUNLIGHT_COLOR = Object.freeze(new Color(1, 0.93, 0.87));
115655
+
115578
115656
  class EngineHarness {
115579
115657
  constructor() {
115580
115658
  /**
@@ -115842,12 +115920,21 @@ class EngineHarness {
115842
115920
  * @param {EntityComponentDataset} [param.ecd]
115843
115921
  * @param {number} [param.shadowmapResolution]
115844
115922
  * @param {boolean} [param.castShadow]
115923
+ * @param {Color} [param.sun]
115924
+ * @param {number} [param.sunIntensity]
115925
+ * @param {Color} [param.ambient]
115926
+ * @param {number} [param.ambientIntensity]
115845
115927
  */
115846
115928
  static async buildLights({
115847
115929
  engine,
115848
115930
  ecd = engine.entityManager.dataset,
115849
115931
  shadowmapResolution = 1024,
115850
- castShadow = true
115932
+ castShadow = true,
115933
+ sun = DEFAULT_SUNLIGHT_COLOR,
115934
+ sunIntensity = 0.9,
115935
+ sunDirection = new Vector3$1(0.1, -1, 0.1),
115936
+ ambient = Color.white,
115937
+ ambientIntensity = 0.1
115851
115938
  }) {
115852
115939
  const em = engine.entityManager;
115853
115940
 
@@ -115863,18 +115950,13 @@ class EngineHarness {
115863
115950
 
115864
115951
  const key = new Light();
115865
115952
  key.type.set(Light.Type.DIRECTION);
115866
- key.color.setRGB(1, 1, 1);
115867
- key.intensity.set(0.8);
115953
+ key.color.copy(sun);
115954
+ key.intensity.set(sunIntensity);
115868
115955
  key.castShadow.set(castShadow);
115869
115956
 
115870
115957
  const transform = new Transform();
115871
115958
  transform.position.set(30, 70, 30);
115872
- transform.rotation.set(
115873
- -0.18780341950959473,
115874
- 0.8049745556929917,
115875
- -0.4533975611897181,
115876
- -0.3334313787830773
115877
- );
115959
+ transform.rotation.lookRotation(sunDirection);
115878
115960
 
115879
115961
  new Entity()
115880
115962
  .add(key)
@@ -115885,8 +115967,8 @@ class EngineHarness {
115885
115967
 
115886
115968
  const fill = new Light();
115887
115969
  fill.type.set(Light.Type.AMBIENT);
115888
- fill.color.setRGB(1, 1, 1);
115889
- fill.intensity.set(0.1);
115970
+ fill.color.copy(ambient);
115971
+ fill.intensity.set(ambientIntensity);
115890
115972
 
115891
115973
 
115892
115974
  new Entity()
@@ -117664,4 +117746,4 @@ function v4_distance_sqr(
117664
117746
  return v4_length_sqr(x0 - x1, y0 - y1, z0 - z1, w0 - w1);
117665
117747
  }
117666
117748
 
117667
- export { AmbientOcclusionPostProcessEffect, Behavior, BehaviorStatus, Blackboard, Cache, EngineConfiguration, EngineHarness, ForwardPlusRenderingPlugin, HashMap, Light, ParallelBehavior, ParallelBehaviorPolicy, SGMesh, SGMeshSystem, SelectorBehavior, SequenceBehavior, ShadedGeometry, ShadedGeometrySystem, Signal, SignalBinding, Transform, dispatchViaProxy, findSignalHandlerIndexByHandle, findSignalHandlerIndexByHandleAndContext, find_path_on_grid_astar, quat3_createFromAxisAngle, v2_angle_between, v2_bearing_angle_towards, v2_distance, v2_dot, v2_length_sqr, v2_magnitude, v4_distance_sqr, v4_dot, v4_length_sqr, v4_multiply_mat4 };
117749
+ export { AmbientOcclusionPostProcessEffect, Behavior, BehaviorStatus, Blackboard, Cache, EngineConfiguration, EngineHarness, ForwardPlusRenderingPlugin, HashMap, Light, ParallelBehavior, ParallelBehaviorPolicy, SGMesh, SGMeshSystem, SelectorBehavior, SequenceBehavior, ShadedGeometry, ShadedGeometrySystem, Signal, SignalBinding, Transform, dispatchViaProxy, findSignalHandlerIndexByHandle, findSignalHandlerIndexByHandleAndContext, find_path_on_grid_astar, quat3_createFromAxisAngle, three_update_shadow_camera_extents, v2_angle_between, v2_bearing_angle_towards, v2_distance, v2_dot, v2_length_sqr, v2_magnitude, v4_distance_sqr, v4_dot, v4_length_sqr, v4_multiply_mat4 };