@woosh/meep-engine 2.62.0 → 2.63.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.
@@ -55588,79 +55588,314 @@ ObservedValue.prototype.fromJSON = function (value) {
55588
55588
  this.set(value);
55589
55589
  };
55590
55590
 
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
55591
+ /**
55592
+ * Common utilities
55593
+ * @module glMatrix
55594
+ */
55595
+ var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
55596
+ if (!Math.hypot) Math.hypot = function () {
55597
+ var y = 0,
55598
+ i = arguments.length;
55599
+
55600
+ while (i--) {
55601
+ y += arguments[i] * arguments[i];
55602
+ }
55603
+
55604
+ return Math.sqrt(y);
55662
55605
  };
55663
55606
 
55607
+ /**
55608
+ * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
55609
+ * @module mat4
55610
+ */
55611
+
55612
+ /**
55613
+ * Creates a new identity mat4
55614
+ *
55615
+ * @returns {mat4} a new 4x4 matrix
55616
+ */
55617
+
55618
+ function create$1() {
55619
+ var out = new ARRAY_TYPE(16);
55620
+
55621
+ if (ARRAY_TYPE != Float32Array) {
55622
+ out[1] = 0;
55623
+ out[2] = 0;
55624
+ out[3] = 0;
55625
+ out[4] = 0;
55626
+ out[6] = 0;
55627
+ out[7] = 0;
55628
+ out[8] = 0;
55629
+ out[9] = 0;
55630
+ out[11] = 0;
55631
+ out[12] = 0;
55632
+ out[13] = 0;
55633
+ out[14] = 0;
55634
+ }
55635
+
55636
+ out[0] = 1;
55637
+ out[5] = 1;
55638
+ out[10] = 1;
55639
+ out[15] = 1;
55640
+ return out;
55641
+ }
55642
+ /**
55643
+ * Copy the values from one mat4 to another
55644
+ *
55645
+ * @param {mat4} out the receiving matrix
55646
+ * @param {ReadonlyMat4} a the source matrix
55647
+ * @returns {mat4} out
55648
+ */
55649
+
55650
+ function copy(out, a) {
55651
+ out[0] = a[0];
55652
+ out[1] = a[1];
55653
+ out[2] = a[2];
55654
+ out[3] = a[3];
55655
+ out[4] = a[4];
55656
+ out[5] = a[5];
55657
+ out[6] = a[6];
55658
+ out[7] = a[7];
55659
+ out[8] = a[8];
55660
+ out[9] = a[9];
55661
+ out[10] = a[10];
55662
+ out[11] = a[11];
55663
+ out[12] = a[12];
55664
+ out[13] = a[13];
55665
+ out[14] = a[14];
55666
+ out[15] = a[15];
55667
+ return out;
55668
+ }
55669
+ /**
55670
+ * Inverts a mat4
55671
+ *
55672
+ * @param {mat4} out the receiving matrix
55673
+ * @param {ReadonlyMat4} a the source matrix
55674
+ * @returns {mat4} out
55675
+ */
55676
+
55677
+ function invert(out, a) {
55678
+ var a00 = a[0],
55679
+ a01 = a[1],
55680
+ a02 = a[2],
55681
+ a03 = a[3];
55682
+ var a10 = a[4],
55683
+ a11 = a[5],
55684
+ a12 = a[6],
55685
+ a13 = a[7];
55686
+ var a20 = a[8],
55687
+ a21 = a[9],
55688
+ a22 = a[10],
55689
+ a23 = a[11];
55690
+ var a30 = a[12],
55691
+ a31 = a[13],
55692
+ a32 = a[14],
55693
+ a33 = a[15];
55694
+ var b00 = a00 * a11 - a01 * a10;
55695
+ var b01 = a00 * a12 - a02 * a10;
55696
+ var b02 = a00 * a13 - a03 * a10;
55697
+ var b03 = a01 * a12 - a02 * a11;
55698
+ var b04 = a01 * a13 - a03 * a11;
55699
+ var b05 = a02 * a13 - a03 * a12;
55700
+ var b06 = a20 * a31 - a21 * a30;
55701
+ var b07 = a20 * a32 - a22 * a30;
55702
+ var b08 = a20 * a33 - a23 * a30;
55703
+ var b09 = a21 * a32 - a22 * a31;
55704
+ var b10 = a21 * a33 - a23 * a31;
55705
+ var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
55706
+
55707
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
55708
+
55709
+ if (!det) {
55710
+ return null;
55711
+ }
55712
+
55713
+ det = 1.0 / det;
55714
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
55715
+ out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
55716
+ out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
55717
+ out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
55718
+ out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
55719
+ out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
55720
+ out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
55721
+ out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
55722
+ out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
55723
+ out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
55724
+ out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
55725
+ out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
55726
+ out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
55727
+ out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
55728
+ out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
55729
+ out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
55730
+ return out;
55731
+ }
55732
+ /**
55733
+ * Multiplies two mat4s
55734
+ *
55735
+ * @param {mat4} out the receiving matrix
55736
+ * @param {ReadonlyMat4} a the first operand
55737
+ * @param {ReadonlyMat4} b the second operand
55738
+ * @returns {mat4} out
55739
+ */
55740
+
55741
+ function multiply(out, a, b) {
55742
+ var a00 = a[0],
55743
+ a01 = a[1],
55744
+ a02 = a[2],
55745
+ a03 = a[3];
55746
+ var a10 = a[4],
55747
+ a11 = a[5],
55748
+ a12 = a[6],
55749
+ a13 = a[7];
55750
+ var a20 = a[8],
55751
+ a21 = a[9],
55752
+ a22 = a[10],
55753
+ a23 = a[11];
55754
+ var a30 = a[12],
55755
+ a31 = a[13],
55756
+ a32 = a[14],
55757
+ a33 = a[15]; // Cache only the current line of the second matrix
55758
+
55759
+ var b0 = b[0],
55760
+ b1 = b[1],
55761
+ b2 = b[2],
55762
+ b3 = b[3];
55763
+ out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55764
+ out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55765
+ out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55766
+ out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55767
+ b0 = b[4];
55768
+ b1 = b[5];
55769
+ b2 = b[6];
55770
+ b3 = b[7];
55771
+ out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55772
+ out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55773
+ out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55774
+ out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55775
+ b0 = b[8];
55776
+ b1 = b[9];
55777
+ b2 = b[10];
55778
+ b3 = b[11];
55779
+ out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55780
+ out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55781
+ out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55782
+ out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55783
+ b0 = b[12];
55784
+ b1 = b[13];
55785
+ b2 = b[14];
55786
+ b3 = b[15];
55787
+ out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
55788
+ out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
55789
+ out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
55790
+ out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
55791
+ return out;
55792
+ }
55793
+
55794
+ /**
55795
+ * 3 Dimensional Vector
55796
+ * @module vec3
55797
+ */
55798
+
55799
+ /**
55800
+ * Creates a new, empty vec3
55801
+ *
55802
+ * @returns {vec3} a new 3D vector
55803
+ */
55804
+
55805
+ function create() {
55806
+ var out = new ARRAY_TYPE(3);
55807
+
55808
+ if (ARRAY_TYPE != Float32Array) {
55809
+ out[0] = 0;
55810
+ out[1] = 0;
55811
+ out[2] = 0;
55812
+ }
55813
+
55814
+ return out;
55815
+ }
55816
+ /**
55817
+ * Creates a new vec3 initialized with the given values
55818
+ *
55819
+ * @param {Number} x X component
55820
+ * @param {Number} y Y component
55821
+ * @param {Number} z Z component
55822
+ * @returns {vec3} a new 3D vector
55823
+ */
55824
+
55825
+ function fromValues(x, y, z) {
55826
+ var out = new ARRAY_TYPE(3);
55827
+ out[0] = x;
55828
+ out[1] = y;
55829
+ out[2] = z;
55830
+ return out;
55831
+ }
55832
+ /**
55833
+ * Transforms the vec3 with a mat4.
55834
+ * 4th vector component is implicitly '1'
55835
+ *
55836
+ * @param {vec3} out the receiving vector
55837
+ * @param {ReadonlyVec3} a the vector to transform
55838
+ * @param {ReadonlyMat4} m matrix to transform with
55839
+ * @returns {vec3} out
55840
+ */
55841
+
55842
+ function transformMat4(out, a, m) {
55843
+ var x = a[0],
55844
+ y = a[1],
55845
+ z = a[2];
55846
+ var w = m[3] * x + m[7] * y + m[11] * z + m[15];
55847
+ w = w || 1.0;
55848
+ out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
55849
+ out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
55850
+ out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
55851
+ return out;
55852
+ }
55853
+ /**
55854
+ * Perform some operation over an array of vec3s.
55855
+ *
55856
+ * @param {Array} a the array of vectors to iterate over
55857
+ * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
55858
+ * @param {Number} offset Number of elements to skip at the beginning of the array
55859
+ * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
55860
+ * @param {Function} fn Function to call for each vector in the array
55861
+ * @param {Object} [arg] additional argument to pass to fn
55862
+ * @returns {Array} a
55863
+ * @function
55864
+ */
55865
+
55866
+ (function () {
55867
+ var vec = create();
55868
+ return function (a, stride, offset, count, fn, arg) {
55869
+ var i, l;
55870
+
55871
+ if (!stride) {
55872
+ stride = 3;
55873
+ }
55874
+
55875
+ if (!offset) {
55876
+ offset = 0;
55877
+ }
55878
+
55879
+ if (count) {
55880
+ l = Math.min(count * stride + offset, a.length);
55881
+ } else {
55882
+ l = a.length;
55883
+ }
55884
+
55885
+ for (i = offset; i < l; i += stride) {
55886
+ vec[0] = a[i];
55887
+ vec[1] = a[i + 1];
55888
+ vec[2] = a[i + 2];
55889
+ fn(vec, vec, arg);
55890
+ a[i] = vec[0];
55891
+ a[i + 1] = vec[1];
55892
+ a[i + 2] = vec[2];
55893
+ }
55894
+
55895
+ return a;
55896
+ };
55897
+ })();
55898
+
55664
55899
  class IndexedBinaryBVHVisitor {
55665
55900
  /**
55666
55901
  *
@@ -56374,6 +56609,445 @@ class SurfacePoint3 {
56374
56609
  }
56375
56610
  }
56376
56611
 
56612
+ /**
56613
+ * Compute fraction of linear interpolation
56614
+ * @param {number} a
56615
+ * @param {number} b
56616
+ * @param {number} value
56617
+ * @returns {number} fraction
56618
+ */
56619
+ function inverseLerp(a, b, value) {
56620
+ const range = b - a;
56621
+ const scaledValue = value - a;
56622
+
56623
+ if (range === 0) {
56624
+
56625
+ // avoid division by zero error
56626
+
56627
+ // this is arbitrary output, as actual answer is undefined
56628
+
56629
+ return 0;
56630
+ }
56631
+
56632
+ return scaledValue / range;
56633
+ }
56634
+
56635
+ /**
56636
+ *
56637
+ * @param {number} min
56638
+ * @param {number} max
56639
+ * @constructor
56640
+ */
56641
+
56642
+ class NumericInterval {
56643
+ /**
56644
+ *
56645
+ * @param {number} [min=-Infinity]
56646
+ * @param {number} [max=Infinity]
56647
+ * @constructor
56648
+ */
56649
+ constructor(
56650
+ min = Number.NEGATIVE_INFINITY,
56651
+ max = Number.POSITIVE_INFINITY
56652
+ ) {
56653
+ assert.isNumber(min, 'min');
56654
+ assert.isNumber(max, 'max');
56655
+
56656
+ assert.ok(max >= min, `max=${max} must be >= than min=${min}`);
56657
+
56658
+ /**
56659
+ *
56660
+ * @type {number}
56661
+ */
56662
+ this.min = min;
56663
+ /**
56664
+ *
56665
+ * @type {number}
56666
+ */
56667
+ this.max = max;
56668
+
56669
+ this.onChanged = new Signal();
56670
+ }
56671
+
56672
+
56673
+ /**
56674
+ *
56675
+ * @param {number} min
56676
+ * @param {number} max
56677
+ */
56678
+ set(min, max) {
56679
+ assert.isNumber(min, 'min');
56680
+ assert.isNumber(max, 'max');
56681
+
56682
+ assert.notNaN(min, 'min');
56683
+ assert.notNaN(max, 'max');
56684
+
56685
+ assert.greaterThanOrEqual(max, min, `max [${max}] must be >= than min[${min}]`);
56686
+
56687
+ const oldMin = this.min;
56688
+ const oldMax = this.max;
56689
+
56690
+ if (min !== oldMin || max !== oldMax) {
56691
+ this.min = min;
56692
+ this.max = max;
56693
+
56694
+ if (this.onChanged.hasHandlers()) {
56695
+ this.onChanged.send4(min, max, oldMin, oldMax);
56696
+ }
56697
+ }
56698
+ }
56699
+
56700
+ /**
56701
+ *
56702
+ * @param {NumericInterval} other
56703
+ */
56704
+ copy(other) {
56705
+ this.set(other.min, other.max);
56706
+ }
56707
+
56708
+ /**
56709
+ *
56710
+ * @param {number} value
56711
+ */
56712
+ multiplyScalar(value) {
56713
+ const v0 = this.min * value;
56714
+ const v1 = this.max * value;
56715
+
56716
+ if (v0 > v1) {
56717
+ //probably negative scale
56718
+ this.set(v1, v0);
56719
+ } else {
56720
+
56721
+ this.set(v0, v1);
56722
+ }
56723
+ }
56724
+
56725
+ /**
56726
+ * Performs inverse linear interpolation on a given input
56727
+ * @param {number} v
56728
+ * @returns {number}
56729
+ */
56730
+ normalizeValue(v) {
56731
+ return inverseLerp(this.min, this.max, v);
56732
+ }
56733
+
56734
+ /**
56735
+ * Both min and max are exactly 0
56736
+ * @returns {boolean}
56737
+ */
56738
+ isZero() {
56739
+ return this.min === 0 && this.max === 0;
56740
+ }
56741
+
56742
+ /**
56743
+ * Whether min and max are the same
56744
+ * In other words if span is 0
56745
+ * @returns {boolean}
56746
+ */
56747
+ isExact() {
56748
+ return this.min === this.max;
56749
+ }
56750
+
56751
+ /**
56752
+ *
56753
+ * @returns {number}
56754
+ */
56755
+ computeAverage() {
56756
+ return (this.min + this.max) / 2;
56757
+ }
56758
+
56759
+ /**
56760
+ *
56761
+ * @param {function} random Random number generator function, must return values between 0 and 1
56762
+ * @returns {number}
56763
+ */
56764
+ sampleRandom(random) {
56765
+ assert.equal(typeof random, 'function', `random must be a function, instead was ${typeof random}`);
56766
+
56767
+ return this.min + random() * (this.max - this.min);
56768
+ }
56769
+
56770
+ fromJSON(json) {
56771
+ this.set(json.min, json.max);
56772
+ }
56773
+
56774
+ toJSON() {
56775
+ return {
56776
+ min: this.min,
56777
+ max: this.max
56778
+ };
56779
+ }
56780
+
56781
+ /**
56782
+ *
56783
+ * @param {BinaryBuffer} buffer
56784
+ */
56785
+ toBinaryBuffer(buffer) {
56786
+ buffer.writeFloat64(this.min);
56787
+ buffer.writeFloat64(this.max);
56788
+ }
56789
+
56790
+ /**
56791
+ *
56792
+ * @param {BinaryBuffer} buffer
56793
+ */
56794
+ fromBinaryBuffer(buffer) {
56795
+ this.min = buffer.readFloat64();
56796
+ this.max = buffer.readFloat64();
56797
+ }
56798
+
56799
+ /**
56800
+ *
56801
+ * @param {NumericInterval} other
56802
+ * @returns {boolean}
56803
+ */
56804
+ equals(other) {
56805
+ return this.min === other.min && this.max === other.max;
56806
+ }
56807
+
56808
+ /**
56809
+ *
56810
+ * @returns {number}
56811
+ */
56812
+ hash() {
56813
+ let hash = computeHashFloat(this.min);
56814
+
56815
+ hash = ((hash << 5) - hash) + computeHashFloat(this.max);
56816
+
56817
+ return hash;
56818
+ }
56819
+
56820
+ /**
56821
+ * Distance between min and max (= max - min)
56822
+ * @returns {number}
56823
+ */
56824
+ get span() {
56825
+ return this.max - this.min;
56826
+ }
56827
+ }
56828
+
56829
+ /**
56830
+ * @readonly
56831
+ * @type {boolean}
56832
+ */
56833
+ NumericInterval.prototype.isNumericInterval = true;
56834
+
56835
+ /**
56836
+ * @readonly
56837
+ * @type {NumericInterval}
56838
+ */
56839
+ NumericInterval.one_one = Object.freeze(new NumericInterval(1, 1));
56840
+ /**
56841
+ * @readonly
56842
+ * @type {NumericInterval}
56843
+ */
56844
+ NumericInterval.zero_zero = Object.freeze(new NumericInterval(0, 0));
56845
+
56846
+ class ObservedInteger extends Number {
56847
+ /**
56848
+ * @readonly
56849
+ * @type {Signal}
56850
+ */
56851
+ onChanged = new Signal();
56852
+
56853
+ /**
56854
+ *
56855
+ * @param {Number} [value]
56856
+ * @constructor
56857
+ */
56858
+ constructor(value = 0) {
56859
+ super();
56860
+
56861
+ assert.isNumber(value, 'value');
56862
+ assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
56863
+
56864
+
56865
+ /**
56866
+ *
56867
+ * @type {Number}
56868
+ * @private
56869
+ */
56870
+ this.__value = value;
56871
+
56872
+ }
56873
+
56874
+ /**
56875
+ *
56876
+ * @returns {Number}
56877
+ */
56878
+ valueOf() {
56879
+ return this.getValue();
56880
+ }
56881
+
56882
+ toString() {
56883
+ return this.getValue().toString();
56884
+ }
56885
+
56886
+ /**
56887
+ *
56888
+ * @param {Number} value
56889
+ * @returns {ObservedInteger}
56890
+ */
56891
+ set(value) {
56892
+ assert.isNumber(value, 'value');
56893
+ assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
56894
+
56895
+ const oldValue = this.__value;
56896
+ if (oldValue !== value) {
56897
+ this.__value = value;
56898
+ this.onChanged.send2(value, oldValue);
56899
+ }
56900
+
56901
+ return this;
56902
+ }
56903
+
56904
+ /**
56905
+ * Set value without dispatching change notification
56906
+ * @param {number} value
56907
+ */
56908
+ setSilent(value) {
56909
+ assert.isNumber(value, 'value');
56910
+ assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
56911
+
56912
+ this.__value = value;
56913
+ }
56914
+
56915
+ /**
56916
+ *
56917
+ * @return {boolean}
56918
+ */
56919
+ isZero() {
56920
+ return this.getValue() === 0;
56921
+ }
56922
+
56923
+ /**
56924
+ *
56925
+ * @param {ObservedInteger} other
56926
+ */
56927
+ subtract(other) {
56928
+ this._add(-other.getValue());
56929
+ }
56930
+
56931
+ /**
56932
+ *
56933
+ * @param {number} value
56934
+ */
56935
+ _subtract(value) {
56936
+ this.set(this.getValue() - value);
56937
+ }
56938
+
56939
+ /**
56940
+ *
56941
+ * @param {ObservedInteger} other
56942
+ */
56943
+ add(other) {
56944
+ this._add(other.getValue());
56945
+ }
56946
+
56947
+ /**
56948
+ *
56949
+ * @param {number} value
56950
+ */
56951
+ _add(value) {
56952
+ this.set(this.getValue() + value);
56953
+ }
56954
+
56955
+ /**
56956
+ * Increment the stored value by 1, same as adding 1
56957
+ */
56958
+ increment() {
56959
+ this.set(this.getValue() + 1);
56960
+ }
56961
+
56962
+ /**
56963
+ * Decrement the stored value by 1, same as subtracting 1
56964
+ */
56965
+ decrement() {
56966
+ this.set(this.getValue() - 1);
56967
+ }
56968
+
56969
+ /**
56970
+ *
56971
+ * @returns {Number}
56972
+ */
56973
+ getValue() {
56974
+ return this.__value;
56975
+ }
56976
+
56977
+ /**
56978
+ *
56979
+ * @param {ObservedInteger} other
56980
+ */
56981
+ copy(other) {
56982
+ this.set(other.__value);
56983
+ }
56984
+
56985
+ /**
56986
+ *
56987
+ * @param {ObservedInteger} other
56988
+ * @returns {boolean}
56989
+ */
56990
+ equals(other) {
56991
+ return this.__value === other.__value;
56992
+ }
56993
+
56994
+ /**
56995
+ *
56996
+ * @returns {Number}
56997
+ */
56998
+ hash() {
56999
+ return this.__value;
57000
+ }
57001
+
57002
+ toJSON() {
57003
+ return this.__value;
57004
+ }
57005
+
57006
+ fromJSON(obj) {
57007
+ this.set(obj);
57008
+ }
57009
+
57010
+ /**
57011
+ *
57012
+ * @param {BinaryBuffer} buffer
57013
+ */
57014
+ toBinaryBuffer(buffer) {
57015
+ const v = this.__value;
57016
+
57017
+ if (v === Infinity) {
57018
+ buffer.writeInt32(2147483647);
57019
+ } else if (v === -Infinity) {
57020
+ buffer.writeInt32(-2147483648);
57021
+ } else {
57022
+ //TODO it's possible to write encoded Infinity values by accident
57023
+ buffer.writeInt32(v);
57024
+ }
57025
+ }
57026
+
57027
+ /**
57028
+ *
57029
+ * @param {BinaryBuffer} buffer
57030
+ */
57031
+ fromBinaryBuffer(buffer) {
57032
+ const value = buffer.readInt32();
57033
+
57034
+ if (value === 2147483647) {
57035
+ this.set(Infinity);
57036
+ } else if (value === -2147483648) {
57037
+ this.set(-Infinity);
57038
+ } else {
57039
+ this.set(value);
57040
+ }
57041
+ }
57042
+ }
57043
+
57044
+
57045
+ /**
57046
+ * @readonly
57047
+ * @type {boolean}
57048
+ */
57049
+ ObservedInteger.prototype.isObservedInteger = true;
57050
+
56377
57051
  /**
56378
57052
  * NOTE: adapted from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
56379
57053
  * @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 +57297,24 @@ function ray3_array_apply_matrix4(output, output_offset, input, input_offset, m4
56623
57297
  return true;
56624
57298
  }
56625
57299
 
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;
57300
+ /**
57301
+ *
57302
+ * @param {number[]|ArrayLike<number>|Float32Array} output
57303
+ * @param {number} origin_x
57304
+ * @param {number} origin_y
57305
+ * @param {number} origin_z
57306
+ * @param {number} direction_x
57307
+ * @param {number} direction_y
57308
+ * @param {number} direction_z
57309
+ */
57310
+ function ray3_array_compose(output, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z) {
57311
+ output[0] = origin_x;
57312
+ output[1] = origin_y;
57313
+ output[2] = origin_z;
57314
+
57315
+ output[3] = direction_x;
57316
+ output[4] = direction_y;
57317
+ output[5] = direction_z;
56952
57318
  }
56953
57319
 
56954
57320
  const hit$1 = new Vector3();
@@ -56965,657 +57331,295 @@ const m4_tmp = [];
56965
57331
  * @param {number[]|Uint8Array|Uint16Array|Uint32Array} indices
56966
57332
  * @param {number[]|Float32Array|Float64Array} vertices
56967
57333
  * @param {number} index
56968
- */
56969
- function bindGeometryFace(indices, vertices, index) {
56970
- const index3 = index * 3;
56971
-
56972
- assert.lessThan(index3, indices.length, 'index underflow');
56973
-
56974
- const a = indices[index3] * 3;
56975
- const b = indices[index3 + 1] * 3;
56976
- const c = indices[index3 + 2] * 3;
56977
-
56978
- vA.set(vertices[a], vertices[a + 1], vertices[a + 2]);
56979
- vB.set(vertices[b], vertices[b + 1], vertices[b + 2]);
56980
- vC.set(vertices[c], vertices[c + 1], vertices[c + 2]);
56981
- }
56982
-
56983
- const vNormal = new Vector3$1();
56984
-
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
- }
57334
+ */
57335
+ function bindGeometryFace(indices, vertices, index) {
57336
+ const index3 = index * 3;
57323
57337
 
57324
- /**
57325
- *
57326
- * @returns {Number}
57327
- */
57328
- hash() {
57329
- return this.__value;
57330
- }
57338
+ assert.lessThan(index3, indices.length, 'index underflow');
57331
57339
 
57332
- toJSON() {
57333
- return this.__value;
57334
- }
57340
+ const a = indices[index3] * 3;
57341
+ const b = indices[index3 + 1] * 3;
57342
+ const c = indices[index3 + 2] * 3;
57335
57343
 
57336
- fromJSON(obj) {
57337
- this.set(obj);
57338
- }
57344
+ vA.set(vertices[a], vertices[a + 1], vertices[a + 2]);
57345
+ vB.set(vertices[b], vertices[b + 1], vertices[b + 2]);
57346
+ vC.set(vertices[c], vertices[c + 1], vertices[c + 2]);
57347
+ }
57339
57348
 
57340
- /**
57341
- *
57342
- * @param {BinaryBuffer} buffer
57343
- */
57344
- toBinaryBuffer(buffer) {
57345
- const v = this.__value;
57349
+ const vNormal = new Vector3$1();
57346
57350
 
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
- }
57351
+ function bindGeometryFaceNormal(indices, normals, index) {
57356
57352
 
57357
- /**
57358
- *
57359
- * @param {BinaryBuffer} buffer
57360
- */
57361
- fromBinaryBuffer(buffer) {
57362
- const value = buffer.readInt32();
57353
+ const index3 = index * 3;
57363
57354
 
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
- }
57355
+ const a = indices[index3] * 3;
57356
+ const b = indices[index3 + 1] * 3;
57357
+ const c = indices[index3 + 2] * 3;
57373
57358
 
57359
+ //read vertex normals
57360
+ const naX = normals[a];
57361
+ const naY = normals[a + 1];
57362
+ const naZ = normals[a + 2];
57374
57363
 
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;
57364
+ const nbX = normals[b];
57365
+ const nbY = normals[b + 1];
57366
+ const nbZ = normals[b + 2];
57391
57367
 
57392
- if (range === 0) {
57368
+ const ncX = normals[c];
57369
+ const ncY = normals[c + 1];
57370
+ const ncZ = normals[c + 2];
57393
57371
 
57394
- // avoid division by zero error
57372
+ //add normals
57373
+ const nsX = (naX + nbX + ncX);
57374
+ const nsY = (naY + nbY + ncY);
57375
+ const nsZ = (naZ + nbZ + ncZ);
57395
57376
 
57396
- // this is arbitrary output, as actual answer is undefined
57377
+ //normalize
57378
+ const l = v3_length(nsX, nsY, nsZ);
57379
+ const m = 1 / l;
57397
57380
 
57398
- return 0;
57399
- }
57381
+ const nx = nsX * m;
57382
+ const ny = nsY * m;
57383
+ const nz = nsZ * m;
57400
57384
 
57401
- return scaledValue / range;
57402
- }
57403
-
57404
- /**
57405
- *
57406
- * @param {number} min
57407
- * @param {number} max
57408
- * @constructor
57409
- */
57385
+ vNormal.set(nx, ny, nz);
57386
+ }
57410
57387
 
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
57388
 
57425
- assert.ok(max >= min, `max=${max} must be >= than min=${min}`);
57389
+ function extractFaceIndexFromLeaf_default(leaf) {
57390
+ return leaf.object;
57391
+ }
57426
57392
 
57393
+ class BVHGeometryRaycaster {
57394
+ constructor() {
57427
57395
  /**
57428
57396
  *
57429
- * @type {number}
57397
+ * @type {BufferGeometry|null}
57430
57398
  */
57431
- this.min = min;
57399
+ this.geometry = null;
57400
+ /**
57401
+ *
57402
+ * @type {BinaryNode|null}
57403
+ */
57404
+ this.bvh = null;
57405
+
57406
+ /**
57407
+ *
57408
+ * @type {Vector2|null}
57409
+ */
57410
+ this.position = null;
57411
+ /**
57412
+ *
57413
+ * @type {Vector2|null}
57414
+ */
57415
+ this.scale = null;
57432
57416
  /**
57433
57417
  *
57434
57418
  * @type {number}
57435
57419
  */
57436
- this.max = max;
57420
+ this.resolution = 0;
57437
57421
 
57438
- this.onChanged = new Signal();
57439
- }
57422
+ /**
57423
+ *
57424
+ * @type {Vector2|null}
57425
+ */
57426
+ this.size = null;
57440
57427
 
57428
+ this.__bestDistance = 0;
57429
+ this.__bestPosition = new Vector3$1();
57430
+ this.__bestIndex = 0;
57431
+
57432
+
57433
+ this.origin = new Vector3$1();
57434
+ this.direction = new Vector3$1();
57435
+
57436
+ /**
57437
+ *
57438
+ * @type {Float32Array}
57439
+ */
57440
+ this.transform = new Float32Array(16);
57441
+
57442
+ array_copy(MATRIX_4_IDENTITY, 0, this.transform, 0, 16);
57443
+
57444
+ this.extractFaceIndexFromLeaf = extractFaceIndexFromLeaf_default;
57445
+ }
57441
57446
 
57442
57447
  /**
57443
57448
  *
57444
- * @param {number} min
57445
- * @param {number} max
57449
+ * @param {*} leaf
57446
57450
  */
57447
- set(min, max) {
57448
- assert.isNumber(min, 'min');
57449
- assert.isNumber(max, 'max');
57451
+ visitLeafIntersection(leaf) {
57450
57452
 
57451
- assert.notNaN(min, 'min');
57452
- assert.notNaN(max, 'max');
57453
+ const geometry = this.geometry;
57453
57454
 
57454
- assert.greaterThanOrEqual(max, min, `max [${max}] must be >= than min[${min}]`);
57455
+ const geometryIndices = geometry.getIndex().array;
57456
+ const geometryVertices = geometry.getAttribute('position').array;
57455
57457
 
57456
- const oldMin = this.min;
57457
- const oldMax = this.max;
57458
+ const extractFaceIndexFromLeaf = this.extractFaceIndexFromLeaf;
57458
57459
 
57459
- if (min !== oldMin || max !== oldMax) {
57460
- this.min = min;
57461
- this.max = max;
57460
+ const index = extractFaceIndexFromLeaf(leaf);
57462
57461
 
57463
- if (this.onChanged.hasHandlers()) {
57464
- this.onChanged.send4(min, max, oldMin, oldMax);
57462
+ bindGeometryFace(geometryIndices, geometryVertices, index);
57463
+
57464
+ const hitFound = rayTriangleIntersection(hit$1, this.origin, this.direction, vA, vB, vC);
57465
+
57466
+ if (hitFound) {
57467
+
57468
+ const d = this.origin.distanceSqrTo(hit$1);
57469
+ if (d < this.__bestDistance) {
57470
+ this.__bestDistance = d;
57471
+ this.__bestPosition.copy(hit$1);
57472
+ this.__bestIndex = index;
57465
57473
  }
57474
+
57466
57475
  }
57467
57476
  }
57468
57477
 
57469
57478
  /**
57470
57479
  *
57471
- * @param {NumericInterval} other
57480
+ * @param {SurfacePoint3} hit
57481
+ * @param {number} originX
57482
+ * @param {number} originY
57483
+ * @param {number} originZ
57484
+ * @param {number} directionX
57485
+ * @param {number} directionY
57486
+ * @param {number} directionZ
57487
+ * @returns {boolean}
57472
57488
  */
57473
- copy(other) {
57474
- this.set(other.min, other.max);
57475
- }
57489
+ raycast(
57490
+ hit,
57491
+ originX, originY, originZ,
57492
+ directionX, directionY, directionZ
57493
+ ) {
57476
57494
 
57477
- /**
57478
- *
57479
- * @param {number} value
57480
- */
57481
- multiplyScalar(value) {
57482
- const v0 = this.min * value;
57483
- const v1 = this.max * value;
57495
+ invert(m4_tmp, this.transform);
57484
57496
 
57485
- if (v0 > v1) {
57486
- //probably negative scale
57487
- this.set(v1, v0);
57488
- } else {
57497
+ ray3_array_compose(
57498
+ ray_tmp,
57499
+ originX, originY, originZ,
57500
+ directionX, directionY, directionZ
57501
+ );
57489
57502
 
57490
- this.set(v0, v1);
57491
- }
57492
- }
57503
+ ray3_array_apply_matrix4(ray_tmp, 0,ray_tmp,0, m4_tmp);
57493
57504
 
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
- }
57505
+ const _originX = ray_tmp[0];
57506
+ const _originY = ray_tmp[1];
57507
+ const _originZ = ray_tmp[2];
57502
57508
 
57503
- /**
57504
- * Both min and max are exactly 0
57505
- * @returns {boolean}
57506
- */
57507
- isZero() {
57508
- return this.min === 0 && this.max === 0;
57509
- }
57509
+ const _directionX = ray_tmp[3];
57510
+ const _directionY = ray_tmp[4];
57511
+ const _directionZ = ray_tmp[5];
57510
57512
 
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
- }
57513
+ this.origin.set(_originX, _originY, _originZ);
57514
+ this.direction.set(_directionX, _directionY, _directionZ);
57519
57515
 
57520
- /**
57521
- *
57522
- * @returns {number}
57523
- */
57524
- computeAverage() {
57525
- return (this.min + this.max) / 2;
57526
- }
57516
+ this.__bestDistance = Number.POSITIVE_INFINITY;
57527
57517
 
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}`);
57518
+ this.bvh.traverseRayLeafIntersections(_originX, _originY, _originZ, _directionX, _directionY, _directionZ, this.visitLeafIntersection, this);
57535
57519
 
57536
- return this.min + random() * (this.max - this.min);
57537
- }
57520
+ if (this.__bestDistance !== Number.POSITIVE_INFINITY) {
57538
57521
 
57539
- fromJSON(json) {
57540
- this.set(json.min, json.max);
57541
- }
57522
+ const geometry = this.geometry;
57542
57523
 
57543
- toJSON() {
57544
- return {
57545
- min: this.min,
57546
- max: this.max
57547
- };
57548
- }
57524
+ const geometryIndices = geometry.getIndex().array;
57525
+ const geometryNormals = geometry.getAttribute('normal').array;
57549
57526
 
57550
- /**
57551
- *
57552
- * @param {BinaryBuffer} buffer
57553
- */
57554
- toBinaryBuffer(buffer) {
57555
- buffer.writeFloat64(this.min);
57556
- buffer.writeFloat64(this.max);
57557
- }
57527
+ bindGeometryFaceNormal(geometryIndices, geometryNormals, this.__bestIndex);
57558
57528
 
57559
- /**
57560
- *
57561
- * @param {BinaryBuffer} buffer
57562
- */
57563
- fromBinaryBuffer(buffer) {
57564
- this.min = buffer.readFloat64();
57565
- this.max = buffer.readFloat64();
57566
- }
57529
+ hit.position.copy(this.__bestPosition);
57530
+ hit.normal.copy(vNormal);
57567
57531
 
57568
- /**
57569
- *
57570
- * @param {NumericInterval} other
57571
- * @returns {boolean}
57572
- */
57573
- equals(other) {
57574
- return this.min === other.min && this.max === other.max;
57532
+ hit.applyMatrix4(this.transform);
57533
+
57534
+ return true;
57535
+ } else {
57536
+ //no hit
57537
+ return false;
57538
+ }
57575
57539
  }
57540
+ }
57541
+
57542
+ /**
57543
+ * Created by Alex on 28/01/2017.
57544
+ */
57576
57545
 
57577
- /**
57578
- *
57579
- * @returns {number}
57580
- */
57581
- hash() {
57582
- let hash = computeHashFloat(this.min);
57546
+ function prepareObject(object) {
57547
+ //turn off automatic matrix re-calculations each frame
57548
+ object.matrixAutoUpdate = false;
57549
+ //disable frustum culling
57550
+ object.frustumCulled = false;
57551
+ }
57583
57552
 
57584
- hash = ((hash << 5) - hash) + computeHashFloat(this.max);
57553
+ /**
57554
+ *
57555
+ * @param {BufferGeometry} [geometry]
57556
+ * @param {Material} [material]
57557
+ * @returns {Mesh}
57558
+ */
57559
+ function createMesh(geometry, material) {
57560
+ const result = new Mesh(geometry, material);
57585
57561
 
57586
- return hash;
57587
- }
57562
+ prepareObject(result);
57588
57563
 
57589
- /**
57590
- * Distance between min and max (= max - min)
57591
- * @returns {number}
57592
- */
57593
- get span() {
57594
- return this.max - this.min;
57595
- }
57564
+ return result;
57596
57565
  }
57597
57566
 
57598
57567
  /**
57599
- * @readonly
57600
- * @type {boolean}
57568
+ *
57569
+ * @param {BufferGeometry} geometry
57570
+ * @param {THREE.Material} material
57571
+ * @returns {THREE.SkinnedMesh}
57601
57572
  */
57602
- NumericInterval.prototype.isNumericInterval = true;
57573
+ function createSkinnedMesh(geometry, material) {
57574
+ const result = new SkinnedMesh(geometry, material);
57575
+
57576
+ prepareObject(result);
57577
+
57578
+ return result;
57579
+ }
57603
57580
 
57604
57581
  /**
57605
- * @readonly
57606
- * @type {NumericInterval}
57582
+ *
57583
+ * @param {Material} material
57607
57584
  */
57608
- NumericInterval.one_one = Object.freeze(new NumericInterval(1, 1));
57585
+ function prepareMaterial(material) {
57586
+
57587
+ //make shadows render from front side, this avoids artifacts due to gaps in geometry that can't be seen from the front
57588
+ material.shadowSide = DoubleSide;
57589
+
57590
+ if (typeof material.envMapIntensity === 'number' && material.envMapIntensity !== 1) {
57591
+ // make material react to environment map in the same way as others
57592
+ material.envMapIntensity = 1;
57593
+ }
57594
+ }
57595
+
57609
57596
  /**
57610
- * @readonly
57611
- * @type {NumericInterval}
57597
+ *
57598
+ * @returns {Group}
57612
57599
  */
57613
- NumericInterval.zero_zero = Object.freeze(new NumericInterval(0, 0));
57600
+ function createGroup() {
57601
+ const result = new Group();
57602
+
57603
+ prepareObject(result);
57604
+
57605
+ return result;
57606
+ }
57607
+
57608
+ var ThreeFactory = {
57609
+ createMesh,
57610
+ createSkinnedMesh,
57611
+ createGroup,
57612
+ prepareMaterial
57613
+ };
57614
57614
 
57615
57615
  /**
57616
57616
  * Created by Alex on 09/11/2014.
57617
57617
  */
57618
57618
 
57619
+
57620
+ const EMPTY_GEOMETRY = new BufferGeometry();
57621
+ const DEFAULT_MATERIAL = new MeshBasicMaterial();
57622
+
57619
57623
  /**
57620
57624
  * terrain tile is a part of a 2d array
57621
57625
  */
@@ -57631,7 +57635,7 @@ class TerrainTile {
57631
57635
  * @type {Material}
57632
57636
  */
57633
57637
  material = null;
57634
- mesh = ThreeFactory.createMesh();
57638
+ mesh = ThreeFactory.createMesh(EMPTY_GEOMETRY, DEFAULT_MATERIAL);
57635
57639
 
57636
57640
 
57637
57641
  /**
@@ -60075,70 +60079,70 @@ class TerrainTileManager {
60075
60079
  const raycastBVHVisitor = new RaycastBVHVisitor();
60076
60080
  const firstRayIntersectionTerrainBVHVisitor = new FirstRayIntersectionTerrainBVHVisitor();
60077
60081
 
60078
- function TerrainPreview() {
60082
+ class TerrainPreview {
60079
60083
  /**
60080
60084
  *
60081
60085
  * @type {String}
60082
60086
  */
60083
- this.url = "";
60087
+ url = "";
60084
60088
 
60085
60089
  /**
60086
60090
  *
60087
60091
  * @type {Vector2}
60088
60092
  */
60089
- this.offset = new Vector2(0, 0);
60093
+ offset = new Vector2(0, 0);
60090
60094
  /**
60091
60095
  *
60092
60096
  * @type {Vector2}
60093
60097
  */
60094
- this.scale = new Vector2(1, 1);
60095
- }
60098
+ scale = new Vector2(1, 1);
60096
60099
 
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
- };
60100
+ /**
60101
+ *
60102
+ * @param {TerrainPreview} other
60103
+ */
60104
+ copy(other) {
60105
+ this.url = other.url;
60106
+ this.scale.copy(other.scale);
60107
+ this.offset.copy(other.offset);
60108
+ }
60106
60109
 
60107
- TerrainPreview.prototype.toJSON = function () {
60108
- return {
60109
- url: this.url,
60110
- offset: this.offset.toJSON(),
60111
- scale: this.scale.toJSON()
60112
- };
60113
- };
60110
+ toJSON() {
60111
+ return {
60112
+ url: this.url,
60113
+ offset: this.offset.toJSON(),
60114
+ scale: this.scale.toJSON()
60115
+ };
60116
+ }
60114
60117
 
60115
- TerrainPreview.prototype.fromJSON = function (obj) {
60116
- this.url = obj.url;
60117
- this.offset.fromJSON(obj.offset);
60118
- this.scale.fromJSON(obj.scale);
60119
- };
60118
+ fromJSON(obj) {
60119
+ this.url = obj.url;
60120
+ this.offset.fromJSON(obj.offset);
60121
+ this.scale.fromJSON(obj.scale);
60122
+ }
60120
60123
 
60121
- /**
60122
- *
60123
- * @param {BinaryBuffer} buffer
60124
- */
60125
- TerrainPreview.prototype.toBinaryBuffer = function (buffer) {
60126
- buffer.writeUTF8String(this.url);
60124
+ /**
60125
+ *
60126
+ * @param {BinaryBuffer} buffer
60127
+ */
60128
+ toBinaryBuffer(buffer) {
60129
+ buffer.writeUTF8String(this.url);
60127
60130
 
60128
- this.offset.toBinaryBuffer(buffer);
60129
- this.scale.toBinaryBuffer(buffer);
60130
- };
60131
+ this.offset.toBinaryBuffer(buffer);
60132
+ this.scale.toBinaryBuffer(buffer);
60133
+ }
60131
60134
 
60132
- /**
60133
- *
60134
- * @param {BinaryBuffer} buffer
60135
- */
60136
- TerrainPreview.prototype.fromBinaryBuffer = function (buffer) {
60137
- this.url = buffer.readUTF8String();
60135
+ /**
60136
+ *
60137
+ * @param {BinaryBuffer} buffer
60138
+ */
60139
+ fromBinaryBuffer(buffer) {
60140
+ this.url = buffer.readUTF8String();
60138
60141
 
60139
- this.offset.fromBinaryBuffer(buffer);
60140
- this.scale.fromBinaryBuffer(buffer);
60141
- };
60142
+ this.offset.fromBinaryBuffer(buffer);
60143
+ this.scale.fromBinaryBuffer(buffer);
60144
+ }
60145
+ }
60142
60146
 
60143
60147
  /**
60144
60148
  * NOTE, trying to keep to IANA registry: https://www.iana.org/assignments/media-types/media-types.xhtml
@@ -68667,8 +68671,10 @@ class EBBVHLeafProxy {
68667
68671
  unlink() {
68668
68672
  assert.equal(this.is_linked, true, 'not linked');
68669
68673
 
68670
- this.#tree.remove_leaf(this.#node_id);
68671
- this.#tree.release_node(this.#node_id);
68674
+ const node_id = this.#node_id;
68675
+
68676
+ this.#tree.remove_leaf(node_id);
68677
+ this.#tree.release_node(node_id);
68672
68678
 
68673
68679
  this.#node_id = -1;
68674
68680
  this.#tree = null;
@@ -110003,7 +110009,7 @@ class WebEnginePlatform extends EnginePlatform {
110003
110009
  class Tag {
110004
110010
  /**
110005
110011
  * @private
110006
- * @type {String[]}
110012
+ * @type {string[]}
110007
110013
  */
110008
110014
  values = [];
110009
110015
 
@@ -110185,41 +110191,31 @@ class Tag {
110185
110191
  * @return {boolean}
110186
110192
  */
110187
110193
  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;
110194
+ return isArrayEqualStrict(this.values, other.values);
110211
110195
  }
110212
110196
 
110213
110197
  toJSON() {
110214
110198
  return this.values;
110215
110199
  }
110216
110200
 
110201
+ /**
110202
+ *
110203
+ * @param {string[]|string} json
110204
+ */
110217
110205
  fromJSON(json) {
110206
+
110207
+ this.clear();
110208
+
110218
110209
  if (typeof json === "string") {
110219
- this.clear();
110220
110210
  this.add(json);
110221
- } else if (Array.isArray(json)) {
110222
- this.values = json;
110211
+ } else {
110212
+ assert.isArray(json, 'json');
110213
+
110214
+ const n = json.length;
110215
+
110216
+ for (let i = 0; i < n; i++) {
110217
+ this.add(json[i]);
110218
+ }
110223
110219
  }
110224
110220
  }
110225
110221