I try to do a camera flight from on object to another and to another and to another…(and stay there for a couple secconds before fly to next object)
Objects are in an array.
My problem can be seen here :Click
I need the camera to rotate to next object and move from this position to next object. No just like noe, move out and move in again to next object. Should look like a path abit.
My function to move the camera to next object
function camFlyTo(o,object){ var ob=this;
if(!ob.autoRender){ob.autoRender=24;}
if(!ob.camera.neddedDirection){
ob.camera.neddedDirection={curPosition:ob.camera.position,curRotation:ob.camera.rotation,distance:ob.Distance(ob.camera,o),rotation:ob.Rotation(o,ob.camera),obPos:o.position,speed:0.4,stayaway:0,altitude:10}
if(object){
if(object.altitude){ob.camera.neddedDirection.altitude=object.altitude;}
if(object.speed){ob.camera.neddedDirection.speed=object.speed;}
if(object.stayaway){ob.camera.neddedDirection.stayaway=object.stayaway;}
}
ob.camera.moveSteps=0;
}
ob.camera.rotation.order = "YXZ";
var distance=ob.Distance(ob.camera,o);
ob.camera.moveSteps+=ob.camera.neddedDirection.speed;
var prz=100/(ob.camera.neddedDirection.distance-ob.camera.neddedDirection.stayaway)*ob.camera.moveSteps;
if(prz>100){ return true;}else{
var ease='regularinout';
var x=ob.Onvalback(ob.camera.neddedDirection.curPosition.x,ob.camera.neddedDirection.obPos.x,prz,ease);
var y=ob.Onvalback(ob.camera.neddedDirection.curPosition.y,ob.camera.neddedDirection.obPos.y,prz,ease);
var z=ob.Onvalback(ob.camera.neddedDirection.curPosition.z,ob.camera.neddedDirection.obPos.z,prz,ease)+ob.camera.neddedDirection.altitude;
var rx=ob.Onvalback(ob.camera.neddedDirection.curRotation.x,ob.camera.neddedDirection.rotation.x,prz,ease);
var ry=ob.Onvalback(ob.camera.neddedDirection.curRotation.y,ob.camera.neddedDirection.rotation.y,prz,ease);
var rz=ob.Onvalback(ob.camera.neddedDirection.curRotation.z,ob.camera.neddedDirection.rotation.z,prz,ease);
var bounds=ob.getVector(o,x,y,z);
ob.setPosition(ob.camera,x,y,z);
ob.setRotation(ob.camera,rx,ry,rz);
ob.camera.lookAt(new THREE.Vector3(x,y,z));
}
return false;
}
// camFlyTo([object, mesh, model],[ob.camera.neddedDirection Add ons as Object])
//ob.Distance calculates distance between two objects
//ob.Rotation returns the angles as {rotation.x,rotation.y,rotation.z} from one object to another
//ob.Onvalback returns the result for two numbers by percentage and easing
//ob.setPosition just sets position.x - position.y for object
//ob.setRotation just sets rotation.x - rotation.y for object
I’m a complete newbe with three.js.
Anybody out there who may help me