What is the best options for animations (texture animations, moving objects, hiding/showing object,...) in three.js ? Do you use extra lib. such as tween.js or something els
I made this to emulate orbiting with human characteristics (jerky) but it can be used for other animations like object translations, positions and rotations.
function twController(node,prop,arr,dur){
var obj,first,second,xyz,i,v,tween,html,prev,starter;
switch(node){
case "camera": obj = camera; break;
default: obj = scene.getObjectByName(node);
}
xyz = "x,y,z".split(",");
$.each(arr,function(i,v){
first = obj[prop];
second = {};
$.each(v,function(i,v){
second[xyz[i]] = v;
})
tween = new TWEEN.Tween(first)
.to(second, dur)
.onUpdate(function(){
$.each(xyz,function(i,v){
obj[prop][xyz[i]] = first[xyz[i]];
})
})
.onComplete(function(){
html = [];
$.each(xyz,function(i,v){
html.push(Math.round(first[xyz[i]]));
})
$("#camPos").html(html.join(","))
})
if(i >0){
tween.delay(250);
prev.chain(tween);
}
else{
starter = tween;
}
prev = tween;
});
starter.start();
}