diff --git a/index.js b/index.js index 736e713..ad246bc 100644 --- a/index.js +++ b/index.js @@ -669,7 +669,6 @@ const _finishCollisionShape = function(collisionShape, options, scale) { export const iterateGeometries = (function() { const inverse = new THREE.Matrix4(); - const vertices = []; return function(root, options, cb) { inverse.copy(root.matrixWorld).invert(); root.traverse(mesh => { @@ -688,7 +687,7 @@ export const iterateGeometries = (function() { // todo: might want to return null xform if this is the root so that callers can avoid multiplying // things by the identity matrix - let unInterleavedVertices; + let vertices; if (mesh.geometry.isBufferGeometry) { const verticesAttribute = mesh.geometry.attributes.position; if (verticesAttribute.isInterleavedBufferAttribute) { @@ -698,22 +697,21 @@ export const iterateGeometries = (function() { // regular array here to not carry this logic around in // the shape api. // - vertices.length = 0; + vertices = []; for (let i = 0; i < verticesAttribute.count; i += 3) { vertices.push(verticesAttribute.getX(i)); vertices.push(verticesAttribute.getY(i)); vertices.push(verticesAttribute.getZ(i)); } - unInterleavedVertices = vertices; } else { - unInterleavedVertices = verticesAttribute.array; + vertices = verticesAttribute.array; } } else { - unInterleavedVertices = mesh.geometry.vertices; + vertices = mesh.geometry.vertices; } cb( - unInterleavedVertices, + vertices, transform.elements, mesh.geometry.index ? mesh.geometry.index.array : null ); diff --git a/package.json b/package.json index 014a362..b2affc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@c-frame/three-to-ammo", - "version": "1.0.2", + "version": "1.0.3", "description": "Convert THREE.Mesh to Ammo.btCollisionShape", "homepage": "https://github.com/infinitelee/three-to-ammo", "main": "index.js",