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