@liveroom-tech/react-immersive 1.2.0 → 1.2.1
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/dist/index.js +16 -28
- package/dist/index.mjs +16 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2503,38 +2503,26 @@ function collectGeometries(root) {
|
|
|
2503
2503
|
});
|
|
2504
2504
|
return [...seen];
|
|
2505
2505
|
}
|
|
2506
|
+
function countTriangles(geometries) {
|
|
2507
|
+
let total = 0;
|
|
2508
|
+
for (const geometry of geometries) {
|
|
2509
|
+
const count = geometry.index ? geometry.index.count : geometry.attributes.position.count;
|
|
2510
|
+
total += count / 3;
|
|
2511
|
+
}
|
|
2512
|
+
return total;
|
|
2513
|
+
}
|
|
2514
|
+
var MAX_BVH_TRIANGLES = 12e6;
|
|
2506
2515
|
async function buildSceneBVH(root, signal) {
|
|
2507
2516
|
const geometries = collectGeometries(root);
|
|
2508
2517
|
if (geometries.length === 0) return;
|
|
2518
|
+
if (countTriangles(geometries) > MAX_BVH_TRIANGLES) return;
|
|
2509
2519
|
enableAcceleratedRaycast();
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
worker = null;
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
try {
|
|
2520
|
-
for (const geometry of geometries) {
|
|
2521
|
-
if (signal?.aborted) return;
|
|
2522
|
-
let tree;
|
|
2523
|
-
if (worker) {
|
|
2524
|
-
try {
|
|
2525
|
-
tree = await worker.generate(geometry);
|
|
2526
|
-
} catch {
|
|
2527
|
-
}
|
|
2528
|
-
}
|
|
2529
|
-
if (tree === void 0) {
|
|
2530
|
-
tree = import_three_mesh_bvh.computeBoundsTree.call(geometry);
|
|
2531
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2532
|
-
}
|
|
2533
|
-
if (signal?.aborted) return;
|
|
2534
|
-
geometry.boundsTree = tree;
|
|
2535
|
-
}
|
|
2536
|
-
} finally {
|
|
2537
|
-
worker?.dispose?.();
|
|
2520
|
+
for (const geometry of geometries) {
|
|
2521
|
+
if (signal?.aborted) return;
|
|
2522
|
+
const tree = import_three_mesh_bvh.computeBoundsTree.call(geometry);
|
|
2523
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2524
|
+
if (signal?.aborted) return;
|
|
2525
|
+
geometry.boundsTree = tree;
|
|
2538
2526
|
}
|
|
2539
2527
|
}
|
|
2540
2528
|
function disposeSceneBVH(root) {
|
package/dist/index.mjs
CHANGED
|
@@ -2535,38 +2535,26 @@ function collectGeometries(root) {
|
|
|
2535
2535
|
});
|
|
2536
2536
|
return [...seen];
|
|
2537
2537
|
}
|
|
2538
|
+
function countTriangles(geometries) {
|
|
2539
|
+
let total = 0;
|
|
2540
|
+
for (const geometry of geometries) {
|
|
2541
|
+
const count = geometry.index ? geometry.index.count : geometry.attributes.position.count;
|
|
2542
|
+
total += count / 3;
|
|
2543
|
+
}
|
|
2544
|
+
return total;
|
|
2545
|
+
}
|
|
2546
|
+
var MAX_BVH_TRIANGLES = 12e6;
|
|
2538
2547
|
async function buildSceneBVH(root, signal) {
|
|
2539
2548
|
const geometries = collectGeometries(root);
|
|
2540
2549
|
if (geometries.length === 0) return;
|
|
2550
|
+
if (countTriangles(geometries) > MAX_BVH_TRIANGLES) return;
|
|
2541
2551
|
enableAcceleratedRaycast();
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
worker = null;
|
|
2549
|
-
}
|
|
2550
|
-
}
|
|
2551
|
-
try {
|
|
2552
|
-
for (const geometry of geometries) {
|
|
2553
|
-
if (signal?.aborted) return;
|
|
2554
|
-
let tree;
|
|
2555
|
-
if (worker) {
|
|
2556
|
-
try {
|
|
2557
|
-
tree = await worker.generate(geometry);
|
|
2558
|
-
} catch {
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
if (tree === void 0) {
|
|
2562
|
-
tree = computeBoundsTree.call(geometry);
|
|
2563
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2564
|
-
}
|
|
2565
|
-
if (signal?.aborted) return;
|
|
2566
|
-
geometry.boundsTree = tree;
|
|
2567
|
-
}
|
|
2568
|
-
} finally {
|
|
2569
|
-
worker?.dispose?.();
|
|
2552
|
+
for (const geometry of geometries) {
|
|
2553
|
+
if (signal?.aborted) return;
|
|
2554
|
+
const tree = computeBoundsTree.call(geometry);
|
|
2555
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2556
|
+
if (signal?.aborted) return;
|
|
2557
|
+
geometry.boundsTree = tree;
|
|
2570
2558
|
}
|
|
2571
2559
|
}
|
|
2572
2560
|
function disposeSceneBVH(root) {
|