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

查看:855
本文介绍了在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天全站免登陆