@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
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
@@ -52076,6 +52064,8 @@ function array_buffer_copy(
52076
52064
  target, target_offset,
52077
52065
  byte_length
52078
52066
  ) {
52067
+ // assert.ok(source instanceof ArrayBuffer || source instanceof SharedArrayBuffer,'source is not an ArrayBuffer');
52068
+ // assert.ok(target instanceof ArrayBuffer || target instanceof SharedArrayBuffer,'source is not an ArrayBuffer');
52079
52069
 
52080
52070
  /**
52081
52071
  * @type {Uint8Array|Uint16Array|Uint32Array}
@@ -55304,29 +55294,6 @@ function v3_morton_encode_bounded(x, y, z, bounds) {
55304
55294
  );
55305
55295
  }
55306
55296
 
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
55297
  /**
55331
55298
  * @readonly
55332
55299
  * @type {number}
@@ -55612,73 +55579,6 @@ class BinaryUint32BVH {
55612
55579
  return result;
55613
55580
  }
55614
55581
 
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
55582
  /**
55683
55583
  * Sort leaf nodes according to their morton codes
55684
55584
  * @param {number[]} bounds
@@ -55692,15 +55592,17 @@ class BinaryUint32BVH {
55692
55592
  return;
55693
55593
  }
55694
55594
 
55695
- let stackPointer = 2;
55595
+ const stack_top = stack$9.pointer;
55596
+
55597
+ let stackPointer = stack_top;
55696
55598
  let i, j;
55697
55599
 
55698
- stack$9[0] = 0; // first node
55699
- stack$9[1] = this.__node_count_leaf - 1; // last node
55600
+ stack$9[stackPointer++] = 0; // first node
55601
+ stack$9[stackPointer++] = this.__node_count_leaf - 1; // last node
55700
55602
 
55701
55603
  const data = this.__data_float32;
55702
55604
 
55703
- while (stackPointer > 0) {
55605
+ while (stackPointer > stack_top) {
55704
55606
  stackPointer -= 2;
55705
55607
 
55706
55608
  const right = stack$9[stackPointer + 1];
@@ -55709,14 +55611,15 @@ class BinaryUint32BVH {
55709
55611
  i = left;
55710
55612
  j = right;
55711
55613
 
55712
- const pivotIndex = (left + right) >> 1;
55614
+ const pivot_index = (left + right) >> 1;
55713
55615
 
55714
- const pivot_address = pivotIndex * BVH_LEAF_NODE_SIZE + leaf_block_address;
55616
+ const pivot_address = pivot_index * BVH_LEAF_NODE_SIZE + leaf_block_address;
55715
55617
 
55716
55618
  const pivot = build_morton(data, pivot_address, bounds);
55717
55619
 
55718
55620
  /* partition */
55719
55621
  while (i <= j) {
55622
+
55720
55623
  while (build_morton(data, i * BVH_LEAF_NODE_SIZE + leaf_block_address, bounds) < pivot) {
55721
55624
  i++;
55722
55625
  }
@@ -55750,7 +55653,7 @@ class BinaryUint32BVH {
55750
55653
  }
55751
55654
 
55752
55655
  /**
55753
- *
55656
+ * Does not update intermediate node bounds
55754
55657
  * @param {number} i
55755
55658
  * @param {number} j
55756
55659
  * @private
@@ -56424,13 +56327,6 @@ class AABB3 {
56424
56327
  || (z + tolerance) < this.z0 || (z - tolerance) > this.z1);
56425
56328
  }
56426
56329
 
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
56330
  /**
56435
56331
  *
56436
56332
  * @returns {number}
@@ -57741,7 +57637,7 @@ const m4_tmp = [];
57741
57637
  class TerrainTile {
57742
57638
  gridPosition = new Vector2();
57743
57639
  scale = new Vector2(1, 1);
57744
- size = new Vector2();
57640
+ size = new Vector2(1, 1);
57745
57641
  position = new Vector2();
57746
57642
  resolution = new ObservedInteger(1);
57747
57643
 
@@ -58211,6 +58107,7 @@ class TerrainTile {
58211
58107
 
58212
58108
  geometry.boundingSphere = new Sphere(center, radius);
58213
58109
  }
58110
+
58214
58111
  //pull bounding box from geometry
58215
58112
 
58216
58113
  bb = geometry.boundingBox;
@@ -58218,6 +58115,7 @@ class TerrainTile {
58218
58115
  geometry.computeBoundingBox();
58219
58116
  bb = geometry.boundingBox;
58220
58117
  }
58118
+
58221
58119
  }
58222
58120
 
58223
58121
  const x0 = bb.min.x;
@@ -59115,11 +59013,11 @@ function writeSample2DDataToDataTexture(sampler, texture) {
59115
59013
  }
59116
59014
  } else if (sampler.itemSize === 3) {
59117
59015
  if (texture.format !== RGBFormat$1) {
59118
- throw new Error('itemSize is 2 and texture.format is not RGBFormat');
59016
+ throw new Error('itemSize is 3 and texture.format is not RGBFormat');
59119
59017
  }
59120
59018
  } else if (sampler.itemSize === 4) {
59121
59019
  if (texture.format !== RGBAFormat) {
59122
- throw new Error('itemSize is 2 and texture.format is not RGBAFormat');
59020
+ throw new Error('itemSize is 4 and texture.format is not RGBAFormat');
59123
59021
  }
59124
59022
  } else {
59125
59023
  throw new Error('Unsupported itemSize');
@@ -61497,10 +61395,25 @@ function typed_array_copy(source, destination) {
61497
61395
  const destination_size = destination.length;
61498
61396
 
61499
61397
  if (destination_size >= source.length) {
61398
+
61500
61399
  destination.set(source, 0);
61400
+
61401
+ } else if (source.constructor === destination.constructor) {
61402
+
61403
+ // same type
61404
+ array_buffer_copy(
61405
+ source.buffer,
61406
+ source.byteOffset,
61407
+ destination.buffer,
61408
+ destination.byteOffset,
61409
+ Math.min(source.byteLength, destination.byteLength)
61410
+ );
61411
+
61501
61412
  } else {
61413
+
61502
61414
  // destination is smaller than source, crop source data
61503
61415
  array_copy(source, 0, destination, 0, destination_size);
61416
+
61504
61417
  }
61505
61418
  }
61506
61419
 
@@ -62622,7 +62535,7 @@ function saturated_value_by_constructor(ctor) {
62622
62535
  * @param {Sampler2D} source
62623
62536
  * @param {Sampler2D} destination
62624
62537
  */
62625
- function copy_Sampler2D_channel_data(source, destination) {
62538
+ function sampler2d_transfer_data(source, destination) {
62626
62539
  if (source.width !== destination.width || source.height !== destination.height) {
62627
62540
  throw new Error('Source and destination dimensions do not match');
62628
62541
  }
@@ -62829,7 +62742,7 @@ class TerrainLayer {
62829
62742
 
62830
62743
  const source = new Sampler2D(source_data, source_item_size, image.width, image.height);
62831
62744
 
62832
- copy_Sampler2D_channel_data(source, this.diffuse);
62745
+ sampler2d_transfer_data(source, this.diffuse);
62833
62746
 
62834
62747
  this.onChanged.send0();
62835
62748
 
@@ -63648,11 +63561,16 @@ class WorkerProxy {
63648
63561
  __id_counter = 0;
63649
63562
 
63650
63563
 
63564
+ /**
63565
+ *
63566
+ * @param {string} url
63567
+ * @param {Object} methods
63568
+ */
63651
63569
  constructor(url, methods) {
63652
63570
  this.url = url;
63653
63571
  this.methods = methods;
63654
63572
 
63655
- this.__generateAPI(this, methods);
63573
+ this.__generateAPI();
63656
63574
  }
63657
63575
 
63658
63576
  /**
@@ -63731,6 +63649,10 @@ class WorkerProxy {
63731
63649
 
63732
63650
  }
63733
63651
 
63652
+ /**
63653
+ *
63654
+ * @private
63655
+ */
63734
63656
  __generateAPI() {
63735
63657
 
63736
63658
 
@@ -66111,6 +66033,29 @@ function read_three_planes_to_array(planes, array) {
66111
66033
  }
66112
66034
  }
66113
66035
 
66036
+ /**
66037
+ * Returns highest value out of 3 supplied
66038
+ * @param {number} a
66039
+ * @param {number} b
66040
+ * @param {number} c
66041
+ * @returns {number}
66042
+ */
66043
+ function max3(a, b, c) {
66044
+
66045
+ let v = a;
66046
+
66047
+ if (v < b) {
66048
+ v = b;
66049
+ }
66050
+
66051
+ if (v < c) {
66052
+ v = c;
66053
+ }
66054
+
66055
+ return v;
66056
+
66057
+ }
66058
+
66114
66059
  /**
66115
66060
  *
66116
66061
  * @param {number[]|Float32Array} output
@@ -85589,7 +85534,7 @@ class Deque {
85589
85534
 
85590
85535
  /**
85591
85536
  *
85592
- * @param {E} e
85537
+ * @param {T} e
85593
85538
  * @returns {boolean}
85594
85539
  */
85595
85540
  has(e) {
@@ -92962,14 +92907,12 @@ const LogLevel = {
92962
92907
  };
92963
92908
 
92964
92909
  class Logger {
92965
- constructor() {
92966
- /**
92967
- *
92968
- * @private
92969
- * @type {LoggerBackend[]}
92970
- */
92971
- this.backends = [];
92972
- }
92910
+ /**
92911
+ *
92912
+ * @private
92913
+ * @type {LoggerBackend[]}
92914
+ */
92915
+ backends = [];
92973
92916
 
92974
92917
  /**
92975
92918
  * Add a logging backend, this is a structure that handles incoming log messages.
@@ -115513,14 +115456,14 @@ class InputControllerSystem extends System {
115513
115456
  }
115514
115457
 
115515
115458
  class LoggerBackend {
115516
- constructor() {
115517
115459
 
115518
- /**
115519
- * @private
115520
- * @type {LogLevel|number}
115521
- */
115522
- this.level = LogLevel.Info;
115523
- }
115460
+
115461
+ /**
115462
+ * @private
115463
+ * @type {LogLevel|number}
115464
+ */
115465
+ level = LogLevel.Info;
115466
+
115524
115467
 
115525
115468
  /**
115526
115469
  *