Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
f9fb5739
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,发现更多精彩内容 >>
提交
f9fb5739
编写于
4月 29, 2019
作者:
F
Fernando Serrano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove matrices from camera and object and move them to aux variables to reuse them
上级
ea60c3b7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
53 deletion
+63
-53
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+5
-15
src/renderers/webgl/WebGLMultiview.js
src/renderers/webgl/WebGLMultiview.js
+58
-38
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
f9fb5739
...
...
@@ -1463,16 +1463,8 @@ function WebGLRenderer( parameters ) {
object
.
onBeforeRender
(
_this
,
scene
,
camera
,
geometry
,
material
,
group
);
currentRenderState
=
renderStates
.
get
(
scene
,
_currentArrayCamera
||
camera
);
if
(
multiview
.
isEnabled
()
)
{
multiview
.
computeObjectMatrices
(
object
,
camera
);
}
else
{
object
.
modelViewMatrix
.
multiplyMatrices
(
camera
.
matrixWorldInverse
,
object
.
matrixWorld
);
object
.
normalMatrix
.
getNormalMatrix
(
object
.
modelViewMatrix
);
}
object
.
modelViewMatrix
.
multiplyMatrices
(
camera
.
matrixWorldInverse
,
object
.
matrixWorld
);
object
.
normalMatrix
.
getNormalMatrix
(
object
.
modelViewMatrix
);
if
(
object
.
isImmediateRenderObject
)
{
...
...
@@ -1745,8 +1737,7 @@ function WebGLRenderer( parameters ) {
if
(
material
.
supportsMultiview
&&
multiview
.
isEnabled
()
)
{
multiview
.
computeCameraMatrices
(
camera
);
p_uniforms
.
setValue
(
_gl
,
'
projectionMatrices
'
,
camera
.
projectionMatrices
);
multiview
.
updateCameraProjectionMatrices
(
camera
,
p_uniforms
);
}
else
{
...
...
@@ -1802,7 +1793,7 @@ function WebGLRenderer( parameters ) {
if
(
material
.
supportsMultiview
&&
multiview
.
isEnabled
()
)
{
p_uniforms
.
setValue
(
_gl
,
'
viewMatrices
'
,
camera
.
viewMatrice
s
);
multiview
.
updateCameraViewMatrices
(
camera
,
p_uniform
s
);
}
else
{
...
...
@@ -2008,8 +1999,7 @@ function WebGLRenderer( parameters ) {
if
(
material
.
supportsMultiview
&&
multiview
.
isEnabled
()
)
{
p_uniforms
.
setValue
(
_gl
,
'
modelViewMatrices
'
,
object
.
modelViewMatrices
);
p_uniforms
.
setValue
(
_gl
,
'
normalMatrices
'
,
object
.
normalMatrices
);
multiview
.
updateObjectMatrices
(
object
,
camera
,
p_uniforms
);
}
else
{
...
...
src/renderers/webgl/WebGLMultiview.js
浏览文件 @
f9fb5739
...
...
@@ -7,13 +7,33 @@ import { WebGLMultiviewRenderTarget } from '../WebGLMultiviewRenderTarget.js';
import
{
Matrix3
}
from
'
../../math/Matrix3.js
'
;
import
{
Matrix4
}
from
'
../../math/Matrix4.js
'
;
function
WebGLMultiview
(
renderer
,
requested
)
{
function
WebGLMultiview
(
renderer
,
requested
,
options
)
{
options
=
Object
.
assign
(
{},
{
debug
:
false
},
options
);
var
gl
=
renderer
.
context
;
var
canvas
=
renderer
.
domElement
;
var
capabilities
=
renderer
.
capabilities
;
var
properties
=
renderer
.
properties
;
var
numViews
=
2
;
var
renderTarget
,
currentRenderTarget
;
// Auxiliary matrices to be used when updating arrays of uniforms
var
aux
=
{
mat4
:
[],
mat3
:
[]
};
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
aux
.
mat4
[
i
]
=
new
Matrix4
();
aux
.
mat3
[
i
]
=
new
Matrix3
();
}
//
this
.
isAvailable
=
function
()
{
return
capabilities
.
multiview
;
...
...
@@ -38,41 +58,27 @@ function WebGLMultiview( renderer, requested ) {
};
if
(
requested
&&
!
this
.
isAvailable
()
)
{
console
.
warn
(
'
WebGLRenderer: Multiview requested but not supported by the browser
'
);
if
(
options
.
debug
)
{
}
else
if
(
requested
!==
false
&&
this
.
isAvailable
()
)
{
if
(
requested
&&
!
this
.
isAvailable
()
)
{
console
.
info
(
'
WebGLRenderer: Multiview enabled
'
);
console
.
warn
(
'
WebGLRenderer: Multiview requested but not supported by the browser
'
);
}
}
else
if
(
requested
!==
false
&&
this
.
isAvailable
()
)
{
var
numViews
=
2
;
var
renderTarget
,
currentRenderTarget
;
console
.
info
(
'
WebGLRenderer: Multiview enabled
'
);
this
.
computeCameraMatrices
=
function
(
camera
)
{
if
(
!
camera
.
projectionMatrices
)
{
camera
.
projectionMatrices
=
new
Array
(
numViews
);
camera
.
viewMatrices
=
new
Array
(
numViews
);
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
camera
.
projectionMatrices
[
i
]
=
new
Matrix4
();
camera
.
viewMatrices
[
i
]
=
new
Matrix4
();
}
}
}
}
this
.
updateCameraProjectionMatrices
=
function
(
camera
,
p_uniforms
)
{
if
(
camera
.
isArrayCamera
)
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
camera
.
projectionMatrices
[
i
].
copy
(
camera
.
cameras
[
i
].
projectionMatrix
);
camera
.
viewMatrices
[
i
].
copy
(
camera
.
cameras
[
i
].
matrixWorldInverse
);
aux
.
mat4
[
i
].
copy
(
camera
.
cameras
[
i
].
projectionMatrix
);
}
...
...
@@ -80,55 +86,69 @@ function WebGLMultiview( renderer, requested ) {
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
camera
.
projectionMatrices
[
i
].
copy
(
camera
.
projectionMatrix
);
camera
.
viewMatrices
[
i
].
copy
(
camera
.
matrixWorldInverse
);
aux
.
mat4
[
i
].
copy
(
camera
.
projectionMatrix
);
}
}
p_uniforms
.
setValue
(
gl
,
'
projectionMatrices
'
,
aux
.
mat4
);
};
this
.
computeObjectMatrices
=
function
(
object
,
camera
)
{
this
.
updateCameraViewMatrices
=
function
(
camera
,
p_uniforms
)
{
if
(
camera
.
isArrayCamera
)
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
if
(
!
object
.
modelViewMatrices
)
{
aux
.
mat4
[
i
].
copy
(
camera
.
cameras
[
i
].
matrixWorldInverse
);
object
.
modelViewMatrices
=
new
Array
(
numViews
);
object
.
normalMatrices
=
new
Array
(
numViews
);
}
}
else
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
object
.
modelViewMatrices
[
i
]
=
new
Matrix4
();
object
.
normalMatrices
[
i
]
=
new
Matrix3
();
aux
.
mat4
[
i
].
copy
(
camera
.
matrixWorldInverse
);
}
}
p_uniforms
.
setValue
(
gl
,
'
viewMatrices
'
,
aux
.
mat4
);
};
this
.
updateObjectMatrices
=
function
(
object
,
camera
,
p_uniforms
)
{
if
(
camera
.
isArrayCamera
)
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
object
.
modelViewMatrices
[
i
].
multiplyMatrices
(
camera
.
cameras
[
i
].
matrixWorldInverse
,
object
.
matrixWorld
);
object
.
normalMatrices
[
i
].
getNormalMatrix
(
object
.
modelViewMatrices
[
i
]
);
aux
.
mat4
[
i
].
multiplyMatrices
(
camera
.
cameras
[
i
].
matrixWorldInverse
,
object
.
matrixWorld
);
aux
.
mat3
[
i
].
getNormalMatrix
(
aux
.
mat4
[
i
]
);
}
}
else
{
// In this case we still need to provide an array of matrices but just the first one will be used
object
.
modelViewMatrices
[
0
].
multiplyMatrices
(
camera
.
matrixWorldInverse
,
object
.
matrixWorld
);
object
.
normalMatrices
[
0
].
getNormalMatrix
(
object
.
modelViewMatrices
[
0
]
);
aux
.
mat4
[
0
].
multiplyMatrices
(
camera
.
matrixWorldInverse
,
object
.
matrixWorld
);
aux
.
mat3
[
0
].
getNormalMatrix
(
aux
.
mat4
[
0
]
);
for
(
var
i
=
1
;
i
<
numViews
;
i
++
)
{
object
.
modelViewMatrices
[
i
].
copy
(
object
.
modelViewMatrices
[
0
]
);
object
.
normalMatrices
[
i
].
copy
(
object
.
normalMatrices
[
0
]
);
aux
.
mat4
[
i
].
copy
(
aux
.
mat4
[
0
]
);
aux
.
mat3
[
i
].
copy
(
aux
.
mat3
[
0
]
);
}
}
p_uniforms
.
setValue
(
gl
,
'
modelViewMatrices
'
,
aux
.
mat4
);
p_uniforms
.
setValue
(
gl
,
'
normalMatrices
'
,
aux
.
mat3
);
};
this
.
attachRenderTarget
=
function
(
camera
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录