Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
75e66cdf
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,发现更多精彩内容 >>
提交
75e66cdf
编写于
4月 30, 2019
作者:
F
Fernando Serrano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add setNumViews() to WebGLMultiview
上级
ffc4b96b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
66 addition
and
43 deletion
+66
-43
src/renderers/WebGLMultiviewRenderTarget.js
src/renderers/WebGLMultiviewRenderTarget.js
+13
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+2
-2
src/renderers/webgl/WebGLMultiview.js
src/renderers/webgl/WebGLMultiview.js
+47
-37
src/renderers/webgl/WebGLTextures.js
src/renderers/webgl/WebGLTextures.js
+4
-4
未找到文件。
src/renderers/WebGLMultiviewRenderTarget.js
浏览文件 @
75e66cdf
...
...
@@ -30,6 +30,19 @@ WebGLMultiviewRenderTarget.prototype = Object.assign( Object.create( WebGLRender
return
this
;
},
setNumViews
:
function
(
numViews
)
{
if
(
this
.
numViews
!==
numViews
)
{
this
.
numViews
=
numViews
;
this
.
dispose
();
}
return
this
;
}
}
);
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
75e66cdf
...
...
@@ -1242,9 +1242,9 @@ function WebGLRenderer( parameters ) {
state
.
setPolygonOffset
(
false
);
if
(
this
.
multiview
.
isEnabled
()
)
{
if
(
multiview
.
isEnabled
()
)
{
this
.
multiview
.
detachRenderTarget
(
camera
);
multiview
.
detachRenderTarget
(
camera
);
}
...
...
src/renderers/webgl/WebGLMultiview.js
浏览文件 @
75e66cdf
...
...
@@ -11,44 +11,42 @@ function WebGLMultiview( renderer, requested, options ) {
options
=
Object
.
assign
(
{},
{
debug
:
false
},
options
);
var
DEFAULT_NUMVIEWS
=
2
;
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
:
[]
};
this
.
getMaxViews
=
function
()
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
return
capabilities
.
maxMultiviewViews
;
aux
.
mat4
[
i
]
=
new
Matrix4
();
aux
.
mat3
[
i
]
=
new
Matrix3
();
};
}
this
.
getNumViews
=
function
()
{
//
return
renderTarget
?
renderTarget
.
numViews
:
1
;
this
.
isAvailable
=
function
()
{
};
return
capabilities
.
multiview
;
// Auxiliary matrices to be used when updating arrays of uniforms
var
mat4
=
[];
var
mat3
=
[];
};
for
(
var
i
=
0
;
i
<
this
.
getMaxViews
();
i
++
)
{
this
.
getNumViews
=
function
()
{
mat4
[
i
]
=
new
Matrix4
();
mat3
[
i
]
=
new
Matrix3
();
return
numViews
;
}
};
//
this
.
getMaxViews
=
function
()
{
this
.
isAvailable
=
function
()
{
return
capabilities
.
m
axMultiviewViews
;
return
capabilities
.
m
ultiview
;
};
...
...
@@ -72,13 +70,15 @@ function WebGLMultiview( renderer, requested, options ) {
}
this
.
updateCameraProjectionMatrices
=
function
(
camera
,
p_uniforms
)
{
this
.
updateCameraProjectionMatrices
=
function
(
camera
,
uniforms
)
{
var
numViews
=
this
.
getNumViews
();
if
(
camera
.
isArrayCamera
)
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
aux
.
mat4
[
i
].
copy
(
camera
.
cameras
[
i
].
projectionMatrix
);
mat4
[
i
].
copy
(
camera
.
cameras
[
i
].
projectionMatrix
);
}
...
...
@@ -86,23 +86,25 @@ function WebGLMultiview( renderer, requested, options ) {
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
aux
.
mat4
[
i
].
copy
(
camera
.
projectionMatrix
);
mat4
[
i
].
copy
(
camera
.
projectionMatrix
);
}
}
p_uniforms
.
setValue
(
gl
,
'
projectionMatrices
'
,
aux
.
mat4
);
uniforms
.
setValue
(
gl
,
'
projectionMatrices
'
,
mat4
);
};
this
.
updateCameraViewMatrices
=
function
(
camera
,
p_uniforms
)
{
this
.
updateCameraViewMatrices
=
function
(
camera
,
uniforms
)
{
var
numViews
=
this
.
getNumViews
();
if
(
camera
.
isArrayCamera
)
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
aux
.
mat4
[
i
].
copy
(
camera
.
cameras
[
i
].
matrixWorldInverse
);
mat4
[
i
].
copy
(
camera
.
cameras
[
i
].
matrixWorldInverse
);
}
...
...
@@ -110,44 +112,46 @@ function WebGLMultiview( renderer, requested, options ) {
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
aux
.
mat4
[
i
].
copy
(
camera
.
matrixWorldInverse
);
mat4
[
i
].
copy
(
camera
.
matrixWorldInverse
);
}
}
p_uniforms
.
setValue
(
gl
,
'
viewMatrices
'
,
aux
.
mat4
);
uniforms
.
setValue
(
gl
,
'
viewMatrices
'
,
mat4
);
};
this
.
updateObjectMatrices
=
function
(
object
,
camera
,
p_uniforms
)
{
this
.
updateObjectMatrices
=
function
(
object
,
camera
,
uniforms
)
{
var
numViews
=
this
.
getNumViews
();
if
(
camera
.
isArrayCamera
)
{
for
(
var
i
=
0
;
i
<
numViews
;
i
++
)
{
aux
.
mat4
[
i
].
multiplyMatrices
(
camera
.
cameras
[
i
].
matrixWorldInverse
,
object
.
matrixWorld
);
aux
.
mat3
[
i
].
getNormalMatrix
(
aux
.
mat4
[
i
]
);
mat4
[
i
].
multiplyMatrices
(
camera
.
cameras
[
i
].
matrixWorldInverse
,
object
.
matrixWorld
);
mat3
[
i
].
getNormalMatrix
(
mat4
[
i
]
);
}
}
else
{
// In this case we still need to provide an array of matrices but just the first one will be used
aux
.
mat4
[
0
].
multiplyMatrices
(
camera
.
matrixWorldInverse
,
object
.
matrixWorld
);
aux
.
mat3
[
0
].
getNormalMatrix
(
aux
.
mat4
[
0
]
);
mat4
[
0
].
multiplyMatrices
(
camera
.
matrixWorldInverse
,
object
.
matrixWorld
);
mat3
[
0
].
getNormalMatrix
(
mat4
[
0
]
);
for
(
var
i
=
1
;
i
<
numViews
;
i
++
)
{
aux
.
mat4
[
i
].
copy
(
aux
.
mat4
[
0
]
);
aux
.
mat3
[
i
].
copy
(
aux
.
mat3
[
0
]
);
mat4
[
i
].
copy
(
mat4
[
0
]
);
mat3
[
i
].
copy
(
mat3
[
0
]
);
}
}
p_uniforms
.
setValue
(
gl
,
'
modelViewMatrices
'
,
aux
.
mat4
);
p_uniforms
.
setValue
(
gl
,
'
normalMatrices
'
,
aux
.
mat3
);
uniforms
.
setValue
(
gl
,
'
modelViewMatrices
'
,
mat4
);
uniforms
.
setValue
(
gl
,
'
normalMatrices
'
,
mat3
);
};
...
...
@@ -167,6 +171,12 @@ function WebGLMultiview( renderer, requested, options ) {
width
*=
bounds
.
z
;
height
*=
bounds
.
w
;
renderTarget
.
setNumViews
(
camera
.
cameras
.
length
);
}
else
{
renderTarget
.
setNumViews
(
DEFAULT_NUMVIEWS
);
}
renderTarget
.
setSize
(
width
,
height
);
...
...
@@ -213,7 +223,7 @@ function WebGLMultiview( renderer, requested, options ) {
if
(
this
.
isEnabled
()
)
{
renderTarget
=
new
WebGLMultiviewRenderTarget
(
canvas
.
width
,
canvas
.
height
,
numViews
);
renderTarget
=
new
WebGLMultiviewRenderTarget
(
canvas
.
width
,
canvas
.
height
,
this
.
numViews
);
}
...
...
src/renderers/webgl/WebGLTextures.js
浏览文件 @
75e66cdf
...
...
@@ -1024,11 +1024,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
ext
.
framebufferTextureMultiviewOVR
(
_gl
.
FRAMEBUFFER
,
_gl
.
DEPTH_STENCIL_ATTACHMENT
,
depthStencilTexture
,
0
,
0
,
numViews
);
var
viewFramebuffers
=
new
Array
(
numViews
);
for
(
var
viewIndex
=
0
;
viewIndex
<
numViews
;
++
viewIndex
)
{
for
(
var
i
=
0
;
i
<
numViews
;
++
i
)
{
viewFramebuffers
[
viewIndex
]
=
_gl
.
createFramebuffer
();
_gl
.
bindFramebuffer
(
_gl
.
FRAMEBUFFER
,
viewFramebuffers
[
viewIndex
]
);
_gl
.
framebufferTextureLayer
(
_gl
.
FRAMEBUFFER
,
_gl
.
COLOR_ATTACHMENT0
,
colorTexture
,
0
,
viewIndex
);
viewFramebuffers
[
i
]
=
_gl
.
createFramebuffer
();
_gl
.
bindFramebuffer
(
_gl
.
FRAMEBUFFER
,
viewFramebuffers
[
i
]
);
_gl
.
framebufferTextureLayer
(
_gl
.
FRAMEBUFFER
,
_gl
.
COLOR_ATTACHMENT0
,
colorTexture
,
0
,
i
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录