I am really new to Three JS and Tween JS. I picked it up for my project and have been frustrated lately. I've been having trouble trying to tween object1. There are other objects in the scene as well. object2, obeject3, etc. I am not sure if I should add numbers to mtlLoaders and objLoaders as well.
var mtlLoader = new THREE.MTLLoader( );
mtlLoader.transparency = true;
mtlLoader.setBaseUrl( 'assets/' )
mtlLoader.setPath( 'assets/' );
mtlLoader.load( 'exterior.mtl', function ( materials )
{
materials.side = THREE.DoubleSide;
materials.preload();
materials.opacity = 0
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials( materials );
objLoader.setPath( 'assets/' );
objLoader.load( 'exterior.obj', function ( object1 )
{
object1.position.y = .01
object1.position.z = -8
object1.scale.set( .04, .04, .04 );
object1.castShadow = true;
object1.receiveShadow = true;
scene.add( object1 );
}, onProgress, onError );
});
document.getElementById("engage").onclick = function engage()
{
test.start()
};
Here is my tween. I don't want the tween to start right away as I want it to start when a button is hit.
var test = new TWEEN.Tween(object1.position).to({ x: 1, y: 0, z: 0 }, 2000);
test.easing(TWEEN.Easing.Quartic.InOut);
The tween seems to work when I put it after the scene.add( object1 )
and start it right away but I want it to start when a button is clicked. Any help is appreciated.