简体   繁体   中英

Zoom in and Zoom out Threejs

当我放大时,我已经向场景中添加了球体,还向场景中添加了一些平面几何形状。我希望平面几何形状看起来更小,而当我缩小平面几何形状时应该看起来更大,我不知道如何解决此问题,有人可以吗?帮助我解决这个问题。

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM