@woosh/meep-engine 2.34.43 → 2.34.44
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/core/bvh2/BinaryNode.js +10 -8
- package/core/bvh2/LeafNode.js +2 -1
- package/core/bvh2/aabb3/AABB3.js +879 -1059
- package/core/bvh2/aabb3/AABB3.spec.js +5 -7
- package/core/bvh2/aabb3/aabb3_array_intersects_ray.js +2 -2
- package/core/bvh2/aabb3/aabb3_box_surface_area_2.js +10 -0
- package/core/bvh2/aabb3/aabb3_compute_half_surface_area.js +16 -0
- package/core/bvh2/aabb3/aabb3_compute_surface_area.js +18 -0
- package/core/bvh2/aabb3/aabb3_expand_array.js +15 -0
- package/core/bvh2/aabb3/aabb3_intersect_aabb3.js +28 -0
- package/core/bvh2/aabb3/aabb3_intersect_ray_slab.js +73 -0
- package/core/bvh2/aabb3/{aabb3_intersects_frustum.js → aabb3_intersects_frustum_array.js} +16 -1
- package/core/bvh2/aabb3/aabb3_intersects_line_segment.js +79 -0
- package/core/bvh2/aabb3/aabb3_intersects_ray.js +92 -0
- package/core/bvh2/aabb3/{AABB3Math.spec.js → aabb3_intersects_ray.spec.js} +3 -3
- package/core/bvh2/aabb3/aabb3_intersects_ray_fast.js +176 -0
- package/core/bvh2/aabb3/aabb3_score_boxes_SAH.js +43 -0
- package/core/bvh2/aabb3/aabb_score_boxes_SAH_delta.js +37 -0
- package/core/bvh2/aabb3/deserializeAABB3.js +17 -0
- package/core/bvh2/aabb3/deserializeAABB3Encoded_v0.js +73 -0
- package/core/bvh2/aabb3/deserializeAABB3Quantized16Uint.js +36 -0
- package/core/bvh2/aabb3/serializeAABB3.js +13 -0
- package/core/bvh2/aabb3/serializeAABB3Quantized16Uint.js +33 -0
- package/core/bvh2/binary/2/BinaryUint32BVH.js +3 -3
- package/core/bvh2/binary/BinaryBVH.js +2 -2
- package/core/bvh2/binary/RayLeafIntersectionVisitor.js +2 -2
- package/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
- package/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -1
- package/core/bvh2/serialization/serializeBinaryNode.js +1 -1
- package/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -1
- package/core/bvh2/transform/BottomUpOptimizingRebuilder.js +6 -5
- package/core/bvh2/transform/tryRotateSingleNode.js +2 -1
- package/core/geom/3d/frustum/{array_setFromProjectionMatrix.js → frustum_from_projection_matrix_array.js} +1 -1
- package/core/math/fabsf.js +8 -0
- package/engine/development/performance/MetricCollection.js +6 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
- package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +3 -1
- package/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +2 -2
- package/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +3 -2
- package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -2
- package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +15 -41
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +5 -1
- package/engine/graphics/micron/render/refinement/ActivePatchList.js +2 -2
- package/engine/graphics/micron/render/refinement/RefinementSpec.js +16 -20
- package/package.json +1 -1
- package/core/bvh2/aabb3/AABB3Math.js +0 -579
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BinaryBuffer} buffer
|
|
4
|
+
* @param {AABB3} box
|
|
5
|
+
*/
|
|
6
|
+
function deserializeAABB3(buffer, box) {
|
|
7
|
+
const x0 = buffer.readFloat64();
|
|
8
|
+
const y0 = buffer.readFloat64();
|
|
9
|
+
const z0 = buffer.readFloat64();
|
|
10
|
+
const x1 = buffer.readFloat64();
|
|
11
|
+
const y1 = buffer.readFloat64();
|
|
12
|
+
const z1 = buffer.readFloat64();
|
|
13
|
+
|
|
14
|
+
box.setBounds(x0, y0, z0, x1, y1, z1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { deserializeAABB3 };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BinaryBuffer} buffer
|
|
4
|
+
* @param {AABB3} box
|
|
5
|
+
* @param {number} x0
|
|
6
|
+
* @param {number} y0
|
|
7
|
+
* @param {number} z0
|
|
8
|
+
* @param {number} x1
|
|
9
|
+
* @param {number} y1
|
|
10
|
+
* @param {number} z1
|
|
11
|
+
*/
|
|
12
|
+
export function deserializeAABB3Encoded_v0(buffer, box, x0, y0, z0, x1, y1, z1) {
|
|
13
|
+
const header = buffer.readUint8();
|
|
14
|
+
|
|
15
|
+
//compute value ranges
|
|
16
|
+
const xD = x1 - x0;
|
|
17
|
+
const yD = y1 - y0;
|
|
18
|
+
const zD = z1 - z0;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
let qx0;
|
|
22
|
+
let qx1;
|
|
23
|
+
|
|
24
|
+
let qy0;
|
|
25
|
+
let qy1;
|
|
26
|
+
|
|
27
|
+
let qz0;
|
|
28
|
+
let qz1;
|
|
29
|
+
|
|
30
|
+
if ((header & 1) === 0) {
|
|
31
|
+
const _x0 = buffer.readUint16();
|
|
32
|
+
qx0 = (_x0 / 65535) * xD + x0;
|
|
33
|
+
} else {
|
|
34
|
+
qx0 = x0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if ((header & 2) === 0) {
|
|
38
|
+
const _x1 = buffer.readUint16();
|
|
39
|
+
qx1 = (_x1 / 65535) * xD + x0;
|
|
40
|
+
} else {
|
|
41
|
+
qx1 = x1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ((header & 4) === 0) {
|
|
45
|
+
const _y0 = buffer.readUint16();
|
|
46
|
+
qy0 = (_y0 / 65535) * yD + y0;
|
|
47
|
+
} else {
|
|
48
|
+
qy0 = y0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if ((header & 8) === 0) {
|
|
52
|
+
const _y1 = buffer.readUint16();
|
|
53
|
+
qy1 = (_y1 / 65535) * yD + y0;
|
|
54
|
+
} else {
|
|
55
|
+
qy1 = y1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ((header & 16) === 0) {
|
|
59
|
+
const _z0 = buffer.readUint16();
|
|
60
|
+
qz0 = (_z0 / 65535) * zD + z0;
|
|
61
|
+
} else {
|
|
62
|
+
qz0 = z0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if ((header & 32) === 0) {
|
|
66
|
+
const _z1 = buffer.readUint16();
|
|
67
|
+
qz1 = (_z1 / 65535) * zD + z0;
|
|
68
|
+
} else {
|
|
69
|
+
qz1 = z1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
box.setBounds(qx0, qy0, qz0, qx1, qy1, qz1);
|
|
73
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BinaryBuffer} buffer
|
|
4
|
+
* @param {AABB3} box
|
|
5
|
+
* @param {number} x0
|
|
6
|
+
* @param {number} y0
|
|
7
|
+
* @param {number} z0
|
|
8
|
+
* @param {number} x1
|
|
9
|
+
* @param {number} y1
|
|
10
|
+
* @param {number} z1
|
|
11
|
+
*/
|
|
12
|
+
export function deserializeAABB3Quantized16Uint(buffer, box, x0, y0, z0, x1, y1, z1) {
|
|
13
|
+
//compute value ranges
|
|
14
|
+
const xD = x1 - x0;
|
|
15
|
+
const yD = y1 - y0;
|
|
16
|
+
const zD = z1 - z0;
|
|
17
|
+
|
|
18
|
+
//read values
|
|
19
|
+
const _x0 = buffer.readUint16();
|
|
20
|
+
const _y0 = buffer.readUint16();
|
|
21
|
+
const _z0 = buffer.readUint16();
|
|
22
|
+
const _x1 = buffer.readUint16();
|
|
23
|
+
const _y1 = buffer.readUint16();
|
|
24
|
+
const _z1 = buffer.readUint16();
|
|
25
|
+
|
|
26
|
+
//quantize all values
|
|
27
|
+
const qx0 = (_x0 / 65535) * xD + x0;
|
|
28
|
+
const qy0 = (_y0 / 65535) * yD + y0;
|
|
29
|
+
const qz0 = (_z0 / 65535) * zD + z0;
|
|
30
|
+
|
|
31
|
+
const qx1 = (_x1 / 65535) * xD + x0;
|
|
32
|
+
const qy1 = (_y1 / 65535) * yD + y0;
|
|
33
|
+
const qz1 = (_z1 / 65535) * zD + z0;
|
|
34
|
+
|
|
35
|
+
box.setBounds(qx0, qy0, qz0, qx1, qy1, qz1);
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BinaryBuffer} buffer
|
|
4
|
+
* @param {AABB3} box
|
|
5
|
+
*/
|
|
6
|
+
export function serializeAABB3(buffer, box) {
|
|
7
|
+
buffer.writeFloat64(box.x0);
|
|
8
|
+
buffer.writeFloat64(box.y0);
|
|
9
|
+
buffer.writeFloat64(box.z0);
|
|
10
|
+
buffer.writeFloat64(box.x1);
|
|
11
|
+
buffer.writeFloat64(box.y1);
|
|
12
|
+
buffer.writeFloat64(box.z1);
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BinaryBuffer} buffer
|
|
4
|
+
* @param {AABB3} box
|
|
5
|
+
* @param {number} x0
|
|
6
|
+
* @param {number} y0
|
|
7
|
+
* @param {number} z0
|
|
8
|
+
* @param {number} x1
|
|
9
|
+
* @param {number} y1
|
|
10
|
+
* @param {number} z1
|
|
11
|
+
*/
|
|
12
|
+
export function serializeAABB3Quantized16Uint(buffer, box, x0, y0, z0, x1, y1, z1) {
|
|
13
|
+
//compute value ranges
|
|
14
|
+
const xD = x1 - x0;
|
|
15
|
+
const yD = y1 - y0;
|
|
16
|
+
const zD = z1 - z0;
|
|
17
|
+
|
|
18
|
+
//quantize all values
|
|
19
|
+
const _x0 = (((box.x0 - x0) / xD) * 65535) | 0;
|
|
20
|
+
const _y0 = (((box.y0 - y0) / yD) * 65535) | 0;
|
|
21
|
+
const _z0 = (((box.z0 - z0) / zD) * 65535) | 0;
|
|
22
|
+
|
|
23
|
+
const _x1 = (((box.x1 - x0) / xD) * 65535) | 0;
|
|
24
|
+
const _y1 = (((box.y1 - y0) / yD) * 65535) | 0;
|
|
25
|
+
const _z1 = (((box.z1 - z0) / zD) * 65535) | 0;
|
|
26
|
+
|
|
27
|
+
buffer.writeUint16(_x0);
|
|
28
|
+
buffer.writeUint16(_y0);
|
|
29
|
+
buffer.writeUint16(_z0);
|
|
30
|
+
buffer.writeUint16(_x1);
|
|
31
|
+
buffer.writeUint16(_y1);
|
|
32
|
+
buffer.writeUint16(_z1);
|
|
33
|
+
}
|
|
@@ -3,10 +3,10 @@ import { min2 } from "../../../math/min2.js";
|
|
|
3
3
|
import { max2 } from "../../../math/max2.js";
|
|
4
4
|
import { ceilPowerOfTwo } from "../../../binary/operations/ceilPowerOfTwo.js";
|
|
5
5
|
import { array_swap } from "../../../collection/array/array_swap.js";
|
|
6
|
-
import { _boxSurfaceArea2 } from "../../aabb3/AABB3Math.js";
|
|
7
6
|
import { mortonEncode_magicbits } from "../../../geom/3d/morton/mortonEncode_magicbits.js";
|
|
8
7
|
import { min3 } from "../../../math/min3.js";
|
|
9
8
|
import { max3 } from "../../../math/max3.js";
|
|
9
|
+
import { aabb3_compute_half_surface_area } from "../../aabb3/aabb3_compute_half_surface_area.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @readonly
|
|
@@ -272,7 +272,7 @@ export class BinaryUint32BVH {
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
this.readBounds(address, box, 0);
|
|
275
|
-
result +=
|
|
275
|
+
result += aabb3_compute_half_surface_area(box[0], box[1], box[2], box[3], box[4], box[5]);
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
return result;
|
|
@@ -299,7 +299,7 @@ export class BinaryUint32BVH {
|
|
|
299
299
|
const y1 = max3(scratch_box_0[4], scratch_box_1[4], scratch_box_2[4]);
|
|
300
300
|
const z1 = max3(scratch_box_0[5], scratch_box_1[5], scratch_box_2[5]);
|
|
301
301
|
|
|
302
|
-
return
|
|
302
|
+
return aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import PrimitiveType from "../../binary/type/PrimitiveTypes.js";
|
|
5
5
|
import BinaryStructure from "../../binary/type/Type.js";
|
|
6
|
-
import {
|
|
6
|
+
import { aabb3_intersects_ray } from "../aabb3/aabb3_intersects_ray.js";
|
|
7
7
|
|
|
8
8
|
const NodeType = {
|
|
9
9
|
LEAF: 0,
|
|
@@ -262,7 +262,7 @@ BinaryBVH.prototype.traverseRayLeafIntersections = function (startX, startY, sta
|
|
|
262
262
|
const y1 = daNode.read_y1(dataView, address);
|
|
263
263
|
const z1 = daNode.read_z1(dataView, address);
|
|
264
264
|
|
|
265
|
-
let b =
|
|
265
|
+
let b = aabb3_intersects_ray(x0, y0, z0, x1, y1, z1, startX, startY, startZ, directionX, directionY, directionZ);
|
|
266
266
|
|
|
267
267
|
if (!b) {
|
|
268
268
|
return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { noop } from "../../function/Functions.js";
|
|
2
|
-
import { intersectRay } from "../aabb3/AABB3Math.js";
|
|
3
2
|
import { IndexedBinaryBVHVisitor } from "./IndexedBinaryBVHVisitor.js";
|
|
4
3
|
import { NodeType } from "./NodeType.js";
|
|
4
|
+
import { aabb3_intersects_ray } from "../aabb3/aabb3_intersects_ray.js";
|
|
5
5
|
|
|
6
6
|
export class RayLeafIntersectionVisitor extends IndexedBinaryBVHVisitor {
|
|
7
7
|
constructor() {
|
|
@@ -37,7 +37,7 @@ export class RayLeafIntersectionVisitor extends IndexedBinaryBVHVisitor {
|
|
|
37
37
|
const y1 = data[address + 4];
|
|
38
38
|
const z1 = data[address + 5];
|
|
39
39
|
|
|
40
|
-
const intersectionFound =
|
|
40
|
+
const intersectionFound = aabb3_intersects_ray(x0, y0, z0, x1, y1, z1,
|
|
41
41
|
this.originX, this.originY, this.originZ,
|
|
42
42
|
this.directionX, this.directionY, this.directionZ
|
|
43
43
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { deserializeAABB3, deserializeAABB3Encoded_v0 } from "../aabb3/AABB3.js";
|
|
2
1
|
import { BinaryNode } from "../BinaryNode.js";
|
|
3
2
|
import { LeafNode } from "../LeafNode.js";
|
|
3
|
+
import { deserializeAABB3Encoded_v0 } from "../aabb3/deserializeAABB3Encoded_v0.js";
|
|
4
|
+
import { deserializeAABB3 } from "../aabb3/deserializeAABB3.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { boxSurfaceArea2, scoreBoxesSAH } from "../aabb3/AABB3Math.js";
|
|
2
1
|
import { BinaryNode } from "../BinaryNode.js";
|
|
3
2
|
import { isLeaf } from "../LeafNode.js";
|
|
4
3
|
import { surfaceAreaHeuristic } from "../sah/surfaceAreaHeuristic.js";
|
|
4
|
+
import { aabb3_score_boxes_SAH } from "../aabb3/aabb3_score_boxes_SAH.js";
|
|
5
|
+
import { aabb3_box_surface_area_2 } from "../aabb3/aabb3_box_surface_area_2.js";
|
|
5
6
|
|
|
6
7
|
function BottomUpOptimizingRebuilder() {
|
|
7
8
|
this.root = null;
|
|
@@ -9,7 +10,7 @@ function BottomUpOptimizingRebuilder() {
|
|
|
9
10
|
/**
|
|
10
11
|
* @type {function(left:NodeDescription, right:NodeDescription):number} heuristic Cost function of pairing two nodes, lower value means better pairing
|
|
11
12
|
*/
|
|
12
|
-
this.heuristic =
|
|
13
|
+
this.heuristic = aabb3_score_boxes_SAH;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -128,13 +129,13 @@ function leaves(node) {
|
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
function sah(left, right) {
|
|
131
|
-
const leftArea =
|
|
132
|
-
const rightArea =
|
|
132
|
+
const leftArea = aabb3_box_surface_area_2(left);
|
|
133
|
+
const rightArea = aabb3_box_surface_area_2(right);
|
|
133
134
|
|
|
134
135
|
const leftLeaves = leaves(left);
|
|
135
136
|
const rightLeaves = leaves(right);
|
|
136
137
|
|
|
137
|
-
const commonArea =
|
|
138
|
+
const commonArea = aabb3_score_boxes_SAH(left, right);
|
|
138
139
|
|
|
139
140
|
return surfaceAreaHeuristic(commonArea, leftArea, rightArea, leftLeaves, rightLeaves);
|
|
140
141
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { boxSurfaceArea2 as computeArea, scoreBoxesSAH as computeAreaFor2 } from "../aabb3/AABB3Math.js";
|
|
2
1
|
import { surfaceAreaHeuristic as sah } from "../sah/surfaceAreaHeuristic.js";
|
|
3
2
|
import { isLeaf } from "../LeafNode.js";
|
|
3
|
+
import { aabb3_score_boxes_SAH as computeAreaFor2 } from "../aabb3/aabb3_score_boxes_SAH.js";
|
|
4
|
+
import { aabb3_box_surface_area_2 as computeArea } from "../aabb3/aabb3_box_surface_area_2.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -25,7 +25,7 @@ function array_set_plane_normalized(destination, destination_offset, x, y, z, w)
|
|
|
25
25
|
* @param {number[]|Float32Array} frustum_planes
|
|
26
26
|
* @param {number[]} me
|
|
27
27
|
*/
|
|
28
|
-
export function
|
|
28
|
+
export function frustum_from_projection_matrix_array(frustum_planes, me) {
|
|
29
29
|
|
|
30
30
|
const me0 = me[0];
|
|
31
31
|
const me3 = me[3];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ShadedGeometry } from "./ShadedGeometry.js";
|
|
2
2
|
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
3
3
|
import { System } from "../../../ecs/System.js";
|
|
4
|
-
import { intersectRay } from "../../../../core/bvh2/aabb3/AABB3Math.js";
|
|
5
4
|
import { GeometrySpatialQueryAccelerator } from "../../geometry/buffered/query/GeometrySpatialQueryAccelerator.js";
|
|
6
5
|
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
7
6
|
import { v3_distance_sqr } from "../../../../core/geom/v3_distance_sqr.js";
|
|
8
7
|
import { mat4 } from "gl-matrix";
|
|
9
8
|
import { returnTrue } from "../../../../core/function/Functions.js";
|
|
9
|
+
import { aabb3_intersects_ray } from "../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -142,7 +142,7 @@ export class ShadedGeometrySystem extends System {
|
|
|
142
142
|
const node = traversal_stack[traversal_cursor];
|
|
143
143
|
|
|
144
144
|
// test node against the ray
|
|
145
|
-
const intersects =
|
|
145
|
+
const intersects = aabb3_intersects_ray(
|
|
146
146
|
node.x0, node.y0, node.z0,
|
|
147
147
|
node.x1, node.y1, node.z1,
|
|
148
148
|
origin_x, origin_y, origin_z,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
|
|
2
2
|
import { NodeType } from "../../../../../core/bvh2/binary/NodeType.js";
|
|
3
|
-
import { intersectRay } from "../../../../../core/bvh2/aabb3/AABB3Math.js";
|
|
4
3
|
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
5
4
|
import { computeTriangleRayIntersection } from "../../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
|
|
6
5
|
import { GeometrySpatialAcceleratorVisitor } from "./GeometryVisitor.js";
|
|
6
|
+
import { aabb3_intersects_ray } from "../../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
7
7
|
|
|
8
8
|
export class RaycastNearestHitComputingVisitor extends GeometrySpatialAcceleratorVisitor {
|
|
9
9
|
constructor() {
|
|
@@ -158,7 +158,7 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
158
158
|
const y1 = data[address + 4];
|
|
159
159
|
const z1 = data[address + 5];
|
|
160
160
|
|
|
161
|
-
return
|
|
161
|
+
return aabb3_intersects_ray(
|
|
162
162
|
x0, y0, z0,
|
|
163
163
|
x1, y1, z1,
|
|
164
164
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { squirrel3 } from "../../../../core/math/hash/squirrel3.js";
|
|
2
|
+
import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
|
|
2
3
|
|
|
3
4
|
export class MicronGeometryPatchOccurrence {
|
|
4
5
|
constructor() {
|
|
@@ -21,7 +22,7 @@ export class MicronGeometryPatchOccurrence {
|
|
|
21
22
|
this.patch = null;
|
|
22
23
|
/**
|
|
23
24
|
*
|
|
24
|
-
* @type {
|
|
25
|
+
* @type {number[]|Float32Array|null}
|
|
25
26
|
*/
|
|
26
27
|
this.transform = null;
|
|
27
28
|
}
|
|
@@ -41,7 +42,7 @@ export class MicronGeometryPatchOccurrence {
|
|
|
41
42
|
return this.geometry_id === other.geometry_id
|
|
42
43
|
&& this.instance_id === other.instance_id
|
|
43
44
|
&& this.patch.id === other.patch.id
|
|
44
|
-
&& this.transform
|
|
45
|
+
&& isArrayEqualStrict(this.transform, other.transform)
|
|
45
46
|
;
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -460,7 +460,7 @@ function init() {
|
|
|
460
460
|
|
|
461
461
|
// sample_gltf_sponza();
|
|
462
462
|
// gltf_sample('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
|
|
463
|
-
|
|
463
|
+
sample_lucy();
|
|
464
464
|
// sample_gltf_hapro_2();
|
|
465
465
|
// sample_gltf_hapro_1();
|
|
466
466
|
// sample_gltf_broken_isiflow();
|
|
@@ -478,7 +478,7 @@ function init() {
|
|
|
478
478
|
// gltf_sample('moicon/03_Jan_22_Demo/4-area_1st_floor/model.gltf');
|
|
479
479
|
// gltf_sample('moicon/03_Jan_22_Demo/8-assets/model.gltf');
|
|
480
480
|
// gltf_sample('moicon/03_Jan_22_Demo/worker_test/model.gltf');
|
|
481
|
-
gltf_sample('moicon/A4/A4/model.gltf');
|
|
481
|
+
// gltf_sample('moicon/A4/A4/model.gltf');
|
|
482
482
|
|
|
483
483
|
document.addEventListener("mousemove", onDocumentMouseMove);
|
|
484
484
|
|
|
@@ -709,6 +709,8 @@ function print_perf_stats() {
|
|
|
709
709
|
});
|
|
710
710
|
|
|
711
711
|
console.log(values.join(", "));
|
|
712
|
+
|
|
713
|
+
metrics.clear();
|
|
712
714
|
}
|
|
713
715
|
|
|
714
716
|
setInterval(print_perf_stats, 2000);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Frustum, Matrix4 } from "three";
|
|
2
1
|
import { array_copy } from "../../../../core/collection/array/copyArray.js";
|
|
3
2
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
4
3
|
import { MicronGeometryPatchOccurrence } from "../format/MicronGeometryPatchOccurance.js";
|
|
5
4
|
import { RefinementSpec } from "./refinement/RefinementSpec.js";
|
|
6
5
|
import { ActivePatchList } from "./refinement/ActivePatchList.js";
|
|
7
6
|
import { ActivePatchFlags } from "./refinement/ActivePatchFlags.js";
|
|
7
|
+
import { mat4 } from "gl-matrix";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @readonly
|
|
@@ -14,27 +14,27 @@ const refinement_spec = new RefinementSpec();
|
|
|
14
14
|
|
|
15
15
|
export class VirtualGeometryBuilder {
|
|
16
16
|
constructor() {
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const common_buffer = new ArrayBuffer(192);
|
|
20
|
+
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
23
|
+
* Camera's world inverse matrix
|
|
21
24
|
* @type {Float32Array|number[]|mat4}
|
|
22
25
|
*/
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
this.matrix_projection_inverse = new Matrix4();
|
|
26
|
-
|
|
26
|
+
this.matrix_world_inverse = new Float32Array(common_buffer, 0, 16);
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Camera's projection matrix
|
|
29
29
|
* @type {Float32Array|number[]|mat4}
|
|
30
30
|
*/
|
|
31
|
-
this.
|
|
31
|
+
this.matrix_projection = new Float32Array(common_buffer, 64, 16);
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
*
|
|
35
|
-
* @type {
|
|
35
|
+
* @type {Float32Array|number[]|mat4}
|
|
36
36
|
*/
|
|
37
|
-
this.
|
|
37
|
+
this.view_projection_matrix = new Float32Array(common_buffer, 128, 16);
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* @private
|
|
@@ -74,20 +74,6 @@ export class VirtualGeometryBuilder {
|
|
|
74
74
|
* @type {number}
|
|
75
75
|
*/
|
|
76
76
|
this.error_bias = 2;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @type {number}
|
|
81
|
-
* @private
|
|
82
|
-
*/
|
|
83
|
-
this.__info_enforced_node_splits = 0;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @type {boolean}
|
|
88
|
-
* @private
|
|
89
|
-
*/
|
|
90
|
-
this.__flags__enforce_dependency_splits = true;
|
|
91
77
|
}
|
|
92
78
|
|
|
93
79
|
dropCache() {
|
|
@@ -111,27 +97,15 @@ export class VirtualGeometryBuilder {
|
|
|
111
97
|
camera.updateMatrix();
|
|
112
98
|
camera.updateMatrixWorld(true);
|
|
113
99
|
|
|
114
|
-
this.view_projection_matrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
115
|
-
|
|
116
100
|
this.matrix_world_inverse.set(camera.matrixWorldInverse.elements);
|
|
117
101
|
this.matrix_projection.set(camera.projectionMatrix.elements);
|
|
118
102
|
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
this.view_frustum.setFromProjectionMatrix(this.view_projection_matrix);
|
|
103
|
+
mat4.multiply(this.view_projection_matrix, this.matrix_projection, this.matrix_world_inverse);
|
|
122
104
|
|
|
123
105
|
//
|
|
124
106
|
refinement_spec.focal_length = camera.fov / 180;
|
|
125
107
|
}
|
|
126
108
|
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* @param {THREE.Matrix4} matrix
|
|
130
|
-
*/
|
|
131
|
-
setProjectionMatrix(matrix) {
|
|
132
|
-
this.view_projection_matrix.copy(matrix);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
109
|
/**
|
|
136
110
|
*
|
|
137
111
|
* @param {THREE.Object3D|ThreeMicronMesh} object
|
|
@@ -156,7 +130,7 @@ export class VirtualGeometryBuilder {
|
|
|
156
130
|
this.buildForMesh(
|
|
157
131
|
object.instance_id,
|
|
158
132
|
micron_geometry,
|
|
159
|
-
object.matrixWorld,
|
|
133
|
+
object.matrixWorld.elements,
|
|
160
134
|
acl
|
|
161
135
|
);
|
|
162
136
|
}
|
|
@@ -176,7 +150,7 @@ export class VirtualGeometryBuilder {
|
|
|
176
150
|
*
|
|
177
151
|
* @param {number} instance_id
|
|
178
152
|
* @param {MicronGeometry} geometry
|
|
179
|
-
* @param {
|
|
153
|
+
* @param {number[]} transform world transform matrix of the instance
|
|
180
154
|
* @param {ActivePatchList} apl
|
|
181
155
|
*/
|
|
182
156
|
buildForMesh(
|
|
@@ -186,7 +160,7 @@ export class VirtualGeometryBuilder {
|
|
|
186
160
|
apl
|
|
187
161
|
) {
|
|
188
162
|
|
|
189
|
-
refinement_spec.build(transform
|
|
163
|
+
refinement_spec.build(transform, this.view_projection_matrix);
|
|
190
164
|
|
|
191
165
|
const output = this.output;
|
|
192
166
|
|
|
@@ -141,6 +141,10 @@ export class ThreeInstancedAdapter {
|
|
|
141
141
|
const geo = this.__buffer_geometry;
|
|
142
142
|
|
|
143
143
|
const patch_transform_attribute = geo.getAttribute(ATTRIBUTE_NAME_TRANSFORM);
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @type {Float32Array}
|
|
147
|
+
*/
|
|
144
148
|
const patch_transform_array = patch_transform_attribute.array;
|
|
145
149
|
|
|
146
150
|
patch_transform_attribute.needsUpdate = true;
|
|
@@ -157,7 +161,7 @@ export class ThreeInstancedAdapter {
|
|
|
157
161
|
|
|
158
162
|
const i16 = i * 16;
|
|
159
163
|
|
|
160
|
-
occurrence.transform
|
|
164
|
+
patch_transform_array.set(occurrence.transform, i16);
|
|
161
165
|
|
|
162
166
|
const patch_slot_id = patch_data.ensure(occurrence.patch);
|
|
163
167
|
|
|
@@ -2,7 +2,7 @@ import { ActivePatchRecord } from "./ActivePatchRecord.js";
|
|
|
2
2
|
import { ActivePatchFlags } from "./ActivePatchFlags.js";
|
|
3
3
|
import { aabb3_project_to_2d } from "../../../../../core/geom/3d/aabb/aabb3_compute_projected_area.js";
|
|
4
4
|
import { BitSet } from "../../../../../core/binary/BitSet.js";
|
|
5
|
-
import {
|
|
5
|
+
import { aabb3_intersects_frustum_array } from "../../../../../core/bvh2/aabb3/aabb3_intersects_frustum_array.js";
|
|
6
6
|
|
|
7
7
|
export class ActivePatchList {
|
|
8
8
|
constructor() {
|
|
@@ -201,7 +201,7 @@ export class ActivePatchList {
|
|
|
201
201
|
check if node is in view frustum
|
|
202
202
|
NOTE: following suggestion in "FastMesh: Efficient View-dependent Meshing" by Renato Pajarola et al, we can do a more coarse frustum test approximating frustum as a cone initially
|
|
203
203
|
*/
|
|
204
|
-
const in_view_frustum =
|
|
204
|
+
const in_view_frustum = aabb3_intersects_frustum_array(node.bounding_box, frustum_planes);
|
|
205
205
|
|
|
206
206
|
if (!in_view_frustum) {
|
|
207
207
|
// outside of view frustum, cull
|