Zoom in and Zoom out Threejs

2019-09-14 14:47发布

问题:

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.

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

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