Struggling with animating a bin packing problem using Three.JS and Tween.JS. I am having difficulty getting the animation to play successively rather than all at once within my loop. Attempting to use the setTimeout solution has not been successful. Does anyone know how to make ThreeJS/TweenJs wait between each animation loop?
Bin packing placement code :
var GeometryArray = Array();
for(let i=0; i < elementNumber; i++){
let elementHeight = GeometryArray[i].geometry.parameters.height;
let elementWidth = GeometryArray[i].geometry.parameters.width;
//rest of the code...
}
My function to animate the set position :
function MoveObject(mesh, positionX, positionY){
var position = { x : mesh.position.x, y : mesh.position.y };
var target = { x : positionX, y : positionY };
var tween = new TWEEN.Tween(position).to(target, 1000);
tween.onUpdate(function(){
mesh.position.x = position.x;
mesh.position.y = position.y;
});
tween.start();
}