Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
eaa5fbcc
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,发现更多精彩内容 >>
提交
eaa5fbcc
编写于
10月 18, 2017
作者:
K
Kevin Ngo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't use cache object to maintain duplicate requests structure
上级
23690f57
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
22 addition
and
9 deletion
+22
-9
src/loaders/FileLoader.js
src/loaders/FileLoader.js
+22
-9
未找到文件。
src/loaders/FileLoader.js
浏览文件 @
eaa5fbcc
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
import
{
Cache
}
from
'
./Cache
'
;
import
{
Cache
}
from
'
./Cache
'
;
import
{
DefaultLoadingManager
}
from
'
./LoadingManager
'
;
import
{
DefaultLoadingManager
}
from
'
./LoadingManager
'
;
var
currentlyLoadingFiles
=
{};
function
FileLoader
(
manager
)
{
function
FileLoader
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
DefaultLoadingManager
;
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
DefaultLoadingManager
;
...
@@ -23,7 +25,7 @@ Object.assign( FileLoader.prototype, {
...
@@ -23,7 +25,7 @@ Object.assign( FileLoader.prototype, {
var
cached
=
Cache
.
get
(
url
);
var
cached
=
Cache
.
get
(
url
);
if
(
cached
!==
undefined
&&
!
cached
.
loaderSubscriptions
)
{
if
(
cached
!==
undefined
)
{
scope
.
manager
.
itemStart
(
url
);
scope
.
manager
.
itemStart
(
url
);
...
@@ -40,9 +42,9 @@ Object.assign( FileLoader.prototype, {
...
@@ -40,9 +42,9 @@ Object.assign( FileLoader.prototype, {
}
}
// If file is already in process of loading, wait for it to load.
// If file is already in process of loading, wait for it to load.
if
(
c
ached
!==
undefined
&&
cached
.
loaderSubscriptions
)
{
if
(
c
urrentlyLoadingFiles
[
url
]
!==
undefined
)
{
c
ached
.
loaderSubscriptions
.
push
(
function
()
{
c
urrentlyLoadingFiles
[
url
]
.
push
(
function
()
{
scope
.
load
(
url
,
onLoad
,
onProgress
,
onError
);
scope
.
load
(
url
,
onLoad
,
onProgress
,
onError
);
...
@@ -141,11 +143,14 @@ Object.assign( FileLoader.prototype, {
...
@@ -141,11 +143,14 @@ Object.assign( FileLoader.prototype, {
}
else
{
}
else
{
var
loaderSubscriptions
=
[];
var
request
=
new
XMLHttpRequest
();
var
request
=
new
XMLHttpRequest
();
if
(
Cache
.
enabled
)
{
// Allow other file loaders to wait and subscribe on this request.
// Allow other file loaders to wait and subscribe on this request.
Cache
.
add
(
url
,
{
loaderSubscriptions
:
loaderSubscriptions
}
);
currentlyLoadingFiles
[
url
]
=
[];
}
request
.
open
(
'
GET
'
,
url
,
true
);
request
.
open
(
'
GET
'
,
url
,
true
);
...
@@ -181,10 +186,18 @@ Object.assign( FileLoader.prototype, {
...
@@ -181,10 +186,18 @@ Object.assign( FileLoader.prototype, {
}
}
if
(
Cache
.
enabled
)
{
var
duplicateRequests
=
currentlyLoadingFiles
[
url
];
delete
currentlyLoadingFiles
[
url
];
// Tell other requests for the same file that the file has finished loading.
// Tell other requests for the same file that the file has finished loading.
for
(
var
i
=
0
;
i
<
loaderSubscription
s
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
duplicateRequest
s
.
length
;
i
++
)
{
loaderSubscriptions
[
i
](
response
);
duplicateRequests
[
i
](
response
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录