Closed Dannie226 closed 3 years ago
you have to switch to BufferGeometry , eg :
// Create mesh
var geo = new THREE.BufferGeometry();
// Add vertices
let vertices = new Float32Array(shape.vertices.length*3);
for (let i = 0; i < shape.vertices.length; i++) {
let v = shape.vertices[i];
vertices[i*3] = v.x;
vertices[i*3+1] = v.y;
vertices[i*3+2]=v.z;
}
geo.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
let faces = new Uint16Array(shape.faces.length*3);
for(let i=0; i < shape.faces.length; i++){
let face = shape.faces[i];
// add triangles
let a = face[0];
faces[i*3] = a;
for (let j = 1; j < face.length - 1; j++) {
let b = face[j];
let c = face[j + 1];
faces[i*3+1] = b;
faces[i*3+2] = c;
}
}
geo.setAttribute( 'index', new THREE.BufferAttribute( faces, 3 ) );
geo.computeBoundingSphere();
// geo.computeFaceNormals();
mesh = new THREE.Mesh(geo, material);
shape.geometryId = geo.id;
If you guys want, there is a maintained version over at https://github.com/pmndrs/cannon-es-debugger
As of three.js revision 125, there is no longer a THREE.Geometry. So when trying to use the debug renderer, my console gets flooded with errors saying that THREE.Geometry is no longer a constructor. I am not familiar enough with THREE.BufferGeometry yet to be able to propose a solution, so if anyone does have one, that would be great.