在 ThreeJS 中缩放到对象 [英] Zoom to object in ThreeJS

查看:22
本文介绍了在 ThreeJS 中缩放到对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在three.js中哪里可以改变缩放方向?我想放大鼠标光标的方向,但我不知道在哪里可以更改缩放目标.

Where can I change the zoom direction in three.js? I would like to zoom in the direction of the mouse cursor but I don't get where you can change the zoom target.

推荐答案

更新了wetwipe的解决方案以支持Three.js的71修订版,并对其进行了一些清理,效果很赞,参见http://www.tectractys.com/market_globe.html 完整使用示例:

updated wetwipe's solution to support revision 71 of Three.js, and cleaned it up a little bit, works like a charm, see http://www.tectractys.com/market_globe.html for a full usage example:

mX = ( event.clientX / window.innerWidth ) * 2 - 1;
mY = - ( event.clientY / window.innerHeight ) * 2 + 1;
var vector = new THREE.Vector3(mX, mY, 1 );
vector.unproject(camera);
vector.sub(camera.position);
camera.position.addVectors(camera.position,vector.setLength(factor));
controls.target.addVectors(controls.target,vector.setLength(factor));

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

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