You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`var positions=item.geometry.attributes.position.array;
var i,triangles=[];
for(i=0;i<positions.length;i+=3){
triangles.push( new THREE.Vector3().fromArray( positions, i ) );
}
if (!triangles.length) return false;
for ( i = 0; i < triangles.length; i++ ) {
triangle = triangles[i];
vec3_1.setX(triangle.x);
vec3_1.setY(triangle.y);
vec3_1.setZ(triangle.z);
vec3_2.setX(triangle.x);
vec3_2.setY(triangle.y);
vec3_2.setZ(triangle.z);
vec3_3.setX(triangle.x);
vec3_3.setY(triangle.y);
vec3_3.setZ(triangle.z);
triangle_mesh.addTriangle(vec3_1, vec3_2, vec3_3, true);
}
var meshShape = new Ammo.btBvhTriangleMeshShape(triangle_mesh, true, true);`
The text was updated successfully, but these errors were encountered:
btBvhTriangleMeshShape requires a btStridingMeshInterface for its constructor. btTriangleMesh is the only class implemented in Ammo.js of that type but has no constructor or method for creating a btTriangleMesh from an array of vertices. It only has the addTriangle method, which requires you to specify each vertex of a triangle, like in your example.
There are other classes that implement btStridingMeshInterface like btTriangleIndexVertexArray whose constructor takes a pointer (so you could pass a pointer to the start of an array of vertices), but you would need to figure out how to define it in ammo.idl and how to use it, as it is currently not implemented in Ammo.js.
If you want concave shape, as an option, atfirst make some triangles form buffergeometry for example - btConvexTriangleMeshShape by set .addTriangle(Ammo.btVector3) then you can build different shape by using btConvexTriangleMeshShape, if dinamic shape - btCompoundShape. if static
btBvhTriangleMeshShape
`var positions=item.geometry.attributes.position.array;
var i,triangles=[];
for(i=0;i<positions.length;i+=3){
triangles.push( new THREE.Vector3().fromArray( positions, i ) );
}
The text was updated successfully, but these errors were encountered: