Skip to content Skip to sidebar Skip to footer

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 appea

Solution 1:

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;
    } elseif (!zoomingIn && camera.position.z < 100) {
        camera.position.z += 0.1;
    }

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

Post a Comment for "Zoom In And Zoom Out Threejs"