@woosh/meep-engine 2.118.9 → 2.118.12

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 (104) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +209 -266
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +209 -266
  5. package/editor/ecs/component/editors/Sampler2DEditor.js +2 -4
  6. package/package.json +1 -1
  7. package/samples/terrain/editor.js +3 -3
  8. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts +1 -19
  9. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  10. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +10 -78
  11. package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +1 -1
  12. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  13. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +13 -11
  14. package/src/core/collection/array/isArrayEqualStrict.d.ts.map +1 -1
  15. package/src/core/collection/array/isArrayEqualStrict.js +2 -2
  16. package/src/core/collection/array/iterator/ArrayIteratorSequential.d.ts.map +1 -1
  17. package/src/core/collection/array/iterator/ArrayIteratorSequential.js +3 -4
  18. package/src/core/collection/array/typed/array_buffer_copy.js +2 -2
  19. package/src/core/collection/array/typed/typed_array_copy.d.ts.map +1 -1
  20. package/src/core/collection/array/typed/typed_array_copy.js +16 -0
  21. package/src/core/collection/queue/Deque.d.ts.map +1 -1
  22. package/src/core/collection/queue/Deque.js +1 -1
  23. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  24. package/src/core/geom/3d/aabb/AABB3.js +0 -8
  25. package/src/core/geom/3d/aabb/aabb3_compute_surface_area.js +1 -3
  26. package/src/core/geom/3d/morton/{Morton.d.ts → v3_morton_encode.d.ts} +1 -1
  27. package/src/core/geom/3d/morton/v3_morton_encode.d.ts.map +1 -0
  28. package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +2 -2
  29. package/src/core/geom/3d/morton/v3_morton_encode_transformed.js +2 -2
  30. package/src/core/geom/Quaternion.d.ts.map +1 -1
  31. package/src/core/geom/Quaternion.js +7 -10
  32. package/src/core/geom/Vector3.d.ts.map +1 -1
  33. package/src/core/geom/Vector3.js +4 -49
  34. package/src/core/math/sinc.d.ts +8 -0
  35. package/src/core/math/sinc.d.ts.map +1 -0
  36. package/src/core/math/sinc.js +13 -0
  37. package/src/core/process/worker/WorkerProxy.d.ts +12 -3
  38. package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
  39. package/src/core/process/worker/WorkerProxy.js +10 -1
  40. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.d.ts +2 -17
  41. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.d.ts.map +1 -1
  42. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.js +2 -118
  43. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.d.ts +0 -1
  44. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.d.ts.map +1 -1
  45. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +1 -6
  46. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts +5 -5
  47. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
  48. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +20 -28
  49. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.d.ts.map +1 -1
  50. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +2 -2
  51. package/src/engine/ecs/terrain/tiles/TerrainTile.d.ts.map +1 -1
  52. package/src/engine/ecs/terrain/tiles/TerrainTile.js +3 -1
  53. package/src/engine/graphics/geometry/MikkT/MikkTSpace.d.ts +1 -1
  54. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +12 -12
  55. package/src/engine/graphics/geometry/MikkT/STSpace.d.ts.map +1 -1
  56. package/src/engine/graphics/geometry/MikkT/STSpace.js +14 -16
  57. package/src/engine/graphics/geometry/buffered/build_height_field_geometry.d.ts +17 -0
  58. package/src/engine/graphics/geometry/buffered/build_height_field_geometry.d.ts.map +1 -0
  59. package/src/engine/graphics/geometry/buffered/build_height_field_geometry.js +118 -0
  60. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.d.ts +2 -2
  61. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.d.ts.map +1 -1
  62. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.js +1 -1
  63. package/src/engine/graphics/geometry/optimization/VertexCacheOptimizer.d.ts.map +1 -1
  64. package/src/engine/graphics/geometry/optimization/VertexCacheOptimizer.js +36 -22
  65. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.d.ts.map +1 -1
  66. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +2 -2
  67. package/src/engine/graphics/render/forward_plus/materials/FPlusDebugMaterial.js +3 -3
  68. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  69. package/src/engine/graphics/texture/sampler/Sampler2D.js +31 -52
  70. package/src/engine/graphics/texture/sampler/sampler2d_to_texture.d.ts +10 -0
  71. package/src/engine/graphics/texture/sampler/sampler2d_to_texture.d.ts.map +1 -0
  72. package/src/engine/graphics/texture/sampler/{Sampler2D2Texture.js → sampler2d_to_texture.js} +5 -5
  73. package/src/engine/graphics/texture/sampler/{copy_Sampler2D_channel_data.d.ts → sampler2d_transfer_data.d.ts} +2 -2
  74. package/src/engine/graphics/texture/sampler/sampler2d_transfer_data.d.ts.map +1 -0
  75. package/src/engine/graphics/texture/sampler/{copy_Sampler2D_channel_data.js → sampler2d_transfer_data.js} +1 -1
  76. package/src/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.js +2 -2
  77. package/src/engine/graphics/trail/x/simulator/RibbonXFixedPhysicsSimulator.d.ts.map +1 -1
  78. package/src/engine/graphics/trail/x/simulator/RibbonXFixedPhysicsSimulator.js +0 -3
  79. package/src/engine/intelligence/behavior/selector/WeightedElement.d.ts +6 -3
  80. package/src/engine/intelligence/behavior/selector/WeightedElement.d.ts.map +1 -1
  81. package/src/engine/intelligence/behavior/selector/WeightedElement.js +9 -12
  82. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.d.ts +1 -1
  83. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.d.ts.map +1 -1
  84. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.js +20 -23
  85. package/src/engine/intelligence/mcts/StateNode.d.ts.map +1 -1
  86. package/src/engine/intelligence/mcts/StateNode.js +76 -102
  87. package/src/engine/logging/Logger.d.ts.map +1 -1
  88. package/src/engine/logging/Logger.js +7 -9
  89. package/src/engine/logging/LoggerBackend.d.ts.map +1 -1
  90. package/src/engine/logging/LoggerBackend.js +7 -7
  91. package/src/core/geom/3d/morton/Morton.d.ts.map +0 -1
  92. package/src/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.d.ts +0 -9
  93. package/src/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.d.ts.map +0 -1
  94. package/src/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.js +0 -11
  95. package/src/engine/graphics/geometry/MikkT/m_getPosition.d.ts +0 -14
  96. package/src/engine/graphics/geometry/MikkT/m_getPosition.d.ts.map +0 -1
  97. package/src/engine/graphics/geometry/MikkT/m_getPosition.js +0 -20
  98. package/src/engine/graphics/geometry/MikkT/m_setTSpaceBasic.d.ts +0 -21
  99. package/src/engine/graphics/geometry/MikkT/m_setTSpaceBasic.d.ts.map +0 -1
  100. package/src/engine/graphics/geometry/MikkT/m_setTSpaceBasic.js +0 -22
  101. package/src/engine/graphics/texture/sampler/Sampler2D2Texture.d.ts +0 -10
  102. package/src/engine/graphics/texture/sampler/Sampler2D2Texture.d.ts.map +0 -1
  103. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.d.ts.map +0 -1
  104. /package/src/core/geom/3d/morton/{Morton.js → v3_morton_encode.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
- * @param {Array|Uint8Array} a
4
- * @param {Array|Uint8Array} b
3
+ * @param {Array|Uint8Array|Float32Array} a
4
+ * @param {Array|Uint8Array|Float32Array} b
5
5
  * @returns {boolean}
6
6
  */
7
7
  function isArrayEqualStrict(a, b) {
@@ -2531,10 +2531,10 @@ let Vector3$1 = class Vector3 {
2531
2531
  * @param {number} [squaredError]
2532
2532
  * @return {boolean}
2533
2533
  */
2534
- isNormalized(squaredError = 0.01) {
2534
+ isNormalized(squaredError = 1e-5) {
2535
2535
  const lengthSq = this.lengthSqr();
2536
2536
 
2537
- return (lengthSq + squaredError) >= 1 && (lengthSq - squaredError) <= 1;
2537
+ return epsilonEquals(lengthSq, 1, squaredError);
2538
2538
  }
2539
2539
 
2540
2540
  /**
@@ -2584,10 +2584,6 @@ let Vector3$1 = class Vector3 {
2584
2584
  return v3_length_sqr(this.x - x, this.y - y, this.z - z);
2585
2585
  }
2586
2586
 
2587
- distanceToSquared(other) {
2588
- return v3_length_sqr(this.x - other.x, this.y - other.y, this.z - other.z);
2589
- }
2590
-
2591
2587
  /**
2592
2588
  * Angle between two vectors (co-planar) in radians
2593
2589
  * @param {Vector3} other
@@ -2847,31 +2843,6 @@ let Vector3$1 = class Vector3 {
2847
2843
  this._projectVectors(x0, y0, z0, x1, y1, z1);
2848
2844
  }
2849
2845
 
2850
- /**
2851
- * Compute orthogonal vectors given a normal
2852
- * Orthogonal vectors are normalized vectors pointing at right angles away from the input normal and to one another
2853
- * @see https://stackoverflow.com/questions/3684269/component-of-a-quaternion-rotation-around-an-axis
2854
- * @param normal
2855
- * @param orthonormal1
2856
- * @param orthonormal2
2857
- */
2858
- static findOrthonormals(normal, orthonormal1, orthonormal2) {
2859
- throw new Error('Not Implemented');
2860
-
2861
- // Vector3 w = Vector3.Transform(normal, OrthoX);
2862
- // float dot = Vector3.Dot(normal, w);
2863
- // if (Math.Abs(dot) > 0.6)
2864
- // {
2865
- // w = Vector3.Transform(normal, OrthoY);
2866
- // }
2867
- // w.Normalize();
2868
- //
2869
- // orthonormal1 = Vector3.Cross(normal, w);
2870
- // orthonormal1.Normalize();
2871
- // orthonormal2 = Vector3.Cross(normal, orthonormal1);
2872
- // orthonormal2.Normalize();
2873
- }
2874
-
2875
2846
  /**
2876
2847
  * Project first vector onto second one
2877
2848
  * @param {number} x0
@@ -3004,24 +2975,6 @@ let Vector3$1 = class Vector3 {
3004
2975
  this.set(x, y, z);
3005
2976
  }
3006
2977
 
3007
- /**
3008
- *
3009
- * @param {BinaryBuffer} buffer
3010
- * @deprecated use dedicated method directly instead
3011
- */
3012
- toBinaryBufferFloat32_EqualityEncoded(buffer) {
3013
- throw new Error('deprecated, use v3_binary_equality_encode')
3014
- }
3015
-
3016
- /**
3017
- * Uses an extra byte for a header. Only writes unique components. Useful for things like scale where all components usually have the same value
3018
- * @param {BinaryBuffer} buffer
3019
- * @deprecated use dedicated method directly instead
3020
- */
3021
- fromBinaryBufferFloat32_EqualityEncoded(buffer) {
3022
- throw new Error('deprecated, use v3_binary_equality_decode')
3023
- }
3024
-
3025
2978
  hash() {
3026
2979
  const x = computeHashFloat(this.x);
3027
2980
  const y = computeHashFloat(this.y);
@@ -3109,6 +3062,8 @@ let Vector3$1 = class Vector3 {
3109
3062
 
3110
3063
  // Aliases
3111
3064
 
3065
+ Vector3$1.prototype.distanceToSquared = Vector3$1.prototype.distanceSqrTo;
3066
+
3112
3067
  Vector3$1.prototype.lengthSq = Vector3$1.prototype.lengthSqr;
3113
3068
  Vector3$1.prototype.fromArray = Vector3$1.prototype.readFromArray;
3114
3069
  Vector3$1.prototype.toArray = Vector3$1.prototype.writeToArray;
@@ -4015,18 +3970,18 @@ let Quaternion$1 = class Quaternion {
4015
3970
  if (uv_dot < -0.9999999) {
4016
3971
  //to vector is opposite, produce a reversal quaternion
4017
3972
 
4018
- tempvec3.crossVectors(Vector3$1.left, from);
3973
+ scratch_v3_a.crossVectors(Vector3$1.left, from);
4019
3974
 
4020
- if (tempvec3.lengthSqr() < 0.00001) {
4021
- tempvec3.crossVectors(Vector3$1.up, from);
3975
+ if (scratch_v3_a.lengthSqr() < 0.00001) {
3976
+ scratch_v3_a.crossVectors(Vector3$1.up, from);
4022
3977
  }
4023
3978
 
4024
- tempvec3.normalize();
3979
+ scratch_v3_a.normalize();
4025
3980
 
4026
3981
  this.set(
4027
- tempvec3.x,
4028
- tempvec3.y,
4029
- tempvec3.z,
3982
+ scratch_v3_a.x,
3983
+ scratch_v3_a.y,
3984
+ scratch_v3_a.z,
4030
3985
  0
4031
3986
  );
4032
3987
 
@@ -4558,10 +4513,7 @@ Quaternion$1.prototype.toArray = Quaternion$1.prototype.writeToArray;
4558
4513
  * @readonly
4559
4514
  * @type {Quaternion}
4560
4515
  */
4561
- Quaternion$1.identity = Object.freeze(new Quaternion$1(0, 0, 0, 1));
4562
-
4563
-
4564
- const tempvec3 = new Vector3$1();
4516
+ Quaternion$1.identity = Object.freeze(new Quaternion$1(0, 0, 0, 1));
4565
4517
 
4566
4518
  /**
4567
4519
  * @readonly
@@ -49010,34 +48962,6 @@ function compute_typed_array_constructor_from_data_type(dt) {
49010
48962
  return r;
49011
48963
  }
49012
48964
 
49013
- /**
49014
- * Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
49015
- * @param {number[]|Uint32Array|Uint16Array|Uint8Array} array
49016
- * @param {number} offset
49017
- * @param {number} length
49018
- * @param {number} stride
49019
- * @return {number}
49020
- */
49021
- function computeStridedIntegerArrayHash(
49022
- array, offset, length, stride
49023
- ) {
49024
- let hash = length;
49025
-
49026
- for (let i = offset; i < length; i += stride) {
49027
- const value = array[i] >>> 0; //force uint32
49028
-
49029
- /**
49030
- * Simple hashing scheme, multiplying existing hash by a prime and adding next value
49031
- * (h<<5) - h === h*31
49032
- * @type {number}
49033
- */
49034
- hash = ((hash << 5) - hash) + value;
49035
- }
49036
-
49037
- // force uint32
49038
- return hash >>> 0;
49039
- }
49040
-
49041
48965
  /**
49042
48966
  *
49043
48967
  * @param {*} array
@@ -49184,6 +49108,62 @@ function is_typed_array_equals(a, b) {
49184
49108
  return isArrayEqualStrict(a_proxy, b_proxy);
49185
49109
  }
49186
49110
 
49111
+ /**
49112
+ * Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
49113
+ * @template T
49114
+ * @param {T[]|Uint32Array|Uint16Array|Uint8Array} array
49115
+ * @param {number} offset
49116
+ * @param {number} length
49117
+ * @param {number} stride
49118
+ * @param {function(T):number} elementHash
49119
+ * @param {*} [elementHashContext]
49120
+ * @return {number}
49121
+ */
49122
+ function computeStridedArrayHash(
49123
+ array, offset, length, stride,
49124
+ elementHash, elementHashContext
49125
+ ) {
49126
+
49127
+ let hash = length;
49128
+
49129
+ for (let i = offset; i < length; i += stride) {
49130
+ const value = elementHash.call(elementHashContext, array[i]);
49131
+
49132
+ /**
49133
+ * Simple hashing scheme, multiplying existing hash by a prime and adding next value
49134
+ * (h<<5) - h === h*31
49135
+ * @type {number}
49136
+ */
49137
+ hash = ((hash << 5) - hash) + value;
49138
+ }
49139
+
49140
+ // force uint32
49141
+ return hash >>> 0;
49142
+ }
49143
+
49144
+ /**
49145
+ *
49146
+ * @param {Uint32Array} array
49147
+ * @param {number} offset
49148
+ * @param {number} length
49149
+ * @param {number} [sample_limit]
49150
+ * @returns {number}
49151
+ */
49152
+ function sparse_typed_array_hash(array, offset, length, sample_limit = 31) {
49153
+ // limit hash evaluation to first 1k of the data to random memory access and keep CPU cache usage more coherent
49154
+ const hash_evaluation_length = min2(length, 1024);
49155
+
49156
+ // compute stride so that we don't have to iterate over the entire buffer, instead picking at most X(509) values to consider
49157
+ const stride = Math.max(1, Math.ceil(hash_evaluation_length / sample_limit));
49158
+
49159
+ // TODO implement fast dedicated float and int paths
49160
+
49161
+ return computeStridedArrayHash(
49162
+ array, 0, hash_evaluation_length, stride,
49163
+ computeHashFloat
49164
+ );
49165
+ }
49166
+
49187
49167
  function typedArrayConstructorByInstance(a) {
49188
49168
  if (a instanceof Int8Array) {
49189
49169
  return Int8Array;
@@ -49258,19 +49238,19 @@ class Sampler2D {
49258
49238
 
49259
49239
  /**
49260
49240
  *
49261
- * @type {Number}
49241
+ * @type {number}
49262
49242
  */
49263
49243
  this.width = width;
49264
49244
 
49265
49245
  /**
49266
49246
  *
49267
- * @type {Number}
49247
+ * @type {number}
49268
49248
  */
49269
49249
  this.height = height;
49270
49250
 
49271
49251
  /**
49272
49252
  * Number of channels
49273
- * @type {Number}
49253
+ * @type {number}
49274
49254
  */
49275
49255
  this.itemSize = itemSize;
49276
49256
 
@@ -49287,18 +49267,6 @@ class Sampler2D {
49287
49267
  this.version = 0;
49288
49268
  }
49289
49269
 
49290
- /**
49291
- *
49292
- * @deprecated
49293
- * @param {number} x
49294
- * @param {number}y
49295
- * @param {Vector1|Vector2|Vector3|Vector4} result
49296
- * @returns {number}
49297
- */
49298
- get(x, y, result) {
49299
- throw new Error("Deprecated method, use sampleBilinear instead");
49300
- }
49301
-
49302
49270
  /**
49303
49271
  *
49304
49272
  * @param {number} u
@@ -49321,8 +49289,8 @@ class Sampler2D {
49321
49289
  * @returns {number}
49322
49290
  */
49323
49291
  sampleChannelCatmullRomUV(u, v, channel) {
49324
- const x = u * (this.width) - 0.5;
49325
- const y = v * (this.height) - 0.5;
49292
+ const x = u * this.width - 0.5;
49293
+ const y = v * this.height - 0.5;
49326
49294
 
49327
49295
  return this.sampleChannelCatmullRom(x, y, channel);
49328
49296
  }
@@ -49377,8 +49345,8 @@ class Sampler2D {
49377
49345
  const texPos12_x = texPos1_x + offset12_x;
49378
49346
  const texPos12_y = texPos1_y + offset12_y;
49379
49347
 
49380
-
49381
49348
  let result = 0.0;
49349
+
49382
49350
  result += this.sampleChannelBilinear(texPos0_x, texPos0_y, channel) * w0_x * w0_y;
49383
49351
  result += this.sampleChannelBilinear(texPos12_x, texPos0_y, channel) * w12_x * w0_y;
49384
49352
  result += this.sampleChannelBilinear(texPos3_x, texPos0_y, channel) * w3_x * w0_y;
@@ -49440,8 +49408,8 @@ class Sampler2D {
49440
49408
  }
49441
49409
 
49442
49410
  /**
49443
- * TODO there is an oversaturation bug in here somewhere, prefer to use linear sampling for now instead
49444
- * Bicubic-filtered sampling
49411
+ *
49412
+ * Bicubic-filtered sampling, note values can be negative due to the nature of the cubic curve
49445
49413
  * @param {number} x
49446
49414
  * @param {number} y
49447
49415
  * @param {number} channel
@@ -49670,7 +49638,11 @@ class Sampler2D {
49670
49638
  const x = Math.round(u * w - 0.5);
49671
49639
  const y = Math.round(v * h - 0.5);
49672
49640
 
49673
- this.read(clamp$1(x, 0, w - 1), clamp$1(y, 0, h - 1), result);
49641
+ this.read(
49642
+ clamp$1(x, 0, w - 1),
49643
+ clamp$1(y, 0, h - 1),
49644
+ result
49645
+ );
49674
49646
  }
49675
49647
 
49676
49648
  /**
@@ -49725,24 +49697,6 @@ class Sampler2D {
49725
49697
  }
49726
49698
  }
49727
49699
 
49728
- /**
49729
- *
49730
- * @param {number} u
49731
- * @param {number} v
49732
- * @param {Vector4|Vector3|Vector2} [result]
49733
- * @deprecated
49734
- */
49735
- sample(u, v, result) {
49736
-
49737
- const temp = [];
49738
-
49739
- this.sampleBilinear(u * (this.width - 1), v * (this.height - 1), temp, 0);
49740
-
49741
- result.readFromArray(temp);
49742
-
49743
- return temp[0];
49744
- }
49745
-
49746
49700
  /**
49747
49701
  *
49748
49702
  * @param {number} x
@@ -49872,11 +49826,11 @@ class Sampler2D {
49872
49826
 
49873
49827
  /**
49874
49828
  *
49875
- * @param {Number} x
49876
- * @param {Number} y
49877
- * @param {Number} width
49878
- * @param {Number} height
49879
- * @param {Array.<Number>} value
49829
+ * @param {number} x
49830
+ * @param {number} y
49831
+ * @param {number} width
49832
+ * @param {number} height
49833
+ * @param {Array.<number>} value
49880
49834
  */
49881
49835
  fill(x, y, width, height, value) {
49882
49836
 
@@ -50054,10 +50008,13 @@ class Sampler2D {
50054
50008
  computeByteSize() {
50055
50009
  let dataSize;
50056
50010
 
50057
- if (Array.isArray(this.data)) {
50058
- dataSize = 8 * this.data.length;
50011
+ const data = this.data;
50012
+
50013
+ if (Array.isArray(data)) {
50014
+ // Assume IEEE float 64
50015
+ dataSize = 8 * data.length;
50059
50016
  } else {
50060
- dataSize = this.data.buffer.byteLength;
50017
+ dataSize = data.buffer.byteLength;
50061
50018
  }
50062
50019
 
50063
50020
  return dataSize + 280;
@@ -50069,6 +50026,11 @@ class Sampler2D {
50069
50026
  * @return {boolean}
50070
50027
  */
50071
50028
  equals(other) {
50029
+ if(this === other){
50030
+ // special case
50031
+ return true;
50032
+ }
50033
+
50072
50034
  if (
50073
50035
  this.width !== other.width
50074
50036
  || this.height !== other.height
@@ -50089,9 +50051,7 @@ class Sampler2D {
50089
50051
 
50090
50052
  const length = this.data.length;
50091
50053
 
50092
- const stride = Math.max(1, Math.ceil(length / 509));
50093
-
50094
- hash ^= computeStridedIntegerArrayHash(this.data, 0, length, stride);
50054
+ hash ^= sparse_typed_array_hash(this.data, 0, length, 509);
50095
50055
 
50096
50056
  return hash;
50097
50057
  }
@@ -50627,6 +50587,34 @@ Vector1.zero = Object.freeze(new Vector1(0));
50627
50587
  */
50628
50588
  Vector1.one = Object.freeze(new Vector1(1));
50629
50589
 
50590
+ /**
50591
+ * Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
50592
+ * @param {number[]|Uint32Array|Uint16Array|Uint8Array} array
50593
+ * @param {number} offset
50594
+ * @param {number} length
50595
+ * @param {number} stride
50596
+ * @return {number}
50597
+ */
50598
+ function computeStridedIntegerArrayHash(
50599
+ array, offset, length, stride
50600
+ ) {
50601
+ let hash = length;
50602
+
50603
+ for (let i = offset; i < length; i += stride) {
50604
+ const value = array[i] >>> 0; //force uint32
50605
+
50606
+ /**
50607
+ * Simple hashing scheme, multiplying existing hash by a prime and adding next value
50608
+ * (h<<5) - h === h*31
50609
+ * @type {number}
50610
+ */
50611
+ hash = ((hash << 5) - hash) + value;
50612
+ }
50613
+
50614
+ // force uint32
50615
+ return hash >>> 0;
50616
+ }
50617
+
50630
50618
  /**
50631
50619
  *
50632
50620
  * @param {Uint8Array|number[]|ArrayLike<number>|IArguments} data
@@ -52074,6 +52062,8 @@ function array_buffer_copy(
52074
52062
  target, target_offset,
52075
52063
  byte_length
52076
52064
  ) {
52065
+ // assert.ok(source instanceof ArrayBuffer || source instanceof SharedArrayBuffer,'source is not an ArrayBuffer');
52066
+ // assert.ok(target instanceof ArrayBuffer || target instanceof SharedArrayBuffer,'source is not an ArrayBuffer');
52077
52067
 
52078
52068
  /**
52079
52069
  * @type {Uint8Array|Uint16Array|Uint32Array}
@@ -55302,29 +55292,6 @@ function v3_morton_encode_bounded(x, y, z, bounds) {
55302
55292
  );
55303
55293
  }
55304
55294
 
55305
- /**
55306
- * Returns highest value out of 3 supplied
55307
- * @param {number} a
55308
- * @param {number} b
55309
- * @param {number} c
55310
- * @returns {number}
55311
- */
55312
- function max3(a, b, c) {
55313
-
55314
- let v = a;
55315
-
55316
- if (v < b) {
55317
- v = b;
55318
- }
55319
-
55320
- if (v < c) {
55321
- v = c;
55322
- }
55323
-
55324
- return v;
55325
-
55326
- }
55327
-
55328
55295
  /**
55329
55296
  * @readonly
55330
55297
  * @type {number}
@@ -55610,73 +55577,6 @@ class BinaryUint32BVH {
55610
55577
  return result;
55611
55578
  }
55612
55579
 
55613
- /**
55614
- *
55615
- * @param {number} a address
55616
- * @param {number} b address
55617
- * @param {number} c address
55618
- * @returns {number}
55619
- * @private
55620
- */
55621
- __compute_bounds_area_of_3_boxes(a, b, c) {
55622
- const float32 = this.__data_float32;
55623
-
55624
- const x0 = min3(float32[a + 0], float32[b + 0], float32[c + 0]);
55625
- const y0 = min3(float32[a + 1], float32[b + 1], float32[c + 1]);
55626
- const z0 = min3(float32[a + 2], float32[b + 2], float32[c + 2]);
55627
-
55628
- const x1 = max3(float32[a + 3], float32[b + 3], float32[c + 3]);
55629
- const y1 = max3(float32[a + 4], float32[b + 4], float32[c + 4]);
55630
- const z1 = max3(float32[a + 5], float32[b + 5], float32[c + 5]);
55631
-
55632
- return aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1);
55633
- }
55634
-
55635
- /**
55636
- *
55637
- * @param {number} a
55638
- * @param {number} b
55639
- * @returns {number}
55640
- * @private
55641
- */
55642
- __fitness_function_should_swap_leaves_sah(a, b) {
55643
- const a_0 = max2(a - 1, 0);
55644
- const a_1 = min2(a + 1, this.__node_count_leaf - 1);
55645
-
55646
- const leaf_block_offset = this.getLeafBlockAddress();
55647
-
55648
- const a_c_address = a * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55649
- const a_0_address = a_0 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55650
- const a_1_address = a_1 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55651
-
55652
-
55653
- const b_0 = max2(b - 1, 0);
55654
- const b_1 = min2(b + 1, this.__node_count_leaf - 1);
55655
-
55656
- const b_c_address = b * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55657
- const b_0_address = b_0 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55658
- const b_1_address = b_1 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55659
-
55660
-
55661
- const current_area = this.__compute_bounds_area_of_3_boxes(a_0_address, a_c_address, a_1_address) + this.__compute_bounds_area_of_3_boxes(b_0_address, b_c_address, b_1_address);
55662
- const swap_area = this.__compute_bounds_area_of_3_boxes(a_0_address, b_c_address, a_1_address) + this.__compute_bounds_area_of_3_boxes(b_0_address, a_c_address, b_1_address);
55663
-
55664
- return current_area - swap_area;
55665
- }
55666
-
55667
- sort_bubble_sah() {
55668
- const n = this.__node_count_leaf;
55669
-
55670
- for (let i = 0; i < n; i++) {
55671
- for (let j = i + 1; j < n; j++) {
55672
- if (this.__fitness_function_should_swap_leaves_sah(i, j) > 0) {
55673
- this.__swap_leaves(i, j);
55674
- }
55675
- }
55676
- }
55677
- }
55678
-
55679
-
55680
55580
  /**
55681
55581
  * Sort leaf nodes according to their morton codes
55682
55582
  * @param {number[]} bounds
@@ -55690,15 +55590,17 @@ class BinaryUint32BVH {
55690
55590
  return;
55691
55591
  }
55692
55592
 
55693
- let stackPointer = 2;
55593
+ const stack_top = stack$9.pointer;
55594
+
55595
+ let stackPointer = stack_top;
55694
55596
  let i, j;
55695
55597
 
55696
- stack$9[0] = 0; // first node
55697
- stack$9[1] = this.__node_count_leaf - 1; // last node
55598
+ stack$9[stackPointer++] = 0; // first node
55599
+ stack$9[stackPointer++] = this.__node_count_leaf - 1; // last node
55698
55600
 
55699
55601
  const data = this.__data_float32;
55700
55602
 
55701
- while (stackPointer > 0) {
55603
+ while (stackPointer > stack_top) {
55702
55604
  stackPointer -= 2;
55703
55605
 
55704
55606
  const right = stack$9[stackPointer + 1];
@@ -55707,14 +55609,15 @@ class BinaryUint32BVH {
55707
55609
  i = left;
55708
55610
  j = right;
55709
55611
 
55710
- const pivotIndex = (left + right) >> 1;
55612
+ const pivot_index = (left + right) >> 1;
55711
55613
 
55712
- const pivot_address = pivotIndex * BVH_LEAF_NODE_SIZE + leaf_block_address;
55614
+ const pivot_address = pivot_index * BVH_LEAF_NODE_SIZE + leaf_block_address;
55713
55615
 
55714
55616
  const pivot = build_morton(data, pivot_address, bounds);
55715
55617
 
55716
55618
  /* partition */
55717
55619
  while (i <= j) {
55620
+
55718
55621
  while (build_morton(data, i * BVH_LEAF_NODE_SIZE + leaf_block_address, bounds) < pivot) {
55719
55622
  i++;
55720
55623
  }
@@ -55748,7 +55651,7 @@ class BinaryUint32BVH {
55748
55651
  }
55749
55652
 
55750
55653
  /**
55751
- *
55654
+ * Does not update intermediate node bounds
55752
55655
  * @param {number} i
55753
55656
  * @param {number} j
55754
55657
  * @private
@@ -56422,13 +56325,6 @@ class AABB3 {
56422
56325
  || (z + tolerance) < this.z0 || (z - tolerance) > this.z1);
56423
56326
  }
56424
56327
 
56425
- computeMortonCode() {
56426
- const cx = (this.x0 + this.x1) >> 1;
56427
- const cy = (this.y0 + this.y1) >> 1;
56428
- const cz = (this.z0 + this.z1) >> 1;
56429
- return mortonEncode_magicbits(cx, cy, cz);
56430
- }
56431
-
56432
56328
  /**
56433
56329
  *
56434
56330
  * @returns {number}
@@ -57739,7 +57635,7 @@ const m4_tmp = [];
57739
57635
  class TerrainTile {
57740
57636
  gridPosition = new Vector2();
57741
57637
  scale = new Vector2(1, 1);
57742
- size = new Vector2();
57638
+ size = new Vector2(1, 1);
57743
57639
  position = new Vector2();
57744
57640
  resolution = new ObservedInteger(1);
57745
57641
 
@@ -58209,6 +58105,7 @@ class TerrainTile {
58209
58105
 
58210
58106
  geometry.boundingSphere = new Sphere(center, radius);
58211
58107
  }
58108
+
58212
58109
  //pull bounding box from geometry
58213
58110
 
58214
58111
  bb = geometry.boundingBox;
@@ -58216,6 +58113,7 @@ class TerrainTile {
58216
58113
  geometry.computeBoundingBox();
58217
58114
  bb = geometry.boundingBox;
58218
58115
  }
58116
+
58219
58117
  }
58220
58118
 
58221
58119
  const x0 = bb.min.x;
@@ -59113,11 +59011,11 @@ function writeSample2DDataToDataTexture(sampler, texture) {
59113
59011
  }
59114
59012
  } else if (sampler.itemSize === 3) {
59115
59013
  if (texture.format !== RGBFormat$1) {
59116
- throw new Error('itemSize is 2 and texture.format is not RGBFormat');
59014
+ throw new Error('itemSize is 3 and texture.format is not RGBFormat');
59117
59015
  }
59118
59016
  } else if (sampler.itemSize === 4) {
59119
59017
  if (texture.format !== RGBAFormat) {
59120
- throw new Error('itemSize is 2 and texture.format is not RGBAFormat');
59018
+ throw new Error('itemSize is 4 and texture.format is not RGBAFormat');
59121
59019
  }
59122
59020
  } else {
59123
59021
  throw new Error('Unsupported itemSize');
@@ -61495,10 +61393,25 @@ function typed_array_copy(source, destination) {
61495
61393
  const destination_size = destination.length;
61496
61394
 
61497
61395
  if (destination_size >= source.length) {
61396
+
61498
61397
  destination.set(source, 0);
61398
+
61399
+ } else if (source.constructor === destination.constructor) {
61400
+
61401
+ // same type
61402
+ array_buffer_copy(
61403
+ source.buffer,
61404
+ source.byteOffset,
61405
+ destination.buffer,
61406
+ destination.byteOffset,
61407
+ Math.min(source.byteLength, destination.byteLength)
61408
+ );
61409
+
61499
61410
  } else {
61411
+
61500
61412
  // destination is smaller than source, crop source data
61501
61413
  array_copy(source, 0, destination, 0, destination_size);
61414
+
61502
61415
  }
61503
61416
  }
61504
61417
 
@@ -62620,7 +62533,7 @@ function saturated_value_by_constructor(ctor) {
62620
62533
  * @param {Sampler2D} source
62621
62534
  * @param {Sampler2D} destination
62622
62535
  */
62623
- function copy_Sampler2D_channel_data(source, destination) {
62536
+ function sampler2d_transfer_data(source, destination) {
62624
62537
  if (source.width !== destination.width || source.height !== destination.height) {
62625
62538
  throw new Error('Source and destination dimensions do not match');
62626
62539
  }
@@ -62827,7 +62740,7 @@ class TerrainLayer {
62827
62740
 
62828
62741
  const source = new Sampler2D(source_data, source_item_size, image.width, image.height);
62829
62742
 
62830
- copy_Sampler2D_channel_data(source, this.diffuse);
62743
+ sampler2d_transfer_data(source, this.diffuse);
62831
62744
 
62832
62745
  this.onChanged.send0();
62833
62746
 
@@ -63646,11 +63559,16 @@ class WorkerProxy {
63646
63559
  __id_counter = 0;
63647
63560
 
63648
63561
 
63562
+ /**
63563
+ *
63564
+ * @param {string} url
63565
+ * @param {Object} methods
63566
+ */
63649
63567
  constructor(url, methods) {
63650
63568
  this.url = url;
63651
63569
  this.methods = methods;
63652
63570
 
63653
- this.__generateAPI(this, methods);
63571
+ this.__generateAPI();
63654
63572
  }
63655
63573
 
63656
63574
  /**
@@ -63729,6 +63647,10 @@ class WorkerProxy {
63729
63647
 
63730
63648
  }
63731
63649
 
63650
+ /**
63651
+ *
63652
+ * @private
63653
+ */
63732
63654
  __generateAPI() {
63733
63655
 
63734
63656
 
@@ -66109,6 +66031,29 @@ function read_three_planes_to_array(planes, array) {
66109
66031
  }
66110
66032
  }
66111
66033
 
66034
+ /**
66035
+ * Returns highest value out of 3 supplied
66036
+ * @param {number} a
66037
+ * @param {number} b
66038
+ * @param {number} c
66039
+ * @returns {number}
66040
+ */
66041
+ function max3(a, b, c) {
66042
+
66043
+ let v = a;
66044
+
66045
+ if (v < b) {
66046
+ v = b;
66047
+ }
66048
+
66049
+ if (v < c) {
66050
+ v = c;
66051
+ }
66052
+
66053
+ return v;
66054
+
66055
+ }
66056
+
66112
66057
  /**
66113
66058
  *
66114
66059
  * @param {number[]|Float32Array} output
@@ -85587,7 +85532,7 @@ class Deque {
85587
85532
 
85588
85533
  /**
85589
85534
  *
85590
- * @param {E} e
85535
+ * @param {T} e
85591
85536
  * @returns {boolean}
85592
85537
  */
85593
85538
  has(e) {
@@ -92960,14 +92905,12 @@ const LogLevel = {
92960
92905
  };
92961
92906
 
92962
92907
  class Logger {
92963
- constructor() {
92964
- /**
92965
- *
92966
- * @private
92967
- * @type {LoggerBackend[]}
92968
- */
92969
- this.backends = [];
92970
- }
92908
+ /**
92909
+ *
92910
+ * @private
92911
+ * @type {LoggerBackend[]}
92912
+ */
92913
+ backends = [];
92971
92914
 
92972
92915
  /**
92973
92916
  * Add a logging backend, this is a structure that handles incoming log messages.
@@ -115511,14 +115454,14 @@ class InputControllerSystem extends System {
115511
115454
  }
115512
115455
 
115513
115456
  class LoggerBackend {
115514
- constructor() {
115515
115457
 
115516
- /**
115517
- * @private
115518
- * @type {LogLevel|number}
115519
- */
115520
- this.level = LogLevel.Info;
115521
- }
115458
+
115459
+ /**
115460
+ * @private
115461
+ * @type {LogLevel|number}
115462
+ */
115463
+ level = LogLevel.Info;
115464
+
115522
115465
 
115523
115466
  /**
115524
115467
  *