@woosh/meep-engine 2.108.0 → 2.108.3

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 (216) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +650 -308
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +650 -308
  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/uint8_to_float.d.ts +7 -0
  11. package/src/core/binary/uint8_to_float.d.ts.map +1 -0
  12. package/src/core/binary/{uint82float.js → uint8_to_float.js} +1 -1
  13. package/src/core/binary/uint8_to_float.spec.d.ts +2 -0
  14. package/src/core/binary/uint8_to_float.spec.d.ts.map +1 -0
  15. package/src/core/binary/uint8_to_float.spec.js +7 -0
  16. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts +6 -0
  17. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  18. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +15 -3
  19. package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +3 -3
  20. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  21. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +25 -14
  22. package/src/core/codegen/codeToBlob.d.ts +8 -0
  23. package/src/core/codegen/codeToBlob.d.ts.map +1 -0
  24. package/src/core/codegen/codeToBlob.js +36 -0
  25. package/src/core/codegen/codeToURL.d.ts +8 -0
  26. package/src/core/codegen/codeToURL.d.ts.map +1 -0
  27. package/src/core/codegen/codeToURL.js +22 -0
  28. package/src/core/collection/array/arrayQuickSort.d.ts +0 -9
  29. package/src/core/collection/array/arrayQuickSort.d.ts.map +1 -1
  30. package/src/core/collection/array/arrayQuickSort.js +0 -73
  31. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts +10 -0
  32. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts.map +1 -0
  33. package/src/core/collection/array/array_quick_sort_by_comparator.js +75 -0
  34. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +8 -0
  35. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +1 -0
  36. package/src/core/collection/array/array_quick_sort_by_lookup.js +78 -0
  37. package/src/core/collection/array/array_shuffle.d.ts +8 -0
  38. package/src/core/collection/array/array_shuffle.d.ts.map +1 -0
  39. package/src/core/collection/array/array_shuffle.js +22 -0
  40. package/src/core/collection/array/array_shuffle.spec.d.ts +2 -0
  41. package/src/core/collection/array/array_shuffle.spec.d.ts.map +1 -0
  42. package/src/core/collection/array/{randomizeArrayElementOrder.spec.js → array_shuffle.spec.js} +4 -4
  43. package/src/core/collection/array/iterator/ArrayIteratorRandom.js +2 -2
  44. package/src/core/collection/array/randomMultipleFromArray.js +2 -2
  45. package/src/core/color/Color.js +9 -9
  46. package/src/core/color/hsv/hsv2rgb.js +4 -4
  47. package/src/core/color/rgb2uint24.js +4 -4
  48. package/src/core/color/sRGB/linear_to_sRGB.d.ts +1 -0
  49. package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
  50. package/src/core/color/sRGB/linear_to_sRGB.js +4 -4
  51. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +15 -0
  52. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -0
  53. package/src/core/geom/2d/triangle2d_get_barycentric.js +48 -0
  54. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  55. package/src/core/geom/3d/aabb/AABB3.js +4 -1
  56. package/src/core/geom/3d/aabb/aabb3_from_v3_array.d.ts.map +1 -1
  57. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +2 -7
  58. package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +3 -3
  59. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts +11 -0
  60. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts.map +1 -0
  61. package/src/core/geom/3d/aabb3_compute_from_triangle.js +43 -0
  62. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  63. package/src/core/geom/3d/shape/UnitSphereShape3D.js +14 -14
  64. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts.map +1 -1
  65. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js +2 -0
  66. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +5 -5
  67. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts +9 -0
  68. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts.map +1 -0
  69. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.js +17 -0
  70. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +6 -3
  71. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  72. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +56 -18
  73. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts +1 -1
  74. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts.map +1 -1
  75. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.js +11 -4
  76. package/src/core/geom/3d/tetrahedra/{GetDepthForTetrahedronProbe.glsl → triangle/GetDepthForTetrahedronProbe.glsl} +17 -10
  77. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts +2 -0
  78. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts.map +1 -0
  79. package/src/core/geom/3d/tetrahedra/triangle/prototype.js +128 -0
  80. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts +13 -0
  81. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -0
  82. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +120 -0
  83. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +3 -0
  84. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -0
  85. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +106 -0
  86. package/src/core/geom/Vector3.js +3 -3
  87. package/src/core/geom/random/randomPointInSphere.d.ts +1 -1
  88. package/src/core/geom/random/randomPointInSphere.js +2 -2
  89. package/src/core/geom/random/randomPointOnSphere.d.ts +3 -3
  90. package/src/core/geom/random/randomPointOnSphere.d.ts.map +1 -1
  91. package/src/core/geom/random/randomPointOnSphere.js +5 -9
  92. package/src/core/math/factorial.d.ts +7 -0
  93. package/src/core/math/factorial.d.ts.map +1 -0
  94. package/src/core/math/factorial.js +15 -0
  95. package/src/core/math/factorial.spec.d.ts +2 -0
  96. package/src/core/math/factorial.spec.d.ts.map +1 -0
  97. package/src/core/math/factorial.spec.js +9 -0
  98. package/src/core/model/DebouncedObservedBoolean.d.ts +1 -1
  99. package/src/core/model/DebouncedObservedBoolean.d.ts.map +1 -1
  100. package/src/core/model/node-graph/node/NodeDescription.d.ts +6 -4
  101. package/src/core/process/task/util/randomCountTask.js +3 -3
  102. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  103. package/src/core/process/worker/WorkerBuilder.js +5 -35
  104. package/src/engine/EngineHarness.d.ts.map +1 -1
  105. package/src/engine/EngineHarness.js +7 -1
  106. package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
  107. package/src/engine/asset/loaders/ArrayBufferLoader.js +17 -10
  108. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.d.ts.map +1 -1
  109. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +3 -0
  110. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  111. package/src/engine/asset/loaders/material/computeTextureEquality.js +8 -1
  112. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +4 -4
  113. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
  114. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +4 -0
  115. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.d.ts.map +1 -1
  116. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js +3 -1
  117. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
  118. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +7 -7
  119. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts +8 -0
  120. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts.map +1 -0
  121. package/src/engine/graphics/filter/{FlipArrayInPlace.js → sampler2d_flipY_in_place.js} +1 -1
  122. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.d.ts.map +1 -1
  123. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js +5 -27
  124. package/src/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +3 -3
  125. package/src/engine/graphics/render/Lines.d.ts.map +1 -1
  126. package/src/engine/graphics/render/Lines.js +10 -2
  127. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +1 -1
  128. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -6
  129. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts +24 -0
  130. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -0
  131. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +293 -0
  132. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts +6 -0
  133. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +1 -0
  134. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +71 -0
  135. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts +6 -0
  136. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +1 -0
  137. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +256 -0
  138. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +4 -4
  139. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +3 -1
  140. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  141. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +12 -1
  142. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  143. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +4 -5
  144. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +2 -1
  145. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  146. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +6 -6
  147. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +8 -0
  148. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  149. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +3 -2
  150. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  151. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +9 -4
  152. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +3 -3
  153. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  154. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
  155. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts +2 -2
  156. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +1 -1
  157. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +18 -8
  158. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +14 -6
  159. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts +10 -0
  160. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts.map +1 -0
  161. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.js +20 -0
  162. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts +10 -0
  163. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts.map +1 -0
  164. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.js +31 -0
  165. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts +9 -0
  166. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts.map +1 -0
  167. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.js +21 -0
  168. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +1 -1
  169. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts.map +1 -1
  170. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.js +2 -3
  171. package/src/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +4 -4
  172. package/src/engine/graphics/sh3/prototypeSH3Probe.js +116 -19
  173. package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
  174. package/src/engine/graphics/texture/AttributeDataTexture.js +8 -2
  175. package/src/engine/graphics/texture/computeThreeTextureFormat.js +2 -1
  176. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts +7 -0
  177. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts.map +1 -0
  178. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.js +13 -0
  179. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts +9 -0
  180. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts.map +1 -0
  181. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.js +31 -0
  182. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  183. package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -4
  184. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
  185. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +47 -19
  186. package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.js +5 -33
  187. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts +11 -0
  188. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts.map +1 -0
  189. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.js +41 -0
  190. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts +0 -4
  191. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts.map +1 -1
  192. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.js +19 -30
  193. package/src/engine/network/convertPathToURL.d.ts +3 -1
  194. package/src/engine/network/convertPathToURL.d.ts.map +1 -1
  195. package/src/engine/network/convertPathToURL.js +68 -51
  196. package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
  197. package/src/engine/physics/fluid/SliceVisualiser.js +4 -4
  198. package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
  199. package/src/generation/filtering/numeric/CellFilterCache.js +1 -0
  200. package/src/core/binary/float2uint8.d.ts +0 -7
  201. package/src/core/binary/float2uint8.d.ts.map +0 -1
  202. package/src/core/binary/uint82float.d.ts +0 -7
  203. package/src/core/binary/uint82float.d.ts.map +0 -1
  204. package/src/core/binary/uint82float.spec.d.ts +0 -2
  205. package/src/core/binary/uint82float.spec.d.ts.map +0 -1
  206. package/src/core/binary/uint82float.spec.js +0 -7
  207. package/src/core/collection/array/randomizeArrayElementOrder.d.ts +0 -8
  208. package/src/core/collection/array/randomizeArrayElementOrder.d.ts.map +0 -1
  209. package/src/core/collection/array/randomizeArrayElementOrder.js +0 -24
  210. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts +0 -2
  211. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts.map +0 -1
  212. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts +0 -8
  213. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts.map +0 -1
  214. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +0 -3
  215. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +0 -1
  216. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +0 -3
package/build/meep.cjs CHANGED
@@ -2870,10 +2870,10 @@ let Vector3$1 = class Vector3 {
2870
2870
  }
2871
2871
 
2872
2872
  /**
2873
- *
2873
+ * Convert spherical coordinates to cartesian
2874
2874
  * @param {number} radius
2875
- * @param {number} phi
2876
- * @param {number} theta
2875
+ * @param {number} phi Also known as Azimuth
2876
+ * @param {number} theta Also known as Elevation
2877
2877
  */
2878
2878
  setFromSphericalCoords(radius, phi, theta) {
2879
2879
 
@@ -49540,7 +49540,7 @@ class Sampler2D {
49540
49540
  *
49541
49541
  * @param {number} u
49542
49542
  * @param {number} v
49543
- * @param {number[]} result
49543
+ * @param {number[]|Float32Array} result
49544
49544
  * @param {number} result_offset
49545
49545
  */
49546
49546
  sampleBilinearUV(u, v, result, result_offset = 0) {
@@ -49608,8 +49608,8 @@ class Sampler2D {
49608
49608
  const clamped_x = clamp$1(x, 0, x_max);
49609
49609
  const clamped_y = clamp$1(y, 0, y_max);
49610
49610
 
49611
- const x0 = clamped_x | 0;
49612
- const y0 = clamped_y | 0;
49611
+ const x0 = clamped_x >>> 0;
49612
+ const y0 = clamped_y >>> 0;
49613
49613
 
49614
49614
  //
49615
49615
  const row0 = y0 * rowSize;
@@ -49670,7 +49670,7 @@ class Sampler2D {
49670
49670
  *
49671
49671
  * @param {number} u
49672
49672
  * @param {number} v
49673
- * @param {ArrayLike<number>} result
49673
+ * @param {number[]|ArrayLike<number>} result
49674
49674
  */
49675
49675
  sampleNearestUV(u, v, result) {
49676
49676
  const w = this.width;
@@ -50290,7 +50290,7 @@ const WHITE_PIXEL_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA
50290
50290
  * @param {number} v
50291
50291
  * @returns {number}
50292
50292
  */
50293
- function float2uint8(v) {
50293
+ function float_to_uint8(v) {
50294
50294
  return Math.round(v * 255);
50295
50295
  }
50296
50296
 
@@ -50299,7 +50299,7 @@ function float2uint8(v) {
50299
50299
  * @param {number} v
50300
50300
  * @returns {number}
50301
50301
  */
50302
- function uint82float(v) {
50302
+ function uint8_to_float(v) {
50303
50303
  return v / 255;
50304
50304
  }
50305
50305
 
@@ -51698,7 +51698,7 @@ class TerrainOverlay {
51698
51698
  for (let i = 0; i < 4; i++) {
51699
51699
  const v = this.sampler.readChannel(x, y, i);
51700
51700
 
51701
- result[i] = uint82float(v);
51701
+ result[i] = uint8_to_float(v);
51702
51702
  }
51703
51703
  }
51704
51704
 
@@ -51745,7 +51745,7 @@ class TerrainOverlay {
51745
51745
  paintPoint(x, y, vec4) {
51746
51746
  for (let i = 0; i < 4; i++) {
51747
51747
 
51748
- this.sampler.writeChannel(x, y, i, float2uint8(vec4[i]));
51748
+ this.sampler.writeChannel(x, y, i, float_to_uint8(vec4[i]));
51749
51749
 
51750
51750
  }
51751
51751
 
@@ -53222,7 +53222,7 @@ function aabb3_intersects_ray(
53222
53222
  const diff_x = origin_x - center_x;
53223
53223
 
53224
53224
 
53225
- if (diff_x * direction_x >= 0.0 && abs(diff_x) > extents_x) {
53225
+ if (diff_x * direction_x >= 0 && abs(diff_x) > extents_x) {
53226
53226
  return false;
53227
53227
  }
53228
53228
 
@@ -53234,7 +53234,7 @@ function aabb3_intersects_ray(
53234
53234
  const diff_y = origin_y - center_y;
53235
53235
 
53236
53236
 
53237
- if (diff_y * direction_y >= 0.0 && abs(diff_y) > extents_y) {
53237
+ if (diff_y * direction_y >= 0 && abs(diff_y) > extents_y) {
53238
53238
  return false;
53239
53239
  }
53240
53240
 
@@ -53246,7 +53246,7 @@ function aabb3_intersects_ray(
53246
53246
  const diff_z = origin_z - center_z;
53247
53247
 
53248
53248
 
53249
- if (diff_z * direction_z >= 0.0 && abs(diff_z) > extents_z) {
53249
+ if (diff_z * direction_z >= 0 && abs(diff_z) > extents_z) {
53250
53250
  return false;
53251
53251
  }
53252
53252
 
@@ -53272,7 +53272,7 @@ function aabb3_intersects_ray(
53272
53272
  return f2 <= extents_x * abs_direction_y + extents_y * abs_direction_x;
53273
53273
  }
53274
53274
 
53275
- const stack$9 = SCRATCH_UINT32_TRAVERSAL_STACK;
53275
+ const stack$a = SCRATCH_UINT32_TRAVERSAL_STACK;
53276
53276
 
53277
53277
 
53278
53278
  /**
@@ -53305,9 +53305,9 @@ function bvh_query_leaves_ray(
53305
53305
  *
53306
53306
  * @type {number}
53307
53307
  */
53308
- const stack_top = stack$9.pointer++;
53308
+ const stack_top = stack$a.pointer++;
53309
53309
 
53310
- stack$9[stack_top] = root;
53310
+ stack$a[stack_top] = root;
53311
53311
 
53312
53312
  let result_cursor = result_offset;
53313
53313
 
@@ -53318,13 +53318,13 @@ function bvh_query_leaves_ray(
53318
53318
  const uint32 = bvh.__data_uint32;
53319
53319
 
53320
53320
  do {
53321
- stack$9.pointer--;
53321
+ stack$a.pointer--;
53322
53322
 
53323
53323
  /**
53324
53324
  *
53325
53325
  * @type {number}
53326
53326
  */
53327
- const node = stack$9[stack$9.pointer];
53327
+ const node = stack$a[stack$a.pointer];
53328
53328
 
53329
53329
  const address = node * ELEMENT_WORD_COUNT;
53330
53330
 
@@ -53346,15 +53346,15 @@ function bvh_query_leaves_ray(
53346
53346
  if (child_1 !== NULL_NODE) {
53347
53347
 
53348
53348
  // this is not a leaf node, push children onto traversal stack
53349
- stack$9[stack$9.pointer++] = uint32[address + COLUMN_CHILD_2];
53350
- stack$9[stack$9.pointer++] = child_1;
53349
+ stack$a[stack$a.pointer++] = uint32[address + COLUMN_CHILD_2];
53350
+ stack$a[stack$a.pointer++] = child_1;
53351
53351
 
53352
53352
  } else {
53353
53353
  // leaf node
53354
53354
 
53355
53355
  result[result_cursor++] = node;
53356
53356
  }
53357
- } while (stack$9.pointer > stack_top);
53357
+ } while (stack$a.pointer > stack_top);
53358
53358
 
53359
53359
  return result_cursor - result_offset;
53360
53360
  }
@@ -53526,9 +53526,9 @@ function hsv2rgb(h, s, v) {
53526
53526
  break;
53527
53527
  }
53528
53528
  return {
53529
- r: float2uint8(r),
53530
- g: float2uint8(g),
53531
- b: float2uint8(b)
53529
+ r: float_to_uint8(r),
53530
+ g: float_to_uint8(g),
53531
+ b: float_to_uint8(b)
53532
53532
  };
53533
53533
  }
53534
53534
 
@@ -53619,9 +53619,9 @@ function parse_color(c) {
53619
53619
  * @returns {number}
53620
53620
  */
53621
53621
  function rgb2uint24(r, g, b) {
53622
- const _r = float2uint8(r);
53623
- const _g = float2uint8(g);
53624
- 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);
53625
53625
 
53626
53626
  return (_b & 0xFF)
53627
53627
  | (_g & 0xFF) << 8
@@ -53640,7 +53640,7 @@ function rgb_to_luminance(r, g, b) {
53640
53640
  return 0.299 * r + 0.587 * g + 0.114 * b;
53641
53641
  }
53642
53642
 
53643
- function convert(c) {
53643
+ function convert_channel_linear_to_sRGB(c) {
53644
53644
  if (c < 0.0031308) {
53645
53645
  return c * 12.92;
53646
53646
  } else {
@@ -53663,9 +53663,9 @@ function linear_to_sRGB(
53663
53663
  const g = input[input_offset + 1];
53664
53664
  const b = input[input_offset + 2];
53665
53665
 
53666
- output[output_offset] = convert(r);
53667
- output[output_offset + 1] = convert(g);
53668
- 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);
53669
53669
  }
53670
53670
 
53671
53671
  /**
@@ -53839,9 +53839,9 @@ class Color {
53839
53839
  */
53840
53840
  setRGBUint8(r, g, b) {
53841
53841
  this.setRGB(
53842
- uint82float(r),
53843
- uint82float(g),
53844
- uint82float(b),
53842
+ uint8_to_float(r),
53843
+ uint8_to_float(g),
53844
+ uint8_to_float(b),
53845
53845
  );
53846
53846
  }
53847
53847
 
@@ -54134,9 +54134,9 @@ class Color {
54134
54134
  */
54135
54135
  toHex() {
54136
54136
  return '#' + rgb2hex(
54137
- float2uint8(this.r),
54138
- float2uint8(this.g),
54139
- float2uint8(this.b)
54137
+ float_to_uint8(this.r),
54138
+ float_to_uint8(this.g),
54139
+ float_to_uint8(this.b)
54140
54140
  );
54141
54141
  }
54142
54142
 
@@ -54145,7 +54145,7 @@ class Color {
54145
54145
  * @returns {string}
54146
54146
  */
54147
54147
  toCssRGBAString() {
54148
- 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})`;
54149
54149
  }
54150
54150
 
54151
54151
  /**
@@ -55234,7 +55234,7 @@ function build_morton(data, address, bounds) {
55234
55234
 
55235
55235
  }
55236
55236
 
55237
- const stack$8 = SCRATCH_UINT32_TRAVERSAL_STACK;
55237
+ const stack$9 = SCRATCH_UINT32_TRAVERSAL_STACK;
55238
55238
 
55239
55239
  class BinaryUint32BVH {
55240
55240
  /**
@@ -55376,6 +55376,18 @@ class BinaryUint32BVH {
55376
55376
 
55377
55377
  }
55378
55378
 
55379
+ /**
55380
+ *
55381
+ * @param {number} index
55382
+ * @return {number}
55383
+ */
55384
+ getLeafAddress(index) {
55385
+
55386
+ const leaf_block_address = this.__node_count_binary * BVH_BINARY_NODE_SIZE;
55387
+
55388
+ return index * BVH_LEAF_NODE_SIZE + leaf_block_address;
55389
+ }
55390
+
55379
55391
  /**
55380
55392
  *
55381
55393
  * @param {number} index
@@ -55393,9 +55405,7 @@ class BinaryUint32BVH {
55393
55405
  x1, y1, z1
55394
55406
  ) {
55395
55407
 
55396
- const leaf_block_address = this.__node_count_binary * BVH_BINARY_NODE_SIZE;
55397
-
55398
- const address = index * BVH_LEAF_NODE_SIZE + leaf_block_address;
55408
+ const address = this.getLeafAddress(index);
55399
55409
 
55400
55410
  aabb3_array_set(
55401
55411
  this.__data_float32,
@@ -55535,16 +55545,16 @@ class BinaryUint32BVH {
55535
55545
  let stackPointer = 2;
55536
55546
  let i, j;
55537
55547
 
55538
- stack$8[0] = 0; // first node
55539
- stack$8[1] = this.__node_count_leaf - 1; // last node
55548
+ stack$9[0] = 0; // first node
55549
+ stack$9[1] = this.__node_count_leaf - 1; // last node
55540
55550
 
55541
55551
  const data = this.__data_float32;
55542
55552
 
55543
55553
  while (stackPointer > 0) {
55544
55554
  stackPointer -= 2;
55545
55555
 
55546
- const right = stack$8[stackPointer + 1];
55547
- const left = stack$8[stackPointer];
55556
+ const right = stack$9[stackPointer + 1];
55557
+ const left = stack$9[stackPointer];
55548
55558
 
55549
55559
  i = left;
55550
55560
  j = right;
@@ -55579,12 +55589,12 @@ class BinaryUint32BVH {
55579
55589
 
55580
55590
  /* recursion */
55581
55591
  if (left < j) {
55582
- stack$8[stackPointer++] = left;
55583
- stack$8[stackPointer++] = j;
55592
+ stack$9[stackPointer++] = left;
55593
+ stack$9[stackPointer++] = j;
55584
55594
  }
55585
55595
  if (i < right) {
55586
- stack$8[stackPointer++] = i;
55587
- stack$8[stackPointer++] = right;
55596
+ stack$9[stackPointer++] = i;
55597
+ stack$9[stackPointer++] = right;
55588
55598
  }
55589
55599
  }
55590
55600
  }
@@ -56761,11 +56771,13 @@ class AABB3 {
56761
56771
  * Get center position of the box
56762
56772
  * @param {Vector3} target where to write result
56763
56773
  */
56764
- getCenter(target) {
56774
+ getCenter(target = new Vector3$1()) {
56765
56775
  const x = this.getCenterX();
56766
56776
  const y = this.getCenterY();
56767
56777
  const z = this.getCenterZ();
56768
56778
  target.set(x, y, z);
56779
+
56780
+ return target;
56769
56781
  }
56770
56782
 
56771
56783
 
@@ -57180,7 +57192,7 @@ function aabb3_array_intersects_ray(
57180
57192
  );
57181
57193
  }
57182
57194
 
57183
- const stack$7 = SCRATCH_UINT32_TRAVERSAL_STACK;
57195
+ const stack$8 = SCRATCH_UINT32_TRAVERSAL_STACK;
57184
57196
 
57185
57197
  /**
57186
57198
  *
@@ -57214,13 +57226,13 @@ function bvh32_query_user_data_ray(
57214
57226
  *
57215
57227
  * @type {number}
57216
57228
  */
57217
- const stack_top = stack$7.pointer++;
57229
+ const stack_top = stack$8.pointer++;
57218
57230
 
57219
57231
  /**
57220
57232
  * After performing empirical tests, stack-based depth-first traversal turns out faster than using a queue
57221
57233
  * @type {number}
57222
57234
  */
57223
- stack$7[stack_top] = 0;
57235
+ stack$8[stack_top] = 0;
57224
57236
 
57225
57237
  const last_valid_index = binary_node_count + bvh.leaf_node_count;
57226
57238
 
@@ -57228,10 +57240,10 @@ function bvh32_query_user_data_ray(
57228
57240
  const uint32 = bvh.uint32;
57229
57241
 
57230
57242
  do {
57231
- stack$7.pointer--;
57243
+ stack$8.pointer--;
57232
57244
 
57233
57245
  // query_bvh_frustum_from_objects.iteration_count++;
57234
- const node_index = stack$7[stack$7.pointer];
57246
+ const node_index = stack$8[stack$8.pointer];
57235
57247
 
57236
57248
  const node_address = bvh.getNodeAddress(node_index);
57237
57249
 
@@ -57253,11 +57265,11 @@ function bvh32_query_user_data_ray(
57253
57265
 
57254
57266
  // left node ends up on top of the stack, which aligns with the desired access sequence
57255
57267
  if (right_index < last_valid_index) {
57256
- stack$7[stack$7.pointer++] = right_index;
57268
+ stack$8[stack$8.pointer++] = right_index;
57257
57269
  // micro-optimization, since we know that right node is valid and left appears before that, left is valid too
57258
- stack$7[stack$7.pointer++] = left_index;
57270
+ stack$8[stack$8.pointer++] = left_index;
57259
57271
  } else if (left_index < last_valid_index) {
57260
- stack$7[stack$7.pointer++] = left_index;
57272
+ stack$8[stack$8.pointer++] = left_index;
57261
57273
  }
57262
57274
 
57263
57275
 
@@ -57270,7 +57282,7 @@ function bvh32_query_user_data_ray(
57270
57282
  hit_count++;
57271
57283
  }
57272
57284
 
57273
- } while (stack$7.pointer > stack_top)
57285
+ } while (stack$8.pointer > stack_top)
57274
57286
 
57275
57287
  return hit_count;
57276
57288
  }
@@ -63070,72 +63082,137 @@ const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
63070
63082
  * @param {string} path
63071
63083
  * @return {string}
63072
63084
  */
63073
- function convertPathToURL(path) {
63074
-
63075
- if (!isGlobalPath(path)) {
63085
+ function localPathToGlobal(path) {
63086
+ /**
63087
+ * @type {Window|DedicatedWorkerGlobalScope}
63088
+ */
63089
+ let scope;
63076
63090
 
63077
- /**
63078
- * @type {Window|DedicatedWorkerGlobalScope}
63079
- */
63080
- let scope;
63091
+ if (ENVIRONMENT_IS_WEB) {
63092
+ scope = window;
63093
+ } else if (ENVIRONMENT_IS_WORKER) {
63094
+ scope = self;
63095
+ } else if (ENVIRONMENT_IS_NODE) {
63081
63096
 
63082
- if (ENVIRONMENT_IS_WEB) {
63083
- scope = window;
63084
- } else if (ENVIRONMENT_IS_WORKER) {
63085
- scope = self;
63086
- } else if (ENVIRONMENT_IS_NODE) {
63097
+ let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63087
63098
 
63088
- let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63099
+ // remove multiple sequential slashes
63100
+ normalized_path = normalized_path.replace(/\/+/g, '/');
63089
63101
 
63090
- // remove multiple sequential slashes
63091
- normalized_path = normalized_path.replace(/\/+/g, '/');
63102
+ if (normalized_path[0] !== '/') {
63103
+ // Windows drive letter must be prefixed with a slash.
63104
+ normalized_path = `/${normalized_path}`;
63105
+ }
63092
63106
 
63093
- if (normalized_path[0] !== '/') {
63094
- // Windows drive letter must be prefixed with a slash.
63095
- normalized_path = `/${normalized_path}`;
63107
+ scope = {
63108
+ location: {
63109
+ pathname: normalized_path,
63110
+ host: '',
63111
+ protocol: 'file:'
63096
63112
  }
63113
+ };
63114
+ } else {
63115
+ throw new Error('Unknown environment');
63116
+ }
63097
63117
 
63098
- scope = {
63099
- location: {
63100
- pathname: normalized_path,
63101
- host: '',
63102
- protocol: 'file:'
63103
- }
63104
- };
63118
+ const location = scope.location;
63119
+ const pathname = location.pathname;
63120
+
63121
+ let directoryPath;
63122
+
63123
+ /*
63124
+ path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63125
+ we need to extract directory to load relative path
63126
+ */
63127
+
63128
+ if (pathname.endsWith('/')) {
63129
+ //path is to a directory, strip last slash
63130
+ directoryPath = pathname.substring(0, pathname.length - 1);
63131
+ } else {
63132
+ //path is to a file
63133
+ const i = pathname.lastIndexOf('/');
63134
+
63135
+ if (i === -1) {
63136
+ //root level file
63137
+ directoryPath = "";
63105
63138
  } else {
63106
- throw new Error('Unknown environment');
63139
+ directoryPath = pathname.substring(0, i);
63107
63140
  }
63141
+ }
63108
63142
 
63109
- const location = scope.location;
63110
- const pathname = location.pathname;
63143
+ const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63144
+ return urlBase + path;
63145
+ }
63111
63146
 
63112
- let directoryPath;
63147
+ /**
63148
+ * Given a path, which may be a local path, produce a fully qualified URL
63149
+ * @example '/path' -> 'http://example.com/path'
63150
+ * @example 'some/local/path' -> 'http://example.com/current_path/some/local/path'
63151
+ * @param {string} path
63152
+ * @return {string}
63153
+ */
63154
+ function convertPathToURL(path) {
63113
63155
 
63114
- /*
63115
- path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63116
- we need to extract directory to load relative path
63117
- */
63156
+ const is_global = isGlobalPath(path);
63118
63157
 
63119
- if (pathname.endsWith('/')) {
63120
- //path is to a directory, strip last slash
63121
- directoryPath = pathname.substring(0, pathname.length - 1);
63122
- } else {
63123
- //path is to a file
63124
- const i = pathname.lastIndexOf('/');
63158
+ let result = path;
63125
63159
 
63126
- if (i === -1) {
63127
- //root level file
63128
- directoryPath = "";
63129
- } else {
63130
- directoryPath = pathname.substring(0, i);
63131
- }
63160
+ if (!is_global) {
63161
+ result = localPathToGlobal(path);
63162
+ }
63163
+
63164
+ return result;
63165
+ }
63166
+
63167
+ /**
63168
+ *
63169
+ * @param {string} code
63170
+ * @param {string} [mime_type]
63171
+ * @return {Blob}
63172
+ */
63173
+ function codeToBlob(code, mime_type = 'application/javascript') {
63174
+
63175
+ let blob;
63176
+
63177
+ if (typeof globalThis.Blob !== "undefined") {
63178
+ blob = new Blob([code], { type: mime_type });
63179
+ } else {
63180
+ // Backwards-compatibility
63181
+ const BlobBuilder = globalThis.BlobBuilder
63182
+ || globalThis.BlobBuilder
63183
+ || globalThis.WebKitBlobBuilder
63184
+ || globalThis.MozBlobBuilder;
63185
+
63186
+ if (BlobBuilder !== undefined) {
63187
+ blob = new BlobBuilder();
63188
+ blob.append(code);
63189
+ blob = blob.getBlob();
63190
+ } else {
63191
+ throw new Error(`No BlobBuilder interface supported in current context`);
63132
63192
  }
63133
63193
 
63134
- const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63135
- path = urlBase + path;
63136
63194
  }
63137
63195
 
63138
- return path;
63196
+
63197
+ return blob;
63198
+ }
63199
+
63200
+ /**
63201
+ *
63202
+ * @param {string} code
63203
+ * @param {string} [mime_type]
63204
+ * @return {string}
63205
+ */
63206
+ function codeToURL(code, mime_type = 'application/javascript') {
63207
+
63208
+ const blob = codeToBlob(code, mime_type);
63209
+
63210
+ if (blob !== undefined && URL.createObjectURL !== undefined) {
63211
+ return URL.createObjectURL(blob);
63212
+ } else {
63213
+ // build data URL in a slowest way possible
63214
+ return `data:${mime_type},${encodeURIComponent(code)}`;
63215
+ }
63139
63216
  }
63140
63217
 
63141
63218
  class Line {
@@ -63591,6 +63668,7 @@ class WorkerProxy {
63591
63668
 
63592
63669
  const RxMatchFunctionName = /(function\s*)([a-zA-Z0-9_]+)?(\s*\([^\]]*\)\s*\{.*)/g;
63593
63670
 
63671
+
63594
63672
  class WorkerBuilder {
63595
63673
 
63596
63674
  imports = [];
@@ -63633,9 +63711,9 @@ class WorkerBuilder {
63633
63711
  * @param {string} path
63634
63712
  */
63635
63713
  importScript(path) {
63636
- path = convertPathToURL(path);
63714
+ const qualified_path = convertPathToURL(path);
63637
63715
 
63638
- this.imports.push(path);
63716
+ this.imports.push(qualified_path);
63639
63717
  }
63640
63718
 
63641
63719
  /**
@@ -63645,7 +63723,7 @@ class WorkerBuilder {
63645
63723
  build() {
63646
63724
  const codeLines = [];
63647
63725
 
63648
- codeLines.push('var globalScope = this;');
63726
+ codeLines.push('var globalScope = globalThis;');
63649
63727
 
63650
63728
  //handle imports
63651
63729
  this.imports.forEach(function (url) {
@@ -63746,37 +63824,6 @@ class WorkerBuilder {
63746
63824
 
63747
63825
  return new WorkerProxy(workerURL, this.methods);
63748
63826
  }
63749
- }
63750
- /**
63751
- *
63752
- * @param {string} code
63753
- * @return {string}
63754
- */
63755
- function codeToURL(code) {
63756
- const js_mime = 'application/javascript';
63757
-
63758
- let blob;
63759
-
63760
- if (typeof window === 'object') {
63761
- if (typeof window.Blob !== "undefined") {
63762
- blob = new Blob([code], {type: js_mime});
63763
- } else {
63764
- // Backwards-compatibility
63765
- const BlobBuilder = window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
63766
- if (BlobBuilder !== undefined) {
63767
- blob = new BlobBuilder();
63768
- blob.append(code);
63769
- blob = blob.getBlob();
63770
- }
63771
- }
63772
- }
63773
-
63774
- if (blob !== undefined && URL.createObjectURL !== undefined) {
63775
- return URL.createObjectURL(blob);
63776
- } else {
63777
- // build data URL in a slowest way possible
63778
- return `data:${js_mime},${encodeURIComponent(code)}`;
63779
- }
63780
63827
  }
63781
63828
 
63782
63829
  /**
@@ -65846,14 +65893,17 @@ function read_three_planes_to_array(planes, array) {
65846
65893
 
65847
65894
  /**
65848
65895
  *
65849
- * @param {BinaryUint32BVH} bvh
65850
- * @param {number} triangle_index
65896
+ * @param {number[]|Float32Array} output
65897
+ * @param {number} output_offset
65851
65898
  * @param {number[]|Float32Array} vertices
65852
65899
  * @param {number} a_index
65853
65900
  * @param {number} b_index
65854
65901
  * @param {number} c_index
65855
65902
  */
65856
- function bvh32_set_leaf_from_triangle(bvh, triangle_index, vertices, a_index, b_index, c_index) {
65903
+ function aabb3_compute_from_triangle(
65904
+ output, output_offset,
65905
+ vertices, a_index, b_index, c_index
65906
+ ) {
65857
65907
  const a = a_index * 3;
65858
65908
  const b = b_index * 3;
65859
65909
  const c = c_index * 3;
@@ -65872,15 +65922,31 @@ function bvh32_set_leaf_from_triangle(bvh, triangle_index, vertices, a_index, b_
65872
65922
  const cZ = vertices[c + 2];
65873
65923
 
65874
65924
  // compute bounds of the triangle
65875
- const x0 = min3(aX, bX, cX);
65876
- const y0 = min3(aY, bY, cY);
65877
- const z0 = min3(aZ, bZ, cZ);
65925
+ output[output_offset] = min3(aX, bX, cX);
65926
+ output[output_offset + 1] = min3(aY, bY, cY);
65927
+ output[output_offset + 2] = min3(aZ, bZ, cZ);
65878
65928
 
65879
- const x1 = max3(aX, bX, cX);
65880
- const y1 = max3(aY, bY, cY);
65881
- const z1 = max3(aZ, bZ, cZ);
65929
+ output[output_offset + 3] = max3(aX, bX, cX);
65930
+ output[output_offset + 4] = max3(aY, bY, cY);
65931
+ output[output_offset + 5] = max3(aZ, bZ, cZ);
65932
+
65933
+ }
65934
+
65935
+ /**
65936
+ *
65937
+ * @param {BinaryUint32BVH} bvh
65938
+ * @param {number} triangle_index
65939
+ * @param {number[]|Float32Array} vertices
65940
+ * @param {number} a_index
65941
+ * @param {number} b_index
65942
+ * @param {number} c_index
65943
+ */
65944
+ function bvh32_set_leaf_from_triangle(bvh, triangle_index, vertices, a_index, b_index, c_index) {
65945
+
65946
+ const address = bvh.getLeafAddress(triangle_index);
65947
+ aabb3_compute_from_triangle(bvh.__data_float32, address, vertices, a_index, b_index, c_index);
65948
+ bvh.__data_uint32[address + 6] = triangle_index;
65882
65949
 
65883
- bvh.setLeafData(triangle_index, triangle_index, x0, y0, z0, x1, y1, z1);
65884
65950
  }
65885
65951
 
65886
65952
  /**
@@ -66008,7 +66074,7 @@ function aabb3_array_intersects_clipping_volume_array(
66008
66074
  );
66009
66075
  }
66010
66076
 
66011
- const stack$6 = SCRATCH_UINT32_TRAVERSAL_STACK;
66077
+ const stack$7 = SCRATCH_UINT32_TRAVERSAL_STACK;
66012
66078
 
66013
66079
  /**
66014
66080
  *
@@ -66038,13 +66104,13 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66038
66104
  *
66039
66105
  * @type {number}
66040
66106
  */
66041
- const stack_top = stack$6.pointer++;
66107
+ const stack_top = stack$7.pointer++;
66042
66108
 
66043
66109
  /**
66044
66110
  * After performing empirical tests, stack-based depth-first traversal turns out faster than using a queue
66045
66111
  * @type {number}
66046
66112
  */
66047
- stack$6[stack_top] = 0;
66113
+ stack$7[stack_top] = 0;
66048
66114
 
66049
66115
  const last_valid_index = binary_node_count + bvh.leaf_node_count;
66050
66116
 
@@ -66052,10 +66118,10 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66052
66118
  const uint32 = bvh.uint32;
66053
66119
 
66054
66120
  do {
66055
- stack$6.pointer--;
66121
+ stack$7.pointer--;
66056
66122
 
66057
66123
  // query_bvh_frustum_from_objects.iteration_count++;
66058
- const node_index = stack$6[stack$6.pointer];
66124
+ const node_index = stack$7[stack$7.pointer];
66059
66125
 
66060
66126
  const node_address = bvh.getNodeAddress(node_index);
66061
66127
 
@@ -66076,11 +66142,11 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66076
66142
 
66077
66143
  // left node ends up on top of the stack, which aligns with the desired access sequence
66078
66144
  if (right_index < last_valid_index) {
66079
- stack$6[stack$6.pointer++] = right_index;
66145
+ stack$7[stack$7.pointer++] = right_index;
66080
66146
  // micro-optimization, since we know that right node is valid and left appears before that, left is valid too
66081
- stack$6[stack$6.pointer++] = left_index;
66147
+ stack$7[stack$7.pointer++] = left_index;
66082
66148
  } else if (left_index < last_valid_index) {
66083
- stack$6[stack$6.pointer++] = left_index;
66149
+ stack$7[stack$7.pointer++] = left_index;
66084
66150
  }
66085
66151
 
66086
66152
 
@@ -66093,7 +66159,7 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66093
66159
  hit_count++;
66094
66160
  }
66095
66161
 
66096
- } while (stack$6.pointer > stack_top)
66162
+ } while (stack$7.pointer > stack_top)
66097
66163
 
66098
66164
  return hit_count;
66099
66165
  }
@@ -67204,7 +67270,7 @@ function aabb3_array_intersects_frustum_degree(aabb, frustum) {
67204
67270
  //
67205
67271
 
67206
67272
 
67207
- const stack$5 = SCRATCH_UINT32_TRAVERSAL_STACK;
67273
+ const stack$6 = SCRATCH_UINT32_TRAVERSAL_STACK;
67208
67274
 
67209
67275
  /**
67210
67276
  *
@@ -67227,20 +67293,20 @@ function bvh_collect_user_data(
67227
67293
  *
67228
67294
  * @type {number}
67229
67295
  */
67230
- const stack_top = stack$5.pointer++;
67296
+ const stack_top = stack$6.pointer++;
67231
67297
 
67232
- stack$5[stack_top] = root;
67298
+ stack$6[stack_top] = root;
67233
67299
 
67234
67300
  let result_cursor = destination_offset;
67235
67301
 
67236
- while (stack$5.pointer > stack_top) {
67237
- stack$5.pointer--;
67302
+ while (stack$6.pointer > stack_top) {
67303
+ stack$6.pointer--;
67238
67304
 
67239
67305
  /**
67240
67306
  *
67241
67307
  * @type {number}
67242
67308
  */
67243
- const node = stack$5[stack$5.pointer];
67309
+ const node = stack$6[stack$6.pointer];
67244
67310
 
67245
67311
  const node_is_leaf = bvh.node_is_leaf(node);
67246
67312
 
@@ -67251,8 +67317,8 @@ function bvh_collect_user_data(
67251
67317
  const child2 = bvh.node_get_child2(node);
67252
67318
 
67253
67319
  // write to stack in reverse order, so that fist child ends up being visited first
67254
- stack$5[stack$5.pointer++] = child1;
67255
- stack$5[stack$5.pointer++] = child2;
67320
+ stack$6[stack$6.pointer++] = child1;
67321
+ stack$6[stack$6.pointer++] = child2;
67256
67322
 
67257
67323
  } else {
67258
67324
  // leaf root
@@ -67268,7 +67334,7 @@ function bvh_collect_user_data(
67268
67334
 
67269
67335
  //
67270
67336
 
67271
- const stack$4 = SCRATCH_UINT32_TRAVERSAL_STACK;
67337
+ const stack$5 = SCRATCH_UINT32_TRAVERSAL_STACK;
67272
67338
 
67273
67339
  const scratch_aabb$1 = new Float32Array(6);
67274
67340
 
@@ -67295,20 +67361,20 @@ function bvh_query_user_data_overlaps_frustum(
67295
67361
  *
67296
67362
  * @type {number}
67297
67363
  */
67298
- const stack_top = stack$4.pointer++;
67364
+ const stack_top = stack$5.pointer++;
67299
67365
 
67300
- stack$4[stack_top] = root;
67366
+ stack$5[stack_top] = root;
67301
67367
 
67302
67368
  let result_cursor = result_offset;
67303
67369
 
67304
- while (stack$4.pointer > stack_top) {
67305
- stack$4.pointer--;
67370
+ while (stack$5.pointer > stack_top) {
67371
+ stack$5.pointer--;
67306
67372
 
67307
67373
  /**
67308
67374
  *
67309
67375
  * @type {number}
67310
67376
  */
67311
- const node = stack$4[stack$4.pointer];
67377
+ const node = stack$5[stack$5.pointer];
67312
67378
 
67313
67379
  // test node against the ray
67314
67380
  bvh.node_get_aabb(node, scratch_aabb$1);
@@ -67335,8 +67401,8 @@ function bvh_query_user_data_overlaps_frustum(
67335
67401
  const child2 = bvh.node_get_child2(node);
67336
67402
 
67337
67403
  // write to stack in reverse order, so that fist child ends up being visited first
67338
- stack$4[stack$4.pointer++] = child1;
67339
- stack$4[stack$4.pointer++] = child2;
67404
+ stack$5[stack$5.pointer++] = child1;
67405
+ stack$5[stack$5.pointer++] = child2;
67340
67406
  }
67341
67407
  }
67342
67408
 
@@ -67397,7 +67463,7 @@ function computeFileExtension(path) {
67397
67463
  * @param {number} height
67398
67464
  * @param {number} channel_count
67399
67465
  */
67400
- function flipArrayInPlace(input, width, height, channel_count = 4) {
67466
+ function sampler2d_flipY_in_place(input, width, height, channel_count = 4) {
67401
67467
  const row_size = width * channel_count;
67402
67468
  let t, x0, x1;
67403
67469
  let i = 0;
@@ -67468,6 +67534,235 @@ const CopyShader = {
67468
67534
 
67469
67535
  };
67470
67536
 
67537
+ /**
67538
+ *
67539
+ * @param {number} format
67540
+ * @returns {number}
67541
+ */
67542
+ function formatToChannelCount(format) {
67543
+ switch (format) {
67544
+ case RedFormat:
67545
+ case RedIntegerFormat:
67546
+ return 1;
67547
+ case RGFormat:
67548
+ return 2;
67549
+ case RGBFormat:
67550
+ return 3;
67551
+ case RGBAFormat:
67552
+ return 4;
67553
+ default:
67554
+ throw new Error(`Unsupported format '${format}'`);
67555
+ }
67556
+ }
67557
+
67558
+ /**
67559
+ *
67560
+ * @param {Uint8Array|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array} array
67561
+ * @return {boolean}
67562
+ */
67563
+ function typed_array_is_integer(array) {
67564
+ const ctor = array.constructor;
67565
+
67566
+ return ctor === Uint8ClampedArray
67567
+ || ctor === Uint8Array
67568
+ || ctor === Uint16Array
67569
+ || ctor === Uint32Array
67570
+ || ctor === Int8Array
67571
+ || ctor === Int16Array
67572
+ || ctor === Int32Array
67573
+ ;
67574
+ }
67575
+
67576
+ /**
67577
+ * Applies a linear polynomial transform to each value of a given channel
67578
+ * @param {Sampler2D} output
67579
+ * @param {Sampler2D} input
67580
+ * @param {number} output_channel_index
67581
+ * @param {number} input_channel_index
67582
+ * @param {number} gradient
67583
+ * @param {number} intercept
67584
+ */
67585
+ function sampler2d_channel_linear_transform(
67586
+ output, input,
67587
+ output_channel_index, input_channel_index,
67588
+ gradient, intercept
67589
+ ) {
67590
+
67591
+ const input_width = input.width;
67592
+ const input_height = input.height;
67593
+
67594
+ const output_width = output.width;
67595
+ const output_height = output.height;
67596
+
67597
+ if (
67598
+ input_width !== output_width
67599
+ || input_height !== output_height
67600
+ ) {
67601
+ throw new Error('Dimensions of input and output are incompatible');
67602
+ }
67603
+
67604
+ const input_item_size = input.itemSize;
67605
+ const output_item_size = output.itemSize;
67606
+
67607
+ const input_data = input.data;
67608
+ const output_data = output.data;
67609
+
67610
+ const pixel_count = input_width * input_height;
67611
+
67612
+
67613
+ if (typed_array_is_integer(output_data)) {
67614
+
67615
+ for (let i = 0; i < pixel_count; i++) {
67616
+
67617
+ const input_address = i * input_item_size + input_channel_index;
67618
+ const output_address = i * output_item_size + output_channel_index;
67619
+
67620
+ const input_value = input_data[input_address];
67621
+
67622
+ output_data[output_address] = Math.round(input_value * gradient + intercept);
67623
+
67624
+ }
67625
+
67626
+ } else {
67627
+
67628
+ for (let i = 0; i < pixel_count; i++) {
67629
+
67630
+ const input_address = i * input_item_size + input_channel_index;
67631
+ const output_address = i * output_item_size + output_channel_index;
67632
+
67633
+ const input_value = input_data[input_address];
67634
+
67635
+ output_data[output_address] = input_value * gradient + intercept;
67636
+
67637
+ }
67638
+
67639
+ }
67640
+
67641
+ }
67642
+
67643
+ function compute_gradient_and_intercept_uint8(ctor) {
67644
+ let gradient = 1;
67645
+ let intercept = 0;
67646
+
67647
+ switch (ctor) {
67648
+ case Uint16Array:
67649
+ gradient = 0.0038910505836575876;
67650
+ break;
67651
+ case Uint32Array:
67652
+ gradient = 5.937181414556033e-8;
67653
+ break;
67654
+ case Int8Array:
67655
+ gradient = 1;
67656
+ intercept = 127;
67657
+ break
67658
+ case Int16Array:
67659
+ gradient = 0.0038910505836575876;
67660
+ intercept = 127;
67661
+ break;
67662
+ case Int32Array:
67663
+ gradient = 5.937181414556033e-8;
67664
+ intercept = 127;
67665
+ break
67666
+ case Float32Array:
67667
+ case Float64Array:
67668
+ gradient = 255;
67669
+ break;
67670
+ // do nothing;
67671
+ }
67672
+
67673
+ return {
67674
+ gradient, intercept
67675
+ }
67676
+ }
67677
+
67678
+ /**
67679
+ * Many applications work with 8bit RGBA images, this utility function converts a given input to that format
67680
+ * @param {Sampler2D} input
67681
+ * @param {Sampler2D} output
67682
+ */
67683
+ function sampler2d_to_uint8_RGBA(output, input) {
67684
+ if (
67685
+ input.width !== output.width
67686
+ || input.height !== output.height
67687
+ ) {
67688
+ throw new Error('Dimensions of source and destination are incompatible');
67689
+ }
67690
+
67691
+ if (output.itemSize !== 4) {
67692
+ throw new Error(`Destination must have 4 channels exactly, instead got '${output.itemSize}'`);
67693
+ }
67694
+
67695
+ const { gradient, intercept } = compute_gradient_and_intercept_uint8(input.data.constructor);
67696
+
67697
+ const source_item_size = input.itemSize;
67698
+
67699
+ if (intercept === 0 && gradient === 1 && source_item_size === 4) {
67700
+ // already in the right format, use shortcut
67701
+ output.data.set(input.data);
67702
+ return;
67703
+ }
67704
+
67705
+ if (source_item_size === 1) {
67706
+
67707
+ // grayscale
67708
+
67709
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67710
+ sampler2d_channel_linear_transform(output, input, 1, 0, gradient, intercept);
67711
+ sampler2d_channel_linear_transform(output, input, 2, 0, gradient, intercept);
67712
+
67713
+ output.channelFill(3, 255);
67714
+
67715
+ } else if (source_item_size === 2) {
67716
+
67717
+ // grayscale with alpha
67718
+
67719
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67720
+ sampler2d_channel_linear_transform(output, input, 1, 0, gradient, intercept);
67721
+ sampler2d_channel_linear_transform(output, input, 2, 0, gradient, intercept);
67722
+ sampler2d_channel_linear_transform(output, input, 3, 1, gradient, intercept);
67723
+
67724
+ } else if (source_item_size === 3) {
67725
+
67726
+ // RGB
67727
+
67728
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67729
+ sampler2d_channel_linear_transform(output, input, 1, 1, gradient, intercept);
67730
+ sampler2d_channel_linear_transform(output, input, 2, 2, gradient, intercept);
67731
+
67732
+ output.channelFill(3, 255);
67733
+
67734
+ } else if (source_item_size === 4) {
67735
+
67736
+ // RGBA
67737
+
67738
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67739
+ sampler2d_channel_linear_transform(output, input, 1, 1, gradient, intercept);
67740
+ sampler2d_channel_linear_transform(output, input, 2, 2, gradient, intercept);
67741
+ sampler2d_channel_linear_transform(output, input, 3, 3, gradient, intercept);
67742
+
67743
+ }
67744
+ }
67745
+
67746
+ /**
67747
+ *
67748
+ * @param {Sampler2D} input
67749
+ * @returns {Sampler2D}
67750
+ */
67751
+ function sampler2d_ensure_uint8_RGBA(input) {
67752
+ if (
67753
+ input.itemSize === 4
67754
+ && (input.data.constructor === Uint8Array || input.data.constructor === Uint8ClampedArray)
67755
+ ) {
67756
+ return input;
67757
+ }
67758
+
67759
+ const resampled = Sampler2D.uint8(4, input.width, input.height);
67760
+
67761
+ sampler2d_to_uint8_RGBA(resampled, input);
67762
+
67763
+ return resampled;
67764
+ }
67765
+
67471
67766
  const DEFAULT_TEXTURE_WIDTH = 512;
67472
67767
  const DEFAULT_TEXTURE_HEIGHT = 512;
67473
67768
 
@@ -67488,6 +67783,8 @@ function convertTexture2Sampler2D(
67488
67783
  let _height = height;
67489
67784
  let _width = width;
67490
67785
 
67786
+ const channel_count = formatToChannelCount(texture.format);
67787
+
67491
67788
  // TODO take channel count into account
67492
67789
 
67493
67790
  if (_width === undefined || _height === undefined) {
@@ -67522,34 +67819,57 @@ function convertTexture2Sampler2D(
67522
67819
 
67523
67820
  }
67524
67821
 
67525
- // TODO add special case for DataTexture
67526
67822
 
67527
- const built = WebGLRendererPool.global.use(renderer => {
67823
+ let data;
67528
67824
 
67529
- const ctx = renderer.getContext();
67825
+ if (texture.isDataTexture === true) {
67530
67826
 
67531
- //support for compressed textures
67532
- ctx.getExtension("WEBGL_compressed_texture_s3tc");
67827
+ // special case
67828
+
67829
+ const source = new Sampler2D(texture.image.data, channel_count, texture.image.width, texture.image.height);
67830
+
67831
+ let converted = sampler2d_ensure_uint8_RGBA(source);
67832
+
67833
+ if (converted.width !== _width || converted.height !== _height) {
67834
+ const target = Sampler2D.uint8(4, _width, _height);
67835
+
67836
+ sampler2d_scale(converted, target);
67837
+
67838
+ converted = target;
67839
+ }
67840
+
67841
+ data = converted.data;
67842
+
67843
+ } else {
67844
+ const built = WebGLRendererPool.global.use(renderer => {
67845
+
67846
+ const ctx = renderer.getContext();
67847
+
67848
+ //support for compressed textures
67849
+ ctx.getExtension("WEBGL_compressed_texture_s3tc");
67850
+
67851
+ return processTexture(renderer, _width, _height, {
67852
+ vertexShader: CopyShader.vertexShader,
67853
+ fragmentShader: CopyShader.fragmentShader,
67854
+ uniforms: {
67855
+ tDiffuse: {
67856
+ value: texture,
67857
+ type: 't'
67858
+ },
67859
+ opacity: { value: 1.0 }
67860
+ }
67861
+ });
67533
67862
 
67534
- return processTexture(renderer, _width, _height, {
67535
- vertexShader: CopyShader.vertexShader,
67536
- fragmentShader: CopyShader.fragmentShader,
67537
- uniforms: {
67538
- tDiffuse: {
67539
- value: texture,
67540
- type: 't'
67541
- },
67542
- opacity: { value: 1.0 }
67543
- }
67544
67863
  });
67545
67864
 
67546
- });
67865
+ data = built.array;
67866
+ }
67547
67867
 
67548
67868
  if (flipY) {
67549
- flipArrayInPlace(built.array, _width, _height);
67869
+ sampler2d_flipY_in_place(data, _width, _height);
67550
67870
  }
67551
67871
 
67552
- return new Sampler2D(built.array, 4, _width, _height);
67872
+ return new Sampler2D(data, 4, _width, _height);
67553
67873
  }
67554
67874
 
67555
67875
  /**
@@ -67691,20 +68011,19 @@ class AssetLoader {
67691
68011
  function observeResponseProgress(input, progress) {
67692
68012
  let response = input;
67693
68013
 
67694
-
67695
- if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
68014
+ // Workaround: Checking if response.body === undefined for Alipay browser
68015
+ if (typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined) {
67696
68016
 
67697
68017
  return response;
67698
68018
 
67699
68019
  }
67700
68020
 
67701
- /**
67702
- * @type {ReadableStreamDefaultReader<Uint8Array>}
67703
- */
67704
- const reader = response.body.getReader();
68021
+ // Nginx needs X-File-Size check
68022
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
68023
+ const contentLength = response.headers.get('Content-Length') || response.headers.get('X-File-Size');
67705
68024
 
67706
- const contentLength = response.headers.get('Content-Length');
67707
68025
  const total = contentLength ? parseInt(contentLength) : 0;
68026
+
67708
68027
  let loaded = 0;
67709
68028
 
67710
68029
  // periodically read data into the new stream tracking while download progress
@@ -67712,6 +68031,11 @@ function observeResponseProgress(input, progress) {
67712
68031
  type: "bytes",
67713
68032
  start(controller) {
67714
68033
 
68034
+ /**
68035
+ * @type {ReadableStreamDefaultReader<Uint8Array>}
68036
+ */
68037
+ const reader = response.body.getReader();
68038
+
67715
68039
  pump();
67716
68040
 
67717
68041
  function pump() {
@@ -67729,6 +68053,7 @@ function observeResponseProgress(input, progress) {
67729
68053
  progress(loaded, total);
67730
68054
 
67731
68055
  controller.enqueue(value);
68056
+
67732
68057
  pump();
67733
68058
 
67734
68059
  });
@@ -67800,16 +68125,13 @@ class ArrayBufferLoader extends AssetLoader {
67800
68125
 
67801
68126
  let response = await fetch(request);
67802
68127
 
67803
- if (!(response.status === 200 || response.status === 0)) {
68128
+ const response_status = response.status;
67804
68129
 
67805
- throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
68130
+ if (response_status !== 200 && response_status !== 0) {
67806
68131
 
67807
- }
67808
-
67809
- // Some browsers return HTTP Status 0 when using non-http protocol
67810
- // e.g. 'file://' or 'data://'. Handle as success.
68132
+ throw Error(`fetch for "${response.url}" responded with ${response_status}: ${response.statusText}`);
67811
68133
 
67812
- if (response.status === 0) ;
68134
+ }
67813
68135
 
67814
68136
  try {
67815
68137
  response = observeResponseProgress(response, progress);
@@ -74740,7 +75062,7 @@ class SGMeshSystem extends System {
74740
75062
  }
74741
75063
  }
74742
75064
 
74743
- const stack$3 = SCRATCH_UINT32_TRAVERSAL_STACK;
75065
+ const stack$4 = SCRATCH_UINT32_TRAVERSAL_STACK;
74744
75066
 
74745
75067
  /**
74746
75068
  *
@@ -74764,20 +75086,20 @@ function bvh_query_leaves_generic(
74764
75086
  *
74765
75087
  * @type {number}
74766
75088
  */
74767
- const stack_top = stack$3.pointer++;
75089
+ const stack_top = stack$4.pointer++;
74768
75090
 
74769
- stack$3[stack_top] = root;
75091
+ stack$4[stack_top] = root;
74770
75092
 
74771
75093
  let result_cursor = result_offset;
74772
75094
 
74773
- while (stack$3.pointer > stack_top) {
74774
- stack$3.pointer--;
75095
+ while (stack$4.pointer > stack_top) {
75096
+ stack$4.pointer--;
74775
75097
 
74776
75098
  /**
74777
75099
  *
74778
75100
  * @type {number}
74779
75101
  */
74780
- const node = stack$3[stack$3.pointer];
75102
+ const node = stack$4[stack$4.pointer];
74781
75103
 
74782
75104
  // test node against the ray
74783
75105
  const pass = query.evaluate(node, bvh);
@@ -74795,8 +75117,8 @@ function bvh_query_leaves_generic(
74795
75117
  const child2 = bvh.node_get_child2(node);
74796
75118
 
74797
75119
  // write to stack in reverse order, so that fist child ends up being visited first
74798
- stack$3[stack$3.pointer++] = child2;
74799
- stack$3[stack$3.pointer++] = child1;
75120
+ stack$4[stack$4.pointer++] = child2;
75121
+ stack$4[stack$4.pointer++] = child1;
74800
75122
 
74801
75123
  } else {
74802
75124
  // leaf node
@@ -75104,85 +75426,11 @@ class RuntimeDrawMethodOptimizer {
75104
75426
  }
75105
75427
  }
75106
75428
 
75107
- const stack$2 = [];
75108
-
75109
- /**
75110
- * @template T
75111
- * @param {T[]|ArrayLike<number>|Uint32Array} data
75112
- * @param {function(T):number} score_function
75113
- * @param {*} score_function_context
75114
- * @param {number} start
75115
- * @param {number} end
75116
- * @param {function(T[],number, number):*} [swap_operator]
75117
- * @param {*} [swap_context]
75118
- */
75119
- function arrayQuickSort(
75120
- data,
75121
- score_function, score_function_context,
75122
- start, end,
75123
- swap_operator = array_swap_one, swap_context = undefined
75124
- ) {
75125
- if (start >= end) {
75126
- // section of 0 size, nothing to sort
75127
- return;
75128
- }
75129
-
75130
- let stackPointer = 2;
75131
- let i, j;
75132
-
75133
- stack$2[0] = start;
75134
- stack$2[1] = end;
75135
-
75136
- while (stackPointer > 0) {
75137
- stackPointer -= 2;
75138
-
75139
- const right = stack$2[stackPointer + 1];
75140
- const left = stack$2[stackPointer];
75141
-
75142
- i = left;
75143
- j = right;
75144
-
75145
- const pivotIndex = (left + right) >> 1;
75146
-
75147
- const pivot = score_function.call(score_function_context, data[pivotIndex]);
75148
-
75149
- /* partition */
75150
- while (i <= j) {
75151
- while (score_function.call(score_function_context, data[i]) < pivot) {
75152
- i++;
75153
- }
75154
-
75155
- while (score_function.call(score_function_context, data[j]) > pivot) {
75156
- j--;
75157
- }
75158
-
75159
- if (i <= j) {
75160
-
75161
- if (i !== j) {
75162
- //do swap
75163
- swap_operator.call(swap_context, data, i, j);
75164
- }
75165
-
75166
- i++;
75167
- j--;
75168
- }
75169
- }
75170
-
75171
- /* recursion */
75172
- if (left < j) {
75173
- stack$2[stackPointer++] = left;
75174
- stack$2[stackPointer++] = j;
75175
- }
75176
- if (i < right) {
75177
- stack$2[stackPointer++] = i;
75178
- stack$2[stackPointer++] = right;
75179
- }
75180
- }
75181
- }
75429
+ const stack$3 = [];
75182
75430
 
75183
75431
  /**
75184
75432
  * @template T
75185
- * @param {T[]} data
75433
+ * @param {T[]|Uint32Array} data
75186
75434
  * @param {function(T,T):number} compare_function
75187
75435
  * @param {*} compare_function_context
75188
75436
  * @param {number} start
@@ -75201,14 +75449,14 @@ function array_quick_sort_by_comparator(
75201
75449
  let stackPointer = 2;
75202
75450
  let i, j;
75203
75451
 
75204
- stack$2[0] = start;
75205
- stack$2[1] = end;
75452
+ stack$3[0] = start;
75453
+ stack$3[1] = end;
75206
75454
 
75207
75455
  while (stackPointer > 0) {
75208
75456
  stackPointer -= 2;
75209
75457
 
75210
- const right = stack$2[stackPointer + 1];
75211
- const left = stack$2[stackPointer];
75458
+ const right = stack$3[stackPointer + 1];
75459
+ const left = stack$3[stackPointer];
75212
75460
 
75213
75461
  i = left;
75214
75462
  j = right;
@@ -75244,12 +75492,12 @@ function array_quick_sort_by_comparator(
75244
75492
 
75245
75493
  /* recursion */
75246
75494
  if (left < j) {
75247
- stack$2[stackPointer++] = left;
75248
- stack$2[stackPointer++] = j;
75495
+ stack$3[stackPointer++] = left;
75496
+ stack$3[stackPointer++] = j;
75249
75497
  }
75250
75498
  if (i < right) {
75251
- stack$2[stackPointer++] = i;
75252
- stack$2[stackPointer++] = right;
75499
+ stack$3[stackPointer++] = i;
75500
+ stack$3[stackPointer++] = right;
75253
75501
  }
75254
75502
  }
75255
75503
  }
@@ -75592,6 +75840,9 @@ const TextureAttachmentsByMaterialType = {
75592
75840
  taDisplacement,
75593
75841
  taAlphaMap
75594
75842
  ],
75843
+ MeshBasicMaterial: [
75844
+ taDiffuse
75845
+ ],
75595
75846
  MeshStandardMaterial: [
75596
75847
  taDiffuse,
75597
75848
  taAlphaMap,
@@ -76167,6 +76418,12 @@ function textureImagesEqual(a, b) {
76167
76418
 
76168
76419
  }
76169
76420
 
76421
+ if (isTypedArray(a.data) && isTypedArray(b.data)) {
76422
+ if (!textureMipmapEqual(a, b)) {
76423
+ return false;
76424
+ }
76425
+ }
76426
+
76170
76427
  // assume equivalent
76171
76428
  return true;
76172
76429
  }
@@ -88112,7 +88369,7 @@ class ColorAndDepthFrameBuffer extends FrameBuffer {
88112
88369
  }
88113
88370
  }
88114
88371
 
88115
- const stack$1 = [];
88372
+ const stack$2 = [];
88116
88373
 
88117
88374
  class ThreeBypassRenderer {
88118
88375
  constructor() {
@@ -88189,13 +88446,13 @@ class ThreeBypassRenderer {
88189
88446
  const object3D = input[i];
88190
88447
 
88191
88448
  if (input_filter(object3D)) {
88192
- stack$1[stack_top++] = object3D;
88449
+ stack$2[stack_top++] = object3D;
88193
88450
  }
88194
88451
 
88195
88452
  }
88196
88453
 
88197
88454
  while (stack_top > 0) {
88198
- const object3D = stack$1[--stack_top];
88455
+ const object3D = stack$2[--stack_top];
88199
88456
 
88200
88457
  if (
88201
88458
  object_filter(object3D)
@@ -88234,7 +88491,7 @@ class ThreeBypassRenderer {
88234
88491
  for (i = 0; i < child_count; i++) {
88235
88492
  const child = children[i];
88236
88493
 
88237
- stack$1[stack_top++] = child;
88494
+ stack$2[stack_top++] = child;
88238
88495
  }
88239
88496
  }
88240
88497
 
@@ -105068,6 +105325,9 @@ class TopDownCameraController {
105068
105325
 
105069
105326
  this.distance = eye.distanceTo(target);
105070
105327
 
105328
+ // ensure we can maintain this distance
105329
+ this.distanceMax = max2(this.distance, this.distanceMax);
105330
+
105071
105331
  this.target.copy(target);
105072
105332
  }
105073
105333
 
@@ -105755,6 +106015,82 @@ function computeBinaryDataTypeByPrecision(type, precision) {
105755
106015
  throw new Error(`Unsupported numeric type(=${type}) and precision(=${precision}) combination`);
105756
106016
  }
105757
106017
 
106018
+ const stack$1 = [];
106019
+
106020
+ /**
106021
+ * @template T
106022
+ * @param {T[]|ArrayLike<number>|Uint32Array} data
106023
+ * @param {function(T):number} score_function
106024
+ * @param {*} score_function_context
106025
+ * @param {number} start
106026
+ * @param {number} end
106027
+ * @param {function(T[],number, number):*} [swap_operator]
106028
+ * @param {*} [swap_context]
106029
+ */
106030
+ function arrayQuickSort(
106031
+ data,
106032
+ score_function, score_function_context,
106033
+ start, end,
106034
+ swap_operator = array_swap_one, swap_context = undefined
106035
+ ) {
106036
+ if (start >= end) {
106037
+ // section of 0 size, nothing to sort
106038
+ return;
106039
+ }
106040
+
106041
+ let stackPointer = 2;
106042
+ let i, j;
106043
+
106044
+ stack$1[0] = start;
106045
+ stack$1[1] = end;
106046
+
106047
+ while (stackPointer > 0) {
106048
+ stackPointer -= 2;
106049
+
106050
+ const right = stack$1[stackPointer + 1];
106051
+ const left = stack$1[stackPointer];
106052
+
106053
+ i = left;
106054
+ j = right;
106055
+
106056
+ const pivotIndex = (left + right) >> 1;
106057
+
106058
+ const pivot = score_function.call(score_function_context, data[pivotIndex]);
106059
+
106060
+ /* partition */
106061
+ while (i <= j) {
106062
+ while (score_function.call(score_function_context, data[i]) < pivot) {
106063
+ i++;
106064
+ }
106065
+
106066
+ while (score_function.call(score_function_context, data[j]) > pivot) {
106067
+ j--;
106068
+ }
106069
+
106070
+ if (i <= j) {
106071
+
106072
+ if (i !== j) {
106073
+ //do swap
106074
+ swap_operator.call(swap_context, data, i, j);
106075
+ }
106076
+
106077
+ i++;
106078
+ j--;
106079
+ }
106080
+ }
106081
+
106082
+ /* recursion */
106083
+ if (left < j) {
106084
+ stack$1[stackPointer++] = left;
106085
+ stack$1[stackPointer++] = j;
106086
+ }
106087
+ if (i < right) {
106088
+ stack$1[stackPointer++] = i;
106089
+ stack$1[stackPointer++] = right;
106090
+ }
106091
+ }
106092
+ }
106093
+
105758
106094
  /**
105759
106095
  *
105760
106096
  * @param {number[]|Float32Array|Float64Array} source
@@ -115604,6 +115940,12 @@ function setLocale(engine) {
115604
115940
  return engine.localization.loadLocale(locale);
115605
115941
  }
115606
115942
 
115943
+ /**
115944
+ * Equal to ~ 5500 K light color
115945
+ * @type {Readonly<Color>}
115946
+ */
115947
+ const DEFAULT_SUNLIGHT_COLOR = Object.freeze(new Color(1, 0.93, 0.87));
115948
+
115607
115949
  class EngineHarness {
115608
115950
  constructor() {
115609
115951
  /**
@@ -115881,7 +116223,7 @@ class EngineHarness {
115881
116223
  ecd = engine.entityManager.dataset,
115882
116224
  shadowmapResolution = 1024,
115883
116225
  castShadow = true,
115884
- sun = Color.white,
116226
+ sun = DEFAULT_SUNLIGHT_COLOR,
115885
116227
  sunIntensity = 0.9,
115886
116228
  sunDirection = new Vector3$1(0.1, -1, 0.1),
115887
116229
  ambient = Color.white,