Reputation: 3358
How to get the geometry of loaded models using OBJMTLloder on callback, i can't get the geometry of the loaded object, if i get it with the object traverse can get the only one portion of the object, i want to get the geometry of the object dynamically to scale the object into center of the scene
object.traverse( function ( child ) {
if (child instanceof THREE.Mesh) {
var geometry = child.geometry;
material = child.material;
child.material.needsUpdate = true;
}
});
Upvotes: 1
Views: 196
Reputation: 12632
If you want to scale the object you dont need to use the traverse()
method. You can do:
object.scale.x = x_scale;
object.scale.y = y_scale;
object.scale.z = z_scale;
You can also use the BoundingBoxHelper()
method to find the approximate size of the object.
Upvotes: 1