Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
3c904f38
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3c904f38
编写于
10月 22, 2018
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebVR: Moved setProjectionFromUnion method to internal WebVRUtils.
上级
f565ac40
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
72 addition
and
67 deletion
+72
-67
src/cameras/ArrayCamera.js
src/cameras/ArrayCamera.js
+1
-65
src/renderers/webvr/WebVRManager.js
src/renderers/webvr/WebVRManager.js
+2
-1
src/renderers/webvr/WebVRUtils.js
src/renderers/webvr/WebVRUtils.js
+67
-0
src/renderers/webvr/WebXRManager.js
src/renderers/webvr/WebXRManager.js
+2
-1
未找到文件。
src/cameras/ArrayCamera.js
浏览文件 @
3c904f38
...
...
@@ -3,7 +3,6 @@
*/
import
{
PerspectiveCamera
}
from
'
./PerspectiveCamera.js
'
;
import
{
Vector3
}
from
'
../math/Vector3.js
'
;
function
ArrayCamera
(
array
)
{
...
...
@@ -17,70 +16,7 @@ ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototyp
constructor
:
ArrayCamera
,
isArrayCamera
:
true
,
/**
* Assumes 2 cameras that are perpendicular and share an X-axis, and that
* the cameras' projection and world matrices have already been set.
* And that near and far planes are identical for both cameras.
*/
setProjectionFromUnion
:
function
()
{
var
cameraLPos
=
new
Vector3
();
var
cameraRPos
=
new
Vector3
();
return
function
()
{
cameraLPos
.
setFromMatrixPosition
(
this
.
cameras
[
0
].
matrixWorld
);
cameraRPos
.
setFromMatrixPosition
(
this
.
cameras
[
1
].
matrixWorld
);
var
ipd
=
cameraLPos
.
distanceTo
(
cameraRPos
);
var
projL
=
this
.
cameras
[
0
].
projectionMatrix
;
var
projR
=
this
.
cameras
[
1
].
projectionMatrix
;
// VR systems will have identical far and near planes, and
// most likely identical top and bottom frustum extents.
// via: https://computergraphics.stackexchange.com/a/4765
var
near
=
projL
[
14
]
/
(
projL
[
10
]
-
1
);
var
far
=
projL
[
14
]
/
(
projL
[
10
]
+
1
);
var
leftFovL
=
(
projL
[
8
]
-
1
)
/
projL
[
0
];
var
rightFovR
=
(
projR
[
8
]
+
1
)
/
projR
[
0
];
var
leftL
=
leftFovL
*
near
;
var
rightR
=
rightFovR
*
near
;
var
topL
=
near
*
(
projL
[
9
]
+
1
)
/
projL
[
5
];
var
topR
=
near
*
(
projR
[
9
]
+
1
)
/
projR
[
5
];
var
bottomL
=
near
*
(
projL
[
9
]
-
1
)
/
projL
[
5
];
var
bottomR
=
near
*
(
projR
[
9
]
-
1
)
/
projR
[
5
];
// Calculate the new camera's position offset from the
// left camera.
var
zOffset
=
ipd
/
(
leftFovL
+
rightFovR
);
var
xOffset
=
zOffset
*
leftFovL
;
// TODO: Better way to apply this offset?
this
.
cameras
[
0
].
matrixWorld
.
decompose
(
this
.
position
,
this
.
quaternion
,
this
.
scale
);
this
.
translateX
(
xOffset
);
this
.
translateZ
(
-
zOffset
);
this
.
matrixWorld
.
compose
(
this
.
position
,
this
.
quaternion
,
this
.
scale
);
this
.
matrixWorldInverse
.
getInverse
(
this
.
matrixWorld
);
// Find the union of the frustum values of the cameras and scale
// the values so that the near plane's position does not change in world space,
// although must now be relative to the new union camera.
var
near2
=
near
+
zOffset
;
var
far2
=
far
+
zOffset
;
var
left
=
leftL
-
xOffset
;
var
right
=
rightR
+
(
ipd
-
xOffset
);
var
top
=
Math
.
max
(
topL
,
topR
);
var
bottom
=
Math
.
min
(
bottomL
,
bottomR
);
this
.
projectionMatrix
.
makePerspective
(
left
,
right
,
top
,
bottom
,
near2
,
far2
);
};
}(),
isArrayCamera
:
true
}
);
...
...
src/renderers/webvr/WebVRManager.js
浏览文件 @
3c904f38
...
...
@@ -10,6 +10,7 @@ import { Quaternion } from '../../math/Quaternion.js';
import
{
ArrayCamera
}
from
'
../../cameras/ArrayCamera.js
'
;
import
{
PerspectiveCamera
}
from
'
../../cameras/PerspectiveCamera.js
'
;
import
{
WebGLAnimation
}
from
'
../webgl/WebGLAnimation.js
'
;
import
{
setProjectionFromUnion
}
from
'
./WebVRUtils.js
'
;
function
WebVRManager
(
renderer
)
{
...
...
@@ -323,7 +324,7 @@ function WebVRManager( renderer ) {
cameraL
.
projectionMatrix
.
fromArray
(
frameData
.
leftProjectionMatrix
);
cameraR
.
projectionMatrix
.
fromArray
(
frameData
.
rightProjectionMatrix
);
cameraVR
.
setProjectionFromUnion
(
);
setProjectionFromUnion
(
cameraVR
,
cameraL
,
cameraR
);
//
...
...
src/renderers/webvr/WebVRUtils.js
0 → 100644
浏览文件 @
3c904f38
/**
* @author jsantell / https://www.jsantell.com/
* @author mrdoob / http://mrdoob.com/
*/
import
{
Vector3
}
from
'
../../math/Vector3.js
'
;
var
cameraLPos
=
new
Vector3
();
var
cameraRPos
=
new
Vector3
();
/**
* Assumes 2 cameras that are perpendicular and share an X-axis, and that
* the cameras' projection and world matrices have already been set.
* And that near and far planes are identical for both cameras.
*/
function
setProjectionFromUnion
(
camera
,
cameraL
,
cameraR
)
{
cameraLPos
.
setFromMatrixPosition
(
cameraL
.
matrixWorld
);
cameraRPos
.
setFromMatrixPosition
(
cameraR
.
matrixWorld
);
var
ipd
=
cameraLPos
.
distanceTo
(
cameraRPos
);
var
projL
=
cameraL
.
projectionMatrix
;
var
projR
=
cameraR
.
projectionMatrix
;
// VR systems will have identical far and near planes, and
// most likely identical top and bottom frustum extents.
// via: https://computergraphics.stackexchange.com/a/4765
var
near
=
projL
[
14
]
/
(
projL
[
10
]
-
1
);
var
far
=
projL
[
14
]
/
(
projL
[
10
]
+
1
);
var
leftFovL
=
(
projL
[
8
]
-
1
)
/
projL
[
0
];
var
rightFovR
=
(
projR
[
8
]
+
1
)
/
projR
[
0
];
var
leftL
=
leftFovL
*
near
;
var
rightR
=
rightFovR
*
near
;
var
topL
=
near
*
(
projL
[
9
]
+
1
)
/
projL
[
5
];
var
topR
=
near
*
(
projR
[
9
]
+
1
)
/
projR
[
5
];
var
bottomL
=
near
*
(
projL
[
9
]
-
1
)
/
projL
[
5
];
var
bottomR
=
near
*
(
projR
[
9
]
-
1
)
/
projR
[
5
];
// Calculate the new camera's position offset from the
// left camera.
var
zOffset
=
ipd
/
(
leftFovL
+
rightFovR
);
var
xOffset
=
zOffset
*
leftFovL
;
// TODO: Better way to apply this offset?
cameraL
.
matrixWorld
.
decompose
(
camera
.
position
,
camera
.
quaternion
,
camera
.
scale
);
camera
.
translateX
(
xOffset
);
camera
.
translateZ
(
-
zOffset
);
camera
.
matrixWorld
.
compose
(
camera
.
position
,
camera
.
quaternion
,
camera
.
scale
);
camera
.
matrixWorldInverse
.
getInverse
(
camera
.
matrixWorld
);
// Find the union of the frustum values of the cameras and scale
// the values so that the near plane's position does not change in world space,
// although must now be relative to the new union camera.
var
near2
=
near
+
zOffset
;
var
far2
=
far
+
zOffset
;
var
left
=
leftL
-
xOffset
;
var
right
=
rightR
+
(
ipd
-
xOffset
);
var
top
=
Math
.
max
(
topL
,
topR
);
var
bottom
=
Math
.
min
(
bottomL
,
bottomR
);
camera
.
projectionMatrix
.
makePerspective
(
left
,
right
,
top
,
bottom
,
near2
,
far2
);
}
export
{
setProjectionFromUnion
};
src/renderers/webvr/WebXRManager.js
浏览文件 @
3c904f38
...
...
@@ -7,6 +7,7 @@ import { Vector4 } from '../../math/Vector4.js';
import
{
ArrayCamera
}
from
'
../../cameras/ArrayCamera.js
'
;
import
{
PerspectiveCamera
}
from
'
../../cameras/PerspectiveCamera.js
'
;
import
{
WebGLAnimation
}
from
'
../webgl/WebGLAnimation.js
'
;
import
{
setProjectionFromUnion
}
from
'
./WebVRUtils.js
'
;
function
WebXRManager
(
renderer
)
{
...
...
@@ -181,7 +182,7 @@ function WebXRManager( renderer ) {
}
cameraVR
.
setProjectionFromUnion
(
);
setProjectionFromUnion
(
cameraVR
,
cameraL
,
cameraR
);
return
cameraVR
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录