Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
87f40038
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
87f40038
编写于
4月 23, 2019
作者:
F
Fernando Serrano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up WebGLMultiview
上级
9072316c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
49 deletion
+56
-49
src/renderers/webgl/WebGLMultiview.js
src/renderers/webgl/WebGLMultiview.js
+56
-49
未找到文件。
src/renderers/webgl/WebGLMultiview.js
浏览文件 @
87f40038
function
WebGLMultiview
(
requested
,
gl
,
canvas
,
extensions
,
capabilities
)
{
this
.
isAvailable
=
function
()
{
this
.
isAvailable
=
function
()
{
return
capabilities
.
multiview
;
return
capabilities
.
multiview
;
}
};
this
.
getMaxViews
=
function
()
{
this
.
getMaxViews
=
function
()
{
return
capabilities
.
maxMultiviewViews
;
return
capabilities
.
maxMultiviewViews
;
}
};
this
.
isEnabled
=
function
()
{
this
.
isEnabled
=
function
()
{
return
requested
&&
this
.
isAvailable
();
return
requested
&&
this
.
isAvailable
();
}
};
if
(
requested
&&
!
this
.
isAvailable
()
)
{
...
...
@@ -27,10 +27,10 @@ function WebGLMultiview( requested, gl, canvas, extensions, capabilities ) {
console
.
info
(
'
WebGLRenderer: Multiview enabled
'
);
}
}
var
numViews
=
2
;
var
framebuffer
;
// multiview framebuffer.
var
numViews
=
2
;
// @todo Based on arrayCamera
var
framebuffer
;
// multiview framebuffer.
var
viewFramebuffer
;
// single views inside the multiview framebuffer.
var
framebufferWidth
=
0
;
var
framebufferHeight
=
0
;
...
...
@@ -41,14 +41,15 @@ function WebGLMultiview( requested, gl, canvas, extensions, capabilities ) {
};
// @todo Get ArrayCamera
this
.
createMultiviewRenderTargetTexture
=
function
()
{
var
halfWidth
=
Math
.
floor
(
canvas
.
width
*
0.5
);
var
halfWidth
=
Math
.
floor
(
canvas
.
width
*
0.5
);
framebuffer
=
gl
.
createFramebuffer
();
gl
.
bindFramebuffer
(
gl
.
FRAMEBUFFER
,
framebuffer
);
var
ext
=
extensions
.
get
(
'
OVR_multiview2
'
);
var
ext
=
extensions
.
get
(
'
OVR_multiview2
'
);
texture
.
color
=
gl
.
createTexture
();
gl
.
bindTexture
(
gl
.
TEXTURE_2D_ARRAY
,
texture
.
color
);
...
...
@@ -71,30 +72,39 @@ function WebGLMultiview( requested, gl, canvas, extensions, capabilities ) {
gl
.
bindFramebuffer
(
gl
.
FRAMEBUFFER
,
viewFramebuffer
[
viewIndex
]
);
gl
.
framebufferTextureLayer
(
gl
.
FRAMEBUFFER
,
gl
.
COLOR_ATTACHMENT0
,
texture
.
color
,
0
,
viewIndex
);
}
}
framebufferWidth
=
halfWidth
;
framebufferHeight
=
canvas
.
height
;
};
};
this
.
bindMultiviewFrameBuffer
=
function
(
camera
)
{
var
halfWidth
=
Math
.
floor
(
canvas
.
width
*
0.5
);
if
(
camera
.
isArrayCamera
)
{
var
width
=
canvas
.
width
;
var
height
=
canvas
.
height
;
if
(
camera
.
isArrayCamera
)
{
}
else
{
halfWidth
*=
2
;
}
// Every camera must have the same size, so we just get the size from the first one
var
bounds
=
camera
.
cameras
[
0
].
bounds
;
if
(
framebufferWidth
<
halfWidth
||
framebufferHeight
<
canvas
.
height
)
{
console
.
log
(
'
WebGLMultiview: Updating multiview FBO with dimensions:
'
,
halfWidth
,
canvas
.
height
);
width
*=
bounds
.
z
;
height
*=
bounds
.
w
;
}
if
(
framebufferWidth
<
width
||
framebufferHeight
<
height
)
{
console
.
log
(
'
WebGLMultiview: Updating multiview FBO with dimensions:
'
,
width
,
height
);
gl
.
bindTexture
(
gl
.
TEXTURE_2D_ARRAY
,
texture
.
color
);
gl
.
texImage3D
(
gl
.
TEXTURE_2D_ARRAY
,
0
,
gl
.
RGBA8
,
halfWidth
,
canvas
.
height
,
numViews
,
0
,
gl
.
RGBA
,
gl
.
UNSIGNED_BYTE
,
null
);
gl
.
texImage3D
(
gl
.
TEXTURE_2D_ARRAY
,
0
,
gl
.
RGBA8
,
width
,
height
,
numViews
,
0
,
gl
.
RGBA
,
gl
.
UNSIGNED_BYTE
,
null
);
gl
.
bindTexture
(
gl
.
TEXTURE_2D_ARRAY
,
texture
.
depthStencil
);
gl
.
texImage3D
(
gl
.
TEXTURE_2D_ARRAY
,
0
,
gl
.
DEPTH24_STENCIL8
,
halfWidth
,
canvas
.
height
,
numViews
,
0
,
gl
.
DEPTH_STENCIL
,
gl
.
UNSIGNED_INT_24_8
,
null
);
framebufferWidth
=
halfW
idth
;
framebufferHeight
=
canvas
.
height
;
gl
.
texImage3D
(
gl
.
TEXTURE_2D_ARRAY
,
0
,
gl
.
DEPTH24_STENCIL8
,
width
,
height
,
numViews
,
0
,
gl
.
DEPTH_STENCIL
,
gl
.
UNSIGNED_INT_24_8
,
null
);
framebufferWidth
=
w
idth
;
framebufferHeight
=
height
;
}
}
gl
.
bindFramebuffer
(
gl
.
DRAW_FRAMEBUFFER
,
framebuffer
);
...
...
@@ -102,43 +112,40 @@ function WebGLMultiview( requested, gl, canvas, extensions, capabilities ) {
this
.
unbindMultiviewFrameBuffer
=
function
(
camera
)
{
gl
.
bindFramebuffer
(
gl
.
DRAW_FRAMEBUFFER
,
null
);
gl
.
bindFramebuffer
(
gl
.
DRAW_FRAMEBUFFER
,
null
);
if
(
camera
.
isArrayCamera
)
{
if
(
camera
.
isArrayCamera
)
{
for
(
var
i
=
0
;
i
<
camera
.
cameras
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
camera
.
cameras
.
length
;
i
++
)
{
var
bounds
=
camera
.
cameras
[
i
].
bounds
;
var
bounds
=
camera
.
cameras
[
i
].
bounds
;
var
x
=
bounds
.
x
*
canvas
.
width
;
var
y
=
bounds
.
y
*
canvas
.
height
;
var
width
=
bounds
.
z
*
canvas
.
width
;
var
height
=
bounds
.
w
*
canvas
.
height
;
var
x
=
bounds
.
x
*
canvas
.
width
;
var
y
=
bounds
.
y
*
canvas
.
height
;
var
width
=
bounds
.
z
*
canvas
.
width
;
var
height
=
bounds
.
w
*
canvas
.
height
;
gl
.
bindFramebuffer
(
gl
.
READ_FRAMEBUFFER
,
viewFramebuffer
[
i
]
);
gl
.
blitFramebuffer
(
0
,
0
,
width
,
height
,
x
,
y
,
x
+
width
,
y
+
height
,
gl
.
COLOR_BUFFER_BIT
,
gl
.
NEAREST
);
gl
.
bindFramebuffer
(
gl
.
READ_FRAMEBUFFER
,
viewFramebuffer
[
i
]
);
gl
.
blitFramebuffer
(
0
,
0
,
width
,
height
,
x
,
y
,
x
+
width
,
y
+
height
,
gl
.
COLOR_BUFFER_BIT
,
gl
.
NEAREST
);
}
}
}
else
{
}
else
{
gl
.
bindFramebuffer
(
gl
.
READ_FRAMEBUFFER
,
viewFramebuffer
[
0
]
);
gl
.
blitFramebuffer
(
0
,
0
,
canvas
.
width
,
canvas
.
height
,
0
,
0
,
canvas
.
width
,
canvas
.
height
,
gl
.
COLOR_BUFFER_BIT
,
gl
.
NEAREST
);
gl
.
bindFramebuffer
(
gl
.
READ_FRAMEBUFFER
,
viewFramebuffer
[
0
]
);
gl
.
blitFramebuffer
(
0
,
0
,
canvas
.
width
,
canvas
.
height
,
0
,
0
,
canvas
.
width
,
canvas
.
height
,
gl
.
COLOR_BUFFER_BIT
,
gl
.
NEAREST
);
}
}
};
if
(
this
.
isEnabled
()
)
{
if
(
this
.
isEnabled
()
)
{
this
.
createMultiviewRenderTargetTexture
();
this
.
createMultiviewRenderTargetTexture
();
}
}
}
export
{
WebGLMultiview
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录