轨道控制.js:如何放大/缩小 [英] orbitcontrols.js: How to Zoom In/ Zoom Out
问题描述
使用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屋!