@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
@@ -2868,10 +2868,10 @@ let Vector3$1 = class Vector3 {
2868
2868
  }
2869
2869
 
2870
2870
  /**
2871
- *
2871
+ * Convert spherical coordinates to cartesian
2872
2872
  * @param {number} radius
2873
- * @param {number} phi
2874
- * @param {number} theta
2873
+ * @param {number} phi Also known as Azimuth
2874
+ * @param {number} theta Also known as Elevation
2875
2875
  */
2876
2876
  setFromSphericalCoords(radius, phi, theta) {
2877
2877
 
@@ -49538,7 +49538,7 @@ class Sampler2D {
49538
49538
  *
49539
49539
  * @param {number} u
49540
49540
  * @param {number} v
49541
- * @param {number[]} result
49541
+ * @param {number[]|Float32Array} result
49542
49542
  * @param {number} result_offset
49543
49543
  */
49544
49544
  sampleBilinearUV(u, v, result, result_offset = 0) {
@@ -49606,8 +49606,8 @@ class Sampler2D {
49606
49606
  const clamped_x = clamp$1(x, 0, x_max);
49607
49607
  const clamped_y = clamp$1(y, 0, y_max);
49608
49608
 
49609
- const x0 = clamped_x | 0;
49610
- const y0 = clamped_y | 0;
49609
+ const x0 = clamped_x >>> 0;
49610
+ const y0 = clamped_y >>> 0;
49611
49611
 
49612
49612
  //
49613
49613
  const row0 = y0 * rowSize;
@@ -49668,7 +49668,7 @@ class Sampler2D {
49668
49668
  *
49669
49669
  * @param {number} u
49670
49670
  * @param {number} v
49671
- * @param {ArrayLike<number>} result
49671
+ * @param {number[]|ArrayLike<number>} result
49672
49672
  */
49673
49673
  sampleNearestUV(u, v, result) {
49674
49674
  const w = this.width;
@@ -50288,7 +50288,7 @@ const WHITE_PIXEL_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA
50288
50288
  * @param {number} v
50289
50289
  * @returns {number}
50290
50290
  */
50291
- function float2uint8(v) {
50291
+ function float_to_uint8(v) {
50292
50292
  return Math.round(v * 255);
50293
50293
  }
50294
50294
 
@@ -50297,7 +50297,7 @@ function float2uint8(v) {
50297
50297
  * @param {number} v
50298
50298
  * @returns {number}
50299
50299
  */
50300
- function uint82float(v) {
50300
+ function uint8_to_float(v) {
50301
50301
  return v / 255;
50302
50302
  }
50303
50303
 
@@ -51696,7 +51696,7 @@ class TerrainOverlay {
51696
51696
  for (let i = 0; i < 4; i++) {
51697
51697
  const v = this.sampler.readChannel(x, y, i);
51698
51698
 
51699
- result[i] = uint82float(v);
51699
+ result[i] = uint8_to_float(v);
51700
51700
  }
51701
51701
  }
51702
51702
 
@@ -51743,7 +51743,7 @@ class TerrainOverlay {
51743
51743
  paintPoint(x, y, vec4) {
51744
51744
  for (let i = 0; i < 4; i++) {
51745
51745
 
51746
- this.sampler.writeChannel(x, y, i, float2uint8(vec4[i]));
51746
+ this.sampler.writeChannel(x, y, i, float_to_uint8(vec4[i]));
51747
51747
 
51748
51748
  }
51749
51749
 
@@ -53220,7 +53220,7 @@ function aabb3_intersects_ray(
53220
53220
  const diff_x = origin_x - center_x;
53221
53221
 
53222
53222
 
53223
- if (diff_x * direction_x >= 0.0 && abs(diff_x) > extents_x) {
53223
+ if (diff_x * direction_x >= 0 && abs(diff_x) > extents_x) {
53224
53224
  return false;
53225
53225
  }
53226
53226
 
@@ -53232,7 +53232,7 @@ function aabb3_intersects_ray(
53232
53232
  const diff_y = origin_y - center_y;
53233
53233
 
53234
53234
 
53235
- if (diff_y * direction_y >= 0.0 && abs(diff_y) > extents_y) {
53235
+ if (diff_y * direction_y >= 0 && abs(diff_y) > extents_y) {
53236
53236
  return false;
53237
53237
  }
53238
53238
 
@@ -53244,7 +53244,7 @@ function aabb3_intersects_ray(
53244
53244
  const diff_z = origin_z - center_z;
53245
53245
 
53246
53246
 
53247
- if (diff_z * direction_z >= 0.0 && abs(diff_z) > extents_z) {
53247
+ if (diff_z * direction_z >= 0 && abs(diff_z) > extents_z) {
53248
53248
  return false;
53249
53249
  }
53250
53250
 
@@ -53270,7 +53270,7 @@ function aabb3_intersects_ray(
53270
53270
  return f2 <= extents_x * abs_direction_y + extents_y * abs_direction_x;
53271
53271
  }
53272
53272
 
53273
- const stack$9 = SCRATCH_UINT32_TRAVERSAL_STACK;
53273
+ const stack$a = SCRATCH_UINT32_TRAVERSAL_STACK;
53274
53274
 
53275
53275
 
53276
53276
  /**
@@ -53303,9 +53303,9 @@ function bvh_query_leaves_ray(
53303
53303
  *
53304
53304
  * @type {number}
53305
53305
  */
53306
- const stack_top = stack$9.pointer++;
53306
+ const stack_top = stack$a.pointer++;
53307
53307
 
53308
- stack$9[stack_top] = root;
53308
+ stack$a[stack_top] = root;
53309
53309
 
53310
53310
  let result_cursor = result_offset;
53311
53311
 
@@ -53316,13 +53316,13 @@ function bvh_query_leaves_ray(
53316
53316
  const uint32 = bvh.__data_uint32;
53317
53317
 
53318
53318
  do {
53319
- stack$9.pointer--;
53319
+ stack$a.pointer--;
53320
53320
 
53321
53321
  /**
53322
53322
  *
53323
53323
  * @type {number}
53324
53324
  */
53325
- const node = stack$9[stack$9.pointer];
53325
+ const node = stack$a[stack$a.pointer];
53326
53326
 
53327
53327
  const address = node * ELEMENT_WORD_COUNT;
53328
53328
 
@@ -53344,15 +53344,15 @@ function bvh_query_leaves_ray(
53344
53344
  if (child_1 !== NULL_NODE) {
53345
53345
 
53346
53346
  // this is not a leaf node, push children onto traversal stack
53347
- stack$9[stack$9.pointer++] = uint32[address + COLUMN_CHILD_2];
53348
- stack$9[stack$9.pointer++] = child_1;
53347
+ stack$a[stack$a.pointer++] = uint32[address + COLUMN_CHILD_2];
53348
+ stack$a[stack$a.pointer++] = child_1;
53349
53349
 
53350
53350
  } else {
53351
53351
  // leaf node
53352
53352
 
53353
53353
  result[result_cursor++] = node;
53354
53354
  }
53355
- } while (stack$9.pointer > stack_top);
53355
+ } while (stack$a.pointer > stack_top);
53356
53356
 
53357
53357
  return result_cursor - result_offset;
53358
53358
  }
@@ -53524,9 +53524,9 @@ function hsv2rgb(h, s, v) {
53524
53524
  break;
53525
53525
  }
53526
53526
  return {
53527
- r: float2uint8(r),
53528
- g: float2uint8(g),
53529
- b: float2uint8(b)
53527
+ r: float_to_uint8(r),
53528
+ g: float_to_uint8(g),
53529
+ b: float_to_uint8(b)
53530
53530
  };
53531
53531
  }
53532
53532
 
@@ -53617,9 +53617,9 @@ function parse_color(c) {
53617
53617
  * @returns {number}
53618
53618
  */
53619
53619
  function rgb2uint24(r, g, b) {
53620
- const _r = float2uint8(r);
53621
- const _g = float2uint8(g);
53622
- 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);
53623
53623
 
53624
53624
  return (_b & 0xFF)
53625
53625
  | (_g & 0xFF) << 8
@@ -53638,7 +53638,7 @@ function rgb_to_luminance(r, g, b) {
53638
53638
  return 0.299 * r + 0.587 * g + 0.114 * b;
53639
53639
  }
53640
53640
 
53641
- function convert(c) {
53641
+ function convert_channel_linear_to_sRGB(c) {
53642
53642
  if (c < 0.0031308) {
53643
53643
  return c * 12.92;
53644
53644
  } else {
@@ -53661,9 +53661,9 @@ function linear_to_sRGB(
53661
53661
  const g = input[input_offset + 1];
53662
53662
  const b = input[input_offset + 2];
53663
53663
 
53664
- output[output_offset] = convert(r);
53665
- output[output_offset + 1] = convert(g);
53666
- 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);
53667
53667
  }
53668
53668
 
53669
53669
  /**
@@ -53837,9 +53837,9 @@ class Color {
53837
53837
  */
53838
53838
  setRGBUint8(r, g, b) {
53839
53839
  this.setRGB(
53840
- uint82float(r),
53841
- uint82float(g),
53842
- uint82float(b),
53840
+ uint8_to_float(r),
53841
+ uint8_to_float(g),
53842
+ uint8_to_float(b),
53843
53843
  );
53844
53844
  }
53845
53845
 
@@ -54132,9 +54132,9 @@ class Color {
54132
54132
  */
54133
54133
  toHex() {
54134
54134
  return '#' + rgb2hex(
54135
- float2uint8(this.r),
54136
- float2uint8(this.g),
54137
- float2uint8(this.b)
54135
+ float_to_uint8(this.r),
54136
+ float_to_uint8(this.g),
54137
+ float_to_uint8(this.b)
54138
54138
  );
54139
54139
  }
54140
54140
 
@@ -54143,7 +54143,7 @@ class Color {
54143
54143
  * @returns {string}
54144
54144
  */
54145
54145
  toCssRGBAString() {
54146
- 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})`;
54147
54147
  }
54148
54148
 
54149
54149
  /**
@@ -55232,7 +55232,7 @@ function build_morton(data, address, bounds) {
55232
55232
 
55233
55233
  }
55234
55234
 
55235
- const stack$8 = SCRATCH_UINT32_TRAVERSAL_STACK;
55235
+ const stack$9 = SCRATCH_UINT32_TRAVERSAL_STACK;
55236
55236
 
55237
55237
  class BinaryUint32BVH {
55238
55238
  /**
@@ -55374,6 +55374,18 @@ class BinaryUint32BVH {
55374
55374
 
55375
55375
  }
55376
55376
 
55377
+ /**
55378
+ *
55379
+ * @param {number} index
55380
+ * @return {number}
55381
+ */
55382
+ getLeafAddress(index) {
55383
+
55384
+ const leaf_block_address = this.__node_count_binary * BVH_BINARY_NODE_SIZE;
55385
+
55386
+ return index * BVH_LEAF_NODE_SIZE + leaf_block_address;
55387
+ }
55388
+
55377
55389
  /**
55378
55390
  *
55379
55391
  * @param {number} index
@@ -55391,9 +55403,7 @@ class BinaryUint32BVH {
55391
55403
  x1, y1, z1
55392
55404
  ) {
55393
55405
 
55394
- const leaf_block_address = this.__node_count_binary * BVH_BINARY_NODE_SIZE;
55395
-
55396
- const address = index * BVH_LEAF_NODE_SIZE + leaf_block_address;
55406
+ const address = this.getLeafAddress(index);
55397
55407
 
55398
55408
  aabb3_array_set(
55399
55409
  this.__data_float32,
@@ -55533,16 +55543,16 @@ class BinaryUint32BVH {
55533
55543
  let stackPointer = 2;
55534
55544
  let i, j;
55535
55545
 
55536
- stack$8[0] = 0; // first node
55537
- stack$8[1] = this.__node_count_leaf - 1; // last node
55546
+ stack$9[0] = 0; // first node
55547
+ stack$9[1] = this.__node_count_leaf - 1; // last node
55538
55548
 
55539
55549
  const data = this.__data_float32;
55540
55550
 
55541
55551
  while (stackPointer > 0) {
55542
55552
  stackPointer -= 2;
55543
55553
 
55544
- const right = stack$8[stackPointer + 1];
55545
- const left = stack$8[stackPointer];
55554
+ const right = stack$9[stackPointer + 1];
55555
+ const left = stack$9[stackPointer];
55546
55556
 
55547
55557
  i = left;
55548
55558
  j = right;
@@ -55577,12 +55587,12 @@ class BinaryUint32BVH {
55577
55587
 
55578
55588
  /* recursion */
55579
55589
  if (left < j) {
55580
- stack$8[stackPointer++] = left;
55581
- stack$8[stackPointer++] = j;
55590
+ stack$9[stackPointer++] = left;
55591
+ stack$9[stackPointer++] = j;
55582
55592
  }
55583
55593
  if (i < right) {
55584
- stack$8[stackPointer++] = i;
55585
- stack$8[stackPointer++] = right;
55594
+ stack$9[stackPointer++] = i;
55595
+ stack$9[stackPointer++] = right;
55586
55596
  }
55587
55597
  }
55588
55598
  }
@@ -56759,11 +56769,13 @@ class AABB3 {
56759
56769
  * Get center position of the box
56760
56770
  * @param {Vector3} target where to write result
56761
56771
  */
56762
- getCenter(target) {
56772
+ getCenter(target = new Vector3$1()) {
56763
56773
  const x = this.getCenterX();
56764
56774
  const y = this.getCenterY();
56765
56775
  const z = this.getCenterZ();
56766
56776
  target.set(x, y, z);
56777
+
56778
+ return target;
56767
56779
  }
56768
56780
 
56769
56781
 
@@ -57178,7 +57190,7 @@ function aabb3_array_intersects_ray(
57178
57190
  );
57179
57191
  }
57180
57192
 
57181
- const stack$7 = SCRATCH_UINT32_TRAVERSAL_STACK;
57193
+ const stack$8 = SCRATCH_UINT32_TRAVERSAL_STACK;
57182
57194
 
57183
57195
  /**
57184
57196
  *
@@ -57212,13 +57224,13 @@ function bvh32_query_user_data_ray(
57212
57224
  *
57213
57225
  * @type {number}
57214
57226
  */
57215
- const stack_top = stack$7.pointer++;
57227
+ const stack_top = stack$8.pointer++;
57216
57228
 
57217
57229
  /**
57218
57230
  * After performing empirical tests, stack-based depth-first traversal turns out faster than using a queue
57219
57231
  * @type {number}
57220
57232
  */
57221
- stack$7[stack_top] = 0;
57233
+ stack$8[stack_top] = 0;
57222
57234
 
57223
57235
  const last_valid_index = binary_node_count + bvh.leaf_node_count;
57224
57236
 
@@ -57226,10 +57238,10 @@ function bvh32_query_user_data_ray(
57226
57238
  const uint32 = bvh.uint32;
57227
57239
 
57228
57240
  do {
57229
- stack$7.pointer--;
57241
+ stack$8.pointer--;
57230
57242
 
57231
57243
  // query_bvh_frustum_from_objects.iteration_count++;
57232
- const node_index = stack$7[stack$7.pointer];
57244
+ const node_index = stack$8[stack$8.pointer];
57233
57245
 
57234
57246
  const node_address = bvh.getNodeAddress(node_index);
57235
57247
 
@@ -57251,11 +57263,11 @@ function bvh32_query_user_data_ray(
57251
57263
 
57252
57264
  // left node ends up on top of the stack, which aligns with the desired access sequence
57253
57265
  if (right_index < last_valid_index) {
57254
- stack$7[stack$7.pointer++] = right_index;
57266
+ stack$8[stack$8.pointer++] = right_index;
57255
57267
  // micro-optimization, since we know that right node is valid and left appears before that, left is valid too
57256
- stack$7[stack$7.pointer++] = left_index;
57268
+ stack$8[stack$8.pointer++] = left_index;
57257
57269
  } else if (left_index < last_valid_index) {
57258
- stack$7[stack$7.pointer++] = left_index;
57270
+ stack$8[stack$8.pointer++] = left_index;
57259
57271
  }
57260
57272
 
57261
57273
 
@@ -57268,7 +57280,7 @@ function bvh32_query_user_data_ray(
57268
57280
  hit_count++;
57269
57281
  }
57270
57282
 
57271
- } while (stack$7.pointer > stack_top)
57283
+ } while (stack$8.pointer > stack_top)
57272
57284
 
57273
57285
  return hit_count;
57274
57286
  }
@@ -63068,72 +63080,137 @@ const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
63068
63080
  * @param {string} path
63069
63081
  * @return {string}
63070
63082
  */
63071
- function convertPathToURL(path) {
63072
-
63073
- if (!isGlobalPath(path)) {
63083
+ function localPathToGlobal(path) {
63084
+ /**
63085
+ * @type {Window|DedicatedWorkerGlobalScope}
63086
+ */
63087
+ let scope;
63074
63088
 
63075
- /**
63076
- * @type {Window|DedicatedWorkerGlobalScope}
63077
- */
63078
- let scope;
63089
+ if (ENVIRONMENT_IS_WEB) {
63090
+ scope = window;
63091
+ } else if (ENVIRONMENT_IS_WORKER) {
63092
+ scope = self;
63093
+ } else if (ENVIRONMENT_IS_NODE) {
63079
63094
 
63080
- if (ENVIRONMENT_IS_WEB) {
63081
- scope = window;
63082
- } else if (ENVIRONMENT_IS_WORKER) {
63083
- scope = self;
63084
- } else if (ENVIRONMENT_IS_NODE) {
63095
+ let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63085
63096
 
63086
- let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63097
+ // remove multiple sequential slashes
63098
+ normalized_path = normalized_path.replace(/\/+/g, '/');
63087
63099
 
63088
- // remove multiple sequential slashes
63089
- normalized_path = normalized_path.replace(/\/+/g, '/');
63100
+ if (normalized_path[0] !== '/') {
63101
+ // Windows drive letter must be prefixed with a slash.
63102
+ normalized_path = `/${normalized_path}`;
63103
+ }
63090
63104
 
63091
- if (normalized_path[0] !== '/') {
63092
- // Windows drive letter must be prefixed with a slash.
63093
- normalized_path = `/${normalized_path}`;
63105
+ scope = {
63106
+ location: {
63107
+ pathname: normalized_path,
63108
+ host: '',
63109
+ protocol: 'file:'
63094
63110
  }
63111
+ };
63112
+ } else {
63113
+ throw new Error('Unknown environment');
63114
+ }
63095
63115
 
63096
- scope = {
63097
- location: {
63098
- pathname: normalized_path,
63099
- host: '',
63100
- protocol: 'file:'
63101
- }
63102
- };
63116
+ const location = scope.location;
63117
+ const pathname = location.pathname;
63118
+
63119
+ let directoryPath;
63120
+
63121
+ /*
63122
+ path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63123
+ we need to extract directory to load relative path
63124
+ */
63125
+
63126
+ if (pathname.endsWith('/')) {
63127
+ //path is to a directory, strip last slash
63128
+ directoryPath = pathname.substring(0, pathname.length - 1);
63129
+ } else {
63130
+ //path is to a file
63131
+ const i = pathname.lastIndexOf('/');
63132
+
63133
+ if (i === -1) {
63134
+ //root level file
63135
+ directoryPath = "";
63103
63136
  } else {
63104
- throw new Error('Unknown environment');
63137
+ directoryPath = pathname.substring(0, i);
63105
63138
  }
63139
+ }
63106
63140
 
63107
- const location = scope.location;
63108
- const pathname = location.pathname;
63141
+ const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63142
+ return urlBase + path;
63143
+ }
63109
63144
 
63110
- let directoryPath;
63145
+ /**
63146
+ * Given a path, which may be a local path, produce a fully qualified URL
63147
+ * @example '/path' -> 'http://example.com/path'
63148
+ * @example 'some/local/path' -> 'http://example.com/current_path/some/local/path'
63149
+ * @param {string} path
63150
+ * @return {string}
63151
+ */
63152
+ function convertPathToURL(path) {
63111
63153
 
63112
- /*
63113
- path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63114
- we need to extract directory to load relative path
63115
- */
63154
+ const is_global = isGlobalPath(path);
63116
63155
 
63117
- if (pathname.endsWith('/')) {
63118
- //path is to a directory, strip last slash
63119
- directoryPath = pathname.substring(0, pathname.length - 1);
63120
- } else {
63121
- //path is to a file
63122
- const i = pathname.lastIndexOf('/');
63156
+ let result = path;
63123
63157
 
63124
- if (i === -1) {
63125
- //root level file
63126
- directoryPath = "";
63127
- } else {
63128
- directoryPath = pathname.substring(0, i);
63129
- }
63158
+ if (!is_global) {
63159
+ result = localPathToGlobal(path);
63160
+ }
63161
+
63162
+ return result;
63163
+ }
63164
+
63165
+ /**
63166
+ *
63167
+ * @param {string} code
63168
+ * @param {string} [mime_type]
63169
+ * @return {Blob}
63170
+ */
63171
+ function codeToBlob(code, mime_type = 'application/javascript') {
63172
+
63173
+ let blob;
63174
+
63175
+ if (typeof globalThis.Blob !== "undefined") {
63176
+ blob = new Blob([code], { type: mime_type });
63177
+ } else {
63178
+ // Backwards-compatibility
63179
+ const BlobBuilder = globalThis.BlobBuilder
63180
+ || globalThis.BlobBuilder
63181
+ || globalThis.WebKitBlobBuilder
63182
+ || globalThis.MozBlobBuilder;
63183
+
63184
+ if (BlobBuilder !== undefined) {
63185
+ blob = new BlobBuilder();
63186
+ blob.append(code);
63187
+ blob = blob.getBlob();
63188
+ } else {
63189
+ throw new Error(`No BlobBuilder interface supported in current context`);
63130
63190
  }
63131
63191
 
63132
- const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63133
- path = urlBase + path;
63134
63192
  }
63135
63193
 
63136
- return path;
63194
+
63195
+ return blob;
63196
+ }
63197
+
63198
+ /**
63199
+ *
63200
+ * @param {string} code
63201
+ * @param {string} [mime_type]
63202
+ * @return {string}
63203
+ */
63204
+ function codeToURL(code, mime_type = 'application/javascript') {
63205
+
63206
+ const blob = codeToBlob(code, mime_type);
63207
+
63208
+ if (blob !== undefined && URL.createObjectURL !== undefined) {
63209
+ return URL.createObjectURL(blob);
63210
+ } else {
63211
+ // build data URL in a slowest way possible
63212
+ return `data:${mime_type},${encodeURIComponent(code)}`;
63213
+ }
63137
63214
  }
63138
63215
 
63139
63216
  class Line {
@@ -63589,6 +63666,7 @@ class WorkerProxy {
63589
63666
 
63590
63667
  const RxMatchFunctionName = /(function\s*)([a-zA-Z0-9_]+)?(\s*\([^\]]*\)\s*\{.*)/g;
63591
63668
 
63669
+
63592
63670
  class WorkerBuilder {
63593
63671
 
63594
63672
  imports = [];
@@ -63631,9 +63709,9 @@ class WorkerBuilder {
63631
63709
  * @param {string} path
63632
63710
  */
63633
63711
  importScript(path) {
63634
- path = convertPathToURL(path);
63712
+ const qualified_path = convertPathToURL(path);
63635
63713
 
63636
- this.imports.push(path);
63714
+ this.imports.push(qualified_path);
63637
63715
  }
63638
63716
 
63639
63717
  /**
@@ -63643,7 +63721,7 @@ class WorkerBuilder {
63643
63721
  build() {
63644
63722
  const codeLines = [];
63645
63723
 
63646
- codeLines.push('var globalScope = this;');
63724
+ codeLines.push('var globalScope = globalThis;');
63647
63725
 
63648
63726
  //handle imports
63649
63727
  this.imports.forEach(function (url) {
@@ -63744,37 +63822,6 @@ class WorkerBuilder {
63744
63822
 
63745
63823
  return new WorkerProxy(workerURL, this.methods);
63746
63824
  }
63747
- }
63748
- /**
63749
- *
63750
- * @param {string} code
63751
- * @return {string}
63752
- */
63753
- function codeToURL(code) {
63754
- const js_mime = 'application/javascript';
63755
-
63756
- let blob;
63757
-
63758
- if (typeof window === 'object') {
63759
- if (typeof window.Blob !== "undefined") {
63760
- blob = new Blob([code], {type: js_mime});
63761
- } else {
63762
- // Backwards-compatibility
63763
- const BlobBuilder = window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
63764
- if (BlobBuilder !== undefined) {
63765
- blob = new BlobBuilder();
63766
- blob.append(code);
63767
- blob = blob.getBlob();
63768
- }
63769
- }
63770
- }
63771
-
63772
- if (blob !== undefined && URL.createObjectURL !== undefined) {
63773
- return URL.createObjectURL(blob);
63774
- } else {
63775
- // build data URL in a slowest way possible
63776
- return `data:${js_mime},${encodeURIComponent(code)}`;
63777
- }
63778
63825
  }
63779
63826
 
63780
63827
  /**
@@ -65844,14 +65891,17 @@ function read_three_planes_to_array(planes, array) {
65844
65891
 
65845
65892
  /**
65846
65893
  *
65847
- * @param {BinaryUint32BVH} bvh
65848
- * @param {number} triangle_index
65894
+ * @param {number[]|Float32Array} output
65895
+ * @param {number} output_offset
65849
65896
  * @param {number[]|Float32Array} vertices
65850
65897
  * @param {number} a_index
65851
65898
  * @param {number} b_index
65852
65899
  * @param {number} c_index
65853
65900
  */
65854
- function bvh32_set_leaf_from_triangle(bvh, triangle_index, vertices, a_index, b_index, c_index) {
65901
+ function aabb3_compute_from_triangle(
65902
+ output, output_offset,
65903
+ vertices, a_index, b_index, c_index
65904
+ ) {
65855
65905
  const a = a_index * 3;
65856
65906
  const b = b_index * 3;
65857
65907
  const c = c_index * 3;
@@ -65870,15 +65920,31 @@ function bvh32_set_leaf_from_triangle(bvh, triangle_index, vertices, a_index, b_
65870
65920
  const cZ = vertices[c + 2];
65871
65921
 
65872
65922
  // compute bounds of the triangle
65873
- const x0 = min3(aX, bX, cX);
65874
- const y0 = min3(aY, bY, cY);
65875
- const z0 = min3(aZ, bZ, cZ);
65923
+ output[output_offset] = min3(aX, bX, cX);
65924
+ output[output_offset + 1] = min3(aY, bY, cY);
65925
+ output[output_offset + 2] = min3(aZ, bZ, cZ);
65876
65926
 
65877
- const x1 = max3(aX, bX, cX);
65878
- const y1 = max3(aY, bY, cY);
65879
- const z1 = max3(aZ, bZ, cZ);
65927
+ output[output_offset + 3] = max3(aX, bX, cX);
65928
+ output[output_offset + 4] = max3(aY, bY, cY);
65929
+ output[output_offset + 5] = max3(aZ, bZ, cZ);
65930
+
65931
+ }
65932
+
65933
+ /**
65934
+ *
65935
+ * @param {BinaryUint32BVH} bvh
65936
+ * @param {number} triangle_index
65937
+ * @param {number[]|Float32Array} vertices
65938
+ * @param {number} a_index
65939
+ * @param {number} b_index
65940
+ * @param {number} c_index
65941
+ */
65942
+ function bvh32_set_leaf_from_triangle(bvh, triangle_index, vertices, a_index, b_index, c_index) {
65943
+
65944
+ const address = bvh.getLeafAddress(triangle_index);
65945
+ aabb3_compute_from_triangle(bvh.__data_float32, address, vertices, a_index, b_index, c_index);
65946
+ bvh.__data_uint32[address + 6] = triangle_index;
65880
65947
 
65881
- bvh.setLeafData(triangle_index, triangle_index, x0, y0, z0, x1, y1, z1);
65882
65948
  }
65883
65949
 
65884
65950
  /**
@@ -66006,7 +66072,7 @@ function aabb3_array_intersects_clipping_volume_array(
66006
66072
  );
66007
66073
  }
66008
66074
 
66009
- const stack$6 = SCRATCH_UINT32_TRAVERSAL_STACK;
66075
+ const stack$7 = SCRATCH_UINT32_TRAVERSAL_STACK;
66010
66076
 
66011
66077
  /**
66012
66078
  *
@@ -66036,13 +66102,13 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66036
66102
  *
66037
66103
  * @type {number}
66038
66104
  */
66039
- const stack_top = stack$6.pointer++;
66105
+ const stack_top = stack$7.pointer++;
66040
66106
 
66041
66107
  /**
66042
66108
  * After performing empirical tests, stack-based depth-first traversal turns out faster than using a queue
66043
66109
  * @type {number}
66044
66110
  */
66045
- stack$6[stack_top] = 0;
66111
+ stack$7[stack_top] = 0;
66046
66112
 
66047
66113
  const last_valid_index = binary_node_count + bvh.leaf_node_count;
66048
66114
 
@@ -66050,10 +66116,10 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66050
66116
  const uint32 = bvh.uint32;
66051
66117
 
66052
66118
  do {
66053
- stack$6.pointer--;
66119
+ stack$7.pointer--;
66054
66120
 
66055
66121
  // query_bvh_frustum_from_objects.iteration_count++;
66056
- const node_index = stack$6[stack$6.pointer];
66122
+ const node_index = stack$7[stack$7.pointer];
66057
66123
 
66058
66124
  const node_address = bvh.getNodeAddress(node_index);
66059
66125
 
@@ -66074,11 +66140,11 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66074
66140
 
66075
66141
  // left node ends up on top of the stack, which aligns with the desired access sequence
66076
66142
  if (right_index < last_valid_index) {
66077
- stack$6[stack$6.pointer++] = right_index;
66143
+ stack$7[stack$7.pointer++] = right_index;
66078
66144
  // micro-optimization, since we know that right node is valid and left appears before that, left is valid too
66079
- stack$6[stack$6.pointer++] = left_index;
66145
+ stack$7[stack$7.pointer++] = left_index;
66080
66146
  } else if (left_index < last_valid_index) {
66081
- stack$6[stack$6.pointer++] = left_index;
66147
+ stack$7[stack$7.pointer++] = left_index;
66082
66148
  }
66083
66149
 
66084
66150
 
@@ -66091,7 +66157,7 @@ function bvh32_query_user_data_overlaps_clipping_volume(
66091
66157
  hit_count++;
66092
66158
  }
66093
66159
 
66094
- } while (stack$6.pointer > stack_top)
66160
+ } while (stack$7.pointer > stack_top)
66095
66161
 
66096
66162
  return hit_count;
66097
66163
  }
@@ -67202,7 +67268,7 @@ function aabb3_array_intersects_frustum_degree(aabb, frustum) {
67202
67268
  //
67203
67269
 
67204
67270
 
67205
- const stack$5 = SCRATCH_UINT32_TRAVERSAL_STACK;
67271
+ const stack$6 = SCRATCH_UINT32_TRAVERSAL_STACK;
67206
67272
 
67207
67273
  /**
67208
67274
  *
@@ -67225,20 +67291,20 @@ function bvh_collect_user_data(
67225
67291
  *
67226
67292
  * @type {number}
67227
67293
  */
67228
- const stack_top = stack$5.pointer++;
67294
+ const stack_top = stack$6.pointer++;
67229
67295
 
67230
- stack$5[stack_top] = root;
67296
+ stack$6[stack_top] = root;
67231
67297
 
67232
67298
  let result_cursor = destination_offset;
67233
67299
 
67234
- while (stack$5.pointer > stack_top) {
67235
- stack$5.pointer--;
67300
+ while (stack$6.pointer > stack_top) {
67301
+ stack$6.pointer--;
67236
67302
 
67237
67303
  /**
67238
67304
  *
67239
67305
  * @type {number}
67240
67306
  */
67241
- const node = stack$5[stack$5.pointer];
67307
+ const node = stack$6[stack$6.pointer];
67242
67308
 
67243
67309
  const node_is_leaf = bvh.node_is_leaf(node);
67244
67310
 
@@ -67249,8 +67315,8 @@ function bvh_collect_user_data(
67249
67315
  const child2 = bvh.node_get_child2(node);
67250
67316
 
67251
67317
  // write to stack in reverse order, so that fist child ends up being visited first
67252
- stack$5[stack$5.pointer++] = child1;
67253
- stack$5[stack$5.pointer++] = child2;
67318
+ stack$6[stack$6.pointer++] = child1;
67319
+ stack$6[stack$6.pointer++] = child2;
67254
67320
 
67255
67321
  } else {
67256
67322
  // leaf root
@@ -67266,7 +67332,7 @@ function bvh_collect_user_data(
67266
67332
 
67267
67333
  //
67268
67334
 
67269
- const stack$4 = SCRATCH_UINT32_TRAVERSAL_STACK;
67335
+ const stack$5 = SCRATCH_UINT32_TRAVERSAL_STACK;
67270
67336
 
67271
67337
  const scratch_aabb$1 = new Float32Array(6);
67272
67338
 
@@ -67293,20 +67359,20 @@ function bvh_query_user_data_overlaps_frustum(
67293
67359
  *
67294
67360
  * @type {number}
67295
67361
  */
67296
- const stack_top = stack$4.pointer++;
67362
+ const stack_top = stack$5.pointer++;
67297
67363
 
67298
- stack$4[stack_top] = root;
67364
+ stack$5[stack_top] = root;
67299
67365
 
67300
67366
  let result_cursor = result_offset;
67301
67367
 
67302
- while (stack$4.pointer > stack_top) {
67303
- stack$4.pointer--;
67368
+ while (stack$5.pointer > stack_top) {
67369
+ stack$5.pointer--;
67304
67370
 
67305
67371
  /**
67306
67372
  *
67307
67373
  * @type {number}
67308
67374
  */
67309
- const node = stack$4[stack$4.pointer];
67375
+ const node = stack$5[stack$5.pointer];
67310
67376
 
67311
67377
  // test node against the ray
67312
67378
  bvh.node_get_aabb(node, scratch_aabb$1);
@@ -67333,8 +67399,8 @@ function bvh_query_user_data_overlaps_frustum(
67333
67399
  const child2 = bvh.node_get_child2(node);
67334
67400
 
67335
67401
  // write to stack in reverse order, so that fist child ends up being visited first
67336
- stack$4[stack$4.pointer++] = child1;
67337
- stack$4[stack$4.pointer++] = child2;
67402
+ stack$5[stack$5.pointer++] = child1;
67403
+ stack$5[stack$5.pointer++] = child2;
67338
67404
  }
67339
67405
  }
67340
67406
 
@@ -67395,7 +67461,7 @@ function computeFileExtension(path) {
67395
67461
  * @param {number} height
67396
67462
  * @param {number} channel_count
67397
67463
  */
67398
- function flipArrayInPlace(input, width, height, channel_count = 4) {
67464
+ function sampler2d_flipY_in_place(input, width, height, channel_count = 4) {
67399
67465
  const row_size = width * channel_count;
67400
67466
  let t, x0, x1;
67401
67467
  let i = 0;
@@ -67466,6 +67532,235 @@ const CopyShader = {
67466
67532
 
67467
67533
  };
67468
67534
 
67535
+ /**
67536
+ *
67537
+ * @param {number} format
67538
+ * @returns {number}
67539
+ */
67540
+ function formatToChannelCount(format) {
67541
+ switch (format) {
67542
+ case RedFormat:
67543
+ case RedIntegerFormat:
67544
+ return 1;
67545
+ case RGFormat:
67546
+ return 2;
67547
+ case RGBFormat:
67548
+ return 3;
67549
+ case RGBAFormat:
67550
+ return 4;
67551
+ default:
67552
+ throw new Error(`Unsupported format '${format}'`);
67553
+ }
67554
+ }
67555
+
67556
+ /**
67557
+ *
67558
+ * @param {Uint8Array|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array} array
67559
+ * @return {boolean}
67560
+ */
67561
+ function typed_array_is_integer(array) {
67562
+ const ctor = array.constructor;
67563
+
67564
+ return ctor === Uint8ClampedArray
67565
+ || ctor === Uint8Array
67566
+ || ctor === Uint16Array
67567
+ || ctor === Uint32Array
67568
+ || ctor === Int8Array
67569
+ || ctor === Int16Array
67570
+ || ctor === Int32Array
67571
+ ;
67572
+ }
67573
+
67574
+ /**
67575
+ * Applies a linear polynomial transform to each value of a given channel
67576
+ * @param {Sampler2D} output
67577
+ * @param {Sampler2D} input
67578
+ * @param {number} output_channel_index
67579
+ * @param {number} input_channel_index
67580
+ * @param {number} gradient
67581
+ * @param {number} intercept
67582
+ */
67583
+ function sampler2d_channel_linear_transform(
67584
+ output, input,
67585
+ output_channel_index, input_channel_index,
67586
+ gradient, intercept
67587
+ ) {
67588
+
67589
+ const input_width = input.width;
67590
+ const input_height = input.height;
67591
+
67592
+ const output_width = output.width;
67593
+ const output_height = output.height;
67594
+
67595
+ if (
67596
+ input_width !== output_width
67597
+ || input_height !== output_height
67598
+ ) {
67599
+ throw new Error('Dimensions of input and output are incompatible');
67600
+ }
67601
+
67602
+ const input_item_size = input.itemSize;
67603
+ const output_item_size = output.itemSize;
67604
+
67605
+ const input_data = input.data;
67606
+ const output_data = output.data;
67607
+
67608
+ const pixel_count = input_width * input_height;
67609
+
67610
+
67611
+ if (typed_array_is_integer(output_data)) {
67612
+
67613
+ for (let i = 0; i < pixel_count; i++) {
67614
+
67615
+ const input_address = i * input_item_size + input_channel_index;
67616
+ const output_address = i * output_item_size + output_channel_index;
67617
+
67618
+ const input_value = input_data[input_address];
67619
+
67620
+ output_data[output_address] = Math.round(input_value * gradient + intercept);
67621
+
67622
+ }
67623
+
67624
+ } else {
67625
+
67626
+ for (let i = 0; i < pixel_count; i++) {
67627
+
67628
+ const input_address = i * input_item_size + input_channel_index;
67629
+ const output_address = i * output_item_size + output_channel_index;
67630
+
67631
+ const input_value = input_data[input_address];
67632
+
67633
+ output_data[output_address] = input_value * gradient + intercept;
67634
+
67635
+ }
67636
+
67637
+ }
67638
+
67639
+ }
67640
+
67641
+ function compute_gradient_and_intercept_uint8(ctor) {
67642
+ let gradient = 1;
67643
+ let intercept = 0;
67644
+
67645
+ switch (ctor) {
67646
+ case Uint16Array:
67647
+ gradient = 0.0038910505836575876;
67648
+ break;
67649
+ case Uint32Array:
67650
+ gradient = 5.937181414556033e-8;
67651
+ break;
67652
+ case Int8Array:
67653
+ gradient = 1;
67654
+ intercept = 127;
67655
+ break
67656
+ case Int16Array:
67657
+ gradient = 0.0038910505836575876;
67658
+ intercept = 127;
67659
+ break;
67660
+ case Int32Array:
67661
+ gradient = 5.937181414556033e-8;
67662
+ intercept = 127;
67663
+ break
67664
+ case Float32Array:
67665
+ case Float64Array:
67666
+ gradient = 255;
67667
+ break;
67668
+ // do nothing;
67669
+ }
67670
+
67671
+ return {
67672
+ gradient, intercept
67673
+ }
67674
+ }
67675
+
67676
+ /**
67677
+ * Many applications work with 8bit RGBA images, this utility function converts a given input to that format
67678
+ * @param {Sampler2D} input
67679
+ * @param {Sampler2D} output
67680
+ */
67681
+ function sampler2d_to_uint8_RGBA(output, input) {
67682
+ if (
67683
+ input.width !== output.width
67684
+ || input.height !== output.height
67685
+ ) {
67686
+ throw new Error('Dimensions of source and destination are incompatible');
67687
+ }
67688
+
67689
+ if (output.itemSize !== 4) {
67690
+ throw new Error(`Destination must have 4 channels exactly, instead got '${output.itemSize}'`);
67691
+ }
67692
+
67693
+ const { gradient, intercept } = compute_gradient_and_intercept_uint8(input.data.constructor);
67694
+
67695
+ const source_item_size = input.itemSize;
67696
+
67697
+ if (intercept === 0 && gradient === 1 && source_item_size === 4) {
67698
+ // already in the right format, use shortcut
67699
+ output.data.set(input.data);
67700
+ return;
67701
+ }
67702
+
67703
+ if (source_item_size === 1) {
67704
+
67705
+ // grayscale
67706
+
67707
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67708
+ sampler2d_channel_linear_transform(output, input, 1, 0, gradient, intercept);
67709
+ sampler2d_channel_linear_transform(output, input, 2, 0, gradient, intercept);
67710
+
67711
+ output.channelFill(3, 255);
67712
+
67713
+ } else if (source_item_size === 2) {
67714
+
67715
+ // grayscale with alpha
67716
+
67717
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67718
+ sampler2d_channel_linear_transform(output, input, 1, 0, gradient, intercept);
67719
+ sampler2d_channel_linear_transform(output, input, 2, 0, gradient, intercept);
67720
+ sampler2d_channel_linear_transform(output, input, 3, 1, gradient, intercept);
67721
+
67722
+ } else if (source_item_size === 3) {
67723
+
67724
+ // RGB
67725
+
67726
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67727
+ sampler2d_channel_linear_transform(output, input, 1, 1, gradient, intercept);
67728
+ sampler2d_channel_linear_transform(output, input, 2, 2, gradient, intercept);
67729
+
67730
+ output.channelFill(3, 255);
67731
+
67732
+ } else if (source_item_size === 4) {
67733
+
67734
+ // RGBA
67735
+
67736
+ sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
67737
+ sampler2d_channel_linear_transform(output, input, 1, 1, gradient, intercept);
67738
+ sampler2d_channel_linear_transform(output, input, 2, 2, gradient, intercept);
67739
+ sampler2d_channel_linear_transform(output, input, 3, 3, gradient, intercept);
67740
+
67741
+ }
67742
+ }
67743
+
67744
+ /**
67745
+ *
67746
+ * @param {Sampler2D} input
67747
+ * @returns {Sampler2D}
67748
+ */
67749
+ function sampler2d_ensure_uint8_RGBA(input) {
67750
+ if (
67751
+ input.itemSize === 4
67752
+ && (input.data.constructor === Uint8Array || input.data.constructor === Uint8ClampedArray)
67753
+ ) {
67754
+ return input;
67755
+ }
67756
+
67757
+ const resampled = Sampler2D.uint8(4, input.width, input.height);
67758
+
67759
+ sampler2d_to_uint8_RGBA(resampled, input);
67760
+
67761
+ return resampled;
67762
+ }
67763
+
67469
67764
  const DEFAULT_TEXTURE_WIDTH = 512;
67470
67765
  const DEFAULT_TEXTURE_HEIGHT = 512;
67471
67766
 
@@ -67486,6 +67781,8 @@ function convertTexture2Sampler2D(
67486
67781
  let _height = height;
67487
67782
  let _width = width;
67488
67783
 
67784
+ const channel_count = formatToChannelCount(texture.format);
67785
+
67489
67786
  // TODO take channel count into account
67490
67787
 
67491
67788
  if (_width === undefined || _height === undefined) {
@@ -67520,34 +67817,57 @@ function convertTexture2Sampler2D(
67520
67817
 
67521
67818
  }
67522
67819
 
67523
- // TODO add special case for DataTexture
67524
67820
 
67525
- const built = WebGLRendererPool.global.use(renderer => {
67821
+ let data;
67526
67822
 
67527
- const ctx = renderer.getContext();
67823
+ if (texture.isDataTexture === true) {
67528
67824
 
67529
- //support for compressed textures
67530
- ctx.getExtension("WEBGL_compressed_texture_s3tc");
67825
+ // special case
67826
+
67827
+ const source = new Sampler2D(texture.image.data, channel_count, texture.image.width, texture.image.height);
67828
+
67829
+ let converted = sampler2d_ensure_uint8_RGBA(source);
67830
+
67831
+ if (converted.width !== _width || converted.height !== _height) {
67832
+ const target = Sampler2D.uint8(4, _width, _height);
67833
+
67834
+ sampler2d_scale(converted, target);
67835
+
67836
+ converted = target;
67837
+ }
67838
+
67839
+ data = converted.data;
67840
+
67841
+ } else {
67842
+ const built = WebGLRendererPool.global.use(renderer => {
67843
+
67844
+ const ctx = renderer.getContext();
67845
+
67846
+ //support for compressed textures
67847
+ ctx.getExtension("WEBGL_compressed_texture_s3tc");
67848
+
67849
+ return processTexture(renderer, _width, _height, {
67850
+ vertexShader: CopyShader.vertexShader,
67851
+ fragmentShader: CopyShader.fragmentShader,
67852
+ uniforms: {
67853
+ tDiffuse: {
67854
+ value: texture,
67855
+ type: 't'
67856
+ },
67857
+ opacity: { value: 1.0 }
67858
+ }
67859
+ });
67531
67860
 
67532
- return processTexture(renderer, _width, _height, {
67533
- vertexShader: CopyShader.vertexShader,
67534
- fragmentShader: CopyShader.fragmentShader,
67535
- uniforms: {
67536
- tDiffuse: {
67537
- value: texture,
67538
- type: 't'
67539
- },
67540
- opacity: { value: 1.0 }
67541
- }
67542
67861
  });
67543
67862
 
67544
- });
67863
+ data = built.array;
67864
+ }
67545
67865
 
67546
67866
  if (flipY) {
67547
- flipArrayInPlace(built.array, _width, _height);
67867
+ sampler2d_flipY_in_place(data, _width, _height);
67548
67868
  }
67549
67869
 
67550
- return new Sampler2D(built.array, 4, _width, _height);
67870
+ return new Sampler2D(data, 4, _width, _height);
67551
67871
  }
67552
67872
 
67553
67873
  /**
@@ -67689,20 +68009,19 @@ class AssetLoader {
67689
68009
  function observeResponseProgress(input, progress) {
67690
68010
  let response = input;
67691
68011
 
67692
-
67693
- if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
68012
+ // Workaround: Checking if response.body === undefined for Alipay browser
68013
+ if (typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined) {
67694
68014
 
67695
68015
  return response;
67696
68016
 
67697
68017
  }
67698
68018
 
67699
- /**
67700
- * @type {ReadableStreamDefaultReader<Uint8Array>}
67701
- */
67702
- const reader = response.body.getReader();
68019
+ // Nginx needs X-File-Size check
68020
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
68021
+ const contentLength = response.headers.get('Content-Length') || response.headers.get('X-File-Size');
67703
68022
 
67704
- const contentLength = response.headers.get('Content-Length');
67705
68023
  const total = contentLength ? parseInt(contentLength) : 0;
68024
+
67706
68025
  let loaded = 0;
67707
68026
 
67708
68027
  // periodically read data into the new stream tracking while download progress
@@ -67710,6 +68029,11 @@ function observeResponseProgress(input, progress) {
67710
68029
  type: "bytes",
67711
68030
  start(controller) {
67712
68031
 
68032
+ /**
68033
+ * @type {ReadableStreamDefaultReader<Uint8Array>}
68034
+ */
68035
+ const reader = response.body.getReader();
68036
+
67713
68037
  pump();
67714
68038
 
67715
68039
  function pump() {
@@ -67727,6 +68051,7 @@ function observeResponseProgress(input, progress) {
67727
68051
  progress(loaded, total);
67728
68052
 
67729
68053
  controller.enqueue(value);
68054
+
67730
68055
  pump();
67731
68056
 
67732
68057
  });
@@ -67798,16 +68123,13 @@ class ArrayBufferLoader extends AssetLoader {
67798
68123
 
67799
68124
  let response = await fetch(request);
67800
68125
 
67801
- if (!(response.status === 200 || response.status === 0)) {
68126
+ const response_status = response.status;
67802
68127
 
67803
- throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
68128
+ if (response_status !== 200 && response_status !== 0) {
67804
68129
 
67805
- }
67806
-
67807
- // Some browsers return HTTP Status 0 when using non-http protocol
67808
- // e.g. 'file://' or 'data://'. Handle as success.
68130
+ throw Error(`fetch for "${response.url}" responded with ${response_status}: ${response.statusText}`);
67809
68131
 
67810
- if (response.status === 0) ;
68132
+ }
67811
68133
 
67812
68134
  try {
67813
68135
  response = observeResponseProgress(response, progress);
@@ -74738,7 +75060,7 @@ class SGMeshSystem extends System {
74738
75060
  }
74739
75061
  }
74740
75062
 
74741
- const stack$3 = SCRATCH_UINT32_TRAVERSAL_STACK;
75063
+ const stack$4 = SCRATCH_UINT32_TRAVERSAL_STACK;
74742
75064
 
74743
75065
  /**
74744
75066
  *
@@ -74762,20 +75084,20 @@ function bvh_query_leaves_generic(
74762
75084
  *
74763
75085
  * @type {number}
74764
75086
  */
74765
- const stack_top = stack$3.pointer++;
75087
+ const stack_top = stack$4.pointer++;
74766
75088
 
74767
- stack$3[stack_top] = root;
75089
+ stack$4[stack_top] = root;
74768
75090
 
74769
75091
  let result_cursor = result_offset;
74770
75092
 
74771
- while (stack$3.pointer > stack_top) {
74772
- stack$3.pointer--;
75093
+ while (stack$4.pointer > stack_top) {
75094
+ stack$4.pointer--;
74773
75095
 
74774
75096
  /**
74775
75097
  *
74776
75098
  * @type {number}
74777
75099
  */
74778
- const node = stack$3[stack$3.pointer];
75100
+ const node = stack$4[stack$4.pointer];
74779
75101
 
74780
75102
  // test node against the ray
74781
75103
  const pass = query.evaluate(node, bvh);
@@ -74793,8 +75115,8 @@ function bvh_query_leaves_generic(
74793
75115
  const child2 = bvh.node_get_child2(node);
74794
75116
 
74795
75117
  // write to stack in reverse order, so that fist child ends up being visited first
74796
- stack$3[stack$3.pointer++] = child2;
74797
- stack$3[stack$3.pointer++] = child1;
75118
+ stack$4[stack$4.pointer++] = child2;
75119
+ stack$4[stack$4.pointer++] = child1;
74798
75120
 
74799
75121
  } else {
74800
75122
  // leaf node
@@ -75102,85 +75424,11 @@ class RuntimeDrawMethodOptimizer {
75102
75424
  }
75103
75425
  }
75104
75426
 
75105
- const stack$2 = [];
75106
-
75107
- /**
75108
- * @template T
75109
- * @param {T[]|ArrayLike<number>|Uint32Array} data
75110
- * @param {function(T):number} score_function
75111
- * @param {*} score_function_context
75112
- * @param {number} start
75113
- * @param {number} end
75114
- * @param {function(T[],number, number):*} [swap_operator]
75115
- * @param {*} [swap_context]
75116
- */
75117
- function arrayQuickSort(
75118
- data,
75119
- score_function, score_function_context,
75120
- start, end,
75121
- swap_operator = array_swap_one, swap_context = undefined
75122
- ) {
75123
- if (start >= end) {
75124
- // section of 0 size, nothing to sort
75125
- return;
75126
- }
75127
-
75128
- let stackPointer = 2;
75129
- let i, j;
75130
-
75131
- stack$2[0] = start;
75132
- stack$2[1] = end;
75133
-
75134
- while (stackPointer > 0) {
75135
- stackPointer -= 2;
75136
-
75137
- const right = stack$2[stackPointer + 1];
75138
- const left = stack$2[stackPointer];
75139
-
75140
- i = left;
75141
- j = right;
75142
-
75143
- const pivotIndex = (left + right) >> 1;
75144
-
75145
- const pivot = score_function.call(score_function_context, data[pivotIndex]);
75146
-
75147
- /* partition */
75148
- while (i <= j) {
75149
- while (score_function.call(score_function_context, data[i]) < pivot) {
75150
- i++;
75151
- }
75152
-
75153
- while (score_function.call(score_function_context, data[j]) > pivot) {
75154
- j--;
75155
- }
75156
-
75157
- if (i <= j) {
75158
-
75159
- if (i !== j) {
75160
- //do swap
75161
- swap_operator.call(swap_context, data, i, j);
75162
- }
75163
-
75164
- i++;
75165
- j--;
75166
- }
75167
- }
75168
-
75169
- /* recursion */
75170
- if (left < j) {
75171
- stack$2[stackPointer++] = left;
75172
- stack$2[stackPointer++] = j;
75173
- }
75174
- if (i < right) {
75175
- stack$2[stackPointer++] = i;
75176
- stack$2[stackPointer++] = right;
75177
- }
75178
- }
75179
- }
75427
+ const stack$3 = [];
75180
75428
 
75181
75429
  /**
75182
75430
  * @template T
75183
- * @param {T[]} data
75431
+ * @param {T[]|Uint32Array} data
75184
75432
  * @param {function(T,T):number} compare_function
75185
75433
  * @param {*} compare_function_context
75186
75434
  * @param {number} start
@@ -75199,14 +75447,14 @@ function array_quick_sort_by_comparator(
75199
75447
  let stackPointer = 2;
75200
75448
  let i, j;
75201
75449
 
75202
- stack$2[0] = start;
75203
- stack$2[1] = end;
75450
+ stack$3[0] = start;
75451
+ stack$3[1] = end;
75204
75452
 
75205
75453
  while (stackPointer > 0) {
75206
75454
  stackPointer -= 2;
75207
75455
 
75208
- const right = stack$2[stackPointer + 1];
75209
- const left = stack$2[stackPointer];
75456
+ const right = stack$3[stackPointer + 1];
75457
+ const left = stack$3[stackPointer];
75210
75458
 
75211
75459
  i = left;
75212
75460
  j = right;
@@ -75242,12 +75490,12 @@ function array_quick_sort_by_comparator(
75242
75490
 
75243
75491
  /* recursion */
75244
75492
  if (left < j) {
75245
- stack$2[stackPointer++] = left;
75246
- stack$2[stackPointer++] = j;
75493
+ stack$3[stackPointer++] = left;
75494
+ stack$3[stackPointer++] = j;
75247
75495
  }
75248
75496
  if (i < right) {
75249
- stack$2[stackPointer++] = i;
75250
- stack$2[stackPointer++] = right;
75497
+ stack$3[stackPointer++] = i;
75498
+ stack$3[stackPointer++] = right;
75251
75499
  }
75252
75500
  }
75253
75501
  }
@@ -75590,6 +75838,9 @@ const TextureAttachmentsByMaterialType = {
75590
75838
  taDisplacement,
75591
75839
  taAlphaMap
75592
75840
  ],
75841
+ MeshBasicMaterial: [
75842
+ taDiffuse
75843
+ ],
75593
75844
  MeshStandardMaterial: [
75594
75845
  taDiffuse,
75595
75846
  taAlphaMap,
@@ -76165,6 +76416,12 @@ function textureImagesEqual(a, b) {
76165
76416
 
76166
76417
  }
76167
76418
 
76419
+ if (isTypedArray(a.data) && isTypedArray(b.data)) {
76420
+ if (!textureMipmapEqual(a, b)) {
76421
+ return false;
76422
+ }
76423
+ }
76424
+
76168
76425
  // assume equivalent
76169
76426
  return true;
76170
76427
  }
@@ -88110,7 +88367,7 @@ class ColorAndDepthFrameBuffer extends FrameBuffer {
88110
88367
  }
88111
88368
  }
88112
88369
 
88113
- const stack$1 = [];
88370
+ const stack$2 = [];
88114
88371
 
88115
88372
  class ThreeBypassRenderer {
88116
88373
  constructor() {
@@ -88187,13 +88444,13 @@ class ThreeBypassRenderer {
88187
88444
  const object3D = input[i];
88188
88445
 
88189
88446
  if (input_filter(object3D)) {
88190
- stack$1[stack_top++] = object3D;
88447
+ stack$2[stack_top++] = object3D;
88191
88448
  }
88192
88449
 
88193
88450
  }
88194
88451
 
88195
88452
  while (stack_top > 0) {
88196
- const object3D = stack$1[--stack_top];
88453
+ const object3D = stack$2[--stack_top];
88197
88454
 
88198
88455
  if (
88199
88456
  object_filter(object3D)
@@ -88232,7 +88489,7 @@ class ThreeBypassRenderer {
88232
88489
  for (i = 0; i < child_count; i++) {
88233
88490
  const child = children[i];
88234
88491
 
88235
- stack$1[stack_top++] = child;
88492
+ stack$2[stack_top++] = child;
88236
88493
  }
88237
88494
  }
88238
88495
 
@@ -105066,6 +105323,9 @@ class TopDownCameraController {
105066
105323
 
105067
105324
  this.distance = eye.distanceTo(target);
105068
105325
 
105326
+ // ensure we can maintain this distance
105327
+ this.distanceMax = max2(this.distance, this.distanceMax);
105328
+
105069
105329
  this.target.copy(target);
105070
105330
  }
105071
105331
 
@@ -105753,6 +106013,82 @@ function computeBinaryDataTypeByPrecision(type, precision) {
105753
106013
  throw new Error(`Unsupported numeric type(=${type}) and precision(=${precision}) combination`);
105754
106014
  }
105755
106015
 
106016
+ const stack$1 = [];
106017
+
106018
+ /**
106019
+ * @template T
106020
+ * @param {T[]|ArrayLike<number>|Uint32Array} data
106021
+ * @param {function(T):number} score_function
106022
+ * @param {*} score_function_context
106023
+ * @param {number} start
106024
+ * @param {number} end
106025
+ * @param {function(T[],number, number):*} [swap_operator]
106026
+ * @param {*} [swap_context]
106027
+ */
106028
+ function arrayQuickSort(
106029
+ data,
106030
+ score_function, score_function_context,
106031
+ start, end,
106032
+ swap_operator = array_swap_one, swap_context = undefined
106033
+ ) {
106034
+ if (start >= end) {
106035
+ // section of 0 size, nothing to sort
106036
+ return;
106037
+ }
106038
+
106039
+ let stackPointer = 2;
106040
+ let i, j;
106041
+
106042
+ stack$1[0] = start;
106043
+ stack$1[1] = end;
106044
+
106045
+ while (stackPointer > 0) {
106046
+ stackPointer -= 2;
106047
+
106048
+ const right = stack$1[stackPointer + 1];
106049
+ const left = stack$1[stackPointer];
106050
+
106051
+ i = left;
106052
+ j = right;
106053
+
106054
+ const pivotIndex = (left + right) >> 1;
106055
+
106056
+ const pivot = score_function.call(score_function_context, data[pivotIndex]);
106057
+
106058
+ /* partition */
106059
+ while (i <= j) {
106060
+ while (score_function.call(score_function_context, data[i]) < pivot) {
106061
+ i++;
106062
+ }
106063
+
106064
+ while (score_function.call(score_function_context, data[j]) > pivot) {
106065
+ j--;
106066
+ }
106067
+
106068
+ if (i <= j) {
106069
+
106070
+ if (i !== j) {
106071
+ //do swap
106072
+ swap_operator.call(swap_context, data, i, j);
106073
+ }
106074
+
106075
+ i++;
106076
+ j--;
106077
+ }
106078
+ }
106079
+
106080
+ /* recursion */
106081
+ if (left < j) {
106082
+ stack$1[stackPointer++] = left;
106083
+ stack$1[stackPointer++] = j;
106084
+ }
106085
+ if (i < right) {
106086
+ stack$1[stackPointer++] = i;
106087
+ stack$1[stackPointer++] = right;
106088
+ }
106089
+ }
106090
+ }
106091
+
105756
106092
  /**
105757
106093
  *
105758
106094
  * @param {number[]|Float32Array|Float64Array} source
@@ -115602,6 +115938,12 @@ function setLocale(engine) {
115602
115938
  return engine.localization.loadLocale(locale);
115603
115939
  }
115604
115940
 
115941
+ /**
115942
+ * Equal to ~ 5500 K light color
115943
+ * @type {Readonly<Color>}
115944
+ */
115945
+ const DEFAULT_SUNLIGHT_COLOR = Object.freeze(new Color(1, 0.93, 0.87));
115946
+
115605
115947
  class EngineHarness {
115606
115948
  constructor() {
115607
115949
  /**
@@ -115879,7 +116221,7 @@ class EngineHarness {
115879
116221
  ecd = engine.entityManager.dataset,
115880
116222
  shadowmapResolution = 1024,
115881
116223
  castShadow = true,
115882
- sun = Color.white,
116224
+ sun = DEFAULT_SUNLIGHT_COLOR,
115883
116225
  sunIntensity = 0.9,
115884
116226
  sunDirection = new Vector3$1(0.1, -1, 0.1),
115885
116227
  ambient = Color.white,