@woosh/meep-engine 2.61.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 +1277 -1259
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +1277 -1259
- 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/bvh2/BinaryNode.js +16 -13
- package/src/core/bvh2/LeafNode.js +6 -3
- package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +4 -2
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +81 -0
- package/src/core/cache/LoadingCache.js +4 -1
- package/src/core/collection/map/BiMap.js +49 -0
- package/src/core/geom/3d/aabb/AABB3.js +24 -36
- package/src/core/geom/3d/aabb/aabb3_array_compute_from_sphere.js +22 -0
- package/src/core/geom/3d/aabb/aabb3_array_intersects_sphere.js +22 -0
- package/src/core/geom/3d/aabb/aabb3_array_intersects_sphere_array.js +11 -0
- package/src/core/geom/3d/aabb/aabb3_signed_distance_to_aabb3.js +28 -0
- package/src/core/geom/3d/aabb/serializeAABB3Quantized16Uint.js +19 -10
- package/src/core/geom/3d/tetrahedra/delaunay/Cavity.js +3 -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/foliage/ecs/Foliage2System.js +3 -0
- package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +4 -1
- package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +64 -0
- package/src/engine/ecs/foliage/ecs/{InstancedMeshUtils.js → optimizeIndividualMeshesEntitiesToInstances.js} +11 -70
- 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/camera/testClippingPlaneComputation.js +25 -27
- 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/ecs/path/testPathDisplaySystem.js +49 -52
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +40 -42
- package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +43 -25
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +10 -6
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +37 -41
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +44 -46
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +24 -26
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +40 -42
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +36 -38
- package/src/engine/graphics/shadows/testShadowMapRendering.js +19 -19
- package/src/engine/grid/ORTHOGONAL_NEIGHBOURHOOD_MASK.js +11 -0
- package/src/engine/sound/dB2Volume.js +8 -0
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +125 -99
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.js +4 -42
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +31 -121
- package/src/engine/sound/volume2dB.js +8 -0
- package/src/generation/theme/ThemeEngine.js +19 -53
- package/src/core/binary/stringToByteArray.js +0 -24
- package/src/engine/graphics/geometry/bvh/buffered/BVHFromBufferGeometry.js +0 -133
- package/src/engine/save/storage/LocalStorage.js +0 -148
- package/src/engine/save/storage/MsgPackCodec.js +0 -22
package/build/meep.cjs
CHANGED
|
@@ -49816,6 +49816,95 @@ function array_quick_sort_by_comparator(
|
|
|
49816
49816
|
}
|
|
49817
49817
|
}
|
|
49818
49818
|
|
|
49819
|
+
/**
|
|
49820
|
+
*
|
|
49821
|
+
* @param {number} x0
|
|
49822
|
+
* @param {number} y0
|
|
49823
|
+
* @param {number} z0
|
|
49824
|
+
* @param {number} x1
|
|
49825
|
+
* @param {number} y1
|
|
49826
|
+
* @param {number} z1
|
|
49827
|
+
* @returns {number}
|
|
49828
|
+
*/
|
|
49829
|
+
function aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1) {
|
|
49830
|
+
const dx = x1 - x0;
|
|
49831
|
+
const dy = y1 - y0;
|
|
49832
|
+
const dz = z1 - z0;
|
|
49833
|
+
return dy * (dx + dz) + dz * dx; //1 side, since it's a heuristic only
|
|
49834
|
+
}
|
|
49835
|
+
|
|
49836
|
+
/**
|
|
49837
|
+
*
|
|
49838
|
+
* @param {AABB3} node
|
|
49839
|
+
* @returns {number}
|
|
49840
|
+
*/
|
|
49841
|
+
function aabb3_box_surface_area_2(node) {
|
|
49842
|
+
return aabb3_compute_half_surface_area(node.x0, node.y0, node.z0, node.x1, node.y1, node.z1);
|
|
49843
|
+
}
|
|
49844
|
+
|
|
49845
|
+
/**
|
|
49846
|
+
*
|
|
49847
|
+
* @param {AABB3} a
|
|
49848
|
+
* @param {AABB3} b
|
|
49849
|
+
* @returns {number}
|
|
49850
|
+
*/
|
|
49851
|
+
function aabb3_combined_surface_area(a, b) {
|
|
49852
|
+
const x0 = min2(a.x0, b.x0);
|
|
49853
|
+
const y0 = min2(a.y0, b.y0);
|
|
49854
|
+
const z0 = min2(a.z0, b.z0);
|
|
49855
|
+
|
|
49856
|
+
const x1 = max2(a.x1, b.x1);
|
|
49857
|
+
const y1 = max2(a.y1, b.y1);
|
|
49858
|
+
const z1 = max2(a.z1, b.z1);
|
|
49859
|
+
|
|
49860
|
+
return aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1);
|
|
49861
|
+
}
|
|
49862
|
+
|
|
49863
|
+
/**
|
|
49864
|
+
* Returns true if two 1D lines intersect, touch is treated as intersection
|
|
49865
|
+
* Parameters are assumed to be ordered, a1 >= a0, b1 >= b0
|
|
49866
|
+
* @param {Number} a0
|
|
49867
|
+
* @param {Number} a1
|
|
49868
|
+
* @param {Number} b0
|
|
49869
|
+
* @param {Number} b1
|
|
49870
|
+
* @returns {boolean}
|
|
49871
|
+
*/
|
|
49872
|
+
function intersects1D(a0, a1, b0, b1) {
|
|
49873
|
+
assert.isNumber(a0, "a0");
|
|
49874
|
+
assert.isNumber(a1, "a1");
|
|
49875
|
+
assert.isNumber(b0, "b0");
|
|
49876
|
+
assert.isNumber(b1, "b1");
|
|
49877
|
+
|
|
49878
|
+
return a1 >= b0 && b1 >= a0;
|
|
49879
|
+
}
|
|
49880
|
+
|
|
49881
|
+
/**
|
|
49882
|
+
*
|
|
49883
|
+
* @param {number} ax0
|
|
49884
|
+
* @param {number} ay0
|
|
49885
|
+
* @param {number} az0
|
|
49886
|
+
* @param {number} ax1
|
|
49887
|
+
* @param {number} ay1
|
|
49888
|
+
* @param {number} az1
|
|
49889
|
+
* @param {number} bx0
|
|
49890
|
+
* @param {number} by0
|
|
49891
|
+
* @param {number} bz0
|
|
49892
|
+
* @param {number} bx1
|
|
49893
|
+
* @param {number} by1
|
|
49894
|
+
* @param {number} bz1
|
|
49895
|
+
* @returns {boolean}
|
|
49896
|
+
*/
|
|
49897
|
+
function aabb3_intersects_aabb3(
|
|
49898
|
+
ax0, ay0, az0,
|
|
49899
|
+
ax1, ay1, az1,
|
|
49900
|
+
bx0, by0, bz0,
|
|
49901
|
+
bx1, by1, bz1
|
|
49902
|
+
) {
|
|
49903
|
+
return intersects1D(ax0, ax1, bx0, bx1)
|
|
49904
|
+
&& intersects1D(ay0, ay1, by0, by1)
|
|
49905
|
+
&& intersects1D(az0, az1, bz0, bz1);
|
|
49906
|
+
}
|
|
49907
|
+
|
|
49819
49908
|
/**
|
|
49820
49909
|
*
|
|
49821
49910
|
* @param {number[]} values
|
|
@@ -49902,6 +49991,73 @@ function mortonEncode_magicbits(x, y, z) {
|
|
|
49902
49991
|
return x_bits | y_bits | z_bits;
|
|
49903
49992
|
}
|
|
49904
49993
|
|
|
49994
|
+
//
|
|
49995
|
+
|
|
49996
|
+
/**
|
|
49997
|
+
*
|
|
49998
|
+
* @param {ArrayLike<number>|number[]|AABB3} aabb
|
|
49999
|
+
* @param {number} x
|
|
50000
|
+
* @param {number} y
|
|
50001
|
+
* @param {number} z
|
|
50002
|
+
* @return {boolean}
|
|
50003
|
+
*/
|
|
50004
|
+
function aabb3_array_intersects_point(
|
|
50005
|
+
aabb,
|
|
50006
|
+
x, y, z
|
|
50007
|
+
) {
|
|
50008
|
+
return x >= aabb[0]
|
|
50009
|
+
&& x <= aabb[3]
|
|
50010
|
+
&& y >= aabb[1]
|
|
50011
|
+
&& y <= aabb[4]
|
|
50012
|
+
&& z >= aabb[2]
|
|
50013
|
+
&& z <= aabb[5];
|
|
50014
|
+
}
|
|
50015
|
+
|
|
50016
|
+
/**
|
|
50017
|
+
*
|
|
50018
|
+
* @param {number[]|Float32Array|Float64Array} destination
|
|
50019
|
+
* @param {number} destination_offset
|
|
50020
|
+
* @param {number} x0
|
|
50021
|
+
* @param {number} y0
|
|
50022
|
+
* @param {number} z0
|
|
50023
|
+
* @param {number} x1
|
|
50024
|
+
* @param {number} y1
|
|
50025
|
+
* @param {number} z1
|
|
50026
|
+
*/
|
|
50027
|
+
function aabb3_build_corners(destination, destination_offset, x0, y0, z0, x1, y1, z1) {
|
|
50028
|
+
destination[destination_offset] = x0;
|
|
50029
|
+
destination[destination_offset + 1] = y0;
|
|
50030
|
+
destination[destination_offset + 2] = z0;
|
|
50031
|
+
|
|
50032
|
+
destination[destination_offset + 3] = x1;
|
|
50033
|
+
destination[destination_offset + 4] = y0;
|
|
50034
|
+
destination[destination_offset + 5] = z0;
|
|
50035
|
+
|
|
50036
|
+
destination[destination_offset + 6] = x0;
|
|
50037
|
+
destination[destination_offset + 7] = y1;
|
|
50038
|
+
destination[destination_offset + 8] = z0;
|
|
50039
|
+
|
|
50040
|
+
destination[destination_offset + 9] = x1;
|
|
50041
|
+
destination[destination_offset + 10] = y1;
|
|
50042
|
+
destination[destination_offset + 11] = z0;
|
|
50043
|
+
|
|
50044
|
+
destination[destination_offset + 12] = x0;
|
|
50045
|
+
destination[destination_offset + 13] = y0;
|
|
50046
|
+
destination[destination_offset + 14] = z1;
|
|
50047
|
+
|
|
50048
|
+
destination[destination_offset + 15] = x1;
|
|
50049
|
+
destination[destination_offset + 16] = y0;
|
|
50050
|
+
destination[destination_offset + 17] = z1;
|
|
50051
|
+
|
|
50052
|
+
destination[destination_offset + 18] = x0;
|
|
50053
|
+
destination[destination_offset + 19] = y1;
|
|
50054
|
+
destination[destination_offset + 20] = z1;
|
|
50055
|
+
|
|
50056
|
+
destination[destination_offset + 21] = x1;
|
|
50057
|
+
destination[destination_offset + 22] = y1;
|
|
50058
|
+
destination[destination_offset + 23] = z1;
|
|
50059
|
+
}
|
|
50060
|
+
|
|
49905
50061
|
/**
|
|
49906
50062
|
* Distance of the farthest point along the plane normal from the plane. If the result is >= 0, at least a portion of AABB pokes above the plane
|
|
49907
50063
|
* @param {number} plane_normal_x
|
|
@@ -50016,47 +50172,53 @@ function aabb3_compute_plane_side(
|
|
|
50016
50172
|
|
|
50017
50173
|
/**
|
|
50018
50174
|
*
|
|
50019
|
-
* @param {number[]|Float32Array|Float64Array} destination
|
|
50020
|
-
* @param {number} destination_offset
|
|
50021
50175
|
* @param {number} x0
|
|
50022
50176
|
* @param {number} y0
|
|
50023
50177
|
* @param {number} z0
|
|
50024
50178
|
* @param {number} x1
|
|
50025
50179
|
* @param {number} y1
|
|
50026
50180
|
* @param {number} z1
|
|
50181
|
+
* @returns {number}
|
|
50027
50182
|
*/
|
|
50028
|
-
function
|
|
50029
|
-
|
|
50030
|
-
|
|
50031
|
-
|
|
50032
|
-
|
|
50033
|
-
|
|
50034
|
-
|
|
50035
|
-
|
|
50036
|
-
|
|
50037
|
-
|
|
50038
|
-
|
|
50039
|
-
|
|
50183
|
+
function aabb3_compute_surface_area(x0, y0, z0, x1, y1, z1) {
|
|
50184
|
+
const dx = x1 - x0;
|
|
50185
|
+
const dy = y1 - y0;
|
|
50186
|
+
const dz = z1 - z0;
|
|
50187
|
+
return (dy * (dx + dz) + dz * dx) * 2; //2 of each side
|
|
50188
|
+
}
|
|
50189
|
+
|
|
50190
|
+
/**
|
|
50191
|
+
*
|
|
50192
|
+
* @param {number} x0
|
|
50193
|
+
* @param {number} y0
|
|
50194
|
+
* @param {number} z0
|
|
50195
|
+
* @param {number} x1
|
|
50196
|
+
* @param {number} y1
|
|
50197
|
+
* @param {number} z1
|
|
50198
|
+
* @param {ArrayLike<number>|number[]|Float32Array|Float64Array} frustum
|
|
50199
|
+
* @return {boolean}
|
|
50200
|
+
*/
|
|
50201
|
+
function aabb3_intersects_frustum_array(x0, y0, z0, x1, y1, z1, frustum) {
|
|
50202
|
+
for (let i = 0; i < 24; i += 4) {
|
|
50040
50203
|
|
|
50041
|
-
|
|
50042
|
-
|
|
50043
|
-
|
|
50204
|
+
const plane_x = frustum[i];
|
|
50205
|
+
const plane_y = frustum[i + 1];
|
|
50206
|
+
const plane_z = frustum[i + 2];
|
|
50207
|
+
const plane_w = frustum[i + 3];
|
|
50044
50208
|
|
|
50045
|
-
|
|
50046
|
-
|
|
50047
|
-
|
|
50209
|
+
const plane_distance = aabb3_compute_distance_above_plane_max(
|
|
50210
|
+
plane_x, plane_y, plane_z, plane_w,
|
|
50211
|
+
x0, y0, z0,
|
|
50212
|
+
x1, y1, z1
|
|
50213
|
+
);
|
|
50048
50214
|
|
|
50049
|
-
|
|
50050
|
-
|
|
50051
|
-
|
|
50215
|
+
if (plane_distance < 0) {
|
|
50216
|
+
return false;
|
|
50217
|
+
}
|
|
50052
50218
|
|
|
50053
|
-
|
|
50054
|
-
destination[destination_offset + 19] = y1;
|
|
50055
|
-
destination[destination_offset + 20] = z1;
|
|
50219
|
+
}
|
|
50056
50220
|
|
|
50057
|
-
|
|
50058
|
-
destination[destination_offset + 22] = y1;
|
|
50059
|
-
destination[destination_offset + 23] = z1;
|
|
50221
|
+
return true;
|
|
50060
50222
|
}
|
|
50061
50223
|
|
|
50062
50224
|
//
|
|
@@ -50276,57 +50438,6 @@ function aabb3_intersects_ray(
|
|
|
50276
50438
|
return f2 <= extents_x * abs_direction_y + extents_y * abs_direction_x;
|
|
50277
50439
|
}
|
|
50278
50440
|
|
|
50279
|
-
/**
|
|
50280
|
-
*
|
|
50281
|
-
* @param {number} x0
|
|
50282
|
-
* @param {number} y0
|
|
50283
|
-
* @param {number} z0
|
|
50284
|
-
* @param {number} x1
|
|
50285
|
-
* @param {number} y1
|
|
50286
|
-
* @param {number} z1
|
|
50287
|
-
* @returns {number}
|
|
50288
|
-
*/
|
|
50289
|
-
function aabb3_compute_surface_area(x0, y0, z0, x1, y1, z1) {
|
|
50290
|
-
const dx = x1 - x0;
|
|
50291
|
-
const dy = y1 - y0;
|
|
50292
|
-
const dz = z1 - z0;
|
|
50293
|
-
return (dy * (dx + dz) + dz * dx) * 2; //2 of each side
|
|
50294
|
-
}
|
|
50295
|
-
|
|
50296
|
-
/**
|
|
50297
|
-
*
|
|
50298
|
-
* @param {number} x0
|
|
50299
|
-
* @param {number} y0
|
|
50300
|
-
* @param {number} z0
|
|
50301
|
-
* @param {number} x1
|
|
50302
|
-
* @param {number} y1
|
|
50303
|
-
* @param {number} z1
|
|
50304
|
-
* @param {ArrayLike<number>|number[]|Float32Array|Float64Array} frustum
|
|
50305
|
-
* @return {boolean}
|
|
50306
|
-
*/
|
|
50307
|
-
function aabb3_intersects_frustum_array(x0, y0, z0, x1, y1, z1, frustum) {
|
|
50308
|
-
for (let i = 0; i < 24; i += 4) {
|
|
50309
|
-
|
|
50310
|
-
const plane_x = frustum[i];
|
|
50311
|
-
const plane_y = frustum[i + 1];
|
|
50312
|
-
const plane_z = frustum[i + 2];
|
|
50313
|
-
const plane_w = frustum[i + 3];
|
|
50314
|
-
|
|
50315
|
-
const plane_distance = aabb3_compute_distance_above_plane_max(
|
|
50316
|
-
plane_x, plane_y, plane_z, plane_w,
|
|
50317
|
-
x0, y0, z0,
|
|
50318
|
-
x1, y1, z1
|
|
50319
|
-
);
|
|
50320
|
-
|
|
50321
|
-
if (plane_distance < 0) {
|
|
50322
|
-
return false;
|
|
50323
|
-
}
|
|
50324
|
-
|
|
50325
|
-
}
|
|
50326
|
-
|
|
50327
|
-
return true;
|
|
50328
|
-
}
|
|
50329
|
-
|
|
50330
50441
|
/**
|
|
50331
50442
|
* NOTE: Based on Transforming Axis-Aligned Bounding Boxes by Jim Arvo from "Graphics Gems", Academic Press, 1990
|
|
50332
50443
|
* NOTE: {@link result} and {@link aabb} must be different objects
|
|
@@ -50409,26 +50520,33 @@ function aabb3_signed_distance_sqr_to_point(
|
|
|
50409
50520
|
}
|
|
50410
50521
|
}
|
|
50411
50522
|
|
|
50412
|
-
|
|
50523
|
+
function aabb3_signed_distance_to_aabb3(
|
|
50524
|
+
ax0,ay0,az0,ax1,ay1,az1,
|
|
50525
|
+
bx0,by0,bz0, bx1,by1,bz1
|
|
50526
|
+
){
|
|
50413
50527
|
|
|
50414
|
-
|
|
50415
|
-
|
|
50416
|
-
|
|
50417
|
-
|
|
50418
|
-
|
|
50419
|
-
|
|
50420
|
-
|
|
50421
|
-
|
|
50422
|
-
|
|
50423
|
-
|
|
50424
|
-
|
|
50425
|
-
)
|
|
50426
|
-
|
|
50427
|
-
|
|
50428
|
-
|
|
50429
|
-
|
|
50430
|
-
|
|
50431
|
-
|
|
50528
|
+
//do projection
|
|
50529
|
+
const xp0 = bx0 - ax1;
|
|
50530
|
+
const xp1 = ax0 - bx1;
|
|
50531
|
+
const yp0 = by0 - ay1;
|
|
50532
|
+
const yp1 = ay0 - by1;
|
|
50533
|
+
const zp0 = bz0 - az1;
|
|
50534
|
+
const zp1 = az0 - bz1;
|
|
50535
|
+
|
|
50536
|
+
//calculate separation in each axis
|
|
50537
|
+
const dx = Math.max(xp0, xp1);
|
|
50538
|
+
const dy = Math.max(yp0, yp1);
|
|
50539
|
+
const dz = Math.max(zp0, zp1);
|
|
50540
|
+
|
|
50541
|
+
//straight-line distance
|
|
50542
|
+
let distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
50543
|
+
|
|
50544
|
+
if (dx < 0 && dy < 0 && dz < 0) {
|
|
50545
|
+
//penetration
|
|
50546
|
+
return -distance;
|
|
50547
|
+
} else {
|
|
50548
|
+
return distance;
|
|
50549
|
+
}
|
|
50432
50550
|
}
|
|
50433
50551
|
|
|
50434
50552
|
/**
|
|
@@ -50437,6 +50555,7 @@ function aabb3_array_intersects_point(
|
|
|
50437
50555
|
|
|
50438
50556
|
/**
|
|
50439
50557
|
* Axis-Aligned bounding box in 3D
|
|
50558
|
+
* NOTE: In cases where all you want is raw performance - prefer to use typed arrays instead along with `aabb3_` functions
|
|
50440
50559
|
*/
|
|
50441
50560
|
class AABB3 {
|
|
50442
50561
|
/**
|
|
@@ -50656,7 +50775,12 @@ class AABB3 {
|
|
|
50656
50775
|
* @returns {boolean}
|
|
50657
50776
|
*/
|
|
50658
50777
|
_equals(x0, y0, z0, x1, y1, z1) {
|
|
50659
|
-
return this.x0 === x0
|
|
50778
|
+
return this.x0 === x0
|
|
50779
|
+
&& this.y0 === y0
|
|
50780
|
+
&& this.z0 === z0
|
|
50781
|
+
&& this.x1 === x1
|
|
50782
|
+
&& this.y1 === y1
|
|
50783
|
+
&& this.z1 === z1;
|
|
50660
50784
|
}
|
|
50661
50785
|
|
|
50662
50786
|
/**
|
|
@@ -50750,28 +50874,10 @@ class AABB3 {
|
|
|
50750
50874
|
const _y1 = this.y1;
|
|
50751
50875
|
const _z1 = this.z1;
|
|
50752
50876
|
|
|
50753
|
-
|
|
50754
|
-
|
|
50755
|
-
|
|
50756
|
-
|
|
50757
|
-
const yp1 = y0 - _y1;
|
|
50758
|
-
const zp0 = _z0 - z1;
|
|
50759
|
-
const zp1 = z0 - _z1;
|
|
50760
|
-
|
|
50761
|
-
//calculate separation in each axis
|
|
50762
|
-
const dx = Math.max(xp0, xp1);
|
|
50763
|
-
const dy = Math.max(yp0, yp1);
|
|
50764
|
-
const dz = Math.max(zp0, zp1);
|
|
50765
|
-
|
|
50766
|
-
//straight-line distance
|
|
50767
|
-
let distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
50768
|
-
|
|
50769
|
-
if (dx < 0 && dy < 0 && dz < 0) {
|
|
50770
|
-
//penetration
|
|
50771
|
-
return -distance;
|
|
50772
|
-
} else {
|
|
50773
|
-
return distance;
|
|
50774
|
-
}
|
|
50877
|
+
return aabb3_signed_distance_to_aabb3(
|
|
50878
|
+
_x0, _y0, _z0, _x1, _y1, _z1,
|
|
50879
|
+
x0, y0, z0, x1, y1, z1
|
|
50880
|
+
);
|
|
50775
50881
|
}
|
|
50776
50882
|
|
|
50777
50883
|
/**
|
|
@@ -51196,7 +51302,6 @@ class AABB3 {
|
|
|
51196
51302
|
}
|
|
51197
51303
|
|
|
51198
51304
|
/**
|
|
51199
|
-
*
|
|
51200
51305
|
* @param {Plane[]} clippingPlanes
|
|
51201
51306
|
* @returns {boolean}
|
|
51202
51307
|
*/
|
|
@@ -51491,6 +51596,9 @@ function isLeaf(node) {
|
|
|
51491
51596
|
return node.isLeafNode;
|
|
51492
51597
|
}
|
|
51493
51598
|
|
|
51599
|
+
/**
|
|
51600
|
+
* @deprecated use {@link ExplicitBinaryBoundingVolumeHierarchy} and {@link EBBVHLeafProxy} respectively
|
|
51601
|
+
*/
|
|
51494
51602
|
class LeafNode extends Node {
|
|
51495
51603
|
/**
|
|
51496
51604
|
*
|
|
@@ -51701,95 +51809,6 @@ function traverseBinaryNodeUsingVisitor(node, visitor) {
|
|
|
51701
51809
|
stackPointer$3 = stackOffset;
|
|
51702
51810
|
}
|
|
51703
51811
|
|
|
51704
|
-
/**
|
|
51705
|
-
* Returns true if two 1D lines intersect, touch is treated as intersection
|
|
51706
|
-
* Parameters are assumed to be ordered, a1 >= a0, b1 >= b0
|
|
51707
|
-
* @param {Number} a0
|
|
51708
|
-
* @param {Number} a1
|
|
51709
|
-
* @param {Number} b0
|
|
51710
|
-
* @param {Number} b1
|
|
51711
|
-
* @returns {boolean}
|
|
51712
|
-
*/
|
|
51713
|
-
function intersects1D(a0, a1, b0, b1) {
|
|
51714
|
-
assert.isNumber(a0, "a0");
|
|
51715
|
-
assert.isNumber(a1, "a1");
|
|
51716
|
-
assert.isNumber(b0, "b0");
|
|
51717
|
-
assert.isNumber(b1, "b1");
|
|
51718
|
-
|
|
51719
|
-
return a1 >= b0 && b1 >= a0;
|
|
51720
|
-
}
|
|
51721
|
-
|
|
51722
|
-
/**
|
|
51723
|
-
*
|
|
51724
|
-
* @param {number} ax0
|
|
51725
|
-
* @param {number} ay0
|
|
51726
|
-
* @param {number} az0
|
|
51727
|
-
* @param {number} ax1
|
|
51728
|
-
* @param {number} ay1
|
|
51729
|
-
* @param {number} az1
|
|
51730
|
-
* @param {number} bx0
|
|
51731
|
-
* @param {number} by0
|
|
51732
|
-
* @param {number} bz0
|
|
51733
|
-
* @param {number} bx1
|
|
51734
|
-
* @param {number} by1
|
|
51735
|
-
* @param {number} bz1
|
|
51736
|
-
* @returns {boolean}
|
|
51737
|
-
*/
|
|
51738
|
-
function aabb3_intersects_aabb3(
|
|
51739
|
-
ax0, ay0, az0,
|
|
51740
|
-
ax1, ay1, az1,
|
|
51741
|
-
bx0, by0, bz0,
|
|
51742
|
-
bx1, by1, bz1
|
|
51743
|
-
) {
|
|
51744
|
-
return intersects1D(ax0, ax1, bx0, bx1)
|
|
51745
|
-
&& intersects1D(ay0, ay1, by0, by1)
|
|
51746
|
-
&& intersects1D(az0, az1, bz0, bz1);
|
|
51747
|
-
}
|
|
51748
|
-
|
|
51749
|
-
/**
|
|
51750
|
-
*
|
|
51751
|
-
* @param {number} x0
|
|
51752
|
-
* @param {number} y0
|
|
51753
|
-
* @param {number} z0
|
|
51754
|
-
* @param {number} x1
|
|
51755
|
-
* @param {number} y1
|
|
51756
|
-
* @param {number} z1
|
|
51757
|
-
* @returns {number}
|
|
51758
|
-
*/
|
|
51759
|
-
function aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1) {
|
|
51760
|
-
const dx = x1 - x0;
|
|
51761
|
-
const dy = y1 - y0;
|
|
51762
|
-
const dz = z1 - z0;
|
|
51763
|
-
return dy * (dx + dz) + dz * dx; //1 side, since it's a heuristic only
|
|
51764
|
-
}
|
|
51765
|
-
|
|
51766
|
-
/**
|
|
51767
|
-
*
|
|
51768
|
-
* @param {AABB3} node
|
|
51769
|
-
* @returns {number}
|
|
51770
|
-
*/
|
|
51771
|
-
function aabb3_box_surface_area_2(node) {
|
|
51772
|
-
return aabb3_compute_half_surface_area(node.x0, node.y0, node.z0, node.x1, node.y1, node.z1);
|
|
51773
|
-
}
|
|
51774
|
-
|
|
51775
|
-
/**
|
|
51776
|
-
*
|
|
51777
|
-
* @param {AABB3} a
|
|
51778
|
-
* @param {AABB3} b
|
|
51779
|
-
* @returns {number}
|
|
51780
|
-
*/
|
|
51781
|
-
function aabb3_combined_surface_area(a, b) {
|
|
51782
|
-
const x0 = min2(a.x0, b.x0);
|
|
51783
|
-
const y0 = min2(a.y0, b.y0);
|
|
51784
|
-
const z0 = min2(a.z0, b.z0);
|
|
51785
|
-
|
|
51786
|
-
const x1 = max2(a.x1, b.x1);
|
|
51787
|
-
const y1 = max2(a.y1, b.y1);
|
|
51788
|
-
const z1 = max2(a.z1, b.z1);
|
|
51789
|
-
|
|
51790
|
-
return aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1);
|
|
51791
|
-
}
|
|
51792
|
-
|
|
51793
51812
|
/**
|
|
51794
51813
|
* Created by Alex on 17/11/2014.
|
|
51795
51814
|
*/
|
|
@@ -51813,6 +51832,9 @@ let stackPointer$2 = 0;
|
|
|
51813
51832
|
*/
|
|
51814
51833
|
const stack$9 = [];
|
|
51815
51834
|
|
|
51835
|
+
/**
|
|
51836
|
+
* @deprecated use {@link ExplicitBinaryBoundingVolumeHierarchy} instead
|
|
51837
|
+
*/
|
|
51816
51838
|
class BinaryNode extends Node {
|
|
51817
51839
|
constructor() {
|
|
51818
51840
|
super();
|
|
@@ -55568,79 +55590,314 @@ ObservedValue.prototype.fromJSON = function (value) {
|
|
|
55568
55590
|
this.set(value);
|
|
55569
55591
|
};
|
|
55570
55592
|
|
|
55571
|
-
/**
|
|
55572
|
-
*
|
|
55573
|
-
|
|
55574
|
-
|
|
55575
|
-
|
|
55576
|
-
|
|
55577
|
-
|
|
55578
|
-
|
|
55579
|
-
|
|
55580
|
-
|
|
55581
|
-
|
|
55582
|
-
|
|
55583
|
-
|
|
55584
|
-
|
|
55585
|
-
* @param {Material} [material]
|
|
55586
|
-
* @returns {Mesh}
|
|
55587
|
-
*/
|
|
55588
|
-
function createMesh(geometry, material) {
|
|
55589
|
-
const result = new Mesh(geometry, material);
|
|
55590
|
-
|
|
55591
|
-
prepareObject(result);
|
|
55592
|
-
|
|
55593
|
-
return result;
|
|
55594
|
-
}
|
|
55595
|
-
|
|
55596
|
-
/**
|
|
55597
|
-
*
|
|
55598
|
-
* @param {BufferGeometry} geometry
|
|
55599
|
-
* @param {THREE.Material} material
|
|
55600
|
-
* @returns {THREE.SkinnedMesh}
|
|
55601
|
-
*/
|
|
55602
|
-
function createSkinnedMesh(geometry, material) {
|
|
55603
|
-
const result = new SkinnedMesh(geometry, material);
|
|
55604
|
-
|
|
55605
|
-
prepareObject(result);
|
|
55606
|
-
|
|
55607
|
-
return result;
|
|
55608
|
-
}
|
|
55609
|
-
|
|
55610
|
-
/**
|
|
55611
|
-
*
|
|
55612
|
-
* @param {Material} material
|
|
55613
|
-
*/
|
|
55614
|
-
function prepareMaterial(material) {
|
|
55615
|
-
|
|
55616
|
-
//make shadows render from front side, this avoids artifacts due to gaps in geometry that can't be seen from the front
|
|
55617
|
-
material.shadowSide = DoubleSide;
|
|
55618
|
-
|
|
55619
|
-
if (typeof material.envMapIntensity === 'number' && material.envMapIntensity !== 1) {
|
|
55620
|
-
// make material react to environment map in the same way as others
|
|
55621
|
-
material.envMapIntensity = 1;
|
|
55622
|
-
}
|
|
55623
|
-
}
|
|
55624
|
-
|
|
55625
|
-
/**
|
|
55626
|
-
*
|
|
55627
|
-
* @returns {Group}
|
|
55628
|
-
*/
|
|
55629
|
-
function createGroup() {
|
|
55630
|
-
const result = new Group();
|
|
55631
|
-
|
|
55632
|
-
prepareObject(result);
|
|
55633
|
-
|
|
55634
|
-
return result;
|
|
55635
|
-
}
|
|
55636
|
-
|
|
55637
|
-
var ThreeFactory = {
|
|
55638
|
-
createMesh,
|
|
55639
|
-
createSkinnedMesh,
|
|
55640
|
-
createGroup,
|
|
55641
|
-
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);
|
|
55642
55607
|
};
|
|
55643
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
|
+
|
|
55644
55901
|
class IndexedBinaryBVHVisitor {
|
|
55645
55902
|
/**
|
|
55646
55903
|
*
|
|
@@ -56354,6 +56611,445 @@ class SurfacePoint3 {
|
|
|
56354
56611
|
}
|
|
56355
56612
|
}
|
|
56356
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
|
+
|
|
56357
57053
|
/**
|
|
56358
57054
|
* NOTE: adapted from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
|
|
56359
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)
|
|
@@ -56603,332 +57299,24 @@ function ray3_array_apply_matrix4(output, output_offset, input, input_offset, m4
|
|
|
56603
57299
|
return true;
|
|
56604
57300
|
}
|
|
56605
57301
|
|
|
56606
|
-
/**
|
|
56607
|
-
*
|
|
56608
|
-
* @
|
|
56609
|
-
|
|
56610
|
-
|
|
56611
|
-
|
|
56612
|
-
|
|
56613
|
-
|
|
56614
|
-
|
|
56615
|
-
|
|
56616
|
-
|
|
56617
|
-
|
|
56618
|
-
|
|
56619
|
-
|
|
56620
|
-
|
|
56621
|
-
|
|
56622
|
-
|
|
56623
|
-
|
|
56624
|
-
* @module mat4
|
|
56625
|
-
*/
|
|
56626
|
-
|
|
56627
|
-
/**
|
|
56628
|
-
* Creates a new identity mat4
|
|
56629
|
-
*
|
|
56630
|
-
* @returns {mat4} a new 4x4 matrix
|
|
56631
|
-
*/
|
|
56632
|
-
|
|
56633
|
-
function create$1() {
|
|
56634
|
-
var out = new ARRAY_TYPE(16);
|
|
56635
|
-
|
|
56636
|
-
if (ARRAY_TYPE != Float32Array) {
|
|
56637
|
-
out[1] = 0;
|
|
56638
|
-
out[2] = 0;
|
|
56639
|
-
out[3] = 0;
|
|
56640
|
-
out[4] = 0;
|
|
56641
|
-
out[6] = 0;
|
|
56642
|
-
out[7] = 0;
|
|
56643
|
-
out[8] = 0;
|
|
56644
|
-
out[9] = 0;
|
|
56645
|
-
out[11] = 0;
|
|
56646
|
-
out[12] = 0;
|
|
56647
|
-
out[13] = 0;
|
|
56648
|
-
out[14] = 0;
|
|
56649
|
-
}
|
|
56650
|
-
|
|
56651
|
-
out[0] = 1;
|
|
56652
|
-
out[5] = 1;
|
|
56653
|
-
out[10] = 1;
|
|
56654
|
-
out[15] = 1;
|
|
56655
|
-
return out;
|
|
56656
|
-
}
|
|
56657
|
-
/**
|
|
56658
|
-
* Copy the values from one mat4 to another
|
|
56659
|
-
*
|
|
56660
|
-
* @param {mat4} out the receiving matrix
|
|
56661
|
-
* @param {ReadonlyMat4} a the source matrix
|
|
56662
|
-
* @returns {mat4} out
|
|
56663
|
-
*/
|
|
56664
|
-
|
|
56665
|
-
function copy(out, a) {
|
|
56666
|
-
out[0] = a[0];
|
|
56667
|
-
out[1] = a[1];
|
|
56668
|
-
out[2] = a[2];
|
|
56669
|
-
out[3] = a[3];
|
|
56670
|
-
out[4] = a[4];
|
|
56671
|
-
out[5] = a[5];
|
|
56672
|
-
out[6] = a[6];
|
|
56673
|
-
out[7] = a[7];
|
|
56674
|
-
out[8] = a[8];
|
|
56675
|
-
out[9] = a[9];
|
|
56676
|
-
out[10] = a[10];
|
|
56677
|
-
out[11] = a[11];
|
|
56678
|
-
out[12] = a[12];
|
|
56679
|
-
out[13] = a[13];
|
|
56680
|
-
out[14] = a[14];
|
|
56681
|
-
out[15] = a[15];
|
|
56682
|
-
return out;
|
|
56683
|
-
}
|
|
56684
|
-
/**
|
|
56685
|
-
* Inverts a mat4
|
|
56686
|
-
*
|
|
56687
|
-
* @param {mat4} out the receiving matrix
|
|
56688
|
-
* @param {ReadonlyMat4} a the source matrix
|
|
56689
|
-
* @returns {mat4} out
|
|
56690
|
-
*/
|
|
56691
|
-
|
|
56692
|
-
function invert(out, a) {
|
|
56693
|
-
var a00 = a[0],
|
|
56694
|
-
a01 = a[1],
|
|
56695
|
-
a02 = a[2],
|
|
56696
|
-
a03 = a[3];
|
|
56697
|
-
var a10 = a[4],
|
|
56698
|
-
a11 = a[5],
|
|
56699
|
-
a12 = a[6],
|
|
56700
|
-
a13 = a[7];
|
|
56701
|
-
var a20 = a[8],
|
|
56702
|
-
a21 = a[9],
|
|
56703
|
-
a22 = a[10],
|
|
56704
|
-
a23 = a[11];
|
|
56705
|
-
var a30 = a[12],
|
|
56706
|
-
a31 = a[13],
|
|
56707
|
-
a32 = a[14],
|
|
56708
|
-
a33 = a[15];
|
|
56709
|
-
var b00 = a00 * a11 - a01 * a10;
|
|
56710
|
-
var b01 = a00 * a12 - a02 * a10;
|
|
56711
|
-
var b02 = a00 * a13 - a03 * a10;
|
|
56712
|
-
var b03 = a01 * a12 - a02 * a11;
|
|
56713
|
-
var b04 = a01 * a13 - a03 * a11;
|
|
56714
|
-
var b05 = a02 * a13 - a03 * a12;
|
|
56715
|
-
var b06 = a20 * a31 - a21 * a30;
|
|
56716
|
-
var b07 = a20 * a32 - a22 * a30;
|
|
56717
|
-
var b08 = a20 * a33 - a23 * a30;
|
|
56718
|
-
var b09 = a21 * a32 - a22 * a31;
|
|
56719
|
-
var b10 = a21 * a33 - a23 * a31;
|
|
56720
|
-
var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
|
|
56721
|
-
|
|
56722
|
-
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
56723
|
-
|
|
56724
|
-
if (!det) {
|
|
56725
|
-
return null;
|
|
56726
|
-
}
|
|
56727
|
-
|
|
56728
|
-
det = 1.0 / det;
|
|
56729
|
-
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
56730
|
-
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
56731
|
-
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
56732
|
-
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
|
56733
|
-
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
56734
|
-
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
56735
|
-
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
56736
|
-
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
|
56737
|
-
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
56738
|
-
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
56739
|
-
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
56740
|
-
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
|
56741
|
-
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
|
56742
|
-
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
|
56743
|
-
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
|
56744
|
-
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
56745
|
-
return out;
|
|
56746
|
-
}
|
|
56747
|
-
/**
|
|
56748
|
-
* Multiplies two mat4s
|
|
56749
|
-
*
|
|
56750
|
-
* @param {mat4} out the receiving matrix
|
|
56751
|
-
* @param {ReadonlyMat4} a the first operand
|
|
56752
|
-
* @param {ReadonlyMat4} b the second operand
|
|
56753
|
-
* @returns {mat4} out
|
|
56754
|
-
*/
|
|
56755
|
-
|
|
56756
|
-
function multiply(out, a, b) {
|
|
56757
|
-
var a00 = a[0],
|
|
56758
|
-
a01 = a[1],
|
|
56759
|
-
a02 = a[2],
|
|
56760
|
-
a03 = a[3];
|
|
56761
|
-
var a10 = a[4],
|
|
56762
|
-
a11 = a[5],
|
|
56763
|
-
a12 = a[6],
|
|
56764
|
-
a13 = a[7];
|
|
56765
|
-
var a20 = a[8],
|
|
56766
|
-
a21 = a[9],
|
|
56767
|
-
a22 = a[10],
|
|
56768
|
-
a23 = a[11];
|
|
56769
|
-
var a30 = a[12],
|
|
56770
|
-
a31 = a[13],
|
|
56771
|
-
a32 = a[14],
|
|
56772
|
-
a33 = a[15]; // Cache only the current line of the second matrix
|
|
56773
|
-
|
|
56774
|
-
var b0 = b[0],
|
|
56775
|
-
b1 = b[1],
|
|
56776
|
-
b2 = b[2],
|
|
56777
|
-
b3 = b[3];
|
|
56778
|
-
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
56779
|
-
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
56780
|
-
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
56781
|
-
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
56782
|
-
b0 = b[4];
|
|
56783
|
-
b1 = b[5];
|
|
56784
|
-
b2 = b[6];
|
|
56785
|
-
b3 = b[7];
|
|
56786
|
-
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
56787
|
-
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
56788
|
-
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
56789
|
-
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
56790
|
-
b0 = b[8];
|
|
56791
|
-
b1 = b[9];
|
|
56792
|
-
b2 = b[10];
|
|
56793
|
-
b3 = b[11];
|
|
56794
|
-
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
56795
|
-
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
56796
|
-
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
56797
|
-
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
56798
|
-
b0 = b[12];
|
|
56799
|
-
b1 = b[13];
|
|
56800
|
-
b2 = b[14];
|
|
56801
|
-
b3 = b[15];
|
|
56802
|
-
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
56803
|
-
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
56804
|
-
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
56805
|
-
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
56806
|
-
return out;
|
|
56807
|
-
}
|
|
56808
|
-
|
|
56809
|
-
/**
|
|
56810
|
-
* 3 Dimensional Vector
|
|
56811
|
-
* @module vec3
|
|
56812
|
-
*/
|
|
56813
|
-
|
|
56814
|
-
/**
|
|
56815
|
-
* Creates a new, empty vec3
|
|
56816
|
-
*
|
|
56817
|
-
* @returns {vec3} a new 3D vector
|
|
56818
|
-
*/
|
|
56819
|
-
|
|
56820
|
-
function create() {
|
|
56821
|
-
var out = new ARRAY_TYPE(3);
|
|
56822
|
-
|
|
56823
|
-
if (ARRAY_TYPE != Float32Array) {
|
|
56824
|
-
out[0] = 0;
|
|
56825
|
-
out[1] = 0;
|
|
56826
|
-
out[2] = 0;
|
|
56827
|
-
}
|
|
56828
|
-
|
|
56829
|
-
return out;
|
|
56830
|
-
}
|
|
56831
|
-
/**
|
|
56832
|
-
* Creates a new vec3 initialized with the given values
|
|
56833
|
-
*
|
|
56834
|
-
* @param {Number} x X component
|
|
56835
|
-
* @param {Number} y Y component
|
|
56836
|
-
* @param {Number} z Z component
|
|
56837
|
-
* @returns {vec3} a new 3D vector
|
|
56838
|
-
*/
|
|
56839
|
-
|
|
56840
|
-
function fromValues(x, y, z) {
|
|
56841
|
-
var out = new ARRAY_TYPE(3);
|
|
56842
|
-
out[0] = x;
|
|
56843
|
-
out[1] = y;
|
|
56844
|
-
out[2] = z;
|
|
56845
|
-
return out;
|
|
56846
|
-
}
|
|
56847
|
-
/**
|
|
56848
|
-
* Transforms the vec3 with a mat4.
|
|
56849
|
-
* 4th vector component is implicitly '1'
|
|
56850
|
-
*
|
|
56851
|
-
* @param {vec3} out the receiving vector
|
|
56852
|
-
* @param {ReadonlyVec3} a the vector to transform
|
|
56853
|
-
* @param {ReadonlyMat4} m matrix to transform with
|
|
56854
|
-
* @returns {vec3} out
|
|
56855
|
-
*/
|
|
56856
|
-
|
|
56857
|
-
function transformMat4(out, a, m) {
|
|
56858
|
-
var x = a[0],
|
|
56859
|
-
y = a[1],
|
|
56860
|
-
z = a[2];
|
|
56861
|
-
var w = m[3] * x + m[7] * y + m[11] * z + m[15];
|
|
56862
|
-
w = w || 1.0;
|
|
56863
|
-
out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
|
|
56864
|
-
out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
|
|
56865
|
-
out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
|
|
56866
|
-
return out;
|
|
56867
|
-
}
|
|
56868
|
-
/**
|
|
56869
|
-
* Perform some operation over an array of vec3s.
|
|
56870
|
-
*
|
|
56871
|
-
* @param {Array} a the array of vectors to iterate over
|
|
56872
|
-
* @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
|
|
56873
|
-
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
56874
|
-
* @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
|
|
56875
|
-
* @param {Function} fn Function to call for each vector in the array
|
|
56876
|
-
* @param {Object} [arg] additional argument to pass to fn
|
|
56877
|
-
* @returns {Array} a
|
|
56878
|
-
* @function
|
|
56879
|
-
*/
|
|
56880
|
-
|
|
56881
|
-
(function () {
|
|
56882
|
-
var vec = create();
|
|
56883
|
-
return function (a, stride, offset, count, fn, arg) {
|
|
56884
|
-
var i, l;
|
|
56885
|
-
|
|
56886
|
-
if (!stride) {
|
|
56887
|
-
stride = 3;
|
|
56888
|
-
}
|
|
56889
|
-
|
|
56890
|
-
if (!offset) {
|
|
56891
|
-
offset = 0;
|
|
56892
|
-
}
|
|
56893
|
-
|
|
56894
|
-
if (count) {
|
|
56895
|
-
l = Math.min(count * stride + offset, a.length);
|
|
56896
|
-
} else {
|
|
56897
|
-
l = a.length;
|
|
56898
|
-
}
|
|
56899
|
-
|
|
56900
|
-
for (i = offset; i < l; i += stride) {
|
|
56901
|
-
vec[0] = a[i];
|
|
56902
|
-
vec[1] = a[i + 1];
|
|
56903
|
-
vec[2] = a[i + 2];
|
|
56904
|
-
fn(vec, vec, arg);
|
|
56905
|
-
a[i] = vec[0];
|
|
56906
|
-
a[i + 1] = vec[1];
|
|
56907
|
-
a[i + 2] = vec[2];
|
|
56908
|
-
}
|
|
56909
|
-
|
|
56910
|
-
return a;
|
|
56911
|
-
};
|
|
56912
|
-
})();
|
|
56913
|
-
|
|
56914
|
-
/**
|
|
56915
|
-
*
|
|
56916
|
-
* @param {number[]|ArrayLike<number>|Float32Array} output
|
|
56917
|
-
* @param {number} origin_x
|
|
56918
|
-
* @param {number} origin_y
|
|
56919
|
-
* @param {number} origin_z
|
|
56920
|
-
* @param {number} direction_x
|
|
56921
|
-
* @param {number} direction_y
|
|
56922
|
-
* @param {number} direction_z
|
|
56923
|
-
*/
|
|
56924
|
-
function ray3_array_compose(output, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z) {
|
|
56925
|
-
output[0] = origin_x;
|
|
56926
|
-
output[1] = origin_y;
|
|
56927
|
-
output[2] = origin_z;
|
|
56928
|
-
|
|
56929
|
-
output[3] = direction_x;
|
|
56930
|
-
output[4] = direction_y;
|
|
56931
|
-
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;
|
|
56932
57320
|
}
|
|
56933
57321
|
|
|
56934
57322
|
const hit$1 = new Vector3();
|
|
@@ -56945,657 +57333,295 @@ const m4_tmp = [];
|
|
|
56945
57333
|
* @param {number[]|Uint8Array|Uint16Array|Uint32Array} indices
|
|
56946
57334
|
* @param {number[]|Float32Array|Float64Array} vertices
|
|
56947
57335
|
* @param {number} index
|
|
56948
|
-
*/
|
|
56949
|
-
function bindGeometryFace(indices, vertices, index) {
|
|
56950
|
-
const index3 = index * 3;
|
|
56951
|
-
|
|
56952
|
-
assert.lessThan(index3, indices.length, 'index underflow');
|
|
56953
|
-
|
|
56954
|
-
const a = indices[index3] * 3;
|
|
56955
|
-
const b = indices[index3 + 1] * 3;
|
|
56956
|
-
const c = indices[index3 + 2] * 3;
|
|
56957
|
-
|
|
56958
|
-
vA.set(vertices[a], vertices[a + 1], vertices[a + 2]);
|
|
56959
|
-
vB.set(vertices[b], vertices[b + 1], vertices[b + 2]);
|
|
56960
|
-
vC.set(vertices[c], vertices[c + 1], vertices[c + 2]);
|
|
56961
|
-
}
|
|
56962
|
-
|
|
56963
|
-
const vNormal = new Vector3$1();
|
|
56964
|
-
|
|
56965
|
-
function bindGeometryFaceNormal(indices, normals, index) {
|
|
56966
|
-
|
|
56967
|
-
const index3 = index * 3;
|
|
56968
|
-
|
|
56969
|
-
const a = indices[index3] * 3;
|
|
56970
|
-
const b = indices[index3 + 1] * 3;
|
|
56971
|
-
const c = indices[index3 + 2] * 3;
|
|
56972
|
-
|
|
56973
|
-
//read vertex normals
|
|
56974
|
-
const naX = normals[a];
|
|
56975
|
-
const naY = normals[a + 1];
|
|
56976
|
-
const naZ = normals[a + 2];
|
|
56977
|
-
|
|
56978
|
-
const nbX = normals[b];
|
|
56979
|
-
const nbY = normals[b + 1];
|
|
56980
|
-
const nbZ = normals[b + 2];
|
|
56981
|
-
|
|
56982
|
-
const ncX = normals[c];
|
|
56983
|
-
const ncY = normals[c + 1];
|
|
56984
|
-
const ncZ = normals[c + 2];
|
|
56985
|
-
|
|
56986
|
-
//add normals
|
|
56987
|
-
const nsX = (naX + nbX + ncX);
|
|
56988
|
-
const nsY = (naY + nbY + ncY);
|
|
56989
|
-
const nsZ = (naZ + nbZ + ncZ);
|
|
56990
|
-
|
|
56991
|
-
//normalize
|
|
56992
|
-
const l = v3_length(nsX, nsY, nsZ);
|
|
56993
|
-
const m = 1 / l;
|
|
56994
|
-
|
|
56995
|
-
const nx = nsX * m;
|
|
56996
|
-
const ny = nsY * m;
|
|
56997
|
-
const nz = nsZ * m;
|
|
56998
|
-
|
|
56999
|
-
vNormal.set(nx, ny, nz);
|
|
57000
|
-
}
|
|
57001
|
-
|
|
57002
|
-
|
|
57003
|
-
function extractFaceIndexFromLeaf_default(leaf) {
|
|
57004
|
-
return leaf.object;
|
|
57005
|
-
}
|
|
57006
|
-
|
|
57007
|
-
class BVHGeometryRaycaster {
|
|
57008
|
-
constructor() {
|
|
57009
|
-
/**
|
|
57010
|
-
*
|
|
57011
|
-
* @type {BufferGeometry|null}
|
|
57012
|
-
*/
|
|
57013
|
-
this.geometry = null;
|
|
57014
|
-
/**
|
|
57015
|
-
*
|
|
57016
|
-
* @type {BinaryNode|null}
|
|
57017
|
-
*/
|
|
57018
|
-
this.bvh = null;
|
|
57019
|
-
|
|
57020
|
-
/**
|
|
57021
|
-
*
|
|
57022
|
-
* @type {Vector2|null}
|
|
57023
|
-
*/
|
|
57024
|
-
this.position = null;
|
|
57025
|
-
/**
|
|
57026
|
-
*
|
|
57027
|
-
* @type {Vector2|null}
|
|
57028
|
-
*/
|
|
57029
|
-
this.scale = null;
|
|
57030
|
-
/**
|
|
57031
|
-
*
|
|
57032
|
-
* @type {number}
|
|
57033
|
-
*/
|
|
57034
|
-
this.resolution = 0;
|
|
57035
|
-
|
|
57036
|
-
/**
|
|
57037
|
-
*
|
|
57038
|
-
* @type {Vector2|null}
|
|
57039
|
-
*/
|
|
57040
|
-
this.size = null;
|
|
57041
|
-
|
|
57042
|
-
this.__bestDistance = 0;
|
|
57043
|
-
this.__bestPosition = new Vector3$1();
|
|
57044
|
-
this.__bestIndex = 0;
|
|
57045
|
-
|
|
57046
|
-
|
|
57047
|
-
this.origin = new Vector3$1();
|
|
57048
|
-
this.direction = new Vector3$1();
|
|
57049
|
-
|
|
57050
|
-
/**
|
|
57051
|
-
*
|
|
57052
|
-
* @type {Float32Array}
|
|
57053
|
-
*/
|
|
57054
|
-
this.transform = new Float32Array(16);
|
|
57055
|
-
|
|
57056
|
-
array_copy(MATRIX_4_IDENTITY, 0, this.transform, 0, 16);
|
|
57057
|
-
|
|
57058
|
-
this.extractFaceIndexFromLeaf = extractFaceIndexFromLeaf_default;
|
|
57059
|
-
}
|
|
57060
|
-
|
|
57061
|
-
/**
|
|
57062
|
-
*
|
|
57063
|
-
* @param {*} leaf
|
|
57064
|
-
*/
|
|
57065
|
-
visitLeafIntersection(leaf) {
|
|
57066
|
-
|
|
57067
|
-
const geometry = this.geometry;
|
|
57068
|
-
|
|
57069
|
-
const geometryIndices = geometry.getIndex().array;
|
|
57070
|
-
const geometryVertices = geometry.getAttribute('position').array;
|
|
57071
|
-
|
|
57072
|
-
const extractFaceIndexFromLeaf = this.extractFaceIndexFromLeaf;
|
|
57073
|
-
|
|
57074
|
-
const index = extractFaceIndexFromLeaf(leaf);
|
|
57075
|
-
|
|
57076
|
-
bindGeometryFace(geometryIndices, geometryVertices, index);
|
|
57077
|
-
|
|
57078
|
-
const hitFound = rayTriangleIntersection(hit$1, this.origin, this.direction, vA, vB, vC);
|
|
57079
|
-
|
|
57080
|
-
if (hitFound) {
|
|
57081
|
-
|
|
57082
|
-
const d = this.origin.distanceSqrTo(hit$1);
|
|
57083
|
-
if (d < this.__bestDistance) {
|
|
57084
|
-
this.__bestDistance = d;
|
|
57085
|
-
this.__bestPosition.copy(hit$1);
|
|
57086
|
-
this.__bestIndex = index;
|
|
57087
|
-
}
|
|
57088
|
-
|
|
57089
|
-
}
|
|
57090
|
-
}
|
|
57091
|
-
|
|
57092
|
-
/**
|
|
57093
|
-
*
|
|
57094
|
-
* @param {SurfacePoint3} hit
|
|
57095
|
-
* @param {number} originX
|
|
57096
|
-
* @param {number} originY
|
|
57097
|
-
* @param {number} originZ
|
|
57098
|
-
* @param {number} directionX
|
|
57099
|
-
* @param {number} directionY
|
|
57100
|
-
* @param {number} directionZ
|
|
57101
|
-
* @returns {boolean}
|
|
57102
|
-
*/
|
|
57103
|
-
raycast(
|
|
57104
|
-
hit,
|
|
57105
|
-
originX, originY, originZ,
|
|
57106
|
-
directionX, directionY, directionZ
|
|
57107
|
-
) {
|
|
57108
|
-
|
|
57109
|
-
invert(m4_tmp, this.transform);
|
|
57110
|
-
|
|
57111
|
-
ray3_array_compose(
|
|
57112
|
-
ray_tmp,
|
|
57113
|
-
originX, originY, originZ,
|
|
57114
|
-
directionX, directionY, directionZ
|
|
57115
|
-
);
|
|
57116
|
-
|
|
57117
|
-
ray3_array_apply_matrix4(ray_tmp, 0,ray_tmp,0, m4_tmp);
|
|
57118
|
-
|
|
57119
|
-
const _originX = ray_tmp[0];
|
|
57120
|
-
const _originY = ray_tmp[1];
|
|
57121
|
-
const _originZ = ray_tmp[2];
|
|
57122
|
-
|
|
57123
|
-
const _directionX = ray_tmp[3];
|
|
57124
|
-
const _directionY = ray_tmp[4];
|
|
57125
|
-
const _directionZ = ray_tmp[5];
|
|
57126
|
-
|
|
57127
|
-
this.origin.set(_originX, _originY, _originZ);
|
|
57128
|
-
this.direction.set(_directionX, _directionY, _directionZ);
|
|
57129
|
-
|
|
57130
|
-
this.__bestDistance = Number.POSITIVE_INFINITY;
|
|
57131
|
-
|
|
57132
|
-
this.bvh.traverseRayLeafIntersections(_originX, _originY, _originZ, _directionX, _directionY, _directionZ, this.visitLeafIntersection, this);
|
|
57133
|
-
|
|
57134
|
-
if (this.__bestDistance !== Number.POSITIVE_INFINITY) {
|
|
57135
|
-
|
|
57136
|
-
const geometry = this.geometry;
|
|
57137
|
-
|
|
57138
|
-
const geometryIndices = geometry.getIndex().array;
|
|
57139
|
-
const geometryNormals = geometry.getAttribute('normal').array;
|
|
57140
|
-
|
|
57141
|
-
bindGeometryFaceNormal(geometryIndices, geometryNormals, this.__bestIndex);
|
|
57142
|
-
|
|
57143
|
-
hit.position.copy(this.__bestPosition);
|
|
57144
|
-
hit.normal.copy(vNormal);
|
|
57145
|
-
|
|
57146
|
-
hit.applyMatrix4(this.transform);
|
|
57147
|
-
|
|
57148
|
-
return true;
|
|
57149
|
-
} else {
|
|
57150
|
-
//no hit
|
|
57151
|
-
return false;
|
|
57152
|
-
}
|
|
57153
|
-
}
|
|
57154
|
-
}
|
|
57155
|
-
|
|
57156
|
-
class ObservedInteger extends Number {
|
|
57157
|
-
/**
|
|
57158
|
-
* @readonly
|
|
57159
|
-
* @type {Signal}
|
|
57160
|
-
*/
|
|
57161
|
-
onChanged = new Signal();
|
|
57162
|
-
|
|
57163
|
-
/**
|
|
57164
|
-
*
|
|
57165
|
-
* @param {Number} [value]
|
|
57166
|
-
* @constructor
|
|
57167
|
-
*/
|
|
57168
|
-
constructor(value = 0) {
|
|
57169
|
-
super();
|
|
57170
|
-
|
|
57171
|
-
assert.isNumber(value, 'value');
|
|
57172
|
-
assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
|
|
57173
|
-
|
|
57174
|
-
|
|
57175
|
-
/**
|
|
57176
|
-
*
|
|
57177
|
-
* @type {Number}
|
|
57178
|
-
* @private
|
|
57179
|
-
*/
|
|
57180
|
-
this.__value = value;
|
|
57181
|
-
|
|
57182
|
-
}
|
|
57183
|
-
|
|
57184
|
-
/**
|
|
57185
|
-
*
|
|
57186
|
-
* @returns {Number}
|
|
57187
|
-
*/
|
|
57188
|
-
valueOf() {
|
|
57189
|
-
return this.getValue();
|
|
57190
|
-
}
|
|
57191
|
-
|
|
57192
|
-
toString() {
|
|
57193
|
-
return this.getValue().toString();
|
|
57194
|
-
}
|
|
57195
|
-
|
|
57196
|
-
/**
|
|
57197
|
-
*
|
|
57198
|
-
* @param {Number} value
|
|
57199
|
-
* @returns {ObservedInteger}
|
|
57200
|
-
*/
|
|
57201
|
-
set(value) {
|
|
57202
|
-
assert.isNumber(value, 'value');
|
|
57203
|
-
assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
|
|
57204
|
-
|
|
57205
|
-
const oldValue = this.__value;
|
|
57206
|
-
if (oldValue !== value) {
|
|
57207
|
-
this.__value = value;
|
|
57208
|
-
this.onChanged.send2(value, oldValue);
|
|
57209
|
-
}
|
|
57210
|
-
|
|
57211
|
-
return this;
|
|
57212
|
-
}
|
|
57213
|
-
|
|
57214
|
-
/**
|
|
57215
|
-
* Set value without dispatching change notification
|
|
57216
|
-
* @param {number} value
|
|
57217
|
-
*/
|
|
57218
|
-
setSilent(value) {
|
|
57219
|
-
assert.isNumber(value, 'value');
|
|
57220
|
-
assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
|
|
57221
|
-
|
|
57222
|
-
this.__value = value;
|
|
57223
|
-
}
|
|
57224
|
-
|
|
57225
|
-
/**
|
|
57226
|
-
*
|
|
57227
|
-
* @return {boolean}
|
|
57228
|
-
*/
|
|
57229
|
-
isZero() {
|
|
57230
|
-
return this.getValue() === 0;
|
|
57231
|
-
}
|
|
57232
|
-
|
|
57233
|
-
/**
|
|
57234
|
-
*
|
|
57235
|
-
* @param {ObservedInteger} other
|
|
57236
|
-
*/
|
|
57237
|
-
subtract(other) {
|
|
57238
|
-
this._add(-other.getValue());
|
|
57239
|
-
}
|
|
57240
|
-
|
|
57241
|
-
/**
|
|
57242
|
-
*
|
|
57243
|
-
* @param {number} value
|
|
57244
|
-
*/
|
|
57245
|
-
_subtract(value) {
|
|
57246
|
-
this.set(this.getValue() - value);
|
|
57247
|
-
}
|
|
57248
|
-
|
|
57249
|
-
/**
|
|
57250
|
-
*
|
|
57251
|
-
* @param {ObservedInteger} other
|
|
57252
|
-
*/
|
|
57253
|
-
add(other) {
|
|
57254
|
-
this._add(other.getValue());
|
|
57255
|
-
}
|
|
57256
|
-
|
|
57257
|
-
/**
|
|
57258
|
-
*
|
|
57259
|
-
* @param {number} value
|
|
57260
|
-
*/
|
|
57261
|
-
_add(value) {
|
|
57262
|
-
this.set(this.getValue() + value);
|
|
57263
|
-
}
|
|
57264
|
-
|
|
57265
|
-
/**
|
|
57266
|
-
* Increment the stored value by 1, same as adding 1
|
|
57267
|
-
*/
|
|
57268
|
-
increment() {
|
|
57269
|
-
this.set(this.getValue() + 1);
|
|
57270
|
-
}
|
|
57271
|
-
|
|
57272
|
-
/**
|
|
57273
|
-
* Decrement the stored value by 1, same as subtracting 1
|
|
57274
|
-
*/
|
|
57275
|
-
decrement() {
|
|
57276
|
-
this.set(this.getValue() - 1);
|
|
57277
|
-
}
|
|
57278
|
-
|
|
57279
|
-
/**
|
|
57280
|
-
*
|
|
57281
|
-
* @returns {Number}
|
|
57282
|
-
*/
|
|
57283
|
-
getValue() {
|
|
57284
|
-
return this.__value;
|
|
57285
|
-
}
|
|
57286
|
-
|
|
57287
|
-
/**
|
|
57288
|
-
*
|
|
57289
|
-
* @param {ObservedInteger} other
|
|
57290
|
-
*/
|
|
57291
|
-
copy(other) {
|
|
57292
|
-
this.set(other.__value);
|
|
57293
|
-
}
|
|
57294
|
-
|
|
57295
|
-
/**
|
|
57296
|
-
*
|
|
57297
|
-
* @param {ObservedInteger} other
|
|
57298
|
-
* @returns {boolean}
|
|
57299
|
-
*/
|
|
57300
|
-
equals(other) {
|
|
57301
|
-
return this.__value === other.__value;
|
|
57302
|
-
}
|
|
57336
|
+
*/
|
|
57337
|
+
function bindGeometryFace(indices, vertices, index) {
|
|
57338
|
+
const index3 = index * 3;
|
|
57303
57339
|
|
|
57304
|
-
|
|
57305
|
-
*
|
|
57306
|
-
* @returns {Number}
|
|
57307
|
-
*/
|
|
57308
|
-
hash() {
|
|
57309
|
-
return this.__value;
|
|
57310
|
-
}
|
|
57340
|
+
assert.lessThan(index3, indices.length, 'index underflow');
|
|
57311
57341
|
|
|
57312
|
-
|
|
57313
|
-
|
|
57314
|
-
|
|
57342
|
+
const a = indices[index3] * 3;
|
|
57343
|
+
const b = indices[index3 + 1] * 3;
|
|
57344
|
+
const c = indices[index3 + 2] * 3;
|
|
57315
57345
|
|
|
57316
|
-
|
|
57317
|
-
|
|
57318
|
-
|
|
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
|
+
}
|
|
57319
57350
|
|
|
57320
|
-
|
|
57321
|
-
*
|
|
57322
|
-
* @param {BinaryBuffer} buffer
|
|
57323
|
-
*/
|
|
57324
|
-
toBinaryBuffer(buffer) {
|
|
57325
|
-
const v = this.__value;
|
|
57351
|
+
const vNormal = new Vector3$1();
|
|
57326
57352
|
|
|
57327
|
-
|
|
57328
|
-
buffer.writeInt32(2147483647);
|
|
57329
|
-
} else if (v === -Infinity) {
|
|
57330
|
-
buffer.writeInt32(-2147483648);
|
|
57331
|
-
} else {
|
|
57332
|
-
//TODO it's possible to write encoded Infinity values by accident
|
|
57333
|
-
buffer.writeInt32(v);
|
|
57334
|
-
}
|
|
57335
|
-
}
|
|
57353
|
+
function bindGeometryFaceNormal(indices, normals, index) {
|
|
57336
57354
|
|
|
57337
|
-
|
|
57338
|
-
*
|
|
57339
|
-
* @param {BinaryBuffer} buffer
|
|
57340
|
-
*/
|
|
57341
|
-
fromBinaryBuffer(buffer) {
|
|
57342
|
-
const value = buffer.readInt32();
|
|
57355
|
+
const index3 = index * 3;
|
|
57343
57356
|
|
|
57344
|
-
|
|
57345
|
-
|
|
57346
|
-
|
|
57347
|
-
this.set(-Infinity);
|
|
57348
|
-
} else {
|
|
57349
|
-
this.set(value);
|
|
57350
|
-
}
|
|
57351
|
-
}
|
|
57352
|
-
}
|
|
57357
|
+
const a = indices[index3] * 3;
|
|
57358
|
+
const b = indices[index3 + 1] * 3;
|
|
57359
|
+
const c = indices[index3 + 2] * 3;
|
|
57353
57360
|
|
|
57361
|
+
//read vertex normals
|
|
57362
|
+
const naX = normals[a];
|
|
57363
|
+
const naY = normals[a + 1];
|
|
57364
|
+
const naZ = normals[a + 2];
|
|
57354
57365
|
|
|
57355
|
-
|
|
57356
|
-
|
|
57357
|
-
|
|
57358
|
-
*/
|
|
57359
|
-
ObservedInteger.prototype.isObservedInteger = true;
|
|
57360
|
-
|
|
57361
|
-
/**
|
|
57362
|
-
* Compute fraction of linear interpolation
|
|
57363
|
-
* @param {number} a
|
|
57364
|
-
* @param {number} b
|
|
57365
|
-
* @param {number} value
|
|
57366
|
-
* @returns {number} fraction
|
|
57367
|
-
*/
|
|
57368
|
-
function inverseLerp(a, b, value) {
|
|
57369
|
-
const range = b - a;
|
|
57370
|
-
const scaledValue = value - a;
|
|
57366
|
+
const nbX = normals[b];
|
|
57367
|
+
const nbY = normals[b + 1];
|
|
57368
|
+
const nbZ = normals[b + 2];
|
|
57371
57369
|
|
|
57372
|
-
|
|
57370
|
+
const ncX = normals[c];
|
|
57371
|
+
const ncY = normals[c + 1];
|
|
57372
|
+
const ncZ = normals[c + 2];
|
|
57373
57373
|
|
|
57374
|
-
|
|
57374
|
+
//add normals
|
|
57375
|
+
const nsX = (naX + nbX + ncX);
|
|
57376
|
+
const nsY = (naY + nbY + ncY);
|
|
57377
|
+
const nsZ = (naZ + nbZ + ncZ);
|
|
57375
57378
|
|
|
57376
|
-
|
|
57379
|
+
//normalize
|
|
57380
|
+
const l = v3_length(nsX, nsY, nsZ);
|
|
57381
|
+
const m = 1 / l;
|
|
57377
57382
|
|
|
57378
|
-
|
|
57379
|
-
|
|
57383
|
+
const nx = nsX * m;
|
|
57384
|
+
const ny = nsY * m;
|
|
57385
|
+
const nz = nsZ * m;
|
|
57380
57386
|
|
|
57381
|
-
|
|
57382
|
-
}
|
|
57383
|
-
|
|
57384
|
-
/**
|
|
57385
|
-
*
|
|
57386
|
-
* @param {number} min
|
|
57387
|
-
* @param {number} max
|
|
57388
|
-
* @constructor
|
|
57389
|
-
*/
|
|
57387
|
+
vNormal.set(nx, ny, nz);
|
|
57388
|
+
}
|
|
57390
57389
|
|
|
57391
|
-
class NumericInterval {
|
|
57392
|
-
/**
|
|
57393
|
-
*
|
|
57394
|
-
* @param {number} [min=-Infinity]
|
|
57395
|
-
* @param {number} [max=Infinity]
|
|
57396
|
-
* @constructor
|
|
57397
|
-
*/
|
|
57398
|
-
constructor(
|
|
57399
|
-
min = Number.NEGATIVE_INFINITY,
|
|
57400
|
-
max = Number.POSITIVE_INFINITY
|
|
57401
|
-
) {
|
|
57402
|
-
assert.isNumber(min, 'min');
|
|
57403
|
-
assert.isNumber(max, 'max');
|
|
57404
57390
|
|
|
57405
|
-
|
|
57391
|
+
function extractFaceIndexFromLeaf_default(leaf) {
|
|
57392
|
+
return leaf.object;
|
|
57393
|
+
}
|
|
57406
57394
|
|
|
57395
|
+
class BVHGeometryRaycaster {
|
|
57396
|
+
constructor() {
|
|
57407
57397
|
/**
|
|
57408
57398
|
*
|
|
57409
|
-
* @type {
|
|
57399
|
+
* @type {BufferGeometry|null}
|
|
57410
57400
|
*/
|
|
57411
|
-
this.
|
|
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;
|
|
57412
57418
|
/**
|
|
57413
57419
|
*
|
|
57414
57420
|
* @type {number}
|
|
57415
57421
|
*/
|
|
57416
|
-
this.
|
|
57422
|
+
this.resolution = 0;
|
|
57417
57423
|
|
|
57418
|
-
|
|
57419
|
-
|
|
57424
|
+
/**
|
|
57425
|
+
*
|
|
57426
|
+
* @type {Vector2|null}
|
|
57427
|
+
*/
|
|
57428
|
+
this.size = null;
|
|
57420
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
|
+
}
|
|
57421
57448
|
|
|
57422
57449
|
/**
|
|
57423
57450
|
*
|
|
57424
|
-
* @param {
|
|
57425
|
-
* @param {number} max
|
|
57451
|
+
* @param {*} leaf
|
|
57426
57452
|
*/
|
|
57427
|
-
|
|
57428
|
-
assert.isNumber(min, 'min');
|
|
57429
|
-
assert.isNumber(max, 'max');
|
|
57453
|
+
visitLeafIntersection(leaf) {
|
|
57430
57454
|
|
|
57431
|
-
|
|
57432
|
-
assert.notNaN(max, 'max');
|
|
57455
|
+
const geometry = this.geometry;
|
|
57433
57456
|
|
|
57434
|
-
|
|
57457
|
+
const geometryIndices = geometry.getIndex().array;
|
|
57458
|
+
const geometryVertices = geometry.getAttribute('position').array;
|
|
57435
57459
|
|
|
57436
|
-
const
|
|
57437
|
-
const oldMax = this.max;
|
|
57460
|
+
const extractFaceIndexFromLeaf = this.extractFaceIndexFromLeaf;
|
|
57438
57461
|
|
|
57439
|
-
|
|
57440
|
-
this.min = min;
|
|
57441
|
-
this.max = max;
|
|
57462
|
+
const index = extractFaceIndexFromLeaf(leaf);
|
|
57442
57463
|
|
|
57443
|
-
|
|
57444
|
-
|
|
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;
|
|
57445
57475
|
}
|
|
57476
|
+
|
|
57446
57477
|
}
|
|
57447
57478
|
}
|
|
57448
57479
|
|
|
57449
57480
|
/**
|
|
57450
57481
|
*
|
|
57451
|
-
* @param {
|
|
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}
|
|
57452
57490
|
*/
|
|
57453
|
-
|
|
57454
|
-
|
|
57455
|
-
|
|
57491
|
+
raycast(
|
|
57492
|
+
hit,
|
|
57493
|
+
originX, originY, originZ,
|
|
57494
|
+
directionX, directionY, directionZ
|
|
57495
|
+
) {
|
|
57456
57496
|
|
|
57457
|
-
|
|
57458
|
-
*
|
|
57459
|
-
* @param {number} value
|
|
57460
|
-
*/
|
|
57461
|
-
multiplyScalar(value) {
|
|
57462
|
-
const v0 = this.min * value;
|
|
57463
|
-
const v1 = this.max * value;
|
|
57497
|
+
invert(m4_tmp, this.transform);
|
|
57464
57498
|
|
|
57465
|
-
|
|
57466
|
-
|
|
57467
|
-
|
|
57468
|
-
|
|
57499
|
+
ray3_array_compose(
|
|
57500
|
+
ray_tmp,
|
|
57501
|
+
originX, originY, originZ,
|
|
57502
|
+
directionX, directionY, directionZ
|
|
57503
|
+
);
|
|
57469
57504
|
|
|
57470
|
-
|
|
57471
|
-
}
|
|
57472
|
-
}
|
|
57505
|
+
ray3_array_apply_matrix4(ray_tmp, 0,ray_tmp,0, m4_tmp);
|
|
57473
57506
|
|
|
57474
|
-
|
|
57475
|
-
|
|
57476
|
-
|
|
57477
|
-
* @returns {number}
|
|
57478
|
-
*/
|
|
57479
|
-
normalizeValue(v) {
|
|
57480
|
-
return inverseLerp(this.min, this.max, v);
|
|
57481
|
-
}
|
|
57507
|
+
const _originX = ray_tmp[0];
|
|
57508
|
+
const _originY = ray_tmp[1];
|
|
57509
|
+
const _originZ = ray_tmp[2];
|
|
57482
57510
|
|
|
57483
|
-
|
|
57484
|
-
|
|
57485
|
-
|
|
57486
|
-
*/
|
|
57487
|
-
isZero() {
|
|
57488
|
-
return this.min === 0 && this.max === 0;
|
|
57489
|
-
}
|
|
57511
|
+
const _directionX = ray_tmp[3];
|
|
57512
|
+
const _directionY = ray_tmp[4];
|
|
57513
|
+
const _directionZ = ray_tmp[5];
|
|
57490
57514
|
|
|
57491
|
-
|
|
57492
|
-
|
|
57493
|
-
* In other words if span is 0
|
|
57494
|
-
* @returns {boolean}
|
|
57495
|
-
*/
|
|
57496
|
-
isExact() {
|
|
57497
|
-
return this.min === this.max;
|
|
57498
|
-
}
|
|
57515
|
+
this.origin.set(_originX, _originY, _originZ);
|
|
57516
|
+
this.direction.set(_directionX, _directionY, _directionZ);
|
|
57499
57517
|
|
|
57500
|
-
|
|
57501
|
-
*
|
|
57502
|
-
* @returns {number}
|
|
57503
|
-
*/
|
|
57504
|
-
computeAverage() {
|
|
57505
|
-
return (this.min + this.max) / 2;
|
|
57506
|
-
}
|
|
57518
|
+
this.__bestDistance = Number.POSITIVE_INFINITY;
|
|
57507
57519
|
|
|
57508
|
-
|
|
57509
|
-
*
|
|
57510
|
-
* @param {function} random Random number generator function, must return values between 0 and 1
|
|
57511
|
-
* @returns {number}
|
|
57512
|
-
*/
|
|
57513
|
-
sampleRandom(random) {
|
|
57514
|
-
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);
|
|
57515
57521
|
|
|
57516
|
-
|
|
57517
|
-
}
|
|
57522
|
+
if (this.__bestDistance !== Number.POSITIVE_INFINITY) {
|
|
57518
57523
|
|
|
57519
|
-
|
|
57520
|
-
this.set(json.min, json.max);
|
|
57521
|
-
}
|
|
57524
|
+
const geometry = this.geometry;
|
|
57522
57525
|
|
|
57523
|
-
|
|
57524
|
-
|
|
57525
|
-
min: this.min,
|
|
57526
|
-
max: this.max
|
|
57527
|
-
};
|
|
57528
|
-
}
|
|
57526
|
+
const geometryIndices = geometry.getIndex().array;
|
|
57527
|
+
const geometryNormals = geometry.getAttribute('normal').array;
|
|
57529
57528
|
|
|
57530
|
-
|
|
57531
|
-
*
|
|
57532
|
-
* @param {BinaryBuffer} buffer
|
|
57533
|
-
*/
|
|
57534
|
-
toBinaryBuffer(buffer) {
|
|
57535
|
-
buffer.writeFloat64(this.min);
|
|
57536
|
-
buffer.writeFloat64(this.max);
|
|
57537
|
-
}
|
|
57529
|
+
bindGeometryFaceNormal(geometryIndices, geometryNormals, this.__bestIndex);
|
|
57538
57530
|
|
|
57539
|
-
|
|
57540
|
-
|
|
57541
|
-
* @param {BinaryBuffer} buffer
|
|
57542
|
-
*/
|
|
57543
|
-
fromBinaryBuffer(buffer) {
|
|
57544
|
-
this.min = buffer.readFloat64();
|
|
57545
|
-
this.max = buffer.readFloat64();
|
|
57546
|
-
}
|
|
57531
|
+
hit.position.copy(this.__bestPosition);
|
|
57532
|
+
hit.normal.copy(vNormal);
|
|
57547
57533
|
|
|
57548
|
-
|
|
57549
|
-
|
|
57550
|
-
|
|
57551
|
-
|
|
57552
|
-
|
|
57553
|
-
|
|
57554
|
-
|
|
57534
|
+
hit.applyMatrix4(this.transform);
|
|
57535
|
+
|
|
57536
|
+
return true;
|
|
57537
|
+
} else {
|
|
57538
|
+
//no hit
|
|
57539
|
+
return false;
|
|
57540
|
+
}
|
|
57555
57541
|
}
|
|
57542
|
+
}
|
|
57543
|
+
|
|
57544
|
+
/**
|
|
57545
|
+
* Created by Alex on 28/01/2017.
|
|
57546
|
+
*/
|
|
57556
57547
|
|
|
57557
|
-
|
|
57558
|
-
|
|
57559
|
-
|
|
57560
|
-
|
|
57561
|
-
|
|
57562
|
-
|
|
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
|
+
}
|
|
57563
57554
|
|
|
57564
|
-
|
|
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);
|
|
57565
57563
|
|
|
57566
|
-
|
|
57567
|
-
}
|
|
57564
|
+
prepareObject(result);
|
|
57568
57565
|
|
|
57569
|
-
|
|
57570
|
-
* Distance between min and max (= max - min)
|
|
57571
|
-
* @returns {number}
|
|
57572
|
-
*/
|
|
57573
|
-
get span() {
|
|
57574
|
-
return this.max - this.min;
|
|
57575
|
-
}
|
|
57566
|
+
return result;
|
|
57576
57567
|
}
|
|
57577
57568
|
|
|
57578
57569
|
/**
|
|
57579
|
-
*
|
|
57580
|
-
* @
|
|
57570
|
+
*
|
|
57571
|
+
* @param {BufferGeometry} geometry
|
|
57572
|
+
* @param {THREE.Material} material
|
|
57573
|
+
* @returns {THREE.SkinnedMesh}
|
|
57581
57574
|
*/
|
|
57582
|
-
|
|
57575
|
+
function createSkinnedMesh(geometry, material) {
|
|
57576
|
+
const result = new SkinnedMesh(geometry, material);
|
|
57577
|
+
|
|
57578
|
+
prepareObject(result);
|
|
57579
|
+
|
|
57580
|
+
return result;
|
|
57581
|
+
}
|
|
57583
57582
|
|
|
57584
57583
|
/**
|
|
57585
|
-
*
|
|
57586
|
-
* @
|
|
57584
|
+
*
|
|
57585
|
+
* @param {Material} material
|
|
57587
57586
|
*/
|
|
57588
|
-
|
|
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
|
+
|
|
57589
57598
|
/**
|
|
57590
|
-
*
|
|
57591
|
-
* @
|
|
57599
|
+
*
|
|
57600
|
+
* @returns {Group}
|
|
57592
57601
|
*/
|
|
57593
|
-
|
|
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
|
+
};
|
|
57594
57616
|
|
|
57595
57617
|
/**
|
|
57596
57618
|
* Created by Alex on 09/11/2014.
|
|
57597
57619
|
*/
|
|
57598
57620
|
|
|
57621
|
+
|
|
57622
|
+
const EMPTY_GEOMETRY = new BufferGeometry();
|
|
57623
|
+
const DEFAULT_MATERIAL = new MeshBasicMaterial();
|
|
57624
|
+
|
|
57599
57625
|
/**
|
|
57600
57626
|
* terrain tile is a part of a 2d array
|
|
57601
57627
|
*/
|
|
@@ -57611,7 +57637,7 @@ class TerrainTile {
|
|
|
57611
57637
|
* @type {Material}
|
|
57612
57638
|
*/
|
|
57613
57639
|
material = null;
|
|
57614
|
-
mesh = ThreeFactory.createMesh();
|
|
57640
|
+
mesh = ThreeFactory.createMesh(EMPTY_GEOMETRY, DEFAULT_MATERIAL);
|
|
57615
57641
|
|
|
57616
57642
|
|
|
57617
57643
|
/**
|
|
@@ -60055,70 +60081,70 @@ class TerrainTileManager {
|
|
|
60055
60081
|
const raycastBVHVisitor = new RaycastBVHVisitor();
|
|
60056
60082
|
const firstRayIntersectionTerrainBVHVisitor = new FirstRayIntersectionTerrainBVHVisitor();
|
|
60057
60083
|
|
|
60058
|
-
|
|
60084
|
+
class TerrainPreview {
|
|
60059
60085
|
/**
|
|
60060
60086
|
*
|
|
60061
60087
|
* @type {String}
|
|
60062
60088
|
*/
|
|
60063
|
-
|
|
60089
|
+
url = "";
|
|
60064
60090
|
|
|
60065
60091
|
/**
|
|
60066
60092
|
*
|
|
60067
60093
|
* @type {Vector2}
|
|
60068
60094
|
*/
|
|
60069
|
-
|
|
60095
|
+
offset = new Vector2(0, 0);
|
|
60070
60096
|
/**
|
|
60071
60097
|
*
|
|
60072
60098
|
* @type {Vector2}
|
|
60073
60099
|
*/
|
|
60074
|
-
|
|
60075
|
-
}
|
|
60100
|
+
scale = new Vector2(1, 1);
|
|
60076
60101
|
|
|
60077
|
-
/**
|
|
60078
|
-
|
|
60079
|
-
|
|
60080
|
-
|
|
60081
|
-
|
|
60082
|
-
|
|
60083
|
-
|
|
60084
|
-
|
|
60085
|
-
}
|
|
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
|
+
}
|
|
60086
60111
|
|
|
60087
|
-
|
|
60088
|
-
|
|
60089
|
-
|
|
60090
|
-
|
|
60091
|
-
|
|
60092
|
-
|
|
60093
|
-
}
|
|
60112
|
+
toJSON() {
|
|
60113
|
+
return {
|
|
60114
|
+
url: this.url,
|
|
60115
|
+
offset: this.offset.toJSON(),
|
|
60116
|
+
scale: this.scale.toJSON()
|
|
60117
|
+
};
|
|
60118
|
+
}
|
|
60094
60119
|
|
|
60095
|
-
|
|
60096
|
-
|
|
60097
|
-
|
|
60098
|
-
|
|
60099
|
-
}
|
|
60120
|
+
fromJSON(obj) {
|
|
60121
|
+
this.url = obj.url;
|
|
60122
|
+
this.offset.fromJSON(obj.offset);
|
|
60123
|
+
this.scale.fromJSON(obj.scale);
|
|
60124
|
+
}
|
|
60100
60125
|
|
|
60101
|
-
/**
|
|
60102
|
-
|
|
60103
|
-
|
|
60104
|
-
|
|
60105
|
-
|
|
60106
|
-
|
|
60126
|
+
/**
|
|
60127
|
+
*
|
|
60128
|
+
* @param {BinaryBuffer} buffer
|
|
60129
|
+
*/
|
|
60130
|
+
toBinaryBuffer(buffer) {
|
|
60131
|
+
buffer.writeUTF8String(this.url);
|
|
60107
60132
|
|
|
60108
|
-
|
|
60109
|
-
|
|
60110
|
-
}
|
|
60133
|
+
this.offset.toBinaryBuffer(buffer);
|
|
60134
|
+
this.scale.toBinaryBuffer(buffer);
|
|
60135
|
+
}
|
|
60111
60136
|
|
|
60112
|
-
/**
|
|
60113
|
-
|
|
60114
|
-
|
|
60115
|
-
|
|
60116
|
-
|
|
60117
|
-
|
|
60137
|
+
/**
|
|
60138
|
+
*
|
|
60139
|
+
* @param {BinaryBuffer} buffer
|
|
60140
|
+
*/
|
|
60141
|
+
fromBinaryBuffer(buffer) {
|
|
60142
|
+
this.url = buffer.readUTF8String();
|
|
60118
60143
|
|
|
60119
|
-
|
|
60120
|
-
|
|
60121
|
-
}
|
|
60144
|
+
this.offset.fromBinaryBuffer(buffer);
|
|
60145
|
+
this.scale.fromBinaryBuffer(buffer);
|
|
60146
|
+
}
|
|
60147
|
+
}
|
|
60122
60148
|
|
|
60123
60149
|
/**
|
|
60124
60150
|
* NOTE, trying to keep to IANA registry: https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
@@ -68647,8 +68673,10 @@ class EBBVHLeafProxy {
|
|
|
68647
68673
|
unlink() {
|
|
68648
68674
|
assert.equal(this.is_linked, true, 'not linked');
|
|
68649
68675
|
|
|
68650
|
-
this.#
|
|
68651
|
-
|
|
68676
|
+
const node_id = this.#node_id;
|
|
68677
|
+
|
|
68678
|
+
this.#tree.remove_leaf(node_id);
|
|
68679
|
+
this.#tree.release_node(node_id);
|
|
68652
68680
|
|
|
68653
68681
|
this.#node_id = -1;
|
|
68654
68682
|
this.#tree = null;
|
|
@@ -109983,7 +110011,7 @@ class WebEnginePlatform extends EnginePlatform {
|
|
|
109983
110011
|
class Tag {
|
|
109984
110012
|
/**
|
|
109985
110013
|
* @private
|
|
109986
|
-
* @type {
|
|
110014
|
+
* @type {string[]}
|
|
109987
110015
|
*/
|
|
109988
110016
|
values = [];
|
|
109989
110017
|
|
|
@@ -110165,41 +110193,31 @@ class Tag {
|
|
|
110165
110193
|
* @return {boolean}
|
|
110166
110194
|
*/
|
|
110167
110195
|
equals(other) {
|
|
110168
|
-
|
|
110169
|
-
const s0 = this.values;
|
|
110170
|
-
|
|
110171
|
-
const s1 = other.values;
|
|
110172
|
-
|
|
110173
|
-
const n0 = s0.length;
|
|
110174
|
-
const n1 = s1.length;
|
|
110175
|
-
|
|
110176
|
-
if (n0 !== n1) {
|
|
110177
|
-
//wrong length
|
|
110178
|
-
return false;
|
|
110179
|
-
}
|
|
110180
|
-
|
|
110181
|
-
for (let i = 0; i < n0; i++) {
|
|
110182
|
-
const v0 = s0[i];
|
|
110183
|
-
const v1 = s1[i];
|
|
110184
|
-
|
|
110185
|
-
if (v0 !== v1) {
|
|
110186
|
-
return false;
|
|
110187
|
-
}
|
|
110188
|
-
}
|
|
110189
|
-
|
|
110190
|
-
return true;
|
|
110196
|
+
return isArrayEqualStrict(this.values, other.values);
|
|
110191
110197
|
}
|
|
110192
110198
|
|
|
110193
110199
|
toJSON() {
|
|
110194
110200
|
return this.values;
|
|
110195
110201
|
}
|
|
110196
110202
|
|
|
110203
|
+
/**
|
|
110204
|
+
*
|
|
110205
|
+
* @param {string[]|string} json
|
|
110206
|
+
*/
|
|
110197
110207
|
fromJSON(json) {
|
|
110208
|
+
|
|
110209
|
+
this.clear();
|
|
110210
|
+
|
|
110198
110211
|
if (typeof json === "string") {
|
|
110199
|
-
this.clear();
|
|
110200
110212
|
this.add(json);
|
|
110201
|
-
} else
|
|
110202
|
-
|
|
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
|
+
}
|
|
110203
110221
|
}
|
|
110204
110222
|
}
|
|
110205
110223
|
|