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