@woosh/meep-engine 2.68.0 → 2.70.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/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +1090 -1581
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +1090 -1581
- package/package.json +1 -1
- package/src/core/__module.js +1 -0
- package/src/core/binary/BinaryBuffer.js +37 -31
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +76 -52
- package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +5 -7
- package/src/core/bvh2/binary/2/bvh32_query_user_data_overlaps_clipping_volume.js +94 -0
- package/src/core/bvh2/binary/2/bvh32_query_user_data_ray.js +17 -18
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +4 -2
- package/src/core/geom/3d/aabb/AABB3.js +14 -14
- package/src/core/geom/3d/aabb/aabb3_array_intersects_clipping_volume_array.js +30 -0
- package/src/core/geom/3d/aabb/aabb3_intersects_clipping_volume_array.js +51 -0
- package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.js +3 -2
- package/src/core/geom/3d/frustum/{read_frustum_planes_to_array.js → read_three_planes_to_array.js} +5 -3
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +34 -0
- package/src/core/geom/3d/morton/v3_morton_encode_transformed.js +2 -1
- package/src/core/geom/3d/quaternion/quat3_createFromAxisAngle.js +11 -0
- package/src/core/geom/3d/quaternion/quat_decode_from_uint32.js +53 -0
- package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +106 -0
- package/src/core/geom/3d/triangle/triangle_intersects_clipping_volume.js +51 -0
- package/src/core/geom/Quaternion.js +8 -142
- package/src/core/geom/Vector2.js +6 -7
- package/src/core/geom/Vector3.js +15 -82
- package/src/core/geom/vec3/v3_binary_equality_decode.js +44 -0
- package/src/core/geom/vec3/v3_binary_equality_encode.js +47 -0
- package/src/core/primitives/numbers/computeHashFloat.js +2 -2
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +2 -2
- package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +9 -46
- package/src/engine/ecs/transform/Transform.js +8 -9
- package/src/engine/ecs/transform/TransformSerializationAdapter.js +18 -7
- package/src/engine/graphics/ecs/mesh/Mesh.js +11 -11
- package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts +2 -2
- package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +79 -36
- package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_overlap_clipping_volume.js +88 -0
- package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_raycast.js +108 -0
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js +4 -30
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_unindexed_geometry.js +30 -0
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js +41 -0
- package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +2 -2
- package/src/engine/graphics/render/view/CameraView.js +8 -8
- package/src/core/bvh2/binary/BinaryBVH.js +0 -281
- package/src/core/bvh2/binary/IndexedBinaryBVH.js +0 -407
- package/src/core/bvh2/binary/IndexedBinaryBVH.spec.js +0 -27
- package/src/core/bvh2/binary/IndexedBinaryBVHVisitor.js +0 -11
- package/src/core/bvh2/binary/NodeType.js +0 -8
- package/src/core/bvh2/binary/RayLeafIntersectionVisitor.js +0 -59
- package/src/core/geom/3d/aabb/aabb3_array_intersects_frustum_array.js +0 -20
- package/src/core/geom/3d/aabb/aabb3_intersects_frustum_array.js +0 -35
- package/src/engine/graphics/geometry/buffered/query/ClippingPlaneContainmentComputingVisitor.js +0 -195
- package/src/engine/graphics/geometry/buffered/query/GeometryVisitor.js +0 -87
- package/src/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +0 -206
- package/src/engine/graphics/geometry/bvh/buffered/BinaryBVHFromBufferGeometry.js +0 -123
package/src/core/geom/Vector3.js
CHANGED
|
@@ -5,17 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "../assert.js";
|
|
7
7
|
import Signal from "../events/signal/Signal.js";
|
|
8
|
+
import { EPSILON } from "../math/EPSILON.js";
|
|
9
|
+
import { epsilonEquals } from "../math/epsilonEquals.js";
|
|
8
10
|
import { lerp } from "../math/lerp.js";
|
|
9
11
|
import { sign } from "../math/sign.js";
|
|
12
|
+
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
13
|
+
import { v3_angle_between } from "./vec3/v3_angle_between.js";
|
|
14
|
+
import { v3_binary_equality_decode } from "./vec3/v3_binary_equality_decode.js";
|
|
15
|
+
import { v3_binary_equality_encode } from "./vec3/v3_binary_equality_encode.js";
|
|
10
16
|
import { v3_dot } from "./vec3/v3_dot.js";
|
|
11
|
-
import { v3_length_sqr } from "./vec3/v3_length_sqr.js";
|
|
12
17
|
import { v3_length } from "./vec3/v3_length.js";
|
|
13
|
-
import {
|
|
18
|
+
import { v3_length_sqr } from "./vec3/v3_length_sqr.js";
|
|
14
19
|
import { v3_lerp } from "./vec3/v3_lerp.js";
|
|
15
20
|
import { v3_slerp } from "./vec3/v3_slerp.js";
|
|
16
|
-
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
17
|
-
import { epsilonEquals } from "../math/epsilonEquals.js";
|
|
18
|
-
import { EPSILON } from "../math/EPSILON.js";
|
|
19
21
|
|
|
20
22
|
class Vector3 {
|
|
21
23
|
/**
|
|
@@ -856,100 +858,31 @@ class Vector3 {
|
|
|
856
858
|
/**
|
|
857
859
|
*
|
|
858
860
|
* @param {BinaryBuffer} buffer
|
|
861
|
+
* @deprecated use dedicated method directly instead
|
|
859
862
|
*/
|
|
860
863
|
toBinaryBufferFloat32_EqualityEncoded(buffer) {
|
|
861
864
|
const x = this.x;
|
|
862
865
|
const y = this.y;
|
|
863
866
|
const z = this.z;
|
|
864
867
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
if (x === y) {
|
|
868
|
-
header |= 1;
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
if (y === z) {
|
|
872
|
-
header |= 2;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
if (x === z) {
|
|
876
|
-
header |= 4;
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
buffer.writeUint8(header);
|
|
880
|
-
|
|
881
|
-
if ((header & 7) === 7) {
|
|
882
|
-
//all components are the same
|
|
883
|
-
buffer.writeFloat32(x);
|
|
884
|
-
} else if (header === 1) {
|
|
885
|
-
//X and Y are the same, Z is different
|
|
886
|
-
buffer.writeFloat32(x);
|
|
887
|
-
buffer.writeFloat32(z);
|
|
888
|
-
} else if (header === 2) {
|
|
889
|
-
//Y and Z are the same, X is different
|
|
890
|
-
buffer.writeFloat32(x);
|
|
891
|
-
buffer.writeFloat32(y);
|
|
892
|
-
} else if (header === 4) {
|
|
893
|
-
//X and Z are the same, Y is different
|
|
894
|
-
buffer.writeFloat32(x);
|
|
895
|
-
buffer.writeFloat32(y);
|
|
896
|
-
} else {
|
|
897
|
-
//scale components are different
|
|
898
|
-
buffer.writeFloat32(x);
|
|
899
|
-
buffer.writeFloat32(y);
|
|
900
|
-
buffer.writeFloat32(z);
|
|
901
|
-
}
|
|
868
|
+
v3_binary_equality_encode(buffer, x, y, z);
|
|
902
869
|
}
|
|
903
870
|
|
|
904
871
|
/**
|
|
905
872
|
* Uses an extra byte for a header. Only writes unique components. Useful for things like scale where all components usually have the same value
|
|
906
873
|
* @param {BinaryBuffer} buffer
|
|
874
|
+
* @deprecated use dedicated method directly instead
|
|
907
875
|
*/
|
|
908
876
|
fromBinaryBufferFloat32_EqualityEncoded(buffer) {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
let x = 0;
|
|
912
|
-
let y = 0;
|
|
913
|
-
let z = 0;
|
|
914
|
-
|
|
915
|
-
if ((header & 7) === 7) {
|
|
916
|
-
//all scale components are the same
|
|
917
|
-
x = buffer.readFloat32();
|
|
918
|
-
y = x;
|
|
919
|
-
z = x;
|
|
920
|
-
} else if ((header & 1) === 1) {
|
|
921
|
-
//X and Y are the same, Z is different
|
|
922
|
-
x = buffer.readFloat32();
|
|
923
|
-
y = x;
|
|
924
|
-
z = buffer.readFloat32();
|
|
925
|
-
} else if ((header & 2) === 2) {
|
|
926
|
-
//Y and Z are the same, X is different
|
|
927
|
-
x = buffer.readFloat32();
|
|
928
|
-
y = buffer.readFloat32();
|
|
929
|
-
z = y;
|
|
930
|
-
} else if ((header & 4) === 4) {
|
|
931
|
-
//X and Z are the same, Y is different
|
|
932
|
-
x = buffer.readFloat32();
|
|
933
|
-
y = buffer.readFloat32();
|
|
934
|
-
z = x;
|
|
935
|
-
} else {
|
|
936
|
-
//scale components are different
|
|
937
|
-
x = buffer.readFloat32();
|
|
938
|
-
y = buffer.readFloat32();
|
|
939
|
-
z = buffer.readFloat32();
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
this.set(x, y, z);
|
|
877
|
+
v3_binary_equality_decode(buffer, this, 0);
|
|
943
878
|
}
|
|
944
879
|
|
|
945
880
|
hash() {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
hash = ((hash << 5) - hash) + computeHashFloat(this.z);
|
|
881
|
+
const x = computeHashFloat(this.x);
|
|
882
|
+
const y = computeHashFloat(this.y);
|
|
883
|
+
const z = computeHashFloat(this.z);
|
|
951
884
|
|
|
952
|
-
return
|
|
885
|
+
return x ^ (y << 1) ^ (z << 2);
|
|
953
886
|
}
|
|
954
887
|
|
|
955
888
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BinaryBuffer} buffer
|
|
4
|
+
* @param {number[]} result
|
|
5
|
+
* @param {number} result_offset
|
|
6
|
+
*/
|
|
7
|
+
export function v3_binary_equality_decode(buffer, result, result_offset) {
|
|
8
|
+
const header = buffer.readUint8();
|
|
9
|
+
|
|
10
|
+
let x = 0;
|
|
11
|
+
let y = 0;
|
|
12
|
+
let z = 0;
|
|
13
|
+
|
|
14
|
+
if ((header & 7) === 7) {
|
|
15
|
+
//all scale components are the same
|
|
16
|
+
x = buffer.readFloat32();
|
|
17
|
+
y = x;
|
|
18
|
+
z = x;
|
|
19
|
+
} else if ((header & 1) === 1) {
|
|
20
|
+
//X and Y are the same, Z is different
|
|
21
|
+
x = buffer.readFloat32();
|
|
22
|
+
y = x;
|
|
23
|
+
z = buffer.readFloat32();
|
|
24
|
+
} else if ((header & 2) === 2) {
|
|
25
|
+
//Y and Z are the same, X is different
|
|
26
|
+
x = buffer.readFloat32();
|
|
27
|
+
y = buffer.readFloat32();
|
|
28
|
+
z = y;
|
|
29
|
+
} else if ((header & 4) === 4) {
|
|
30
|
+
//X and Z are the same, Y is different
|
|
31
|
+
x = buffer.readFloat32();
|
|
32
|
+
y = buffer.readFloat32();
|
|
33
|
+
z = x;
|
|
34
|
+
} else {
|
|
35
|
+
//scale components are different
|
|
36
|
+
x = buffer.readFloat32();
|
|
37
|
+
y = buffer.readFloat32();
|
|
38
|
+
z = buffer.readFloat32();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
result[result_offset] = x;
|
|
42
|
+
result[result_offset + 1] = y;
|
|
43
|
+
result[result_offset + 2] = z;
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BinaryBuffer} buffer
|
|
4
|
+
* @param {number} x
|
|
5
|
+
* @param {number} y
|
|
6
|
+
* @param {number} z
|
|
7
|
+
*/
|
|
8
|
+
export function v3_binary_equality_encode(buffer, x, y, z){
|
|
9
|
+
|
|
10
|
+
let header = 0;
|
|
11
|
+
|
|
12
|
+
if (x === y) {
|
|
13
|
+
header |= 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (y === z) {
|
|
17
|
+
header |= 2;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (x === z) {
|
|
21
|
+
header |= 4;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
buffer.writeUint8(header);
|
|
25
|
+
|
|
26
|
+
if ((header & 7) === 7) {
|
|
27
|
+
//all components are the same
|
|
28
|
+
buffer.writeFloat32(x);
|
|
29
|
+
} else if (header === 1) {
|
|
30
|
+
//X and Y are the same, Z is different
|
|
31
|
+
buffer.writeFloat32(x);
|
|
32
|
+
buffer.writeFloat32(z);
|
|
33
|
+
} else if (header === 2) {
|
|
34
|
+
//Y and Z are the same, X is different
|
|
35
|
+
buffer.writeFloat32(x);
|
|
36
|
+
buffer.writeFloat32(y);
|
|
37
|
+
} else if (header === 4) {
|
|
38
|
+
//X and Z are the same, Y is different
|
|
39
|
+
buffer.writeFloat32(x);
|
|
40
|
+
buffer.writeFloat32(y);
|
|
41
|
+
} else {
|
|
42
|
+
//scale components are different
|
|
43
|
+
buffer.writeFloat32(x);
|
|
44
|
+
buffer.writeFloat32(y);
|
|
45
|
+
buffer.writeFloat32(z);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function computeHashFloat(v) {
|
|
7
7
|
//we break the number up into fractional and whole parts
|
|
8
|
-
const fraction = v % 1;
|
|
9
|
-
|
|
10
8
|
const whole = v | 0;
|
|
11
9
|
|
|
10
|
+
const fraction = v - whole;
|
|
11
|
+
|
|
12
12
|
//fractional part is scaled up into int32 range, this inexact method, as it will produce 0 hash for values below a certain threshold
|
|
13
13
|
const fractionHash = fraction * 1367130550;
|
|
14
14
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
bvh_query_user_data_overlaps_frustum
|
|
5
5
|
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
6
6
|
import { noop } from "../../../../core/function/Functions.js";
|
|
7
|
-
import {
|
|
7
|
+
import { read_three_planes_to_array } from "../../../../core/geom/3d/frustum/read_three_planes_to_array.js";
|
|
8
8
|
import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
9
9
|
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
10
10
|
import { CameraSystem } from '../../../graphics/ecs/camera/CameraSystem.js';
|
|
@@ -255,7 +255,7 @@ class TerrainSystem extends System {
|
|
|
255
255
|
|
|
256
256
|
for (let i = 0; i < frustums.length; i++) {
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
read_three_planes_to_array(frustums[i].planes, frustum);
|
|
259
259
|
|
|
260
260
|
found_tiles += bvh_query_user_data_overlaps_frustum(tiles, tile_count, tileManager.bvh, frustum);
|
|
261
261
|
}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
Vector3 as ThreeVector3
|
|
14
14
|
} from 'three';
|
|
15
15
|
import { BinaryUint32BVH } from "../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
|
|
16
|
-
import { bvh32_query_user_data_ray } from "../../../../core/bvh2/binary/2/bvh32_query_user_data_ray.js";
|
|
17
16
|
import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
|
|
18
17
|
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
19
18
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
@@ -21,11 +20,11 @@ import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
|
21
20
|
import { ray3_array_apply_matrix4 } from "../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
22
21
|
import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
23
22
|
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
24
|
-
import { computeTriangleRayIntersection } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
|
|
25
23
|
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
26
24
|
import Vector3 from '../../../../core/geom/Vector3.js';
|
|
27
25
|
import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
|
|
28
26
|
import ObservedInteger from "../../../../core/model/ObservedInteger.js";
|
|
27
|
+
import { bvh32_geometry_raycast } from "../../../graphics/geometry/buffered/query/bvh32_geometry_raycast.js";
|
|
29
28
|
|
|
30
29
|
import ThreeFactory from '../../../graphics/three/ThreeFactory.js';
|
|
31
30
|
|
|
@@ -33,9 +32,6 @@ import ThreeFactory from '../../../graphics/three/ThreeFactory.js';
|
|
|
33
32
|
const EMPTY_GEOMETRY = new ThreeBufferGeometry();
|
|
34
33
|
const DEFAULT_MATERIAL = new MeshBasicMaterial();
|
|
35
34
|
|
|
36
|
-
const scratch_array = []
|
|
37
|
-
const scratch_hit = new SurfacePoint3()
|
|
38
|
-
|
|
39
35
|
const ray_tmp = [];
|
|
40
36
|
const m4_tmp = [];
|
|
41
37
|
|
|
@@ -191,52 +187,19 @@ class TerrainTile {
|
|
|
191
187
|
const _directionY = ray_tmp[4];
|
|
192
188
|
const _directionZ = ray_tmp[5];
|
|
193
189
|
|
|
194
|
-
const hit_count = bvh32_query_user_data_ray(
|
|
195
|
-
this.bvh,
|
|
196
|
-
scratch_array, 0,
|
|
197
|
-
_originX, _originY, _originZ,
|
|
198
|
-
_directionX, _directionY, _directionZ
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
let best_distance = Infinity;
|
|
202
|
-
let hit_found = false;
|
|
203
|
-
|
|
204
190
|
const geometry = this.geometry;
|
|
205
191
|
|
|
206
192
|
const geometryIndices = geometry.getIndex().array;
|
|
207
193
|
const geometryPositions = geometry.getAttribute('position').array;
|
|
208
194
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const triangle_hit_found = computeTriangleRayIntersection(
|
|
219
|
-
scratch_hit,
|
|
220
|
-
_originX, _originY, _originZ,
|
|
221
|
-
_directionX, _directionY, _directionZ,
|
|
222
|
-
geometryPositions[a], geometryPositions[a + 1], geometryPositions[a + 2],
|
|
223
|
-
geometryPositions[b], geometryPositions[b + 1], geometryPositions[b + 2],
|
|
224
|
-
geometryPositions[c], geometryPositions[c + 1], geometryPositions[c + 2],
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
if (!triangle_hit_found) {
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
hit_found = true;
|
|
232
|
-
|
|
233
|
-
const distance_sqr = scratch_hit.position._distanceSqrTo(_originX, _originY, _originZ);
|
|
234
|
-
|
|
235
|
-
if (distance_sqr < best_distance) {
|
|
236
|
-
best_distance = distance_sqr;
|
|
237
|
-
result.copy(scratch_hit);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
195
|
+
let hit_found = bvh32_geometry_raycast(
|
|
196
|
+
result,
|
|
197
|
+
this.bvh,
|
|
198
|
+
geometryPositions, 0, 3,
|
|
199
|
+
geometryIndices,
|
|
200
|
+
_originX, _originY, _originZ,
|
|
201
|
+
_directionX, _directionY, _directionZ
|
|
202
|
+
);
|
|
240
203
|
|
|
241
204
|
if (hit_found) {
|
|
242
205
|
result.applyMatrix4(m4);
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Created by Alex on 02/04/2014.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {assert} from "../../../core/assert.js";
|
|
6
|
-
import {compose_matrix4_array} from "../../../core/geom/3d/compose_matrix4_array.js";
|
|
7
|
-
import {decompose_matrix_4_array} from "../../../core/geom/3d/decompose_matrix_4_array.js";
|
|
8
|
-
import {allocate_transform_m4} from "../../../core/geom/3d/matrix/allocate_transform_m4.js";
|
|
9
|
-
import {m4_multiply} from "../../../core/geom/3d/matrix/m4_multiply.js";
|
|
10
|
-
import {MATRIX_4_IDENTITY} from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
5
|
+
import { assert } from "../../../core/assert.js";
|
|
6
|
+
import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
|
|
7
|
+
import { decompose_matrix_4_array } from "../../../core/geom/3d/decompose_matrix_4_array.js";
|
|
8
|
+
import { allocate_transform_m4 } from "../../../core/geom/3d/matrix/allocate_transform_m4.js";
|
|
9
|
+
import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
|
|
10
|
+
import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
11
11
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
12
12
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
13
|
-
import {TransformFlags} from "./TransformFlags.js";
|
|
13
|
+
import { TransformFlags } from "./TransformFlags.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
@@ -261,8 +261,7 @@ export class Transform {
|
|
|
261
261
|
* @returns {boolean}
|
|
262
262
|
*/
|
|
263
263
|
equals(other) {
|
|
264
|
-
return other.
|
|
265
|
-
&& this.position.equals(other.position)
|
|
264
|
+
return this.position.equals(other.position)
|
|
266
265
|
&& this.rotation.equals(other.rotation)
|
|
267
266
|
&& this.scale.equals(other.scale);
|
|
268
267
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { quat_decode_from_uint32 } from "../../../core/geom/3d/quaternion/quat_decode_from_uint32.js";
|
|
2
|
+
import { quat_encode_to_uint32 } from "../../../core/geom/3d/quaternion/quat_encode_to_uint32.js";
|
|
3
|
+
import { v3_binary_equality_decode } from "../../../core/geom/vec3/v3_binary_equality_decode.js";
|
|
4
|
+
import { v3_binary_equality_encode } from "../../../core/geom/vec3/v3_binary_equality_encode.js";
|
|
1
5
|
import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
6
|
import { Transform } from "./Transform.js";
|
|
3
7
|
|
|
@@ -23,11 +27,19 @@ export class TransformSerializationAdapter extends BinaryClassSerializationAdapt
|
|
|
23
27
|
buffer.writeFloat64(positionY);
|
|
24
28
|
buffer.writeFloat64(positionZ);
|
|
25
29
|
|
|
26
|
-
const
|
|
30
|
+
const rotation = value.rotation;
|
|
31
|
+
const encoded_rotation = quat_encode_to_uint32(
|
|
32
|
+
rotation.x,
|
|
33
|
+
rotation.y,
|
|
34
|
+
rotation.z,
|
|
35
|
+
rotation.w
|
|
36
|
+
);
|
|
27
37
|
|
|
28
|
-
buffer.writeUint32(
|
|
38
|
+
buffer.writeUint32(encoded_rotation);
|
|
29
39
|
|
|
30
|
-
value.scale
|
|
40
|
+
const scale = value.scale;
|
|
41
|
+
|
|
42
|
+
v3_binary_equality_encode(buffer, scale.x, scale.y, scale.z);
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
/**
|
|
@@ -40,12 +52,11 @@ export class TransformSerializationAdapter extends BinaryClassSerializationAdapt
|
|
|
40
52
|
const positionY = buffer.readFloat64();
|
|
41
53
|
const positionZ = buffer.readFloat64();
|
|
42
54
|
|
|
43
|
-
const
|
|
55
|
+
const encoded_rotation = buffer.readUint32();
|
|
44
56
|
|
|
45
|
-
value.scale
|
|
57
|
+
v3_binary_equality_decode(buffer, value.scale, 0);
|
|
46
58
|
|
|
59
|
+
quat_decode_from_uint32(value.rotation, 0, encoded_rotation);
|
|
47
60
|
value.position.set(positionX, positionY, positionZ);
|
|
48
|
-
|
|
49
|
-
value.rotation.decodeFromUint32(encodedRotation);
|
|
50
61
|
}
|
|
51
62
|
}
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { assert } from "../../../../core/assert.js";
|
|
5
5
|
import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
|
|
6
|
-
import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
7
6
|
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
8
7
|
import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
9
|
-
import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
10
8
|
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
11
9
|
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
12
10
|
import { applyTransformToThreeObject } from "./applyTransformToThreeObject.js";
|
|
@@ -25,6 +23,15 @@ export const MeshFlags = {
|
|
|
25
23
|
|
|
26
24
|
const DEFAULT_FLAGS = 0;
|
|
27
25
|
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @type {number}
|
|
29
|
+
*/
|
|
30
|
+
const EQUALITY_FLAGS =
|
|
31
|
+
MeshFlags.CastShadow
|
|
32
|
+
| MeshFlags.ReceiveShadow
|
|
33
|
+
;
|
|
34
|
+
|
|
28
35
|
/**
|
|
29
36
|
* Traversal stack
|
|
30
37
|
* @type {Object3D[]}
|
|
@@ -255,13 +262,7 @@ class Mesh {
|
|
|
255
262
|
}
|
|
256
263
|
|
|
257
264
|
hash() {
|
|
258
|
-
|
|
259
|
-
return computeHashIntegerArray(
|
|
260
|
-
urlHash,
|
|
261
|
-
this.castShadow ? 1 : 0,
|
|
262
|
-
this.receiveShadow ? 1 : 0,
|
|
263
|
-
computeHashFloat(this.opacity)
|
|
264
|
-
);
|
|
265
|
+
return computeStringHash(this.url) ^ this.flags;
|
|
265
266
|
}
|
|
266
267
|
|
|
267
268
|
/**
|
|
@@ -271,9 +272,8 @@ class Mesh {
|
|
|
271
272
|
*/
|
|
272
273
|
equals(other) {
|
|
273
274
|
return this.url === other.url
|
|
275
|
+
&& (this.flags & EQUALITY_FLAGS) === (other.flags & EQUALITY_FLAGS)
|
|
274
276
|
&& this.opacity === other.opacity
|
|
275
|
-
&& this.castShadow === other.castShadow
|
|
276
|
-
&& this.receiveShadow === other.receiveShadow
|
|
277
277
|
;
|
|
278
278
|
}
|
|
279
279
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {BufferGeometry, Plane} from "three";
|
|
2
|
-
import Vector3 from "../../../../../core/geom/Vector3";
|
|
3
2
|
import {SurfacePoint3} from "../../../../../core/geom/3d/SurfacePoint3";
|
|
3
|
+
import Vector3 from "../../../../../core/geom/Vector3";
|
|
4
4
|
|
|
5
5
|
export class GeometrySpatialQueryAccelerator {
|
|
6
6
|
constructor(cache_size?: number)
|
|
7
7
|
|
|
8
|
-
queryContainmentViaClippingPlanes(geometry: BufferGeometry, planes: Plane[]):
|
|
8
|
+
queryContainmentViaClippingPlanes(geometry: BufferGeometry, planes: Plane[]): boolean
|
|
9
9
|
|
|
10
10
|
queryRaycastNearest(destination: SurfacePoint3, geometry: BufferGeometry, ray_origin: Vector3, ray_direction: Vector3): boolean
|
|
11
11
|
|