@woosh/meep-engine 2.118.9 → 2.118.11

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 (98) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +192 -266
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +192 -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 +9 -7
  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/queue/Deque.d.ts.map +1 -1
  19. package/src/core/collection/queue/Deque.js +1 -1
  20. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  21. package/src/core/geom/3d/aabb/AABB3.js +0 -8
  22. package/src/core/geom/3d/morton/{Morton.d.ts → v3_morton_encode.d.ts} +1 -1
  23. package/src/core/geom/3d/morton/v3_morton_encode.d.ts.map +1 -0
  24. package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +2 -2
  25. package/src/core/geom/3d/morton/v3_morton_encode_transformed.js +2 -2
  26. package/src/core/geom/Quaternion.d.ts.map +1 -1
  27. package/src/core/geom/Quaternion.js +7 -10
  28. package/src/core/geom/Vector3.d.ts.map +1 -1
  29. package/src/core/geom/Vector3.js +4 -49
  30. package/src/core/math/sinc.d.ts +8 -0
  31. package/src/core/math/sinc.d.ts.map +1 -0
  32. package/src/core/math/sinc.js +13 -0
  33. package/src/core/process/worker/WorkerProxy.d.ts +12 -3
  34. package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
  35. package/src/core/process/worker/WorkerProxy.js +10 -1
  36. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.d.ts +2 -17
  37. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.d.ts.map +1 -1
  38. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.js +2 -118
  39. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.d.ts +0 -1
  40. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.d.ts.map +1 -1
  41. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +1 -6
  42. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts +5 -5
  43. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
  44. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +20 -28
  45. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.d.ts.map +1 -1
  46. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +2 -2
  47. package/src/engine/ecs/terrain/tiles/TerrainTile.d.ts.map +1 -1
  48. package/src/engine/ecs/terrain/tiles/TerrainTile.js +3 -1
  49. package/src/engine/graphics/geometry/MikkT/MikkTSpace.d.ts +1 -1
  50. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +12 -12
  51. package/src/engine/graphics/geometry/MikkT/STSpace.d.ts.map +1 -1
  52. package/src/engine/graphics/geometry/MikkT/STSpace.js +14 -16
  53. package/src/engine/graphics/geometry/buffered/build_height_field_geometry.d.ts +17 -0
  54. package/src/engine/graphics/geometry/buffered/build_height_field_geometry.d.ts.map +1 -0
  55. package/src/engine/graphics/geometry/buffered/build_height_field_geometry.js +118 -0
  56. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.d.ts +2 -2
  57. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.d.ts.map +1 -1
  58. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.js +1 -1
  59. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.d.ts.map +1 -1
  60. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +2 -2
  61. package/src/engine/graphics/render/forward_plus/materials/FPlusDebugMaterial.js +3 -3
  62. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  63. package/src/engine/graphics/texture/sampler/Sampler2D.js +31 -52
  64. package/src/engine/graphics/texture/sampler/sampler2d_to_texture.d.ts +10 -0
  65. package/src/engine/graphics/texture/sampler/sampler2d_to_texture.d.ts.map +1 -0
  66. package/src/engine/graphics/texture/sampler/{Sampler2D2Texture.js → sampler2d_to_texture.js} +5 -5
  67. package/src/engine/graphics/texture/sampler/{copy_Sampler2D_channel_data.d.ts → sampler2d_transfer_data.d.ts} +2 -2
  68. package/src/engine/graphics/texture/sampler/sampler2d_transfer_data.d.ts.map +1 -0
  69. package/src/engine/graphics/texture/sampler/{copy_Sampler2D_channel_data.js → sampler2d_transfer_data.js} +1 -1
  70. package/src/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.js +2 -2
  71. package/src/engine/graphics/trail/x/simulator/RibbonXFixedPhysicsSimulator.d.ts.map +1 -1
  72. package/src/engine/graphics/trail/x/simulator/RibbonXFixedPhysicsSimulator.js +0 -3
  73. package/src/engine/intelligence/behavior/selector/WeightedElement.d.ts +6 -3
  74. package/src/engine/intelligence/behavior/selector/WeightedElement.d.ts.map +1 -1
  75. package/src/engine/intelligence/behavior/selector/WeightedElement.js +9 -12
  76. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.d.ts +1 -1
  77. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.d.ts.map +1 -1
  78. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.js +20 -23
  79. package/src/engine/intelligence/mcts/StateNode.d.ts.map +1 -1
  80. package/src/engine/intelligence/mcts/StateNode.js +76 -102
  81. package/src/engine/logging/Logger.d.ts.map +1 -1
  82. package/src/engine/logging/Logger.js +7 -9
  83. package/src/engine/logging/LoggerBackend.d.ts.map +1 -1
  84. package/src/engine/logging/LoggerBackend.js +7 -7
  85. package/src/core/geom/3d/morton/Morton.d.ts.map +0 -1
  86. package/src/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.d.ts +0 -9
  87. package/src/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.d.ts.map +0 -1
  88. package/src/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.js +0 -11
  89. package/src/engine/graphics/geometry/MikkT/m_getPosition.d.ts +0 -14
  90. package/src/engine/graphics/geometry/MikkT/m_getPosition.d.ts.map +0 -1
  91. package/src/engine/graphics/geometry/MikkT/m_getPosition.js +0 -20
  92. package/src/engine/graphics/geometry/MikkT/m_setTSpaceBasic.d.ts +0 -21
  93. package/src/engine/graphics/geometry/MikkT/m_setTSpaceBasic.d.ts.map +0 -1
  94. package/src/engine/graphics/geometry/MikkT/m_setTSpaceBasic.js +0 -22
  95. package/src/engine/graphics/texture/sampler/Sampler2D2Texture.d.ts +0 -10
  96. package/src/engine/graphics/texture/sampler/Sampler2D2Texture.d.ts.map +0 -1
  97. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.d.ts.map +0 -1
  98. /package/src/core/geom/3d/morton/{Morton.js → v3_morton_encode.js} +0 -0
package/build/meep.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  /**
4
4
  *
5
- * @param {Array|Uint8Array} a
6
- * @param {Array|Uint8Array} b
5
+ * @param {Array|Uint8Array|Float32Array} a
6
+ * @param {Array|Uint8Array|Float32Array} b
7
7
  * @returns {boolean}
8
8
  */
9
9
  function isArrayEqualStrict(a, b) {
@@ -2533,10 +2533,10 @@ let Vector3$1 = class Vector3 {
2533
2533
  * @param {number} [squaredError]
2534
2534
  * @return {boolean}
2535
2535
  */
2536
- isNormalized(squaredError = 0.01) {
2536
+ isNormalized(squaredError = 1e-5) {
2537
2537
  const lengthSq = this.lengthSqr();
2538
2538
 
2539
- return (lengthSq + squaredError) >= 1 && (lengthSq - squaredError) <= 1;
2539
+ return epsilonEquals(lengthSq, 1, squaredError);
2540
2540
  }
2541
2541
 
2542
2542
  /**
@@ -2586,10 +2586,6 @@ let Vector3$1 = class Vector3 {
2586
2586
  return v3_length_sqr(this.x - x, this.y - y, this.z - z);
2587
2587
  }
2588
2588
 
2589
- distanceToSquared(other) {
2590
- return v3_length_sqr(this.x - other.x, this.y - other.y, this.z - other.z);
2591
- }
2592
-
2593
2589
  /**
2594
2590
  * Angle between two vectors (co-planar) in radians
2595
2591
  * @param {Vector3} other
@@ -2849,31 +2845,6 @@ let Vector3$1 = class Vector3 {
2849
2845
  this._projectVectors(x0, y0, z0, x1, y1, z1);
2850
2846
  }
2851
2847
 
2852
- /**
2853
- * Compute orthogonal vectors given a normal
2854
- * Orthogonal vectors are normalized vectors pointing at right angles away from the input normal and to one another
2855
- * @see https://stackoverflow.com/questions/3684269/component-of-a-quaternion-rotation-around-an-axis
2856
- * @param normal
2857
- * @param orthonormal1
2858
- * @param orthonormal2
2859
- */
2860
- static findOrthonormals(normal, orthonormal1, orthonormal2) {
2861
- throw new Error('Not Implemented');
2862
-
2863
- // Vector3 w = Vector3.Transform(normal, OrthoX);
2864
- // float dot = Vector3.Dot(normal, w);
2865
- // if (Math.Abs(dot) > 0.6)
2866
- // {
2867
- // w = Vector3.Transform(normal, OrthoY);
2868
- // }
2869
- // w.Normalize();
2870
- //
2871
- // orthonormal1 = Vector3.Cross(normal, w);
2872
- // orthonormal1.Normalize();
2873
- // orthonormal2 = Vector3.Cross(normal, orthonormal1);
2874
- // orthonormal2.Normalize();
2875
- }
2876
-
2877
2848
  /**
2878
2849
  * Project first vector onto second one
2879
2850
  * @param {number} x0
@@ -3006,24 +2977,6 @@ let Vector3$1 = class Vector3 {
3006
2977
  this.set(x, y, z);
3007
2978
  }
3008
2979
 
3009
- /**
3010
- *
3011
- * @param {BinaryBuffer} buffer
3012
- * @deprecated use dedicated method directly instead
3013
- */
3014
- toBinaryBufferFloat32_EqualityEncoded(buffer) {
3015
- throw new Error('deprecated, use v3_binary_equality_encode')
3016
- }
3017
-
3018
- /**
3019
- * Uses an extra byte for a header. Only writes unique components. Useful for things like scale where all components usually have the same value
3020
- * @param {BinaryBuffer} buffer
3021
- * @deprecated use dedicated method directly instead
3022
- */
3023
- fromBinaryBufferFloat32_EqualityEncoded(buffer) {
3024
- throw new Error('deprecated, use v3_binary_equality_decode')
3025
- }
3026
-
3027
2980
  hash() {
3028
2981
  const x = computeHashFloat(this.x);
3029
2982
  const y = computeHashFloat(this.y);
@@ -3111,6 +3064,8 @@ let Vector3$1 = class Vector3 {
3111
3064
 
3112
3065
  // Aliases
3113
3066
 
3067
+ Vector3$1.prototype.distanceToSquared = Vector3$1.prototype.distanceSqrTo;
3068
+
3114
3069
  Vector3$1.prototype.lengthSq = Vector3$1.prototype.lengthSqr;
3115
3070
  Vector3$1.prototype.fromArray = Vector3$1.prototype.readFromArray;
3116
3071
  Vector3$1.prototype.toArray = Vector3$1.prototype.writeToArray;
@@ -4017,18 +3972,18 @@ let Quaternion$1 = class Quaternion {
4017
3972
  if (uv_dot < -0.9999999) {
4018
3973
  //to vector is opposite, produce a reversal quaternion
4019
3974
 
4020
- tempvec3.crossVectors(Vector3$1.left, from);
3975
+ scratch_v3_a.crossVectors(Vector3$1.left, from);
4021
3976
 
4022
- if (tempvec3.lengthSqr() < 0.00001) {
4023
- tempvec3.crossVectors(Vector3$1.up, from);
3977
+ if (scratch_v3_a.lengthSqr() < 0.00001) {
3978
+ scratch_v3_a.crossVectors(Vector3$1.up, from);
4024
3979
  }
4025
3980
 
4026
- tempvec3.normalize();
3981
+ scratch_v3_a.normalize();
4027
3982
 
4028
3983
  this.set(
4029
- tempvec3.x,
4030
- tempvec3.y,
4031
- tempvec3.z,
3984
+ scratch_v3_a.x,
3985
+ scratch_v3_a.y,
3986
+ scratch_v3_a.z,
4032
3987
  0
4033
3988
  );
4034
3989
 
@@ -4560,10 +4515,7 @@ Quaternion$1.prototype.toArray = Quaternion$1.prototype.writeToArray;
4560
4515
  * @readonly
4561
4516
  * @type {Quaternion}
4562
4517
  */
4563
- Quaternion$1.identity = Object.freeze(new Quaternion$1(0, 0, 0, 1));
4564
-
4565
-
4566
- const tempvec3 = new Vector3$1();
4518
+ Quaternion$1.identity = Object.freeze(new Quaternion$1(0, 0, 0, 1));
4567
4519
 
4568
4520
  /**
4569
4521
  * @readonly
@@ -49012,34 +48964,6 @@ function compute_typed_array_constructor_from_data_type(dt) {
49012
48964
  return r;
49013
48965
  }
49014
48966
 
49015
- /**
49016
- * 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
49017
- * @param {number[]|Uint32Array|Uint16Array|Uint8Array} array
49018
- * @param {number} offset
49019
- * @param {number} length
49020
- * @param {number} stride
49021
- * @return {number}
49022
- */
49023
- function computeStridedIntegerArrayHash(
49024
- array, offset, length, stride
49025
- ) {
49026
- let hash = length;
49027
-
49028
- for (let i = offset; i < length; i += stride) {
49029
- const value = array[i] >>> 0; //force uint32
49030
-
49031
- /**
49032
- * Simple hashing scheme, multiplying existing hash by a prime and adding next value
49033
- * (h<<5) - h === h*31
49034
- * @type {number}
49035
- */
49036
- hash = ((hash << 5) - hash) + value;
49037
- }
49038
-
49039
- // force uint32
49040
- return hash >>> 0;
49041
- }
49042
-
49043
48967
  /**
49044
48968
  *
49045
48969
  * @param {*} array
@@ -49186,6 +49110,62 @@ function is_typed_array_equals(a, b) {
49186
49110
  return isArrayEqualStrict(a_proxy, b_proxy);
49187
49111
  }
49188
49112
 
49113
+ /**
49114
+ * 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
49115
+ * @template T
49116
+ * @param {T[]|Uint32Array|Uint16Array|Uint8Array} array
49117
+ * @param {number} offset
49118
+ * @param {number} length
49119
+ * @param {number} stride
49120
+ * @param {function(T):number} elementHash
49121
+ * @param {*} [elementHashContext]
49122
+ * @return {number}
49123
+ */
49124
+ function computeStridedArrayHash(
49125
+ array, offset, length, stride,
49126
+ elementHash, elementHashContext
49127
+ ) {
49128
+
49129
+ let hash = length;
49130
+
49131
+ for (let i = offset; i < length; i += stride) {
49132
+ const value = elementHash.call(elementHashContext, array[i]);
49133
+
49134
+ /**
49135
+ * Simple hashing scheme, multiplying existing hash by a prime and adding next value
49136
+ * (h<<5) - h === h*31
49137
+ * @type {number}
49138
+ */
49139
+ hash = ((hash << 5) - hash) + value;
49140
+ }
49141
+
49142
+ // force uint32
49143
+ return hash >>> 0;
49144
+ }
49145
+
49146
+ /**
49147
+ *
49148
+ * @param {Uint32Array} array
49149
+ * @param {number} offset
49150
+ * @param {number} length
49151
+ * @param {number} [sample_limit]
49152
+ * @returns {number}
49153
+ */
49154
+ function sparse_typed_array_hash(array, offset, length, sample_limit = 31) {
49155
+ // limit hash evaluation to first 1k of the data to random memory access and keep CPU cache usage more coherent
49156
+ const hash_evaluation_length = min2(length, 1024);
49157
+
49158
+ // compute stride so that we don't have to iterate over the entire buffer, instead picking at most X(509) values to consider
49159
+ const stride = Math.max(1, Math.ceil(hash_evaluation_length / sample_limit));
49160
+
49161
+ // TODO implement fast dedicated float and int paths
49162
+
49163
+ return computeStridedArrayHash(
49164
+ array, 0, hash_evaluation_length, stride,
49165
+ computeHashFloat
49166
+ );
49167
+ }
49168
+
49189
49169
  function typedArrayConstructorByInstance(a) {
49190
49170
  if (a instanceof Int8Array) {
49191
49171
  return Int8Array;
@@ -49260,19 +49240,19 @@ class Sampler2D {
49260
49240
 
49261
49241
  /**
49262
49242
  *
49263
- * @type {Number}
49243
+ * @type {number}
49264
49244
  */
49265
49245
  this.width = width;
49266
49246
 
49267
49247
  /**
49268
49248
  *
49269
- * @type {Number}
49249
+ * @type {number}
49270
49250
  */
49271
49251
  this.height = height;
49272
49252
 
49273
49253
  /**
49274
49254
  * Number of channels
49275
- * @type {Number}
49255
+ * @type {number}
49276
49256
  */
49277
49257
  this.itemSize = itemSize;
49278
49258
 
@@ -49289,18 +49269,6 @@ class Sampler2D {
49289
49269
  this.version = 0;
49290
49270
  }
49291
49271
 
49292
- /**
49293
- *
49294
- * @deprecated
49295
- * @param {number} x
49296
- * @param {number}y
49297
- * @param {Vector1|Vector2|Vector3|Vector4} result
49298
- * @returns {number}
49299
- */
49300
- get(x, y, result) {
49301
- throw new Error("Deprecated method, use sampleBilinear instead");
49302
- }
49303
-
49304
49272
  /**
49305
49273
  *
49306
49274
  * @param {number} u
@@ -49323,8 +49291,8 @@ class Sampler2D {
49323
49291
  * @returns {number}
49324
49292
  */
49325
49293
  sampleChannelCatmullRomUV(u, v, channel) {
49326
- const x = u * (this.width) - 0.5;
49327
- const y = v * (this.height) - 0.5;
49294
+ const x = u * this.width - 0.5;
49295
+ const y = v * this.height - 0.5;
49328
49296
 
49329
49297
  return this.sampleChannelCatmullRom(x, y, channel);
49330
49298
  }
@@ -49379,8 +49347,8 @@ class Sampler2D {
49379
49347
  const texPos12_x = texPos1_x + offset12_x;
49380
49348
  const texPos12_y = texPos1_y + offset12_y;
49381
49349
 
49382
-
49383
49350
  let result = 0.0;
49351
+
49384
49352
  result += this.sampleChannelBilinear(texPos0_x, texPos0_y, channel) * w0_x * w0_y;
49385
49353
  result += this.sampleChannelBilinear(texPos12_x, texPos0_y, channel) * w12_x * w0_y;
49386
49354
  result += this.sampleChannelBilinear(texPos3_x, texPos0_y, channel) * w3_x * w0_y;
@@ -49442,8 +49410,8 @@ class Sampler2D {
49442
49410
  }
49443
49411
 
49444
49412
  /**
49445
- * TODO there is an oversaturation bug in here somewhere, prefer to use linear sampling for now instead
49446
- * Bicubic-filtered sampling
49413
+ *
49414
+ * Bicubic-filtered sampling, note values can be negative due to the nature of the cubic curve
49447
49415
  * @param {number} x
49448
49416
  * @param {number} y
49449
49417
  * @param {number} channel
@@ -49672,7 +49640,11 @@ class Sampler2D {
49672
49640
  const x = Math.round(u * w - 0.5);
49673
49641
  const y = Math.round(v * h - 0.5);
49674
49642
 
49675
- this.read(clamp$1(x, 0, w - 1), clamp$1(y, 0, h - 1), result);
49643
+ this.read(
49644
+ clamp$1(x, 0, w - 1),
49645
+ clamp$1(y, 0, h - 1),
49646
+ result
49647
+ );
49676
49648
  }
49677
49649
 
49678
49650
  /**
@@ -49727,24 +49699,6 @@ class Sampler2D {
49727
49699
  }
49728
49700
  }
49729
49701
 
49730
- /**
49731
- *
49732
- * @param {number} u
49733
- * @param {number} v
49734
- * @param {Vector4|Vector3|Vector2} [result]
49735
- * @deprecated
49736
- */
49737
- sample(u, v, result) {
49738
-
49739
- const temp = [];
49740
-
49741
- this.sampleBilinear(u * (this.width - 1), v * (this.height - 1), temp, 0);
49742
-
49743
- result.readFromArray(temp);
49744
-
49745
- return temp[0];
49746
- }
49747
-
49748
49702
  /**
49749
49703
  *
49750
49704
  * @param {number} x
@@ -49874,11 +49828,11 @@ class Sampler2D {
49874
49828
 
49875
49829
  /**
49876
49830
  *
49877
- * @param {Number} x
49878
- * @param {Number} y
49879
- * @param {Number} width
49880
- * @param {Number} height
49881
- * @param {Array.<Number>} value
49831
+ * @param {number} x
49832
+ * @param {number} y
49833
+ * @param {number} width
49834
+ * @param {number} height
49835
+ * @param {Array.<number>} value
49882
49836
  */
49883
49837
  fill(x, y, width, height, value) {
49884
49838
 
@@ -50056,10 +50010,13 @@ class Sampler2D {
50056
50010
  computeByteSize() {
50057
50011
  let dataSize;
50058
50012
 
50059
- if (Array.isArray(this.data)) {
50060
- dataSize = 8 * this.data.length;
50013
+ const data = this.data;
50014
+
50015
+ if (Array.isArray(data)) {
50016
+ // Assume IEEE float 64
50017
+ dataSize = 8 * data.length;
50061
50018
  } else {
50062
- dataSize = this.data.buffer.byteLength;
50019
+ dataSize = data.buffer.byteLength;
50063
50020
  }
50064
50021
 
50065
50022
  return dataSize + 280;
@@ -50071,6 +50028,11 @@ class Sampler2D {
50071
50028
  * @return {boolean}
50072
50029
  */
50073
50030
  equals(other) {
50031
+ if(this === other){
50032
+ // special case
50033
+ return true;
50034
+ }
50035
+
50074
50036
  if (
50075
50037
  this.width !== other.width
50076
50038
  || this.height !== other.height
@@ -50091,9 +50053,7 @@ class Sampler2D {
50091
50053
 
50092
50054
  const length = this.data.length;
50093
50055
 
50094
- const stride = Math.max(1, Math.ceil(length / 509));
50095
-
50096
- hash ^= computeStridedIntegerArrayHash(this.data, 0, length, stride);
50056
+ hash ^= sparse_typed_array_hash(this.data, 0, length, 509);
50097
50057
 
50098
50058
  return hash;
50099
50059
  }
@@ -50629,6 +50589,34 @@ Vector1.zero = Object.freeze(new Vector1(0));
50629
50589
  */
50630
50590
  Vector1.one = Object.freeze(new Vector1(1));
50631
50591
 
50592
+ /**
50593
+ * 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
50594
+ * @param {number[]|Uint32Array|Uint16Array|Uint8Array} array
50595
+ * @param {number} offset
50596
+ * @param {number} length
50597
+ * @param {number} stride
50598
+ * @return {number}
50599
+ */
50600
+ function computeStridedIntegerArrayHash(
50601
+ array, offset, length, stride
50602
+ ) {
50603
+ let hash = length;
50604
+
50605
+ for (let i = offset; i < length; i += stride) {
50606
+ const value = array[i] >>> 0; //force uint32
50607
+
50608
+ /**
50609
+ * Simple hashing scheme, multiplying existing hash by a prime and adding next value
50610
+ * (h<<5) - h === h*31
50611
+ * @type {number}
50612
+ */
50613
+ hash = ((hash << 5) - hash) + value;
50614
+ }
50615
+
50616
+ // force uint32
50617
+ return hash >>> 0;
50618
+ }
50619
+
50632
50620
  /**
50633
50621
  *
50634
50622
  * @param {Uint8Array|number[]|ArrayLike<number>|IArguments} data
@@ -55304,29 +55292,6 @@ function v3_morton_encode_bounded(x, y, z, bounds) {
55304
55292
  );
55305
55293
  }
55306
55294
 
55307
- /**
55308
- * Returns highest value out of 3 supplied
55309
- * @param {number} a
55310
- * @param {number} b
55311
- * @param {number} c
55312
- * @returns {number}
55313
- */
55314
- function max3(a, b, c) {
55315
-
55316
- let v = a;
55317
-
55318
- if (v < b) {
55319
- v = b;
55320
- }
55321
-
55322
- if (v < c) {
55323
- v = c;
55324
- }
55325
-
55326
- return v;
55327
-
55328
- }
55329
-
55330
55295
  /**
55331
55296
  * @readonly
55332
55297
  * @type {number}
@@ -55612,73 +55577,6 @@ class BinaryUint32BVH {
55612
55577
  return result;
55613
55578
  }
55614
55579
 
55615
- /**
55616
- *
55617
- * @param {number} a address
55618
- * @param {number} b address
55619
- * @param {number} c address
55620
- * @returns {number}
55621
- * @private
55622
- */
55623
- __compute_bounds_area_of_3_boxes(a, b, c) {
55624
- const float32 = this.__data_float32;
55625
-
55626
- const x0 = min3(float32[a + 0], float32[b + 0], float32[c + 0]);
55627
- const y0 = min3(float32[a + 1], float32[b + 1], float32[c + 1]);
55628
- const z0 = min3(float32[a + 2], float32[b + 2], float32[c + 2]);
55629
-
55630
- const x1 = max3(float32[a + 3], float32[b + 3], float32[c + 3]);
55631
- const y1 = max3(float32[a + 4], float32[b + 4], float32[c + 4]);
55632
- const z1 = max3(float32[a + 5], float32[b + 5], float32[c + 5]);
55633
-
55634
- return aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1);
55635
- }
55636
-
55637
- /**
55638
- *
55639
- * @param {number} a
55640
- * @param {number} b
55641
- * @returns {number}
55642
- * @private
55643
- */
55644
- __fitness_function_should_swap_leaves_sah(a, b) {
55645
- const a_0 = max2(a - 1, 0);
55646
- const a_1 = min2(a + 1, this.__node_count_leaf - 1);
55647
-
55648
- const leaf_block_offset = this.getLeafBlockAddress();
55649
-
55650
- const a_c_address = a * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55651
- const a_0_address = a_0 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55652
- const a_1_address = a_1 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55653
-
55654
-
55655
- const b_0 = max2(b - 1, 0);
55656
- const b_1 = min2(b + 1, this.__node_count_leaf - 1);
55657
-
55658
- const b_c_address = b * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55659
- const b_0_address = b_0 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55660
- const b_1_address = b_1 * BVH_LEAF_NODE_SIZE + leaf_block_offset;
55661
-
55662
-
55663
- 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);
55664
- 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);
55665
-
55666
- return current_area - swap_area;
55667
- }
55668
-
55669
- sort_bubble_sah() {
55670
- const n = this.__node_count_leaf;
55671
-
55672
- for (let i = 0; i < n; i++) {
55673
- for (let j = i + 1; j < n; j++) {
55674
- if (this.__fitness_function_should_swap_leaves_sah(i, j) > 0) {
55675
- this.__swap_leaves(i, j);
55676
- }
55677
- }
55678
- }
55679
- }
55680
-
55681
-
55682
55580
  /**
55683
55581
  * Sort leaf nodes according to their morton codes
55684
55582
  * @param {number[]} bounds
@@ -55692,15 +55590,17 @@ class BinaryUint32BVH {
55692
55590
  return;
55693
55591
  }
55694
55592
 
55695
- let stackPointer = 2;
55593
+ const stack_top = stack$9.pointer;
55594
+
55595
+ let stackPointer = stack_top;
55696
55596
  let i, j;
55697
55597
 
55698
- stack$9[0] = 0; // first node
55699
- 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
55700
55600
 
55701
55601
  const data = this.__data_float32;
55702
55602
 
55703
- while (stackPointer > 0) {
55603
+ while (stackPointer > stack_top) {
55704
55604
  stackPointer -= 2;
55705
55605
 
55706
55606
  const right = stack$9[stackPointer + 1];
@@ -55709,14 +55609,15 @@ class BinaryUint32BVH {
55709
55609
  i = left;
55710
55610
  j = right;
55711
55611
 
55712
- const pivotIndex = (left + right) >> 1;
55612
+ const pivot_index = (left + right) >> 1;
55713
55613
 
55714
- const pivot_address = pivotIndex * BVH_LEAF_NODE_SIZE + leaf_block_address;
55614
+ const pivot_address = pivot_index * BVH_LEAF_NODE_SIZE + leaf_block_address;
55715
55615
 
55716
55616
  const pivot = build_morton(data, pivot_address, bounds);
55717
55617
 
55718
55618
  /* partition */
55719
55619
  while (i <= j) {
55620
+
55720
55621
  while (build_morton(data, i * BVH_LEAF_NODE_SIZE + leaf_block_address, bounds) < pivot) {
55721
55622
  i++;
55722
55623
  }
@@ -55750,7 +55651,7 @@ class BinaryUint32BVH {
55750
55651
  }
55751
55652
 
55752
55653
  /**
55753
- *
55654
+ * Does not update intermediate node bounds
55754
55655
  * @param {number} i
55755
55656
  * @param {number} j
55756
55657
  * @private
@@ -56424,13 +56325,6 @@ class AABB3 {
56424
56325
  || (z + tolerance) < this.z0 || (z - tolerance) > this.z1);
56425
56326
  }
56426
56327
 
56427
- computeMortonCode() {
56428
- const cx = (this.x0 + this.x1) >> 1;
56429
- const cy = (this.y0 + this.y1) >> 1;
56430
- const cz = (this.z0 + this.z1) >> 1;
56431
- return mortonEncode_magicbits(cx, cy, cz);
56432
- }
56433
-
56434
56328
  /**
56435
56329
  *
56436
56330
  * @returns {number}
@@ -57741,7 +57635,7 @@ const m4_tmp = [];
57741
57635
  class TerrainTile {
57742
57636
  gridPosition = new Vector2();
57743
57637
  scale = new Vector2(1, 1);
57744
- size = new Vector2();
57638
+ size = new Vector2(1, 1);
57745
57639
  position = new Vector2();
57746
57640
  resolution = new ObservedInteger(1);
57747
57641
 
@@ -58211,6 +58105,7 @@ class TerrainTile {
58211
58105
 
58212
58106
  geometry.boundingSphere = new Sphere(center, radius);
58213
58107
  }
58108
+
58214
58109
  //pull bounding box from geometry
58215
58110
 
58216
58111
  bb = geometry.boundingBox;
@@ -58218,6 +58113,7 @@ class TerrainTile {
58218
58113
  geometry.computeBoundingBox();
58219
58114
  bb = geometry.boundingBox;
58220
58115
  }
58116
+
58221
58117
  }
58222
58118
 
58223
58119
  const x0 = bb.min.x;
@@ -59115,11 +59011,11 @@ function writeSample2DDataToDataTexture(sampler, texture) {
59115
59011
  }
59116
59012
  } else if (sampler.itemSize === 3) {
59117
59013
  if (texture.format !== RGBFormat$1) {
59118
- 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');
59119
59015
  }
59120
59016
  } else if (sampler.itemSize === 4) {
59121
59017
  if (texture.format !== RGBAFormat) {
59122
- 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');
59123
59019
  }
59124
59020
  } else {
59125
59021
  throw new Error('Unsupported itemSize');
@@ -62622,7 +62518,7 @@ function saturated_value_by_constructor(ctor) {
62622
62518
  * @param {Sampler2D} source
62623
62519
  * @param {Sampler2D} destination
62624
62520
  */
62625
- function copy_Sampler2D_channel_data(source, destination) {
62521
+ function sampler2d_transfer_data(source, destination) {
62626
62522
  if (source.width !== destination.width || source.height !== destination.height) {
62627
62523
  throw new Error('Source and destination dimensions do not match');
62628
62524
  }
@@ -62829,7 +62725,7 @@ class TerrainLayer {
62829
62725
 
62830
62726
  const source = new Sampler2D(source_data, source_item_size, image.width, image.height);
62831
62727
 
62832
- copy_Sampler2D_channel_data(source, this.diffuse);
62728
+ sampler2d_transfer_data(source, this.diffuse);
62833
62729
 
62834
62730
  this.onChanged.send0();
62835
62731
 
@@ -63648,11 +63544,16 @@ class WorkerProxy {
63648
63544
  __id_counter = 0;
63649
63545
 
63650
63546
 
63547
+ /**
63548
+ *
63549
+ * @param {string} url
63550
+ * @param {Object} methods
63551
+ */
63651
63552
  constructor(url, methods) {
63652
63553
  this.url = url;
63653
63554
  this.methods = methods;
63654
63555
 
63655
- this.__generateAPI(this, methods);
63556
+ this.__generateAPI();
63656
63557
  }
63657
63558
 
63658
63559
  /**
@@ -63731,6 +63632,10 @@ class WorkerProxy {
63731
63632
 
63732
63633
  }
63733
63634
 
63635
+ /**
63636
+ *
63637
+ * @private
63638
+ */
63734
63639
  __generateAPI() {
63735
63640
 
63736
63641
 
@@ -66111,6 +66016,29 @@ function read_three_planes_to_array(planes, array) {
66111
66016
  }
66112
66017
  }
66113
66018
 
66019
+ /**
66020
+ * Returns highest value out of 3 supplied
66021
+ * @param {number} a
66022
+ * @param {number} b
66023
+ * @param {number} c
66024
+ * @returns {number}
66025
+ */
66026
+ function max3(a, b, c) {
66027
+
66028
+ let v = a;
66029
+
66030
+ if (v < b) {
66031
+ v = b;
66032
+ }
66033
+
66034
+ if (v < c) {
66035
+ v = c;
66036
+ }
66037
+
66038
+ return v;
66039
+
66040
+ }
66041
+
66114
66042
  /**
66115
66043
  *
66116
66044
  * @param {number[]|Float32Array} output
@@ -85589,7 +85517,7 @@ class Deque {
85589
85517
 
85590
85518
  /**
85591
85519
  *
85592
- * @param {E} e
85520
+ * @param {T} e
85593
85521
  * @returns {boolean}
85594
85522
  */
85595
85523
  has(e) {
@@ -92962,14 +92890,12 @@ const LogLevel = {
92962
92890
  };
92963
92891
 
92964
92892
  class Logger {
92965
- constructor() {
92966
- /**
92967
- *
92968
- * @private
92969
- * @type {LoggerBackend[]}
92970
- */
92971
- this.backends = [];
92972
- }
92893
+ /**
92894
+ *
92895
+ * @private
92896
+ * @type {LoggerBackend[]}
92897
+ */
92898
+ backends = [];
92973
92899
 
92974
92900
  /**
92975
92901
  * Add a logging backend, this is a structure that handles incoming log messages.
@@ -115513,14 +115439,14 @@ class InputControllerSystem extends System {
115513
115439
  }
115514
115440
 
115515
115441
  class LoggerBackend {
115516
- constructor() {
115517
115442
 
115518
- /**
115519
- * @private
115520
- * @type {LogLevel|number}
115521
- */
115522
- this.level = LogLevel.Info;
115523
- }
115443
+
115444
+ /**
115445
+ * @private
115446
+ * @type {LogLevel|number}
115447
+ */
115448
+ level = LogLevel.Info;
115449
+
115524
115450
 
115525
115451
  /**
115526
115452
  *