Search code examples
three.jscameraposition

camera movement trajectory three.js


I think this picture better explains my problem: http://i48.tinypic.com/wvrbcy.png

On this picture the camera is moving along the ellipse. The code I have for this trajectory is:

var r = 0;
function render() {
    cameraMain.rotation.y+=0.003;
    cameraMain.position.x = Math.sin(r*0.1)*500;
    cameraMain.position.z = Math.cos(r*0.1)*1000;
    r+=Math.PI/180*2;
}

But that's not what I need. I want my camera to move in a kinda star trajectory, so that it'll have kinda 'zoom in' / 'zoom out' effect. How can I accomplish this?


Solution

  • You want to google "parametric equation" for "astroid", or "deltoid curve", or "superellipse".

    Here are some links where you can get the kinds of parametric equations you are looking for:

    Astroid: http://en.wikipedia.org/wiki/Astroid

    Deltoid Curve: http://en.wikipedia.org/wiki/Deltoid_curve