, , (, , lookAt. . Open GL .
, .
, FOV .
Webgl, , , http://stemkoski.imtqy.com/Three.js/Chase-Camera.html
, .
, , :
if(typeof fc == "undefined") fc=0;
var delta =0.02;
var y=object.rotation.y;
var dir=object.rotation.y-fc;
var fc = THREE.Math.clamp( fc + 2 * delta * dir, y-control.followRadius, y+control.followRadius );
var sn = Math.sin( fc);
var cs = Math.cos(fc);
camera.rotation.set(0,0,0);
camera.position.x=object.position.x+(control.positionOffsetZ*sn);
camera.position.y=object.position.y+control.positionOffsetY;
camera.position.z=object.position.z+(control.positionOffsetZ*cs);
camera.lookAt(new THREE.Vector3(
object.position.x+(control.targetOffsetZ*sn)
,object.position.y+control.targetOffsetY
,object.position.z+(control.targetOffsetZ*cs)
));
var control = {"positionOffsetZ":-39,"positionOffsetY":3.2,"targetOffsetZ":5,"targetOffsetY":0,"followRadius":0.35
});
consider that the βobjectβ is a fictitious invisible cube on which your camera is attached, and you move the same with the key. You can directly insert this piece of code into your wirk and the rest. If any question or doubt feel free to ask.
source
share