@@ -1,4 +1,5 @@
|
|
1
1
|
import { BufferAttribute, BufferGeometry, LineBasicMaterial, LineSegments, Matrix4, Mesh, Object3D, Quaternion, Vector3 } from 'three'
|
2
|
+
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
2
3
|
import { CircularBuffer, getParam } from "./engine_utils.js"
|
3
4
|
import { getWorldPosition, getWorldQuaternion, getWorldScale, setWorldPositionXYZ, setWorldQuaternionXYZW } from "./engine_three_utils.js"
|
4
5
|
import {
|
@@ -547,12 +548,18 @@
|
|
547
548
|
if (debugPhysics) console.warn("Physics are disabled");
|
548
549
|
return;
|
549
550
|
}
|
550
|
-
|
551
|
+
let geo = mesh.geometry;
|
551
552
|
if (!geo) {
|
552
553
|
if (debugPhysics) console.warn("Missing mesh geometry", mesh.name);
|
553
554
|
return;
|
554
555
|
}
|
555
556
|
|
557
|
+
// check if mesh is indexed, if not generate indices
|
558
|
+
if (!geo.index?.array?.length) {
|
559
|
+
console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh \"${mesh.name}\". Consider providing an indexed geometry.`);
|
560
|
+
geo = BufferGeometryUtils.mergeVertices(geo);
|
561
|
+
}
|
562
|
+
|
556
563
|
let positions = geo.getAttribute("position").array as Float32Array;
|
557
564
|
const indices = geo.index?.array as Uint32Array;
|