Three.js:带缩放阻尼的OrbitControl? [英] Three.js: OrbitControl with zoom damping?

查看:1103
本文介绍了Three.js:带缩放阻尼的OrbitControl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阻尼功能已添加到three.js的r.72dev分支中。
它适用于更平滑的旋转。

The damping feature has been added in the r.72dev branch of three.js. It works great for smoother rotating.

它是否也能为缩放启用阻尼(惯性)?

Does it enable damping (inertia) for the zoom as well?

controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.enableDamping = true;
controls.dampingFactor = 0.25;


推荐答案

我为 three.js r73 OrbitControls 查看此演示

http://jsfiddle.net/L0rdzbej/149/

用法就像默认的Orbit Controls一样,您可以使用这些设置进行自定义:

Usage is just like the default Orbit Controls, you can play with these settings to customize it:

controls.constraint.smoothZoom = true;
controls.constraint.zoomDampingFactor = 0.2;
controls.constraint.smoothZoomSpeed = 5.0;

缺点:仅适用于鼠标滚轮,不适用于缩放或鼠标中键。我想它可以延长,但直到现在我还不够在乎。我愿意接受建议。

Drawback: works only for the mousewheel, not touch zoom or middle mouse. I guess it could be extended, but until now I did not care enough. Im open for suggestions.

我的解决方案基于2013年paulkaplan的这个要点: https://gist.github.com/paulkaplan/5770247 。毋庸置疑,自那以后,three.js和Orbit Controls发生了很大的变化。如果一些前作者正式添加此功能,我将不胜感激,但有时需要一段时间; - )

My solution is based on this gist from paulkaplan dated 2013: https://gist.github.com/paulkaplan/5770247. Needless to say three.js and Orbit Controls changed a lot since then. I would be grateful if some former author would add this feature officially, but sometimes it takes quite a while ;-)


为了给你一个快速的概述我修改了以下内容:

To give you a quick overview I modified the following:

OrbitContraint( )

缩放所需的一堆变量,

添加了函数: this.smoothZoomUpdate = function(){/ * ... * /};

并在里面调用它 OrbitConstraint.update()功能:

this.update = function () {
    //...
    this.smoothZoomUpdate ();
    //...
}

同样在<$ c $里面c> THREE.OrbitControls()修改了函数 onMouseWheel(){/ * ... * /}

这篇关于Three.js:带缩放阻尼的OrbitControl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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