放大和缩小Threejs [英] Zoom in and Zoom out Threejs

查看:872
本文介绍了放大和缩小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.

推荐答案

是的!在这种情况下,您应该为相机设置动画。

Yes! You should animate the camera in this case.

我假设您的对象位于0、0、0的中间。

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

这篇关于放大和缩小Threejs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆