问题
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.
Here is a piece of code:
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
I am thankful for your helps in advance.
回答1:
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.71
来源:https://stackoverflow.com/questions/30580997/vertices-array-does-not-give-the-vertices-in-three-js