Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
9a21fad0
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,发现更多精彩内容 >>
提交
9a21fad0
编写于
8月 13, 2019
作者:
J
Joel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use WeakMap for geometries, render lists, and render states
上级
0531e0f5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
30 deletion
+29
-30
src/renderers/webgl/WebGLGeometries.js
src/renderers/webgl/WebGLGeometries.js
+12
-12
src/renderers/webgl/WebGLRenderLists.js
src/renderers/webgl/WebGLRenderLists.js
+8
-8
src/renderers/webgl/WebGLRenderStates.js
src/renderers/webgl/WebGLRenderStates.js
+9
-10
未找到文件。
src/renderers/webgl/WebGLGeometries.js
浏览文件 @
9a21fad0
...
...
@@ -8,13 +8,13 @@ import { arrayMax } from '../../utils.js';
function
WebGLGeometries
(
gl
,
attributes
,
info
)
{
var
geometries
=
{}
;
var
wireframeAttributes
=
{}
;
var
geometries
=
new
WeakMap
()
;
var
wireframeAttributes
=
new
WeakMap
()
;
function
onGeometryDispose
(
event
)
{
var
geometry
=
event
.
target
;
var
buffergeometry
=
geometries
[
geometry
.
id
]
;
var
buffergeometry
=
geometries
.
get
(
geometry
)
;
if
(
buffergeometry
.
index
!==
null
)
{
...
...
@@ -30,14 +30,14 @@ function WebGLGeometries( gl, attributes, info ) {
geometry
.
removeEventListener
(
'
dispose
'
,
onGeometryDispose
);
delete
geometries
[
geometry
.
id
]
;
geometries
.
delete
(
geometry
)
;
var
attribute
=
wireframeAttributes
[
buffergeometry
.
id
]
;
var
attribute
=
wireframeAttributes
.
get
(
buffergeometry
)
;
if
(
attribute
)
{
attributes
.
remove
(
attribute
);
delete
wireframeAttributes
[
buffergeometry
.
id
]
;
wireframeAttributes
.
delete
(
buffergeometry
)
;
}
...
...
@@ -49,7 +49,7 @@ function WebGLGeometries( gl, attributes, info ) {
function
get
(
object
,
geometry
)
{
var
buffergeometry
=
geometries
[
geometry
.
id
]
;
var
buffergeometry
=
geometries
.
get
(
geometry
)
;
if
(
buffergeometry
)
return
buffergeometry
;
...
...
@@ -71,7 +71,7 @@ function WebGLGeometries( gl, attributes, info ) {
}
geometries
[
geometry
.
id
]
=
buffergeometry
;
geometries
.
set
(
geometry
,
buffergeometry
)
;
info
.
memory
.
geometries
++
;
...
...
@@ -161,19 +161,19 @@ function WebGLGeometries( gl, attributes, info ) {
//
var
previousAttribute
=
wireframeAttributes
[
geometry
.
id
]
;
var
previousAttribute
=
wireframeAttributes
.
get
(
geometry
)
;
if
(
previousAttribute
)
attributes
.
remove
(
previousAttribute
);
//
wireframeAttributes
[
geometry
.
id
]
=
attribute
;
wireframeAttributes
.
set
(
geometry
,
attribute
)
;
}
function
getWireframeAttribute
(
geometry
)
{
var
currentAttribute
=
wireframeAttributes
[
geometry
.
id
]
;
var
currentAttribute
=
wireframeAttributes
.
get
(
geometry
)
;
if
(
currentAttribute
)
{
...
...
@@ -197,7 +197,7 @@ function WebGLGeometries( gl, attributes, info ) {
}
return
wireframeAttributes
[
geometry
.
id
]
;
return
wireframeAttributes
.
get
(
geometry
)
;
}
...
...
src/renderers/webgl/WebGLRenderLists.js
浏览文件 @
9a21fad0
...
...
@@ -152,7 +152,7 @@ function WebGLRenderList() {
function
WebGLRenderLists
()
{
var
lists
=
{}
;
var
lists
=
new
WeakMap
()
;
function
onSceneDispose
(
event
)
{
...
...
@@ -160,29 +160,29 @@ function WebGLRenderLists() {
scene
.
removeEventListener
(
'
dispose
'
,
onSceneDispose
);
delete
lists
[
scene
.
id
]
;
lists
.
delete
(
scene
)
;
}
function
get
(
scene
,
camera
)
{
var
cameras
=
lists
[
scene
.
id
]
;
var
cameras
=
lists
.
get
(
scene
)
;
var
list
;
if
(
cameras
===
undefined
)
{
list
=
new
WebGLRenderList
();
lists
[
scene
.
id
]
=
{}
;
lists
[
scene
.
id
][
camera
.
id
]
=
list
;
lists
.
set
(
scene
,
new
WeakMap
()
)
;
lists
.
get
(
scene
).
set
(
camera
,
list
)
;
scene
.
addEventListener
(
'
dispose
'
,
onSceneDispose
);
}
else
{
list
=
cameras
[
camera
.
id
]
;
list
=
cameras
.
get
(
camera
)
;
if
(
list
===
undefined
)
{
list
=
new
WebGLRenderList
();
cameras
[
camera
.
id
]
=
list
;
cameras
.
set
(
camera
,
list
)
;
}
...
...
@@ -194,7 +194,7 @@ function WebGLRenderLists() {
function
dispose
()
{
lists
=
{}
;
lists
=
new
WeakMap
()
;
}
...
...
src/renderers/webgl/WebGLRenderStates.js
浏览文件 @
9a21fad0
...
...
@@ -56,7 +56,7 @@ function WebGLRenderState() {
function
WebGLRenderStates
()
{
var
renderStates
=
{}
;
var
renderStates
=
new
WeakMap
()
;
function
onSceneDispose
(
event
)
{
...
...
@@ -64,32 +64,31 @@ function WebGLRenderStates() {
scene
.
removeEventListener
(
'
dispose
'
,
onSceneDispose
);
delete
renderStates
[
scene
.
id
];
renderStates
.
delete
(
scene
);
}
function
get
(
scene
,
camera
)
{
var
renderState
;
if
(
renderStates
[
scene
.
id
]
===
undefined
)
{
if
(
!
renderStates
.
has
(
scene
)
)
{
renderState
=
new
WebGLRenderState
();
renderStates
[
scene
.
id
]
=
{}
;
renderStates
[
scene
.
id
][
camera
.
id
]
=
renderState
;
renderStates
.
set
(
scene
,
new
WeakMap
())
;
renderStates
.
get
(
scene
).
set
(
camera
,
renderState
)
;
scene
.
addEventListener
(
'
dispose
'
,
onSceneDispose
);
}
else
{
if
(
renderStates
[
scene
.
id
][
camera
.
id
]
===
undefined
)
{
if
(
!
renderStates
.
get
(
scene
).
has
(
camera
)
)
{
renderState
=
new
WebGLRenderState
();
renderStates
[
scene
.
id
][
camera
.
id
]
=
renderState
;
renderStates
.
get
(
scene
).
set
(
camera
,
renderState
)
;
}
else
{
renderState
=
renderStates
[
scene
.
id
][
camera
.
id
]
;
renderState
=
renderStates
.
get
(
scene
).
get
(
camera
)
;
}
...
...
@@ -101,7 +100,7 @@ function WebGLRenderStates() {
function
dispose
()
{
renderStates
=
{}
;
renderStates
=
new
WeakMap
()
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录