.vertices 数组不提供 THREE.js 中的顶点 [英] .vertices array does not give the vertices in THREE.js

查看:28
本文介绍了.vertices 数组不提供 THREE.js 中的顶点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 OBJloader 在 WEBGL 中加载 .obj 文件,Three.js.我想访问对象的顶点和面,但 geometry.vertices 不返回顶点位置,它给我未定义.

I am using OBJloader to load an .obj file in WEBGL , Three.js. I want to access the vertices and faces of the objects but the geometry.vertices does not return the vertices positions and it gives me undefined.

这是一段代码:

 var tool= new THREE.OBJLoader();
 tool.load( '../obj/tool.obj', function ( object ) {
            var material = new THREE.MeshLambertMaterial({color:0xA0A0A0});             
            object.traverse( function ( child ) {
                if ( child instanceof THREE.Mesh ) {
                   child.material = material;
                   console.log( "child" + child.geometry.vertices);} }

r.70

非常感谢您的帮助.

推荐答案

此答案仅适用于 r.125 之前的three.js 版本.

如果您使用的加载器正在返回 BufferGeometry,您可以使用如下模式在加载器回调中将返回的几何图形转换为 Geometry:

If the loader you are using is returning BufferGeometry, you can convert the returned geometry to Geometry in the loader callback using a pattern like so:

var geometry = new THREE.Geometry().fromBufferGeometry( bufferGeometry );

three.js r.124

three.js r.124

这篇关于.vertices 数组不提供 THREE.js 中的顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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