轨道控制.js:如何放大/缩小 [英] orbitcontrols.js: How to Zoom In/ Zoom Out

查看:22
本文介绍了轨道控制.js:如何放大/缩小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用orbitcontrols.js(搭配THREE.js),我想在代码中实现与旋转鼠标滚轮相同的效果.例如,我想调用像 camera.zoomIn() 这样的东西,让它朝着目标移动一个设定的距离.有人知道怎么做吗?

Using orbitcontrols.js (with THREE.js), I want to achieve the same effect in code as rotating the mouse wheel. For example, I want to call something like camera.zoomIn() and have it move a set distance toward the target. Anyone know how to do this?

推荐答案

从源码看可以调用 .dollyIn(dollyScale).dollyOut(dollyScale)OrbitalControls 对象上.

From looking at the source code you can call .dollyIn(dollyScale) and .dollyOut(dollyScale) on the OrbitalControls object.

这些不是公共方法;可以通过编辑 OrbitalControls.js 来访问它们.

these aren't public methods; one can access them by editing OrbitalControls.js though.

我在 THREE.OrbitControls 函数中添加了 this.dIn = dollyIn;,我现在可以通过调用 controls.dIn(1.05); 来放大.control.update(); 来自外部.

I added this.dIn = dollyIn; to the THREE.OrbitControls function, I can now zoom in by calling controls.dIn(1.05); controls.update(); from outside.

这篇关于轨道控制.js:如何放大/缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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