@woosh/meep-engine 2.67.0 → 2.68.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 +0 -1
- package/build/meep.module.js +0 -1
- package/package.json +1 -1
- package/src/engine/graphics/ecs/mesh/Mesh.d.ts +0 -1
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +0 -5
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +0 -1
- package/src/engine/graphics/material/optimization/prototypeMaterialOptimizer.js +16 -19
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +46 -47
- package/src/core/bvh2/BVHTasks.js +0 -65
- package/src/core/bvh2/BinaryNode.d.ts +0 -13
- package/src/core/bvh2/BinaryNode.js +0 -1188
- package/src/core/bvh2/BinaryNode.spec.js +0 -309
- package/src/core/bvh2/LeafNode.d.ts +0 -7
- package/src/core/bvh2/LeafNode.js +0 -147
- package/src/core/bvh2/Node.d.ts +0 -9
- package/src/core/bvh2/Node.js +0 -196
- package/src/core/bvh2/NodeValidator.js +0 -197
- package/src/core/bvh2/StacklessTraverser.js +0 -154
- package/src/core/bvh2/StacklessTraverser.spec.js +0 -109
- package/src/core/bvh2/serialization/deserializeBinaryNode.js +0 -40
- package/src/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +0 -90
- package/src/core/bvh2/serialization/serializeBinaryNode.js +0 -31
- package/src/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +0 -86
- package/src/core/bvh2/transform/BottomUpOptimizingRebuilder.js +0 -144
- package/src/core/bvh2/transform/RotationOptimizer.js +0 -123
- package/src/core/bvh2/transform/RotationOptimizer.spec.js +0 -303
- package/src/core/bvh2/transform/tryRotateSingleNode.js +0 -260
- package/src/core/bvh2/traversal/BVHVisitor.js +0 -30
- package/src/core/bvh2/traversal/RaycastBVHVisitor.js +0 -66
- package/src/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +0 -384
- package/src/core/bvh2/traversal/ThreeFrustumsIntersectionBVHVisitor.js +0 -52
- package/src/core/bvh2/traversal/bvh_traverse_pre_order_using_stack.js +0 -43
- package/src/core/bvh2/traversal/queryBinaryNode_ClippingPlanes.d.ts +0 -5
- package/src/core/bvh2/traversal/queryBinaryNode_ClippingPlanes.js +0 -66
- package/src/core/bvh2/traversal/queryBinaryNode_CollectData.js +0 -49
- package/src/core/bvh2/traversal/queryBinaryNode_CollectLeaves.js +0 -51
- package/src/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +0 -77
- package/src/core/bvh2/traversal/queryBinaryNode_SphereIntersections.js +0 -63
- package/src/core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js +0 -50
- package/src/core/bvh2/traversal/traverseBinaryNodeUsingVisitor_DepthFirst_PreOrder.js +0 -34
- package/src/core/bvh2/util/find_least_common_ancestor.js +0 -34
- package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +0 -50
- package/src/core/geom/2d/bvh/BinaryNode2.js +0 -152
- package/src/core/geom/2d/bvh/LeafNode2.js +0 -11
- package/src/core/geom/2d/bvh/Node2.js +0 -51
- package/src/engine/ecs/terrain/tiles/FirstRayIntersectionTerrainBVHVisitor.js +0 -74
- package/src/engine/graphics/geometry/bvh/BVHFromGeometry.js +0 -72
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +0 -240
- package/src/engine/graphics/geometry/bvh/buffered/IndexedTraingleBoundsComputer.js +0 -43
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +0 -133
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { surfaceAreaHeuristic as sah } from "../sah/surfaceAreaHeuristic.js";
|
|
2
|
-
import { isLeaf } from "../LeafNode.js";
|
|
3
|
-
import { aabb3_score_boxes_SAH as computeAreaFor2 } from "../../geom/3d/aabb/aabb3_score_boxes_SAH.js";
|
|
4
|
-
import { aabb3_box_surface_area_2 as computeArea } from "../../geom/3d/aabb/aabb3_box_surface_area_2.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {Node} node
|
|
9
|
-
* @param {BinaryNode} parent
|
|
10
|
-
*/
|
|
11
|
-
function setParent(node, parent) {
|
|
12
|
-
node.parentNode = parent;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Based on paper "Fast, Effective BVH Updates for Animated Scenes" Kopta et. al. (url: http://www.cs.utah.edu/~thiago/papers/rotations.pdf)
|
|
17
|
-
* @param {BinaryNode} node
|
|
18
|
-
* @returns {int} value from 0 to 6, 0 means no rotation has taken place
|
|
19
|
-
*/
|
|
20
|
-
export function tryRotateSingleNode(node) {
|
|
21
|
-
|
|
22
|
-
const left = node.left;
|
|
23
|
-
const right = node.right;
|
|
24
|
-
|
|
25
|
-
if (left === null || right === null) {
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/*
|
|
30
|
-
First we compute best rotation to apply, enumerated by 0-6
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
let bestRotation = 0;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const nodeArea = computeArea(node);
|
|
37
|
-
const leftArea = computeArea(left);
|
|
38
|
-
const rightArea = computeArea(right);
|
|
39
|
-
|
|
40
|
-
const leftLeaves = left.leafNodeCount;
|
|
41
|
-
const rightLeaves = right.leafNodeCount;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
let bestCost = sah(
|
|
45
|
-
nodeArea,
|
|
46
|
-
leftArea,
|
|
47
|
-
rightArea,
|
|
48
|
-
leftLeaves,
|
|
49
|
-
rightLeaves
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
let candidateCost;
|
|
53
|
-
|
|
54
|
-
let leftLeftArea,
|
|
55
|
-
leftRightArea,
|
|
56
|
-
rightLeftArea,
|
|
57
|
-
rightRightArea;
|
|
58
|
-
|
|
59
|
-
let leftLeft,
|
|
60
|
-
leftRight,
|
|
61
|
-
rightLeft,
|
|
62
|
-
rightRight;
|
|
63
|
-
|
|
64
|
-
let leftLeftLeaves,
|
|
65
|
-
leftRightLeaves,
|
|
66
|
-
rightLeftLeaves,
|
|
67
|
-
rightRightLeaves;
|
|
68
|
-
|
|
69
|
-
let considerLeft = !isLeaf(left);
|
|
70
|
-
|
|
71
|
-
if (considerLeft) {
|
|
72
|
-
leftLeft = left.left;
|
|
73
|
-
leftRight = left.right;
|
|
74
|
-
|
|
75
|
-
considerLeft = (leftLeft !== null && leftRight !== null);
|
|
76
|
-
if (considerLeft) {
|
|
77
|
-
|
|
78
|
-
leftLeftArea = computeArea(leftLeft);
|
|
79
|
-
leftRightArea = computeArea(leftRight);
|
|
80
|
-
|
|
81
|
-
leftLeftLeaves = leftLeft.leafNodeCount;
|
|
82
|
-
leftRightLeaves = leftRight.leafNodeCount;
|
|
83
|
-
|
|
84
|
-
// (1) N N //
|
|
85
|
-
// / \ / \ //
|
|
86
|
-
// L R -----> L LL //
|
|
87
|
-
// / \ / \ //
|
|
88
|
-
// LL LR R LR //
|
|
89
|
-
candidateCost = sah(nodeArea, computeAreaFor2(right, leftRight), leftLeftArea, rightLeaves + leftRightLeaves, leftLeftLeaves);
|
|
90
|
-
|
|
91
|
-
if (candidateCost < bestCost) {
|
|
92
|
-
bestRotation = 1;
|
|
93
|
-
bestCost = candidateCost;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// (2) N N //
|
|
97
|
-
// / \ / \ //
|
|
98
|
-
// L R -----> L LR //
|
|
99
|
-
// / \ / \ //
|
|
100
|
-
// LL LR LL R //
|
|
101
|
-
candidateCost = sah(nodeArea, computeAreaFor2(leftLeft, right), leftRightArea, leftLeftLeaves + rightLeaves, leftRightLeaves);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (candidateCost < bestCost) {
|
|
105
|
-
bestRotation = 2;
|
|
106
|
-
bestCost = candidateCost;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (!isLeaf(right)) {
|
|
111
|
-
rightLeft = right.left;
|
|
112
|
-
rightRight = right.right;
|
|
113
|
-
if (rightLeft !== null && rightRight !== null) {
|
|
114
|
-
|
|
115
|
-
rightLeftArea = computeArea(rightLeft);
|
|
116
|
-
rightRightArea = computeArea(rightRight);
|
|
117
|
-
|
|
118
|
-
rightLeftLeaves = rightLeft.leafNodeCount;
|
|
119
|
-
rightRightLeaves = rightRight.leafNodeCount;
|
|
120
|
-
|
|
121
|
-
// (3) N N //
|
|
122
|
-
// / \ / \ //
|
|
123
|
-
// L R -----> RL R //
|
|
124
|
-
// / \ / \ //
|
|
125
|
-
// RL RR L RR //
|
|
126
|
-
candidateCost = sah(nodeArea, rightLeftArea, computeAreaFor2(left, rightRight), rightLeftLeaves, leftLeaves + rightRightLeaves);
|
|
127
|
-
|
|
128
|
-
if (candidateCost < bestCost) {
|
|
129
|
-
bestRotation = 3;
|
|
130
|
-
bestCost = candidateCost;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// (4) N N //
|
|
134
|
-
// / \ / \ //
|
|
135
|
-
// L R -----> RR R //
|
|
136
|
-
// / \ / \ //
|
|
137
|
-
// RL RR RL L //
|
|
138
|
-
candidateCost = sah(nodeArea, rightRightArea, computeAreaFor2(rightLeft, left), rightRightLeaves, rightLeftLeaves + leftLeaves);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (candidateCost < bestCost) {
|
|
142
|
-
bestRotation = 4;
|
|
143
|
-
bestCost = candidateCost;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (considerLeft) {
|
|
147
|
-
//both child nodes are not leaf
|
|
148
|
-
|
|
149
|
-
// (5) N N //
|
|
150
|
-
// / \ / \ //
|
|
151
|
-
// L R -----> L R //
|
|
152
|
-
// / \ / \ / \ / \ //
|
|
153
|
-
// LL LR RL RR LL RL LR RR //
|
|
154
|
-
candidateCost = sah(
|
|
155
|
-
nodeArea,
|
|
156
|
-
computeAreaFor2(leftLeft, rightLeft),
|
|
157
|
-
computeAreaFor2(leftRight, rightRight),
|
|
158
|
-
leftLeftLeaves + rightLeftLeaves,
|
|
159
|
-
leftRightLeaves + rightRightLeaves
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (candidateCost < bestCost) {
|
|
164
|
-
bestRotation = 5;
|
|
165
|
-
bestCost = candidateCost;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// (6) N N //
|
|
169
|
-
// / \ / \ //
|
|
170
|
-
// L R -----> L R //
|
|
171
|
-
// / \ / \ / \ / \ //
|
|
172
|
-
// LL LR RL RR LL RR RL LR //
|
|
173
|
-
candidateCost = sah(
|
|
174
|
-
nodeArea,
|
|
175
|
-
computeAreaFor2(leftLeft, rightRight),
|
|
176
|
-
computeAreaFor2(rightLeft, leftRight),
|
|
177
|
-
leftLeftLeaves + rightRightLeaves,
|
|
178
|
-
rightLeftLeaves + leftRightLeaves
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
if (candidateCost < bestCost) {
|
|
182
|
-
bestRotation = 6;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
switch (bestRotation) {
|
|
189
|
-
case 0:
|
|
190
|
-
//no rotation
|
|
191
|
-
break;
|
|
192
|
-
case 1:
|
|
193
|
-
node.right = leftLeft;
|
|
194
|
-
setParent(leftLeft, node);
|
|
195
|
-
left.left = right;
|
|
196
|
-
setParent(right, left);
|
|
197
|
-
|
|
198
|
-
left.refit();
|
|
199
|
-
//update leaf count
|
|
200
|
-
node.left.updateLeafNodeCount();
|
|
201
|
-
break;
|
|
202
|
-
case 2:
|
|
203
|
-
node.right = leftRight;
|
|
204
|
-
setParent(leftRight, node);
|
|
205
|
-
left.right = right;
|
|
206
|
-
setParent(right, left);
|
|
207
|
-
|
|
208
|
-
left.refit();
|
|
209
|
-
//update leaf count
|
|
210
|
-
node.left.updateLeafNodeCount();
|
|
211
|
-
break;
|
|
212
|
-
case 3:
|
|
213
|
-
node.left = rightLeft;
|
|
214
|
-
setParent(rightLeft, node);
|
|
215
|
-
right.left = left;
|
|
216
|
-
setParent(left, right);
|
|
217
|
-
|
|
218
|
-
right.refit();
|
|
219
|
-
//update leaf count
|
|
220
|
-
node.right.updateLeafNodeCount();
|
|
221
|
-
break;
|
|
222
|
-
case 4:
|
|
223
|
-
node.left = rightRight;
|
|
224
|
-
setParent(rightRight, node);
|
|
225
|
-
right.right = left;
|
|
226
|
-
setParent(left, right);
|
|
227
|
-
|
|
228
|
-
right.refit();
|
|
229
|
-
//update leaf count
|
|
230
|
-
node.right.updateLeafNodeCount();
|
|
231
|
-
break;
|
|
232
|
-
case 5:
|
|
233
|
-
left.right = rightLeft;
|
|
234
|
-
setParent(rightLeft, left);
|
|
235
|
-
right.left = leftRight;
|
|
236
|
-
setParent(leftRight, right);
|
|
237
|
-
|
|
238
|
-
left.refit();
|
|
239
|
-
right.refit();
|
|
240
|
-
|
|
241
|
-
//update leaf count
|
|
242
|
-
node.left.updateLeafNodeCount();
|
|
243
|
-
node.right.updateLeafNodeCount();
|
|
244
|
-
break;
|
|
245
|
-
case 6:
|
|
246
|
-
left.right = rightRight;
|
|
247
|
-
setParent(rightRight, left);
|
|
248
|
-
right.right = leftRight;
|
|
249
|
-
setParent(leftRight, right);
|
|
250
|
-
|
|
251
|
-
left.refit();
|
|
252
|
-
right.refit();
|
|
253
|
-
//update leaf count
|
|
254
|
-
node.left.updateLeafNodeCount();
|
|
255
|
-
node.right.updateLeafNodeCount();
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return bestRotation;
|
|
260
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export class BVHVisitor {
|
|
2
|
-
constructor() {
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
initialize() {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
finalize() {
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {LeafNode} node
|
|
17
|
-
*/
|
|
18
|
-
visitLeaf(node) {
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {BinaryNode} node
|
|
25
|
-
* @returns {boolean} true if traversal should go deeper, false to exclude descendants from traversal
|
|
26
|
-
*/
|
|
27
|
-
visitBinary(node) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { BVHVisitor } from "./BVHVisitor.js";
|
|
2
|
-
|
|
3
|
-
export class RaycastBVHVisitor extends BVHVisitor {
|
|
4
|
-
constructor() {
|
|
5
|
-
super();
|
|
6
|
-
|
|
7
|
-
this.originX = 0;
|
|
8
|
-
this.originY = 0;
|
|
9
|
-
this.originZ = 0;
|
|
10
|
-
|
|
11
|
-
this.directionX = 0;
|
|
12
|
-
this.directionY = 0;
|
|
13
|
-
this.directionZ = 0;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @type {BVHVisitor}
|
|
18
|
-
*/
|
|
19
|
-
this.collector = null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {number} x
|
|
25
|
-
* @param {number} y
|
|
26
|
-
* @param {number} z
|
|
27
|
-
*/
|
|
28
|
-
setOrigin(x, y, z) {
|
|
29
|
-
this.originX = x;
|
|
30
|
-
this.originY = y;
|
|
31
|
-
this.originZ = z;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @param {number} x
|
|
37
|
-
* @param {number} y
|
|
38
|
-
* @param {number} z
|
|
39
|
-
*/
|
|
40
|
-
setDirection(x, y, z) {
|
|
41
|
-
this.directionX = x;
|
|
42
|
-
this.directionY = y;
|
|
43
|
-
this.directionZ = z;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
visitLeaf(node) {
|
|
47
|
-
|
|
48
|
-
const b = node.intersectRay(this.originX, this.originY, this.originZ, this.directionX, this.directionY, this.directionZ);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (b) {
|
|
52
|
-
this.collector.visitLeaf(node);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
visitBinary(node) {
|
|
58
|
-
const b = node.intersectRay(this.originX, this.originY, this.originZ, this.directionX, this.directionY, this.directionZ);
|
|
59
|
-
|
|
60
|
-
if (b) {
|
|
61
|
-
this.collector.visitBinary(node);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return b;
|
|
65
|
-
}
|
|
66
|
-
}
|