three.js-如何获取对象的顶点? [英] three.js - how do I get the vertices of an object?

查看:278
本文介绍了three.js-如何获取对象的顶点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Blender导入模型并遍历所有顶点.我正在使用colladaloader进行导入.一切正常,模型正在加载.但是我不想要模型的面-我只需要顶点位置即可.

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?

谢谢, 托莫

推荐答案

好吧,我明白了...

Ok now I got it...

console.log()帮助我了解了加载的.dae文件背后的结构.

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...
            }
        }
    }

    //...
} );

这篇关于three.js-如何获取对象的顶点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆