user2716762
user2716762

Reputation: 11

THREE.Js How acess a object outside the OBJMTLLoader

Does anybody knows how can i acess a object outside a OBJMTLLoader

var loader = new THREE.OBJMTLLoader();
loader.load( obj, mtl, function ( object ) {
object.position.set(0,0,0);
scene.add( object );
});

console.log(object);

inside of the function objects = THREE.Object3D but outside is equal do ObjectLoad.

Thanks for everybody.

Upvotes: 0

Views: 918

Answers (1)

Christopher
Christopher

Reputation: 13157

The object is simply inside the scope of the undefined function.

Set the function to return the object

var loader = new THREE.OBJMTLLoader();
loader.load( obj, mtl, function ( object ) {

object.position.set(0,0,0);

return object;//here
});

scene.add( object );
console.log(object);

Upvotes: 1

Related Questions