lakers1234
lakers1234

Reputation: 125

Zoom in and Zoom out Threejs

I have added sphere to the scene and also some plane geometry to the scene when i zoom in I want the plane geometry look smaller and when i zoom out the plane geometry should appear bigger I don't know how to solve this problem can someone please help me with this problem.

Upvotes: 0

Views: 3820

Answers (1)

MartyBoggs
MartyBoggs

Reputation: 381

Yes! You should animate the camera in this case.

I'm assuming your objects are in the middle at 0, 0, 0.

var zoomingIn = true;

function render() {
    if (zoomingIn && camera.position.z > 10) {
        camera.position.z -= 0.1;
    } else if (!zoomingIn && camera.position.z < 100) {
        camera.position.z += 0.1;
    }

    requestAnimationFrame( render );
    renderer.render(scene, camera);
}
render();

Upvotes: 1

Related Questions