问题
I am trying to import a model from blender and loop through all vertices. I am using the colladaloader for the import. It all works fine and the model is loading. But I do not want the faces of the model - I only need the vertex positions for my purposes.
Can anyone tell me if there is a way to do this? e.g. a loop that loops through all vertices of the imported model?
Thanks, Tomo
回答1:
If geo
represents your geometry:
for (var i = 0; i < geo.vertices.length; i++)
{
var v = geo.vertices[i];
// do stuff with v...
}
回答2:
Ok now I got it...
console.log() helped me a lot to see what structure is behind the loaded .dae file.
loader.load( './models/collada/test.dae', function ( collada ) {
for(i = 0; i < collada.scene.children.length; i++) {
if(collada.scene.children[i].geometry) {
for(j = 0; j < collada.scene.children[i].geometry.vertices.length; j++) {
//do stuff...
}
}
}
//...
} );
回答3:
Well, you import your Blender Model as a mesh, using a loader module. The mesh has a geometry it is based on. And the geometry has a vertices-Array. Just iterate over that? And maybe just don't add it to the scene if you don't want to display the model? At first glance, your question seems not very well researched. Check out the Mesh object structure and see the Three.js Examples!
来源:https://stackoverflow.com/questions/18967423/three-js-how-do-i-get-the-vertices-of-an-object