Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
6cf473f2
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
6cf473f2
编写于
3月 04, 2019
作者:
M
Mr.doob
提交者:
GitHub
3月 04, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15891 from donmccurdy/cleanup-gltfloader-multidependencies
GLTFLoader: Clean up, remove getMultiDependencies()
上级
9957632e
28b6b214
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
78 deletion
+41
-78
examples/js/loaders/GLTFLoader.js
examples/js/loaders/GLTFLoader.js
+41
-78
未找到文件。
examples/js/loaders/GLTFLoader.js
浏览文件 @
6cf473f2
...
...
@@ -218,23 +218,7 @@ THREE.GLTFLoader = ( function () {
}
);
parser
.
parse
(
function
(
scene
,
scenes
,
cameras
,
animations
,
json
)
{
var
glTF
=
{
scene
:
scene
,
scenes
:
scenes
,
cameras
:
cameras
,
animations
:
animations
,
asset
:
json
.
asset
,
parser
:
parser
,
userData
:
{}
};
addUnknownExtensionsToUserData
(
extensions
,
glTF
,
json
);
onLoad
(
glTF
);
},
onError
);
parser
.
parse
(
onLoad
,
onError
);
}
...
...
@@ -1362,34 +1346,21 @@ THREE.GLTFLoader = ( function () {
if
(
hasMorphPosition
)
{
// TODO: Error-prone use of a callback inside a loop.
var
accessor
=
target
.
POSITION
!==
undefined
var
pendingAccessor
=
target
.
POSITION
!==
undefined
?
parser
.
getDependency
(
'
accessor
'
,
target
.
POSITION
)
.
then
(
function
(
accessor
)
{
// Cloning not to pollute original accessor below
return
cloneBufferAttribute
(
accessor
);
}
)
:
geometry
.
attributes
.
position
;
pendingPositionAccessors
.
push
(
a
ccessor
);
pendingPositionAccessors
.
push
(
pendingA
ccessor
);
}
if
(
hasMorphNormal
)
{
// TODO: Error-prone use of a callback inside a loop.
var
accessor
=
target
.
NORMAL
!==
undefined
var
pendingAccessor
=
target
.
NORMAL
!==
undefined
?
parser
.
getDependency
(
'
accessor
'
,
target
.
NORMAL
)
.
then
(
function
(
accessor
)
{
return
cloneBufferAttribute
(
accessor
);
}
)
:
geometry
.
attributes
.
normal
;
pendingNormalAccessors
.
push
(
a
ccessor
);
pendingNormalAccessors
.
push
(
pendingA
ccessor
);
}
...
...
@@ -1403,6 +1374,24 @@ THREE.GLTFLoader = ( function () {
var
morphPositions
=
accessors
[
0
];
var
morphNormals
=
accessors
[
1
];
// Clone morph target accessors before modifying them.
for
(
var
i
=
0
,
il
=
morphPositions
.
length
;
i
<
il
;
i
++
)
{
if
(
geometry
.
attributes
.
position
===
morphPositions
[
i
]
)
continue
;
morphPositions
[
i
]
=
cloneBufferAttribute
(
morphPositions
[
i
]
);
}
for
(
var
i
=
0
,
il
=
morphNormals
.
length
;
i
<
il
;
i
++
)
{
if
(
geometry
.
attributes
.
normal
===
morphNormals
[
i
]
)
continue
;
morphNormals
[
i
]
=
cloneBufferAttribute
(
morphNormals
[
i
]
);
}
for
(
var
i
=
0
,
il
=
targets
.
length
;
i
<
il
;
i
++
)
{
var
target
=
targets
[
i
];
...
...
@@ -1623,7 +1612,9 @@ THREE.GLTFLoader = ( function () {
GLTFParser
.
prototype
.
parse
=
function
(
onLoad
,
onError
)
{
var
parser
=
this
;
var
json
=
this
.
json
;
var
extensions
=
this
.
extensions
;
// Clear the loader cache
this
.
cache
.
removeAll
();
...
...
@@ -1631,21 +1622,27 @@ THREE.GLTFLoader = ( function () {
// Mark the special nodes/meshes in json for efficient parse
this
.
markDefs
();
// Fire the callback on complete
this
.
getMultiDependencies
(
[
Promise
.
all
(
[
'
scene
'
,
'
animation
'
,
'
camera
'
this
.
getDependencies
(
'
scene
'
)
,
this
.
getDependencies
(
'
animation
'
)
,
this
.
getDependencies
(
'
camera
'
),
]
).
then
(
function
(
dependencies
)
{
var
scenes
=
dependencies
.
scenes
||
[];
var
scene
=
scenes
[
json
.
scene
||
0
];
var
animations
=
dependencies
.
animations
||
[];
var
cameras
=
dependencies
.
cameras
||
[];
var
result
=
{
scene
:
dependencies
[
0
][
json
.
scene
||
0
],
scenes
:
dependencies
[
0
],
animations
:
dependencies
[
1
],
cameras
:
dependencies
[
2
],
asset
:
json
.
asset
,
parser
:
parser
,
userData
:
{}
};
onLoad
(
scene
,
scenes
,
cameras
,
animations
,
json
);
addUnknownExtensionsToUserData
(
extensions
,
result
,
json
);
onLoad
(
result
);
}
).
catch
(
onError
);
...
...
@@ -1818,40 +1815,6 @@ THREE.GLTFLoader = ( function () {
};
/**
* Requests all multiple dependencies of the specified types asynchronously, with caching.
* @param {Array<string>} types
* @return {Promise<Object<Array<Object>>>}
*/
GLTFParser
.
prototype
.
getMultiDependencies
=
function
(
types
)
{
var
results
=
{};
var
pending
=
[];
for
(
var
i
=
0
,
il
=
types
.
length
;
i
<
il
;
i
++
)
{
var
type
=
types
[
i
];
var
value
=
this
.
getDependencies
(
type
);
// TODO: Error-prone use of a callback inside a loop.
value
=
value
.
then
(
function
(
key
,
value
)
{
results
[
key
]
=
value
;
}.
bind
(
this
,
type
+
(
type
===
'
mesh
'
?
'
es
'
:
'
s
'
)
)
);
pending
.
push
(
value
);
}
return
Promise
.
all
(
pending
).
then
(
function
()
{
return
results
;
}
);
};
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
* @param {number} bufferIndex
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录