如何获得透视相机的角度值Three.js? [英] How to get angles value of perspective camera in Three.js?

查看:2168
本文介绍了如何获得透视相机的角度值Three.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能从我的角度来看摄像机在三维场景中每个角度的价值。 我使用 Three.js 库。

How can I get the value from each angle of my perspective camera in 3D scene. I'm using Three.js library.

要更准确,我要庆祝什么,我想要得到已知下一个符号:

To be more accurate, I shall mark what I want to get known with the next sign:

什么坐标我需要知道的:

What coordinates I need to know:

它需要我,因为我创建一个真正的模式,地图引擎通过鼠标光标的移动在3D场景。

It's needed for me, because I'm creating a real mode map engine with moving in 3D scene via mouse cursor.

我想要实现的是可在这里: http://www.zephyrosanemos.com/windstorm/current/live-demo.html

What I'm trying to achieve is available here: http://www.zephyrosanemos.com/windstorm/current/live-demo.html

正如你可以看到,在此示例中,新的地形加载与相交的新位置(其中previously无法获得与垃圾收集,当相机留下老视):

As you could see, in this sample, new terrain is loading with intersecting the new location (which previously were not available with the garbage collection, when the camera is leaving the old viewport):

现在,我想从我的three.js应用程序显示了一块屏幕:

Now, I want to show a piece of screen from my three.js application:

正如你可以看到,我加载我的现场静态,这里可只有一个有建筑物(建筑数据是从我的服务器加载,数据我有令牌一些OSM服务)面。

As you are able to see, I'm loading my scene statically, where is available only one plane with buildings (buildings data are loading from my server, and the data I have token from some osm services).

和只可以用力推键盘键(用于如3D场景是通过推动键盘箭头后也可以看到地图上的空白定位到新的位置控制:)这只是$ P的,因为$ pparing切割数据,DB出于测试目的,当应用程序已经准备好 - 它不会我空的,它是英里易于使用的记录DB光计数)工作。所有的网都被删除,并用新的数据装入每一个新动作和新的建筑呈现。

And it may be controlled only with pushing the keyboard button (for e.g. the 3D scene is locating to the new location by pushing on keyboard arrows, aslo you could see the empty space in map :) this is only because of preparing the cut data in DB for testing purposes, when the application is ready - it won't me empty, it's miles easy to work with light count of records in DB ). All meshes are being deleted, and with each new movement the new data is loaded and the new building are rendered.

不过,我想令他们动态加载的带摄像头的运动。所以,我想让它能够动态地加载动态地形生成的例子。我建议,我将prepare一个大平面矩阵,它加载数据仅用于8架飞机(如地形生成样品),并做出逻辑与相机intersacting / leavaing旧视图对于这样一个充满活力的工作。

But I want to made them loaded dynamically with camera movement. So I want to make it be able dynamically loaded as in the example of dynamic terrain generation. I suggest, that I shall prepare a big plane matrix, which loads data only for the 8 planes (as in terrain generation sample) and to make a logic with the camera intersacting/leavaing old view for such a dynamic work.

所以...我希望你能帮助我这块硬任务:)

So... I want you to help me with this piece of hard task :)

推荐答案

要获得的视角领域只是得到这个字段的值:

To get the field of view angle simply get the value of this field:

Three.PerspectiveCamera.fov

Three.PerspectiveCamera.fov

通过这个角度,你应该可以有一个想象立方锥和测试它的碰撞。对于碰撞的部分是指这样一个问题:

With that angle you should can have an imaginary cubic cone and test it for collision. For the collision part refer to this question:

如何检测碰撞three.js?

这篇关于如何获得透视相机的角度值Three.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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