@woosh/meep-engine 2.62.0 → 2.64.0

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 (54) hide show
  1. package/build/meep.cjs +1061 -1058
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +1061 -1058
  4. package/package.json +1 -1
  5. package/src/core/binary/EncodingBinaryBuffer.js +7 -43
  6. package/src/core/binary/EncodingBinaryBuffer.spec.js +16 -0
  7. package/src/core/binary/UINT16_MAX.js +5 -0
  8. package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +4 -2
  9. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +5 -5
  10. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +8 -10
  11. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +7 -7
  12. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js +37 -0
  13. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +12 -4
  14. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +29 -0
  15. package/src/core/cache/LoadingCache.js +4 -1
  16. package/src/core/collection/list/List.js +9 -3
  17. package/src/core/collection/map/BiMap.js +49 -0
  18. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +11 -4
  19. package/src/core/geom/Vector2.js +6 -4
  20. package/src/engine/ecs/components/Tag.d.ts +2 -0
  21. package/src/engine/ecs/components/Tag.js +19 -28
  22. package/src/engine/ecs/components/Tag.spec.js +47 -0
  23. package/src/engine/ecs/fow/FogOfWar.js +4 -0
  24. package/src/engine/ecs/fow/FogOfWarEditor.js +3 -0
  25. package/src/engine/ecs/terrain/TerrainPreview.js +45 -44
  26. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +22 -4
  27. package/src/engine/ecs/terrain/tiles/TerrainTile.js +17 -12
  28. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +0 -4
  29. package/src/engine/graphics/ecs/mesh/Mesh.js +0 -11
  30. package/src/engine/graphics/ecs/mesh/MeshSystem.js +57 -67
  31. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +49 -86
  32. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +41 -72
  33. package/src/engine/graphics/particles/particular/engine/emitter/write_particle_patch_uv.js +28 -0
  34. package/src/engine/grid/ORTHOGONAL_NEIGHBOURHOOD_MASK.js +11 -0
  35. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +17 -17
  36. package/src/core/binary/stringToByteArray.js +0 -24
  37. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +0 -81
  38. package/src/engine/ecs/foliage/Foliage.js +0 -151
  39. package/src/engine/ecs/foliage/FoliageLoader.js +0 -39
  40. package/src/engine/ecs/foliage/FoliageVisibilitySetBuilder.js +0 -27
  41. package/src/engine/ecs/foliage/ImpostorFoliage.js +0 -106
  42. package/src/engine/ecs/foliage/InstancedFoliage.js +0 -395
  43. package/src/engine/ecs/foliage/ViewState.js +0 -181
  44. package/src/engine/ecs/foliage/ecs/Foliage2System.js +0 -333
  45. package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +0 -70
  46. package/src/engine/ecs/foliage/ecs/InstancedMeshLayer.js +0 -138
  47. package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +0 -28
  48. package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +0 -64
  49. package/src/engine/ecs/foliage/ecs/optimizeIndividualMeshesEntitiesToInstances.js +0 -233
  50. package/src/engine/save/storage/GooglePlayStorage.js +0 -47
  51. package/src/engine/save/storage/JsonStringCodec.js +0 -24
  52. package/src/engine/save/storage/LocalStorage.js +0 -148
  53. package/src/engine/save/storage/MsgPackCodec.js +0 -22
  54. /package/src/engine/sound/ecs/emitter/{SoundEmitter.spec.js → SoundEmitterSerializationAdapter.spec.js} +0 -0
@@ -53506,8 +53506,8 @@ class Vector2 {
53506
53506
  * @returns {number}
53507
53507
  */
53508
53508
  hash() {
53509
- const x = Math.sin(this.x) * 1367130550;
53510
- const y = Math.sin(this.y) * 1367130550;
53509
+ const x = computeHashFloat(this.x);
53510
+ const y = computeHashFloat(this.y);
53511
53511
 
53512
53512
  let hash = ((x << 5) - x) + y;
53513
53513
 
@@ -53644,6 +53644,7 @@ Vector2.one = Object.freeze(new Vector2(1, 1));
53644
53644
  * @type {boolean}
53645
53645
  */
53646
53646
  Vector2.prototype.isVector2 = true;
53647
+
53647
53648
  /**
53648
53649
  *
53649
53650
  * @param {number} x0
@@ -55588,79 +55589,314 @@ ObservedValue.prototype.fromJSON = function (value) {
55588
55589
  this.set(value);
55589
55590
  };
55590
55591
 
55591
- /**
55592
- * Created by Alex on 28/01/2017.
55593
- */
55594
-
55595
- function prepareObject(object) {
55596
- //turn off automatic matrix re-calculations each frame
55597
- object.matrixAutoUpdate = false;
55598
- //disable frustum culling
55599
- object.frustumCulled = false;
55600
- }
55601
-
55602
- /**
55603
- *
55604
- * @param {BufferGeometry} [geometry]
55605
- * @param {Material} [material]
55606
- * @returns {Mesh}
55607
- */
55608
- function createMesh(geometry, material) {
55609
- const result = new Mesh(geometry, material);
55610
-
55611
- prepareObject(result);
55612
-
55613
- return result;
55614
- }
55615
-
55616
- /**
55617
- *
55618
- * @param {BufferGeometry} geometry
55619
- * @param {THREE.Material} material
55620
- * @returns {THREE.SkinnedMesh}
55621
- */
55622
- function createSkinnedMesh(geometry, material) {
55623
- const result = new SkinnedMesh(geometry, material);
55624
-
55625
- prepareObject(result);
55626
-
55627
- return result;
55628
- }
55629
-
55630
- /**
55631
- *
55632
- * @param {Material} material
55633
- */
55634
- function prepareMaterial(material) {
55635
-
55636
- //make shadows render from front side, this avoids artifacts due to gaps in geometry that can't be seen from the front
55637
- material.shadowSide = DoubleSide;
55638
-
55639
- if (typeof material.envMapIntensity === 'number' && material.envMapIntensity !== 1) {
55640
- // make material react to environment map in the same way as others
55641
- material.envMapIntensity = 1;
55642
- }
55643
- }
55644
-
55645
- /**
55646
- *
55647
- * @returns {Group}
55648
- */
55649
- function createGroup() {
55650
- const result = new Group();
55651
-
55652
- prepareObject(result);
55653
-
55654
- return result;
55655
- }
55656
-
55657
- var ThreeFactory = {
55658
- createMesh,
55659
- createSkinnedMesh,
55660
- createGroup,
55661
- prepareMaterial
55592
+ /**
55593
+ * Common utilities
55594
+ * @module glMatrix
55595
+ */
55596
+ var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
55597
+ if (!Math.hypot) Math.hypot = function () {
55598
+ var y = 0,
55599
+ i = arguments.length;
55600
+
55601
+ while (i--) {
55602
+ y += arguments[i] * arguments[i];
55603
+ }
55604
+
55605
+ return Math.sqrt(y);
55662
55606
  };
55663
55607
 
55608
+ /**
55609
+ * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
55610
+ * @module mat4
55611
+ */
55612
+
55613
+ /**
55614
+ * Creates a new identity mat4
55615
+ *
55616
+ * @returns {mat4} a new 4x4 matrix
55617
+ */
55618
+
55619
+ function create$1() {
55620
+ var out = new ARRAY_TYPE(16);
55621
+
55622
+ if (ARRAY_TYPE != Float32Array) {
55623
+ out[1] = 0;
55624
+ out[2] = 0;
55625
+ out[3] = 0;
55626
+ out[4] = 0;
55627
+ out[6] = 0;
55628
+ out[7] = 0;
55629
+ out[8] = 0;
55630
+ out[9] = 0;
55631
+ out[11] = 0;
55632
+ out[12] = 0;
55633
+ out[13] = 0;
55634
+ out[14] = 0;
55635
+ }
55636
+
55637
+ out[0] = 1;
55638
+ out[5] = 1;
55639
+ out[10] = 1;
55640
+ out[15] = 1;
55641
+ return out;
55642
+ }
55643
+ /**
55644
+ * Copy the values from one mat4 to another
55645
+ *
55646
+ * @param {mat4} out the receiving matrix
55647
+ * @param {ReadonlyMat4} a the source matrix
55648
+ * @returns {mat4} out
55649
+ */
55650
+
55651
+ function copy(out, a) {
55652
+ out[0] = a[0];
55653
+ out[1] = a[1];
55654
+ out[2] = a[2];
55655
+ out[3] = a[3];
55656
+ out[4] = a[4];
55657
+ out[5] = a[5];
55658
+ out[6] = a[6];
55659
+ out[7] = a[7];
55660
+ out[8] = a[8];
55661
+ out[9] = a[9];
55662
+ out[10] = a[10];
55663
+ out[11] = a[11];
55664
+ out[12] = a[12];
55665
+ out[13] = a[13];
55666
+ out[14] = a[14];
55667
+ out[15] = a[15];
55668
+ return out;
55669
+ }
55670
+ /**
55671
+ * Inverts a mat4
55672
+ *
55673
+ * @param {mat4} out the receiving matrix
55674
+ * @param {ReadonlyMat4} a the source matrix
55675
+ * @returns {mat4} out
55676
+ */
55677
+
55678
+ function invert(out, a) {
55679
+ var a00 = a[0],
55680
+ a01 = a[1],
55681
+ a02 = a[2],
55682
+ a03 = a[3];
55683
+ var a10 = a[4],
55684
+ a11 = a[5],
55685
+ a12 = a[6],
55686
+ a13 = a[7];
55687
+ var a20 = a[8],
55688
+ a21 = a[9],
55689
+ a22 = a[10],
55690
+ a23 = a[11];
55691
+ var a30 = a[12],
55692
+ a31 = a[13],
55693
+ a32 = a[14],
55694
+ a33 = a[15];
55695
+ var b00 = a00 * a11 - a01 * a10;
55696
+ var b01 = a00 * a12 - a02 * a10;
55697
+ var b02 = a00 * a13 - a03 * a10;
55698
+ var b03 = a01 * a12 - a02 * a11;
55699
+ var b04 = a01 * a13 - a03 * a11;
55700
+ var b05 = a02 * a13 - a03 * a12;
55701
+ var b06 = a20 * a31 - a21 * a30;
55702
+ var b07 = a20 * a32 - a22 * a30;
55703
+ var b08 = a20 * a33 - a23 * a30;
55704
+ var b09 = a21 * a32 - a22 * a31;
55705
+ var b10 = a21 * a33 - a23 * a31;
55706
+ var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
55707
+
55708
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
55709
+
55710
+ if (!det) {
55711
+ return null;
55712
+ }
55713
+
55714
+ det = 1.0 / det;
55715
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
55716
+ out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
55717
+ out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
55718
+ out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
55719
+ out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
55720
+ out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
55721
+ out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
55722
+ out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
55723
+ out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
55724
+ out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
55725
+ out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
55726
+ out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
55727
+ out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
55728
+ out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
55729
+ out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
55730
+ out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
55731
+ return out;
55732
+ }
55733
+ /**
55734
+ * Multiplies two mat4s
55735
+ *
55736
+ * @param {mat4} out the receiving matrix
55737
+ * @param {ReadonlyMat4} a the first operand
55738
+ * @param {ReadonlyMat4} b the second operand
55739
+ * @returns {mat4} out
55740
+ */
55741
+
55742
+ function multiply(out, a, b) {
55743
+ var a00 = a[0],
55744
+ a01 = a[1],
55745
+ a02 = a[2],
55746
+ a03 = a[3];
55747
+ var a10 = a[4],
55748
+ a11 = a[5],
55749
+ a12 = a[6],
55750
+ a13 = a[7];
55751
+ var a20 = a[8],
55752
+ a21 = a[9],
55753
+ a22 = a[10],
55754
+ a23 = a[11];
55755
+ var a30 = a[12],
55756
+ a31 = a[13],
55757
+ a32 = a[14],
55758
+ a33 = a[15]; // Cache only the current line of the second matrix
55759
+
55760
+ var b0 = b[0],
55761
+ b1 = b[1],
55762
+ b2 = b[2],
55763
+ b3 = b[3];
55764
+ out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55765
+ out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55766
+ out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55767
+ out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55768
+ b0 = b[4];
55769
+ b1 = b[5];
55770
+ b2 = b[6];
55771
+ b3 = b[7];
55772
+ out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55773
+ out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55774
+ out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55775
+ out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55776
+ b0 = b[8];
55777
+ b1 = b[9];
55778
+ b2 = b[10];
55779
+ b3 = b[11];
55780
+ out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55781
+ out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55782
+ out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55783
+ out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55784
+ b0 = b[12];
55785
+ b1 = b[13];
55786
+ b2 = b[14];
55787
+ b3 = b[15];
55788
+ out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55789
+ out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55790
+ out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55791
+ out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55792
+ return out;
55793
+ }
55794
+
55795
+ /**
55796
+ * 3 Dimensional Vector
55797
+ * @module vec3
55798
+ */
55799
+
55800
+ /**
55801
+ * Creates a new, empty vec3
55802
+ *
55803
+ * @returns {vec3} a new 3D vector
55804
+ */
55805
+
55806
+ function create() {
55807
+ var out = new ARRAY_TYPE(3);
55808
+
55809
+ if (ARRAY_TYPE != Float32Array) {
55810
+ out[0] = 0;
55811
+ out[1] = 0;
55812
+ out[2] = 0;
55813
+ }
55814
+
55815
+ return out;
55816
+ }
55817
+ /**
55818
+ * Creates a new vec3 initialized with the given values
55819
+ *
55820
+ * @param {Number} x X component
55821
+ * @param {Number} y Y component
55822
+ * @param {Number} z Z component
55823
+ * @returns {vec3} a new 3D vector
55824
+ */
55825
+
55826
+ function fromValues(x, y, z) {
55827
+ var out = new ARRAY_TYPE(3);
55828
+ out[0] = x;
55829
+ out[1] = y;
55830
+ out[2] = z;
55831
+ return out;
55832
+ }
55833
+ /**
55834
+ * Transforms the vec3 with a mat4.
55835
+ * 4th vector component is implicitly '1'
55836
+ *
55837
+ * @param {vec3} out the receiving vector
55838
+ * @param {ReadonlyVec3} a the vector to transform
55839
+ * @param {ReadonlyMat4} m matrix to transform with
55840
+ * @returns {vec3} out
55841
+ */
55842
+
55843
+ function transformMat4(out, a, m) {
55844
+ var x = a[0],
55845
+ y = a[1],
55846
+ z = a[2];
55847
+ var w = m[3] * x + m[7] * y + m[11] * z + m[15];
55848
+ w = w || 1.0;
55849
+ out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
55850
+ out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
55851
+ out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
55852
+ return out;
55853
+ }
55854
+ /**
55855
+ * Perform some operation over an array of vec3s.
55856
+ *
55857
+ * @param {Array} a the array of vectors to iterate over
55858
+ * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
55859
+ * @param {Number} offset Number of elements to skip at the beginning of the array
55860
+ * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
55861
+ * @param {Function} fn Function to call for each vector in the array
55862
+ * @param {Object} [arg] additional argument to pass to fn
55863
+ * @returns {Array} a
55864
+ * @function
55865
+ */
55866
+
55867
+ (function () {
55868
+ var vec = create();
55869
+ return function (a, stride, offset, count, fn, arg) {
55870
+ var i, l;
55871
+
55872
+ if (!stride) {
55873
+ stride = 3;
55874
+ }
55875
+
55876
+ if (!offset) {
55877
+ offset = 0;
55878
+ }
55879
+
55880
+ if (count) {
55881
+ l = Math.min(count * stride + offset, a.length);
55882
+ } else {
55883
+ l = a.length;
55884
+ }
55885
+
55886
+ for (i = offset; i < l; i += stride) {
55887
+ vec[0] = a[i];
55888
+ vec[1] = a[i + 1];
55889
+ vec[2] = a[i + 2];
55890
+ fn(vec, vec, arg);
55891
+ a[i] = vec[0];
55892
+ a[i + 1] = vec[1];
55893
+ a[i + 2] = vec[2];
55894
+ }
55895
+
55896
+ return a;
55897
+ };
55898
+ })();
55899
+
55664
55900
  class IndexedBinaryBVHVisitor {
55665
55901
  /**
55666
55902
  *
@@ -56374,6 +56610,445 @@ class SurfacePoint3 {
56374
56610
  }
56375
56611
  }
56376
56612
 
56613
+ /**
56614
+ * Compute fraction of linear interpolation
56615
+ * @param {number} a
56616
+ * @param {number} b
56617
+ * @param {number} value
56618
+ * @returns {number} fraction
56619
+ */
56620
+ function inverseLerp(a, b, value) {
56621
+ const range = b - a;
56622
+ const scaledValue = value - a;
56623
+
56624
+ if (range === 0) {
56625
+
56626
+ // avoid division by zero error
56627
+
56628
+ // this is arbitrary output, as actual answer is undefined
56629
+
56630
+ return 0;
56631
+ }
56632
+
56633
+ return scaledValue / range;
56634
+ }
56635
+
56636
+ /**
56637
+ *
56638
+ * @param {number} min
56639
+ * @param {number} max
56640
+ * @constructor
56641
+ */
56642
+
56643
+ class NumericInterval {
56644
+ /**
56645
+ *
56646
+ * @param {number} [min=-Infinity]
56647
+ * @param {number} [max=Infinity]
56648
+ * @constructor
56649
+ */
56650
+ constructor(
56651
+ min = Number.NEGATIVE_INFINITY,
56652
+ max = Number.POSITIVE_INFINITY
56653
+ ) {
56654
+ assert.isNumber(min, 'min');
56655
+ assert.isNumber(max, 'max');
56656
+
56657
+ assert.ok(max >= min, `max=${max} must be >= than min=${min}`);
56658
+
56659
+ /**
56660
+ *
56661
+ * @type {number}
56662
+ */
56663
+ this.min = min;
56664
+ /**
56665
+ *
56666
+ * @type {number}
56667
+ */
56668
+ this.max = max;
56669
+
56670
+ this.onChanged = new Signal();
56671
+ }
56672
+
56673
+
56674
+ /**
56675
+ *
56676
+ * @param {number} min
56677
+ * @param {number} max
56678
+ */
56679
+ set(min, max) {
56680
+ assert.isNumber(min, 'min');
56681
+ assert.isNumber(max, 'max');
56682
+
56683
+ assert.notNaN(min, 'min');
56684
+ assert.notNaN(max, 'max');
56685
+
56686
+ assert.greaterThanOrEqual(max, min, `max [${max}] must be >= than min[${min}]`);
56687
+
56688
+ const oldMin = this.min;
56689
+ const oldMax = this.max;
56690
+
56691
+ if (min !== oldMin || max !== oldMax) {
56692
+ this.min = min;
56693
+ this.max = max;
56694
+
56695
+ if (this.onChanged.hasHandlers()) {
56696
+ this.onChanged.send4(min, max, oldMin, oldMax);
56697
+ }
56698
+ }
56699
+ }
56700
+
56701
+ /**
56702
+ *
56703
+ * @param {NumericInterval} other
56704
+ */
56705
+ copy(other) {
56706
+ this.set(other.min, other.max);
56707
+ }
56708
+
56709
+ /**
56710
+ *
56711
+ * @param {number} value
56712
+ */
56713
+ multiplyScalar(value) {
56714
+ const v0 = this.min * value;
56715
+ const v1 = this.max * value;
56716
+
56717
+ if (v0 > v1) {
56718
+ //probably negative scale
56719
+ this.set(v1, v0);
56720
+ } else {
56721
+
56722
+ this.set(v0, v1);
56723
+ }
56724
+ }
56725
+
56726
+ /**
56727
+ * Performs inverse linear interpolation on a given input
56728
+ * @param {number} v
56729
+ * @returns {number}
56730
+ */
56731
+ normalizeValue(v) {
56732
+ return inverseLerp(this.min, this.max, v);
56733
+ }
56734
+
56735
+ /**
56736
+ * Both min and max are exactly 0
56737
+ * @returns {boolean}
56738
+ */
56739
+ isZero() {
56740
+ return this.min === 0 && this.max === 0;
56741
+ }
56742
+
56743
+ /**
56744
+ * Whether min and max are the same
56745
+ * In other words if span is 0
56746
+ * @returns {boolean}
56747
+ */
56748
+ isExact() {
56749
+ return this.min === this.max;
56750
+ }
56751
+
56752
+ /**
56753
+ *
56754
+ * @returns {number}
56755
+ */
56756
+ computeAverage() {
56757
+ return (this.min + this.max) / 2;
56758
+ }
56759
+
56760
+ /**
56761
+ *
56762
+ * @param {function} random Random number generator function, must return values between 0 and 1
56763
+ * @returns {number}
56764
+ */
56765
+ sampleRandom(random) {
56766
+ assert.equal(typeof random, 'function', `random must be a function, instead was ${typeof random}`);
56767
+
56768
+ return this.min + random() * (this.max - this.min);
56769
+ }
56770
+
56771
+ fromJSON(json) {
56772
+ this.set(json.min, json.max);
56773
+ }
56774
+
56775
+ toJSON() {
56776
+ return {
56777
+ min: this.min,
56778
+ max: this.max
56779
+ };
56780
+ }
56781
+
56782
+ /**
56783
+ *
56784
+ * @param {BinaryBuffer} buffer
56785
+ */
56786
+ toBinaryBuffer(buffer) {
56787
+ buffer.writeFloat64(this.min);
56788
+ buffer.writeFloat64(this.max);
56789
+ }
56790
+
56791
+ /**
56792
+ *
56793
+ * @param {BinaryBuffer} buffer
56794
+ */
56795
+ fromBinaryBuffer(buffer) {
56796
+ this.min = buffer.readFloat64();
56797
+ this.max = buffer.readFloat64();
56798
+ }
56799
+
56800
+ /**
56801
+ *
56802
+ * @param {NumericInterval} other
56803
+ * @returns {boolean}
56804
+ */
56805
+ equals(other) {
56806
+ return this.min === other.min && this.max === other.max;
56807
+ }
56808
+
56809
+ /**
56810
+ *
56811
+ * @returns {number}
56812
+ */
56813
+ hash() {
56814
+ let hash = computeHashFloat(this.min);
56815
+
56816
+ hash = ((hash << 5) - hash) + computeHashFloat(this.max);
56817
+
56818
+ return hash;
56819
+ }
56820
+
56821
+ /**
56822
+ * Distance between min and max (= max - min)
56823
+ * @returns {number}
56824
+ */
56825
+ get span() {
56826
+ return this.max - this.min;
56827
+ }
56828
+ }
56829
+
56830
+ /**
56831
+ * @readonly
56832
+ * @type {boolean}
56833
+ */
56834
+ NumericInterval.prototype.isNumericInterval = true;
56835
+
56836
+ /**
56837
+ * @readonly
56838
+ * @type {NumericInterval}
56839
+ */
56840
+ NumericInterval.one_one = Object.freeze(new NumericInterval(1, 1));
56841
+ /**
56842
+ * @readonly
56843
+ * @type {NumericInterval}
56844
+ */
56845
+ NumericInterval.zero_zero = Object.freeze(new NumericInterval(0, 0));
56846
+
56847
+ class ObservedInteger extends Number {
56848
+ /**
56849
+ * @readonly
56850
+ * @type {Signal}
56851
+ */
56852
+ onChanged = new Signal();
56853
+
56854
+ /**
56855
+ *
56856
+ * @param {Number} [value]
56857
+ * @constructor
56858
+ */
56859
+ constructor(value = 0) {
56860
+ super();
56861
+
56862
+ assert.isNumber(value, 'value');
56863
+ assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
56864
+
56865
+
56866
+ /**
56867
+ *
56868
+ * @type {Number}
56869
+ * @private
56870
+ */
56871
+ this.__value = value;
56872
+
56873
+ }
56874
+
56875
+ /**
56876
+ *
56877
+ * @returns {Number}
56878
+ */
56879
+ valueOf() {
56880
+ return this.getValue();
56881
+ }
56882
+
56883
+ toString() {
56884
+ return this.getValue().toString();
56885
+ }
56886
+
56887
+ /**
56888
+ *
56889
+ * @param {Number} value
56890
+ * @returns {ObservedInteger}
56891
+ */
56892
+ set(value) {
56893
+ assert.isNumber(value, 'value');
56894
+ assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
56895
+
56896
+ const oldValue = this.__value;
56897
+ if (oldValue !== value) {
56898
+ this.__value = value;
56899
+ this.onChanged.send2(value, oldValue);
56900
+ }
56901
+
56902
+ return this;
56903
+ }
56904
+
56905
+ /**
56906
+ * Set value without dispatching change notification
56907
+ * @param {number} value
56908
+ */
56909
+ setSilent(value) {
56910
+ assert.isNumber(value, 'value');
56911
+ assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
56912
+
56913
+ this.__value = value;
56914
+ }
56915
+
56916
+ /**
56917
+ *
56918
+ * @return {boolean}
56919
+ */
56920
+ isZero() {
56921
+ return this.getValue() === 0;
56922
+ }
56923
+
56924
+ /**
56925
+ *
56926
+ * @param {ObservedInteger} other
56927
+ */
56928
+ subtract(other) {
56929
+ this._add(-other.getValue());
56930
+ }
56931
+
56932
+ /**
56933
+ *
56934
+ * @param {number} value
56935
+ */
56936
+ _subtract(value) {
56937
+ this.set(this.getValue() - value);
56938
+ }
56939
+
56940
+ /**
56941
+ *
56942
+ * @param {ObservedInteger} other
56943
+ */
56944
+ add(other) {
56945
+ this._add(other.getValue());
56946
+ }
56947
+
56948
+ /**
56949
+ *
56950
+ * @param {number} value
56951
+ */
56952
+ _add(value) {
56953
+ this.set(this.getValue() + value);
56954
+ }
56955
+
56956
+ /**
56957
+ * Increment the stored value by 1, same as adding 1
56958
+ */
56959
+ increment() {
56960
+ this.set(this.getValue() + 1);
56961
+ }
56962
+
56963
+ /**
56964
+ * Decrement the stored value by 1, same as subtracting 1
56965
+ */
56966
+ decrement() {
56967
+ this.set(this.getValue() - 1);
56968
+ }
56969
+
56970
+ /**
56971
+ *
56972
+ * @returns {Number}
56973
+ */
56974
+ getValue() {
56975
+ return this.__value;
56976
+ }
56977
+
56978
+ /**
56979
+ *
56980
+ * @param {ObservedInteger} other
56981
+ */
56982
+ copy(other) {
56983
+ this.set(other.__value);
56984
+ }
56985
+
56986
+ /**
56987
+ *
56988
+ * @param {ObservedInteger} other
56989
+ * @returns {boolean}
56990
+ */
56991
+ equals(other) {
56992
+ return this.__value === other.__value;
56993
+ }
56994
+
56995
+ /**
56996
+ *
56997
+ * @returns {Number}
56998
+ */
56999
+ hash() {
57000
+ return this.__value;
57001
+ }
57002
+
57003
+ toJSON() {
57004
+ return this.__value;
57005
+ }
57006
+
57007
+ fromJSON(obj) {
57008
+ this.set(obj);
57009
+ }
57010
+
57011
+ /**
57012
+ *
57013
+ * @param {BinaryBuffer} buffer
57014
+ */
57015
+ toBinaryBuffer(buffer) {
57016
+ const v = this.__value;
57017
+
57018
+ if (v === Infinity) {
57019
+ buffer.writeInt32(2147483647);
57020
+ } else if (v === -Infinity) {
57021
+ buffer.writeInt32(-2147483648);
57022
+ } else {
57023
+ //TODO it's possible to write encoded Infinity values by accident
57024
+ buffer.writeInt32(v);
57025
+ }
57026
+ }
57027
+
57028
+ /**
57029
+ *
57030
+ * @param {BinaryBuffer} buffer
57031
+ */
57032
+ fromBinaryBuffer(buffer) {
57033
+ const value = buffer.readInt32();
57034
+
57035
+ if (value === 2147483647) {
57036
+ this.set(Infinity);
57037
+ } else if (value === -2147483648) {
57038
+ this.set(-Infinity);
57039
+ } else {
57040
+ this.set(value);
57041
+ }
57042
+ }
57043
+ }
57044
+
57045
+
57046
+ /**
57047
+ * @readonly
57048
+ * @type {boolean}
57049
+ */
57050
+ ObservedInteger.prototype.isObservedInteger = true;
57051
+
56377
57052
  /**
56378
57053
  * NOTE: adapted from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
56379
57054
  * @source https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm (Möller and Trumbore, « Fast, Minimum Storage Ray-Triangle Intersection », Journal of Graphics Tools, vol. 2,‎ 1997, p. 21–28)
@@ -56623,332 +57298,24 @@ function ray3_array_apply_matrix4(output, output_offset, input, input_offset, m4
56623
57298
  return true;
56624
57299
  }
56625
57300
 
56626
- /**
56627
- * Common utilities
56628
- * @module glMatrix
56629
- */
56630
- var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
56631
- if (!Math.hypot) Math.hypot = function () {
56632
- var y = 0,
56633
- i = arguments.length;
56634
-
56635
- while (i--) {
56636
- y += arguments[i] * arguments[i];
56637
- }
56638
-
56639
- return Math.sqrt(y);
56640
- };
56641
-
56642
- /**
56643
- * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
56644
- * @module mat4
56645
- */
56646
-
56647
- /**
56648
- * Creates a new identity mat4
56649
- *
56650
- * @returns {mat4} a new 4x4 matrix
56651
- */
56652
-
56653
- function create$1() {
56654
- var out = new ARRAY_TYPE(16);
56655
-
56656
- if (ARRAY_TYPE != Float32Array) {
56657
- out[1] = 0;
56658
- out[2] = 0;
56659
- out[3] = 0;
56660
- out[4] = 0;
56661
- out[6] = 0;
56662
- out[7] = 0;
56663
- out[8] = 0;
56664
- out[9] = 0;
56665
- out[11] = 0;
56666
- out[12] = 0;
56667
- out[13] = 0;
56668
- out[14] = 0;
56669
- }
56670
-
56671
- out[0] = 1;
56672
- out[5] = 1;
56673
- out[10] = 1;
56674
- out[15] = 1;
56675
- return out;
56676
- }
56677
- /**
56678
- * Copy the values from one mat4 to another
56679
- *
56680
- * @param {mat4} out the receiving matrix
56681
- * @param {ReadonlyMat4} a the source matrix
56682
- * @returns {mat4} out
56683
- */
56684
-
56685
- function copy(out, a) {
56686
- out[0] = a[0];
56687
- out[1] = a[1];
56688
- out[2] = a[2];
56689
- out[3] = a[3];
56690
- out[4] = a[4];
56691
- out[5] = a[5];
56692
- out[6] = a[6];
56693
- out[7] = a[7];
56694
- out[8] = a[8];
56695
- out[9] = a[9];
56696
- out[10] = a[10];
56697
- out[11] = a[11];
56698
- out[12] = a[12];
56699
- out[13] = a[13];
56700
- out[14] = a[14];
56701
- out[15] = a[15];
56702
- return out;
56703
- }
56704
- /**
56705
- * Inverts a mat4
56706
- *
56707
- * @param {mat4} out the receiving matrix
56708
- * @param {ReadonlyMat4} a the source matrix
56709
- * @returns {mat4} out
56710
- */
56711
-
56712
- function invert(out, a) {
56713
- var a00 = a[0],
56714
- a01 = a[1],
56715
- a02 = a[2],
56716
- a03 = a[3];
56717
- var a10 = a[4],
56718
- a11 = a[5],
56719
- a12 = a[6],
56720
- a13 = a[7];
56721
- var a20 = a[8],
56722
- a21 = a[9],
56723
- a22 = a[10],
56724
- a23 = a[11];
56725
- var a30 = a[12],
56726
- a31 = a[13],
56727
- a32 = a[14],
56728
- a33 = a[15];
56729
- var b00 = a00 * a11 - a01 * a10;
56730
- var b01 = a00 * a12 - a02 * a10;
56731
- var b02 = a00 * a13 - a03 * a10;
56732
- var b03 = a01 * a12 - a02 * a11;
56733
- var b04 = a01 * a13 - a03 * a11;
56734
- var b05 = a02 * a13 - a03 * a12;
56735
- var b06 = a20 * a31 - a21 * a30;
56736
- var b07 = a20 * a32 - a22 * a30;
56737
- var b08 = a20 * a33 - a23 * a30;
56738
- var b09 = a21 * a32 - a22 * a31;
56739
- var b10 = a21 * a33 - a23 * a31;
56740
- var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
56741
-
56742
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
56743
-
56744
- if (!det) {
56745
- return null;
56746
- }
56747
-
56748
- det = 1.0 / det;
56749
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
56750
- out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
56751
- out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
56752
- out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
56753
- out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
56754
- out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
56755
- out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
56756
- out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
56757
- out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
56758
- out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
56759
- out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
56760
- out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
56761
- out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
56762
- out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
56763
- out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
56764
- out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
56765
- return out;
56766
- }
56767
- /**
56768
- * Multiplies two mat4s
56769
- *
56770
- * @param {mat4} out the receiving matrix
56771
- * @param {ReadonlyMat4} a the first operand
56772
- * @param {ReadonlyMat4} b the second operand
56773
- * @returns {mat4} out
56774
- */
56775
-
56776
- function multiply(out, a, b) {
56777
- var a00 = a[0],
56778
- a01 = a[1],
56779
- a02 = a[2],
56780
- a03 = a[3];
56781
- var a10 = a[4],
56782
- a11 = a[5],
56783
- a12 = a[6],
56784
- a13 = a[7];
56785
- var a20 = a[8],
56786
- a21 = a[9],
56787
- a22 = a[10],
56788
- a23 = a[11];
56789
- var a30 = a[12],
56790
- a31 = a[13],
56791
- a32 = a[14],
56792
- a33 = a[15]; // Cache only the current line of the second matrix
56793
-
56794
- var b0 = b[0],
56795
- b1 = b[1],
56796
- b2 = b[2],
56797
- b3 = b[3];
56798
- out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
56799
- out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
56800
- out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
56801
- out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
56802
- b0 = b[4];
56803
- b1 = b[5];
56804
- b2 = b[6];
56805
- b3 = b[7];
56806
- out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
56807
- out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
56808
- out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
56809
- out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
56810
- b0 = b[8];
56811
- b1 = b[9];
56812
- b2 = b[10];
56813
- b3 = b[11];
56814
- out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
56815
- out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
56816
- out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
56817
- out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
56818
- b0 = b[12];
56819
- b1 = b[13];
56820
- b2 = b[14];
56821
- b3 = b[15];
56822
- out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
56823
- out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
56824
- out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
56825
- out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
56826
- return out;
56827
- }
56828
-
56829
- /**
56830
- * 3 Dimensional Vector
56831
- * @module vec3
56832
- */
56833
-
56834
- /**
56835
- * Creates a new, empty vec3
56836
- *
56837
- * @returns {vec3} a new 3D vector
56838
- */
56839
-
56840
- function create() {
56841
- var out = new ARRAY_TYPE(3);
56842
-
56843
- if (ARRAY_TYPE != Float32Array) {
56844
- out[0] = 0;
56845
- out[1] = 0;
56846
- out[2] = 0;
56847
- }
56848
-
56849
- return out;
56850
- }
56851
- /**
56852
- * Creates a new vec3 initialized with the given values
56853
- *
56854
- * @param {Number} x X component
56855
- * @param {Number} y Y component
56856
- * @param {Number} z Z component
56857
- * @returns {vec3} a new 3D vector
56858
- */
56859
-
56860
- function fromValues(x, y, z) {
56861
- var out = new ARRAY_TYPE(3);
56862
- out[0] = x;
56863
- out[1] = y;
56864
- out[2] = z;
56865
- return out;
56866
- }
56867
- /**
56868
- * Transforms the vec3 with a mat4.
56869
- * 4th vector component is implicitly '1'
56870
- *
56871
- * @param {vec3} out the receiving vector
56872
- * @param {ReadonlyVec3} a the vector to transform
56873
- * @param {ReadonlyMat4} m matrix to transform with
56874
- * @returns {vec3} out
56875
- */
56876
-
56877
- function transformMat4(out, a, m) {
56878
- var x = a[0],
56879
- y = a[1],
56880
- z = a[2];
56881
- var w = m[3] * x + m[7] * y + m[11] * z + m[15];
56882
- w = w || 1.0;
56883
- out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
56884
- out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
56885
- out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
56886
- return out;
56887
- }
56888
- /**
56889
- * Perform some operation over an array of vec3s.
56890
- *
56891
- * @param {Array} a the array of vectors to iterate over
56892
- * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
56893
- * @param {Number} offset Number of elements to skip at the beginning of the array
56894
- * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
56895
- * @param {Function} fn Function to call for each vector in the array
56896
- * @param {Object} [arg] additional argument to pass to fn
56897
- * @returns {Array} a
56898
- * @function
56899
- */
56900
-
56901
- (function () {
56902
- var vec = create();
56903
- return function (a, stride, offset, count, fn, arg) {
56904
- var i, l;
56905
-
56906
- if (!stride) {
56907
- stride = 3;
56908
- }
56909
-
56910
- if (!offset) {
56911
- offset = 0;
56912
- }
56913
-
56914
- if (count) {
56915
- l = Math.min(count * stride + offset, a.length);
56916
- } else {
56917
- l = a.length;
56918
- }
56919
-
56920
- for (i = offset; i < l; i += stride) {
56921
- vec[0] = a[i];
56922
- vec[1] = a[i + 1];
56923
- vec[2] = a[i + 2];
56924
- fn(vec, vec, arg);
56925
- a[i] = vec[0];
56926
- a[i + 1] = vec[1];
56927
- a[i + 2] = vec[2];
56928
- }
56929
-
56930
- return a;
56931
- };
56932
- })();
56933
-
56934
- /**
56935
- *
56936
- * @param {number[]|ArrayLike<number>|Float32Array} output
56937
- * @param {number} origin_x
56938
- * @param {number} origin_y
56939
- * @param {number} origin_z
56940
- * @param {number} direction_x
56941
- * @param {number} direction_y
56942
- * @param {number} direction_z
56943
- */
56944
- function ray3_array_compose(output, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z) {
56945
- output[0] = origin_x;
56946
- output[1] = origin_y;
56947
- output[2] = origin_z;
56948
-
56949
- output[3] = direction_x;
56950
- output[4] = direction_y;
56951
- output[5] = direction_z;
57301
+ /**
57302
+ *
57303
+ * @param {number[]|ArrayLike<number>|Float32Array} output
57304
+ * @param {number} origin_x
57305
+ * @param {number} origin_y
57306
+ * @param {number} origin_z
57307
+ * @param {number} direction_x
57308
+ * @param {number} direction_y
57309
+ * @param {number} direction_z
57310
+ */
57311
+ function ray3_array_compose(output, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z) {
57312
+ output[0] = origin_x;
57313
+ output[1] = origin_y;
57314
+ output[2] = origin_z;
57315
+
57316
+ output[3] = direction_x;
57317
+ output[4] = direction_y;
57318
+ output[5] = direction_z;
56952
57319
  }
56953
57320
 
56954
57321
  const hit$1 = new Vector3();
@@ -56982,640 +57349,278 @@ function bindGeometryFace(indices, vertices, index) {
56982
57349
 
56983
57350
  const vNormal = new Vector3$1();
56984
57351
 
56985
- function bindGeometryFaceNormal(indices, normals, index) {
56986
-
56987
- const index3 = index * 3;
56988
-
56989
- const a = indices[index3] * 3;
56990
- const b = indices[index3 + 1] * 3;
56991
- const c = indices[index3 + 2] * 3;
56992
-
56993
- //read vertex normals
56994
- const naX = normals[a];
56995
- const naY = normals[a + 1];
56996
- const naZ = normals[a + 2];
56997
-
56998
- const nbX = normals[b];
56999
- const nbY = normals[b + 1];
57000
- const nbZ = normals[b + 2];
57001
-
57002
- const ncX = normals[c];
57003
- const ncY = normals[c + 1];
57004
- const ncZ = normals[c + 2];
57005
-
57006
- //add normals
57007
- const nsX = (naX + nbX + ncX);
57008
- const nsY = (naY + nbY + ncY);
57009
- const nsZ = (naZ + nbZ + ncZ);
57010
-
57011
- //normalize
57012
- const l = v3_length(nsX, nsY, nsZ);
57013
- const m = 1 / l;
57014
-
57015
- const nx = nsX * m;
57016
- const ny = nsY * m;
57017
- const nz = nsZ * m;
57018
-
57019
- vNormal.set(nx, ny, nz);
57020
- }
57021
-
57022
-
57023
- function extractFaceIndexFromLeaf_default(leaf) {
57024
- return leaf.object;
57025
- }
57026
-
57027
- class BVHGeometryRaycaster {
57028
- constructor() {
57029
- /**
57030
- *
57031
- * @type {BufferGeometry|null}
57032
- */
57033
- this.geometry = null;
57034
- /**
57035
- *
57036
- * @type {BinaryNode|null}
57037
- */
57038
- this.bvh = null;
57039
-
57040
- /**
57041
- *
57042
- * @type {Vector2|null}
57043
- */
57044
- this.position = null;
57045
- /**
57046
- *
57047
- * @type {Vector2|null}
57048
- */
57049
- this.scale = null;
57050
- /**
57051
- *
57052
- * @type {number}
57053
- */
57054
- this.resolution = 0;
57055
-
57056
- /**
57057
- *
57058
- * @type {Vector2|null}
57059
- */
57060
- this.size = null;
57061
-
57062
- this.__bestDistance = 0;
57063
- this.__bestPosition = new Vector3$1();
57064
- this.__bestIndex = 0;
57065
-
57066
-
57067
- this.origin = new Vector3$1();
57068
- this.direction = new Vector3$1();
57069
-
57070
- /**
57071
- *
57072
- * @type {Float32Array}
57073
- */
57074
- this.transform = new Float32Array(16);
57075
-
57076
- array_copy(MATRIX_4_IDENTITY, 0, this.transform, 0, 16);
57077
-
57078
- this.extractFaceIndexFromLeaf = extractFaceIndexFromLeaf_default;
57079
- }
57080
-
57081
- /**
57082
- *
57083
- * @param {*} leaf
57084
- */
57085
- visitLeafIntersection(leaf) {
57086
-
57087
- const geometry = this.geometry;
57088
-
57089
- const geometryIndices = geometry.getIndex().array;
57090
- const geometryVertices = geometry.getAttribute('position').array;
57091
-
57092
- const extractFaceIndexFromLeaf = this.extractFaceIndexFromLeaf;
57093
-
57094
- const index = extractFaceIndexFromLeaf(leaf);
57095
-
57096
- bindGeometryFace(geometryIndices, geometryVertices, index);
57097
-
57098
- const hitFound = rayTriangleIntersection(hit$1, this.origin, this.direction, vA, vB, vC);
57099
-
57100
- if (hitFound) {
57101
-
57102
- const d = this.origin.distanceSqrTo(hit$1);
57103
- if (d < this.__bestDistance) {
57104
- this.__bestDistance = d;
57105
- this.__bestPosition.copy(hit$1);
57106
- this.__bestIndex = index;
57107
- }
57108
-
57109
- }
57110
- }
57111
-
57112
- /**
57113
- *
57114
- * @param {SurfacePoint3} hit
57115
- * @param {number} originX
57116
- * @param {number} originY
57117
- * @param {number} originZ
57118
- * @param {number} directionX
57119
- * @param {number} directionY
57120
- * @param {number} directionZ
57121
- * @returns {boolean}
57122
- */
57123
- raycast(
57124
- hit,
57125
- originX, originY, originZ,
57126
- directionX, directionY, directionZ
57127
- ) {
57128
-
57129
- invert(m4_tmp, this.transform);
57130
-
57131
- ray3_array_compose(
57132
- ray_tmp,
57133
- originX, originY, originZ,
57134
- directionX, directionY, directionZ
57135
- );
57136
-
57137
- ray3_array_apply_matrix4(ray_tmp, 0,ray_tmp,0, m4_tmp);
57138
-
57139
- const _originX = ray_tmp[0];
57140
- const _originY = ray_tmp[1];
57141
- const _originZ = ray_tmp[2];
57142
-
57143
- const _directionX = ray_tmp[3];
57144
- const _directionY = ray_tmp[4];
57145
- const _directionZ = ray_tmp[5];
57146
-
57147
- this.origin.set(_originX, _originY, _originZ);
57148
- this.direction.set(_directionX, _directionY, _directionZ);
57149
-
57150
- this.__bestDistance = Number.POSITIVE_INFINITY;
57151
-
57152
- this.bvh.traverseRayLeafIntersections(_originX, _originY, _originZ, _directionX, _directionY, _directionZ, this.visitLeafIntersection, this);
57153
-
57154
- if (this.__bestDistance !== Number.POSITIVE_INFINITY) {
57155
-
57156
- const geometry = this.geometry;
57157
-
57158
- const geometryIndices = geometry.getIndex().array;
57159
- const geometryNormals = geometry.getAttribute('normal').array;
57160
-
57161
- bindGeometryFaceNormal(geometryIndices, geometryNormals, this.__bestIndex);
57162
-
57163
- hit.position.copy(this.__bestPosition);
57164
- hit.normal.copy(vNormal);
57165
-
57166
- hit.applyMatrix4(this.transform);
57167
-
57168
- return true;
57169
- } else {
57170
- //no hit
57171
- return false;
57172
- }
57173
- }
57174
- }
57175
-
57176
- class ObservedInteger extends Number {
57177
- /**
57178
- * @readonly
57179
- * @type {Signal}
57180
- */
57181
- onChanged = new Signal();
57182
-
57183
- /**
57184
- *
57185
- * @param {Number} [value]
57186
- * @constructor
57187
- */
57188
- constructor(value = 0) {
57189
- super();
57190
-
57191
- assert.isNumber(value, 'value');
57192
- assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
57193
-
57194
-
57195
- /**
57196
- *
57197
- * @type {Number}
57198
- * @private
57199
- */
57200
- this.__value = value;
57201
-
57202
- }
57203
-
57204
- /**
57205
- *
57206
- * @returns {Number}
57207
- */
57208
- valueOf() {
57209
- return this.getValue();
57210
- }
57211
-
57212
- toString() {
57213
- return this.getValue().toString();
57214
- }
57215
-
57216
- /**
57217
- *
57218
- * @param {Number} value
57219
- * @returns {ObservedInteger}
57220
- */
57221
- set(value) {
57222
- assert.isNumber(value, 'value');
57223
- assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
57224
-
57225
- const oldValue = this.__value;
57226
- if (oldValue !== value) {
57227
- this.__value = value;
57228
- this.onChanged.send2(value, oldValue);
57229
- }
57230
-
57231
- return this;
57232
- }
57233
-
57234
- /**
57235
- * Set value without dispatching change notification
57236
- * @param {number} value
57237
- */
57238
- setSilent(value) {
57239
- assert.isNumber(value, 'value');
57240
- assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
57241
-
57242
- this.__value = value;
57243
- }
57244
-
57245
- /**
57246
- *
57247
- * @return {boolean}
57248
- */
57249
- isZero() {
57250
- return this.getValue() === 0;
57251
- }
57252
-
57253
- /**
57254
- *
57255
- * @param {ObservedInteger} other
57256
- */
57257
- subtract(other) {
57258
- this._add(-other.getValue());
57259
- }
57260
-
57261
- /**
57262
- *
57263
- * @param {number} value
57264
- */
57265
- _subtract(value) {
57266
- this.set(this.getValue() - value);
57267
- }
57268
-
57269
- /**
57270
- *
57271
- * @param {ObservedInteger} other
57272
- */
57273
- add(other) {
57274
- this._add(other.getValue());
57275
- }
57276
-
57277
- /**
57278
- *
57279
- * @param {number} value
57280
- */
57281
- _add(value) {
57282
- this.set(this.getValue() + value);
57283
- }
57284
-
57285
- /**
57286
- * Increment the stored value by 1, same as adding 1
57287
- */
57288
- increment() {
57289
- this.set(this.getValue() + 1);
57290
- }
57291
-
57292
- /**
57293
- * Decrement the stored value by 1, same as subtracting 1
57294
- */
57295
- decrement() {
57296
- this.set(this.getValue() - 1);
57297
- }
57298
-
57299
- /**
57300
- *
57301
- * @returns {Number}
57302
- */
57303
- getValue() {
57304
- return this.__value;
57305
- }
57306
-
57307
- /**
57308
- *
57309
- * @param {ObservedInteger} other
57310
- */
57311
- copy(other) {
57312
- this.set(other.__value);
57313
- }
57314
-
57315
- /**
57316
- *
57317
- * @param {ObservedInteger} other
57318
- * @returns {boolean}
57319
- */
57320
- equals(other) {
57321
- return this.__value === other.__value;
57322
- }
57323
-
57324
- /**
57325
- *
57326
- * @returns {Number}
57327
- */
57328
- hash() {
57329
- return this.__value;
57330
- }
57331
-
57332
- toJSON() {
57333
- return this.__value;
57334
- }
57335
-
57336
- fromJSON(obj) {
57337
- this.set(obj);
57338
- }
57339
-
57340
- /**
57341
- *
57342
- * @param {BinaryBuffer} buffer
57343
- */
57344
- toBinaryBuffer(buffer) {
57345
- const v = this.__value;
57346
-
57347
- if (v === Infinity) {
57348
- buffer.writeInt32(2147483647);
57349
- } else if (v === -Infinity) {
57350
- buffer.writeInt32(-2147483648);
57351
- } else {
57352
- //TODO it's possible to write encoded Infinity values by accident
57353
- buffer.writeInt32(v);
57354
- }
57355
- }
57352
+ function bindGeometryFaceNormal(indices, normals, index) {
57356
57353
 
57357
- /**
57358
- *
57359
- * @param {BinaryBuffer} buffer
57360
- */
57361
- fromBinaryBuffer(buffer) {
57362
- const value = buffer.readInt32();
57354
+ const index3 = index * 3;
57363
57355
 
57364
- if (value === 2147483647) {
57365
- this.set(Infinity);
57366
- } else if (value === -2147483648) {
57367
- this.set(-Infinity);
57368
- } else {
57369
- this.set(value);
57370
- }
57371
- }
57372
- }
57356
+ const a = indices[index3] * 3;
57357
+ const b = indices[index3 + 1] * 3;
57358
+ const c = indices[index3 + 2] * 3;
57373
57359
 
57360
+ //read vertex normals
57361
+ const naX = normals[a];
57362
+ const naY = normals[a + 1];
57363
+ const naZ = normals[a + 2];
57374
57364
 
57375
- /**
57376
- * @readonly
57377
- * @type {boolean}
57378
- */
57379
- ObservedInteger.prototype.isObservedInteger = true;
57380
-
57381
- /**
57382
- * Compute fraction of linear interpolation
57383
- * @param {number} a
57384
- * @param {number} b
57385
- * @param {number} value
57386
- * @returns {number} fraction
57387
- */
57388
- function inverseLerp(a, b, value) {
57389
- const range = b - a;
57390
- const scaledValue = value - a;
57365
+ const nbX = normals[b];
57366
+ const nbY = normals[b + 1];
57367
+ const nbZ = normals[b + 2];
57391
57368
 
57392
- if (range === 0) {
57369
+ const ncX = normals[c];
57370
+ const ncY = normals[c + 1];
57371
+ const ncZ = normals[c + 2];
57393
57372
 
57394
- // avoid division by zero error
57373
+ //add normals
57374
+ const nsX = (naX + nbX + ncX);
57375
+ const nsY = (naY + nbY + ncY);
57376
+ const nsZ = (naZ + nbZ + ncZ);
57395
57377
 
57396
- // this is arbitrary output, as actual answer is undefined
57378
+ //normalize
57379
+ const l = v3_length(nsX, nsY, nsZ);
57380
+ const m = 1 / l;
57397
57381
 
57398
- return 0;
57399
- }
57382
+ const nx = nsX * m;
57383
+ const ny = nsY * m;
57384
+ const nz = nsZ * m;
57400
57385
 
57401
- return scaledValue / range;
57402
- }
57403
-
57404
- /**
57405
- *
57406
- * @param {number} min
57407
- * @param {number} max
57408
- * @constructor
57409
- */
57386
+ vNormal.set(nx, ny, nz);
57387
+ }
57410
57388
 
57411
- class NumericInterval {
57412
- /**
57413
- *
57414
- * @param {number} [min=-Infinity]
57415
- * @param {number} [max=Infinity]
57416
- * @constructor
57417
- */
57418
- constructor(
57419
- min = Number.NEGATIVE_INFINITY,
57420
- max = Number.POSITIVE_INFINITY
57421
- ) {
57422
- assert.isNumber(min, 'min');
57423
- assert.isNumber(max, 'max');
57424
57389
 
57425
- assert.ok(max >= min, `max=${max} must be >= than min=${min}`);
57390
+ function extractFaceIndexFromLeaf_default(leaf) {
57391
+ return leaf.object;
57392
+ }
57426
57393
 
57394
+ class BVHGeometryRaycaster {
57395
+ constructor() {
57427
57396
  /**
57428
57397
  *
57429
- * @type {number}
57398
+ * @type {BufferGeometry|null}
57430
57399
  */
57431
- this.min = min;
57400
+ this.geometry = null;
57401
+ /**
57402
+ *
57403
+ * @type {BinaryNode|null}
57404
+ */
57405
+ this.bvh = null;
57406
+
57407
+ /**
57408
+ *
57409
+ * @type {Vector2|null}
57410
+ */
57411
+ this.position = null;
57412
+ /**
57413
+ *
57414
+ * @type {Vector2|null}
57415
+ */
57416
+ this.scale = null;
57432
57417
  /**
57433
57418
  *
57434
57419
  * @type {number}
57435
57420
  */
57436
- this.max = max;
57421
+ this.resolution = 0;
57437
57422
 
57438
- this.onChanged = new Signal();
57439
- }
57423
+ /**
57424
+ *
57425
+ * @type {Vector2|null}
57426
+ */
57427
+ this.size = null;
57428
+
57429
+ this.__bestDistance = 0;
57430
+ this.__bestPosition = new Vector3$1();
57431
+ this.__bestIndex = 0;
57432
+
57433
+
57434
+ this.origin = new Vector3$1();
57435
+ this.direction = new Vector3$1();
57440
57436
 
57437
+ /**
57438
+ *
57439
+ * @type {Float32Array}
57440
+ */
57441
+ this.transform = new Float32Array(16);
57442
+
57443
+ array_copy(MATRIX_4_IDENTITY, 0, this.transform, 0, 16);
57444
+
57445
+ this.extractFaceIndexFromLeaf = extractFaceIndexFromLeaf_default;
57446
+ }
57441
57447
 
57442
57448
  /**
57443
57449
  *
57444
- * @param {number} min
57445
- * @param {number} max
57450
+ * @param {*} leaf
57446
57451
  */
57447
- set(min, max) {
57448
- assert.isNumber(min, 'min');
57449
- assert.isNumber(max, 'max');
57452
+ visitLeafIntersection(leaf) {
57450
57453
 
57451
- assert.notNaN(min, 'min');
57452
- assert.notNaN(max, 'max');
57454
+ const geometry = this.geometry;
57453
57455
 
57454
- assert.greaterThanOrEqual(max, min, `max [${max}] must be >= than min[${min}]`);
57456
+ const geometryIndices = geometry.getIndex().array;
57457
+ const geometryVertices = geometry.getAttribute('position').array;
57455
57458
 
57456
- const oldMin = this.min;
57457
- const oldMax = this.max;
57459
+ const extractFaceIndexFromLeaf = this.extractFaceIndexFromLeaf;
57458
57460
 
57459
- if (min !== oldMin || max !== oldMax) {
57460
- this.min = min;
57461
- this.max = max;
57461
+ const index = extractFaceIndexFromLeaf(leaf);
57462
57462
 
57463
- if (this.onChanged.hasHandlers()) {
57464
- this.onChanged.send4(min, max, oldMin, oldMax);
57463
+ bindGeometryFace(geometryIndices, geometryVertices, index);
57464
+
57465
+ const hitFound = rayTriangleIntersection(hit$1, this.origin, this.direction, vA, vB, vC);
57466
+
57467
+ if (hitFound) {
57468
+
57469
+ const d = this.origin.distanceSqrTo(hit$1);
57470
+ if (d < this.__bestDistance) {
57471
+ this.__bestDistance = d;
57472
+ this.__bestPosition.copy(hit$1);
57473
+ this.__bestIndex = index;
57465
57474
  }
57475
+
57466
57476
  }
57467
57477
  }
57468
57478
 
57469
57479
  /**
57470
57480
  *
57471
- * @param {NumericInterval} other
57481
+ * @param {SurfacePoint3} hit
57482
+ * @param {number} originX
57483
+ * @param {number} originY
57484
+ * @param {number} originZ
57485
+ * @param {number} directionX
57486
+ * @param {number} directionY
57487
+ * @param {number} directionZ
57488
+ * @returns {boolean}
57472
57489
  */
57473
- copy(other) {
57474
- this.set(other.min, other.max);
57475
- }
57490
+ raycast(
57491
+ hit,
57492
+ originX, originY, originZ,
57493
+ directionX, directionY, directionZ
57494
+ ) {
57476
57495
 
57477
- /**
57478
- *
57479
- * @param {number} value
57480
- */
57481
- multiplyScalar(value) {
57482
- const v0 = this.min * value;
57483
- const v1 = this.max * value;
57496
+ invert(m4_tmp, this.transform);
57484
57497
 
57485
- if (v0 > v1) {
57486
- //probably negative scale
57487
- this.set(v1, v0);
57488
- } else {
57498
+ ray3_array_compose(
57499
+ ray_tmp,
57500
+ originX, originY, originZ,
57501
+ directionX, directionY, directionZ
57502
+ );
57489
57503
 
57490
- this.set(v0, v1);
57491
- }
57492
- }
57504
+ ray3_array_apply_matrix4(ray_tmp, 0,ray_tmp,0, m4_tmp);
57493
57505
 
57494
- /**
57495
- * Performs inverse linear interpolation on a given input
57496
- * @param {number} v
57497
- * @returns {number}
57498
- */
57499
- normalizeValue(v) {
57500
- return inverseLerp(this.min, this.max, v);
57501
- }
57506
+ const _originX = ray_tmp[0];
57507
+ const _originY = ray_tmp[1];
57508
+ const _originZ = ray_tmp[2];
57502
57509
 
57503
- /**
57504
- * Both min and max are exactly 0
57505
- * @returns {boolean}
57506
- */
57507
- isZero() {
57508
- return this.min === 0 && this.max === 0;
57509
- }
57510
+ const _directionX = ray_tmp[3];
57511
+ const _directionY = ray_tmp[4];
57512
+ const _directionZ = ray_tmp[5];
57510
57513
 
57511
- /**
57512
- * Whether min and max are the same
57513
- * In other words if span is 0
57514
- * @returns {boolean}
57515
- */
57516
- isExact() {
57517
- return this.min === this.max;
57518
- }
57514
+ this.origin.set(_originX, _originY, _originZ);
57515
+ this.direction.set(_directionX, _directionY, _directionZ);
57519
57516
 
57520
- /**
57521
- *
57522
- * @returns {number}
57523
- */
57524
- computeAverage() {
57525
- return (this.min + this.max) / 2;
57526
- }
57517
+ this.__bestDistance = Number.POSITIVE_INFINITY;
57527
57518
 
57528
- /**
57529
- *
57530
- * @param {function} random Random number generator function, must return values between 0 and 1
57531
- * @returns {number}
57532
- */
57533
- sampleRandom(random) {
57534
- assert.equal(typeof random, 'function', `random must be a function, instead was ${typeof random}`);
57519
+ this.bvh.traverseRayLeafIntersections(_originX, _originY, _originZ, _directionX, _directionY, _directionZ, this.visitLeafIntersection, this);
57535
57520
 
57536
- return this.min + random() * (this.max - this.min);
57537
- }
57521
+ if (this.__bestDistance !== Number.POSITIVE_INFINITY) {
57538
57522
 
57539
- fromJSON(json) {
57540
- this.set(json.min, json.max);
57541
- }
57523
+ const geometry = this.geometry;
57542
57524
 
57543
- toJSON() {
57544
- return {
57545
- min: this.min,
57546
- max: this.max
57547
- };
57548
- }
57525
+ const geometryIndices = geometry.getIndex().array;
57526
+ const geometryNormals = geometry.getAttribute('normal').array;
57549
57527
 
57550
- /**
57551
- *
57552
- * @param {BinaryBuffer} buffer
57553
- */
57554
- toBinaryBuffer(buffer) {
57555
- buffer.writeFloat64(this.min);
57556
- buffer.writeFloat64(this.max);
57557
- }
57528
+ bindGeometryFaceNormal(geometryIndices, geometryNormals, this.__bestIndex);
57558
57529
 
57559
- /**
57560
- *
57561
- * @param {BinaryBuffer} buffer
57562
- */
57563
- fromBinaryBuffer(buffer) {
57564
- this.min = buffer.readFloat64();
57565
- this.max = buffer.readFloat64();
57566
- }
57530
+ hit.position.copy(this.__bestPosition);
57531
+ hit.normal.copy(vNormal);
57567
57532
 
57568
- /**
57569
- *
57570
- * @param {NumericInterval} other
57571
- * @returns {boolean}
57572
- */
57573
- equals(other) {
57574
- return this.min === other.min && this.max === other.max;
57533
+ hit.applyMatrix4(this.transform);
57534
+
57535
+ return true;
57536
+ } else {
57537
+ //no hit
57538
+ return false;
57539
+ }
57575
57540
  }
57541
+ }
57542
+
57543
+ /**
57544
+ * Created by Alex on 28/01/2017.
57545
+ */
57576
57546
 
57577
- /**
57578
- *
57579
- * @returns {number}
57580
- */
57581
- hash() {
57582
- let hash = computeHashFloat(this.min);
57547
+ function prepareObject(object) {
57548
+ //turn off automatic matrix re-calculations each frame
57549
+ object.matrixAutoUpdate = false;
57550
+ //disable frustum culling
57551
+ object.frustumCulled = false;
57552
+ }
57583
57553
 
57584
- hash = ((hash << 5) - hash) + computeHashFloat(this.max);
57554
+ /**
57555
+ *
57556
+ * @param {BufferGeometry} [geometry]
57557
+ * @param {Material} [material]
57558
+ * @returns {Mesh}
57559
+ */
57560
+ function createMesh(geometry, material) {
57561
+ const result = new Mesh(geometry, material);
57585
57562
 
57586
- return hash;
57587
- }
57563
+ prepareObject(result);
57588
57564
 
57589
- /**
57590
- * Distance between min and max (= max - min)
57591
- * @returns {number}
57592
- */
57593
- get span() {
57594
- return this.max - this.min;
57595
- }
57565
+ return result;
57596
57566
  }
57597
57567
 
57598
57568
  /**
57599
- * @readonly
57600
- * @type {boolean}
57569
+ *
57570
+ * @param {BufferGeometry} geometry
57571
+ * @param {THREE.Material} material
57572
+ * @returns {THREE.SkinnedMesh}
57601
57573
  */
57602
- NumericInterval.prototype.isNumericInterval = true;
57574
+ function createSkinnedMesh(geometry, material) {
57575
+ const result = new SkinnedMesh(geometry, material);
57576
+
57577
+ prepareObject(result);
57578
+
57579
+ return result;
57580
+ }
57603
57581
 
57604
57582
  /**
57605
- * @readonly
57606
- * @type {NumericInterval}
57583
+ *
57584
+ * @param {Material} material
57607
57585
  */
57608
- NumericInterval.one_one = Object.freeze(new NumericInterval(1, 1));
57586
+ function prepareMaterial(material) {
57587
+
57588
+ //make shadows render from front side, this avoids artifacts due to gaps in geometry that can't be seen from the front
57589
+ material.shadowSide = DoubleSide;
57590
+
57591
+ if (typeof material.envMapIntensity === 'number' && material.envMapIntensity !== 1) {
57592
+ // make material react to environment map in the same way as others
57593
+ material.envMapIntensity = 1;
57594
+ }
57595
+ }
57596
+
57609
57597
  /**
57610
- * @readonly
57611
- * @type {NumericInterval}
57598
+ *
57599
+ * @returns {Group}
57612
57600
  */
57613
- NumericInterval.zero_zero = Object.freeze(new NumericInterval(0, 0));
57601
+ function createGroup() {
57602
+ const result = new Group();
57603
+
57604
+ prepareObject(result);
57605
+
57606
+ return result;
57607
+ }
57608
+
57609
+ var ThreeFactory = {
57610
+ createMesh,
57611
+ createSkinnedMesh,
57612
+ createGroup,
57613
+ prepareMaterial
57614
+ };
57614
57615
 
57615
57616
  /**
57616
57617
  * Created by Alex on 09/11/2014.
57617
57618
  */
57618
57619
 
57620
+
57621
+ const EMPTY_GEOMETRY = new BufferGeometry();
57622
+ const DEFAULT_MATERIAL = new MeshBasicMaterial();
57623
+
57619
57624
  /**
57620
57625
  * terrain tile is a part of a 2d array
57621
57626
  */
@@ -57631,7 +57636,7 @@ class TerrainTile {
57631
57636
  * @type {Material}
57632
57637
  */
57633
57638
  material = null;
57634
- mesh = ThreeFactory.createMesh();
57639
+ mesh = ThreeFactory.createMesh(EMPTY_GEOMETRY, DEFAULT_MATERIAL);
57635
57640
 
57636
57641
 
57637
57642
  /**
@@ -60075,70 +60080,70 @@ class TerrainTileManager {
60075
60080
  const raycastBVHVisitor = new RaycastBVHVisitor();
60076
60081
  const firstRayIntersectionTerrainBVHVisitor = new FirstRayIntersectionTerrainBVHVisitor();
60077
60082
 
60078
- function TerrainPreview() {
60083
+ class TerrainPreview {
60079
60084
  /**
60080
60085
  *
60081
60086
  * @type {String}
60082
60087
  */
60083
- this.url = "";
60088
+ url = "";
60084
60089
 
60085
60090
  /**
60086
60091
  *
60087
60092
  * @type {Vector2}
60088
60093
  */
60089
- this.offset = new Vector2(0, 0);
60094
+ offset = new Vector2(0, 0);
60090
60095
  /**
60091
60096
  *
60092
60097
  * @type {Vector2}
60093
60098
  */
60094
- this.scale = new Vector2(1, 1);
60095
- }
60099
+ scale = new Vector2(1, 1);
60096
60100
 
60097
- /**
60098
- *
60099
- * @param {TerrainPreview} other
60100
- */
60101
- TerrainPreview.prototype.copy = function (other) {
60102
- this.url = other.url;
60103
- this.scale.copy(other.scale);
60104
- this.offset.copy(other.offset);
60105
- };
60101
+ /**
60102
+ *
60103
+ * @param {TerrainPreview} other
60104
+ */
60105
+ copy(other) {
60106
+ this.url = other.url;
60107
+ this.scale.copy(other.scale);
60108
+ this.offset.copy(other.offset);
60109
+ }
60106
60110
 
60107
- TerrainPreview.prototype.toJSON = function () {
60108
- return {
60109
- url: this.url,
60110
- offset: this.offset.toJSON(),
60111
- scale: this.scale.toJSON()
60112
- };
60113
- };
60111
+ toJSON() {
60112
+ return {
60113
+ url: this.url,
60114
+ offset: this.offset.toJSON(),
60115
+ scale: this.scale.toJSON()
60116
+ };
60117
+ }
60114
60118
 
60115
- TerrainPreview.prototype.fromJSON = function (obj) {
60116
- this.url = obj.url;
60117
- this.offset.fromJSON(obj.offset);
60118
- this.scale.fromJSON(obj.scale);
60119
- };
60119
+ fromJSON(obj) {
60120
+ this.url = obj.url;
60121
+ this.offset.fromJSON(obj.offset);
60122
+ this.scale.fromJSON(obj.scale);
60123
+ }
60120
60124
 
60121
- /**
60122
- *
60123
- * @param {BinaryBuffer} buffer
60124
- */
60125
- TerrainPreview.prototype.toBinaryBuffer = function (buffer) {
60126
- buffer.writeUTF8String(this.url);
60125
+ /**
60126
+ *
60127
+ * @param {BinaryBuffer} buffer
60128
+ */
60129
+ toBinaryBuffer(buffer) {
60130
+ buffer.writeUTF8String(this.url);
60127
60131
 
60128
- this.offset.toBinaryBuffer(buffer);
60129
- this.scale.toBinaryBuffer(buffer);
60130
- };
60132
+ this.offset.toBinaryBuffer(buffer);
60133
+ this.scale.toBinaryBuffer(buffer);
60134
+ }
60131
60135
 
60132
- /**
60133
- *
60134
- * @param {BinaryBuffer} buffer
60135
- */
60136
- TerrainPreview.prototype.fromBinaryBuffer = function (buffer) {
60137
- this.url = buffer.readUTF8String();
60136
+ /**
60137
+ *
60138
+ * @param {BinaryBuffer} buffer
60139
+ */
60140
+ fromBinaryBuffer(buffer) {
60141
+ this.url = buffer.readUTF8String();
60138
60142
 
60139
- this.offset.fromBinaryBuffer(buffer);
60140
- this.scale.fromBinaryBuffer(buffer);
60141
- };
60143
+ this.offset.fromBinaryBuffer(buffer);
60144
+ this.scale.fromBinaryBuffer(buffer);
60145
+ }
60146
+ }
60142
60147
 
60143
60148
  /**
60144
60149
  * NOTE, trying to keep to IANA registry: https://www.iana.org/assignments/media-types/media-types.xhtml
@@ -62089,9 +62094,12 @@ class List {
62089
62094
  /**
62090
62095
  * Retrieve element at a given position in the list
62091
62096
  * @param {number} index
62092
- * @returns {T}
62097
+ * @returns {T|undefined}
62093
62098
  */
62094
62099
  get(index) {
62100
+ assert.isNumber(index, 'index');
62101
+ assert.isNonNegativeInteger(index, 'index');
62102
+
62095
62103
  return this.data[index];
62096
62104
  }
62097
62105
 
@@ -62101,6 +62109,9 @@ class List {
62101
62109
  * @param {T} value
62102
62110
  */
62103
62111
  set(index, value) {
62112
+ assert.isNumber(index, 'index');
62113
+ assert.isNonNegativeInteger(index, 'index');
62114
+
62104
62115
  const oldValue = this.data[index];
62105
62116
 
62106
62117
  if (oldValue !== undefined) {
@@ -62221,7 +62232,7 @@ class List {
62221
62232
  /**
62222
62233
  * Replace the data, replacements is performed surgically, meaning that diff is computed and add/remove operations are performed on the set
62223
62234
  * This method is tailored to work well with visualisation as only elements that's missing from the new set is removed, and only elements that are new to are added
62224
- * Conversely, relevant events are dispatched that a visualisation can observe. This results in fewer changes required to the visualisation
62235
+ * Conversely, relevant events are dispatched that can observe. This results in fewer changes required to the visualisation
62225
62236
  * @param {T[]} newOutput
62226
62237
  */
62227
62238
  patch(newOutput) {
@@ -68667,8 +68678,10 @@ class EBBVHLeafProxy {
68667
68678
  unlink() {
68668
68679
  assert.equal(this.is_linked, true, 'not linked');
68669
68680
 
68670
- this.#tree.remove_leaf(this.#node_id);
68671
- this.#tree.release_node(this.#node_id);
68681
+ const node_id = this.#node_id;
68682
+
68683
+ this.#tree.remove_leaf(node_id);
68684
+ this.#tree.release_node(node_id);
68672
68685
 
68673
68686
  this.#node_id = -1;
68674
68687
  this.#tree = null;
@@ -79034,7 +79047,7 @@ class ExplicitBinaryBoundingVolumeHierarchy {
79034
79047
  /**
79035
79048
  *
79036
79049
  * @param {number} id
79037
- * @param {number[]} result
79050
+ * @param {number[]|Float32Array} result
79038
79051
  */
79039
79052
  node_get_aabb(id, result) {
79040
79053
  assert.isNonNegativeInteger(id, 'id');
@@ -80193,18 +80206,6 @@ function bvh_query_leaves_generic(
80193
80206
  return result_cursor - result_offset;
80194
80207
  }
80195
80208
 
80196
- class BVHQuery {
80197
- /**
80198
- *
80199
- * @param {number} node
80200
- * @param {ExplicitBinaryBoundingVolumeHierarchy} tree
80201
- * @returns {boolean}
80202
- */
80203
- evaluate(node, tree) {
80204
- throw new Error('Not Implemented');
80205
- }
80206
- }
80207
-
80208
80209
  /**
80209
80210
  *
80210
80211
  * @param {ArrayLike<number>|number[]|Float32Array} aabb bounding box, order: x0,y0,z0,x1,y1,z1
@@ -80219,21 +80220,33 @@ function aabb3_array_intersects_ray_array(aabb, ray) {
80219
80220
  );
80220
80221
  }
80221
80222
 
80223
+ class BVHQuery {
80224
+ /**
80225
+ *
80226
+ * @param {number} node
80227
+ * @param {ExplicitBinaryBoundingVolumeHierarchy} tree
80228
+ * @returns {boolean}
80229
+ */
80230
+ evaluate(node, tree) {
80231
+ throw new Error('Not Implemented');
80232
+ }
80233
+ }
80234
+
80222
80235
  const scratch_aabb = [];
80223
80236
 
80224
80237
  class BVHQueryIntersectsRay extends BVHQuery {
80225
- constructor() {
80226
- super();
80227
-
80228
- this.ray = [];
80229
- }
80238
+ /**
80239
+ *
80240
+ * @type {number[]}
80241
+ */
80242
+ ray = [];
80230
80243
 
80231
80244
  /**
80232
80245
  *
80233
80246
  * @param {number[]|ArrayLike<number>} ray
80234
80247
  * @returns {BVHQueryIntersectsRay}
80235
80248
  */
80236
- static from(ray){
80249
+ static from(ray) {
80237
80250
  const r = new BVHQueryIntersectsRay();
80238
80251
 
80239
80252
  r.ray = ray;
@@ -110003,7 +110016,7 @@ class WebEnginePlatform extends EnginePlatform {
110003
110016
  class Tag {
110004
110017
  /**
110005
110018
  * @private
110006
- * @type {String[]}
110019
+ * @type {string[]}
110007
110020
  */
110008
110021
  values = [];
110009
110022
 
@@ -110185,41 +110198,31 @@ class Tag {
110185
110198
  * @return {boolean}
110186
110199
  */
110187
110200
  equals(other) {
110188
-
110189
- const s0 = this.values;
110190
-
110191
- const s1 = other.values;
110192
-
110193
- const n0 = s0.length;
110194
- const n1 = s1.length;
110195
-
110196
- if (n0 !== n1) {
110197
- //wrong length
110198
- return false;
110199
- }
110200
-
110201
- for (let i = 0; i < n0; i++) {
110202
- const v0 = s0[i];
110203
- const v1 = s1[i];
110204
-
110205
- if (v0 !== v1) {
110206
- return false;
110207
- }
110208
- }
110209
-
110210
- return true;
110201
+ return isArrayEqualStrict(this.values, other.values);
110211
110202
  }
110212
110203
 
110213
110204
  toJSON() {
110214
110205
  return this.values;
110215
110206
  }
110216
110207
 
110208
+ /**
110209
+ *
110210
+ * @param {string[]|string} json
110211
+ */
110217
110212
  fromJSON(json) {
110213
+
110214
+ this.clear();
110215
+
110218
110216
  if (typeof json === "string") {
110219
- this.clear();
110220
110217
  this.add(json);
110221
- } else if (Array.isArray(json)) {
110222
- this.values = json;
110218
+ } else {
110219
+ assert.isArray(json, 'json');
110220
+
110221
+ const n = json.length;
110222
+
110223
+ for (let i = 0; i < n; i++) {
110224
+ this.add(json[i]);
110225
+ }
110223
110226
  }
110224
110227
  }
110225
110228