在three.js一个真实世界的角度投射Z值 [英] Projective Z-value of a real-world point in three.js

查看:146
本文介绍了在three.js一个真实世界的角度投射Z值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一些世界点的反规范化投影Z值。

我目前能够得到的投影X,做Y值什么mrdoob显示在这里: http://stackoverflow.com/a/ 11605007

这个例子说明了如何去正常化投影X,Y(从范围服用[-1,1]成实际屏幕坐标)。它没有说明如何去正常化投影Z.这些投影Z值也都在[1,1]的范围内,但我不知道怎么去归他们。

要在框架code中的问题,建立在上述mrdoob的回答:

  VAR WIDTH = 640,高度= 480;
VAR widthHalf =宽度/ 2,heightHalf =身高/ 2;

VAR投影机=新THREE.Projector();
//这可以是任何点;使用例如,从mrdoob的答案
。VAR someWorldPoint = object.matrixWorld.getPosition()的clone();
VAR向量= projector.projectVector(someWorldPoint,摄像头);

vector.x =(vector.x * widthHalf)+ widthHalf;
vector.y =  - (vector.y * heightHalf)+ heightHalf;
//什么呢vector.z重新present和我怎么去规范化vector.z?
 

感谢您的帮助。如果我的任何术语的不正确或混​​淆,请更正。

解决方案

z值用于深度分选

。它不旨在是反规范化

附近平面映射到z = -1,平面映射到z = 1

点的平截头体里面将映射到-1和1之间(映射不是线性的,但是。)

的z值

I want to find the de-normalized projective Z-value for some world point.

I am currently able to get the projective X,Y values by doing what mrdoob shows here: http://stackoverflow.com/a/11605007

That example shows how to de-normalize the projective X,Y (taking it from the range [-1, 1] into actual screen coordinates). It does not show how to de-normalize the projective Z. These projective Z values also are in the range of [-1, 1] but I don't know how to de-normalize them.

To frame the question in code, building on mrdoob's answer above:

var width = 640, height = 480;
var widthHalf = width / 2, heightHalf = height / 2;

var projector = new THREE.Projector();
// this could be any point; using example from mrdoob's answer
var someWorldPoint = object.matrixWorld.getPosition().clone();
var vector = projector.projectVector(someWorldPoint, camera );

vector.x = ( vector.x * widthHalf ) + widthHalf;
vector.y = - ( vector.y * heightHalf ) + heightHalf;
// what does vector.z represent and how do I de-normalize vector.z?

Thanks for your help. If any of my terminology is incorrect or confusing please correct it.

解决方案

The z-value is used for depth-sorting. It is not intended to be "de-normalized".

The near plane maps to z = -1, and the far plane maps to z = 1.

Points inside the frustum will map to a z-value between -1 and 1. (The mapping is not linear, however.)

这篇关于在three.js一个真实世界的角度投射Z值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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