Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2a2a8a55
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 搜索 >>
未验证
提交
2a2a8a55
编写于
4月 09, 2021
作者:
M
Michael Herzog
提交者:
GitHub
4月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Loaders: Convert to ES6. (#21622)
上级
80317f2c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
145 addition
and
152 deletion
+145
-152
src/loaders/CompressedTextureLoader.js
src/loaders/CompressedTextureLoader.js
+6
-8
src/loaders/DataTextureLoader.js
src/loaders/DataTextureLoader.js
+6
-8
src/loaders/FileLoader.js
src/loaders/FileLoader.js
+10
-12
src/loaders/ImageBitmapLoader.js
src/loaders/ImageBitmapLoader.js
+17
-19
src/loaders/Loader.js
src/loaders/Loader.js
+23
-23
src/loaders/LoaderUtils.js
src/loaders/LoaderUtils.js
+5
-5
src/loaders/LoadingManager.js
src/loaders/LoadingManager.js
+72
-69
src/loaders/TextureLoader.js
src/loaders/TextureLoader.js
+6
-8
未找到文件。
src/loaders/CompressedTextureLoader.js
浏览文件 @
2a2a8a55
...
...
@@ -9,17 +9,15 @@ import { Loader } from './Loader.js';
* Sub classes have to implement the parse() method which will be used in load().
*/
function
CompressedTextureLoader
(
manager
)
{
class
CompressedTextureLoader
extends
Loader
{
Loader
.
call
(
this
,
manager
);
constructor
(
manager
)
{
}
CompressedTextureLoader
.
prototype
=
Object
.
assign
(
Object
.
create
(
Loader
.
prototype
),
{
super
(
manager
);
constructor
:
CompressedTextureLoader
,
}
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
load
(
url
,
onLoad
,
onProgress
,
onError
)
{
const
scope
=
this
;
...
...
@@ -130,7 +128,7 @@ CompressedTextureLoader.prototype = Object.assign( Object.create( Loader.prototy
}
}
);
}
export
{
CompressedTextureLoader
};
src/loaders/DataTextureLoader.js
浏览文件 @
2a2a8a55
...
...
@@ -9,17 +9,15 @@ import { Loader } from './Loader.js';
* Sub classes have to implement the parse() method which will be used in load().
*/
function
DataTextureLoader
(
manager
)
{
class
DataTextureLoader
extends
Loader
{
Loader
.
call
(
this
,
manager
);
constructor
(
manager
)
{
}
DataTextureLoader
.
prototype
=
Object
.
assign
(
Object
.
create
(
Loader
.
prototype
),
{
super
(
manager
);
constructor
:
DataTextureLoader
,
}
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
load
(
url
,
onLoad
,
onProgress
,
onError
)
{
const
scope
=
this
;
...
...
@@ -110,7 +108,7 @@ DataTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
}
}
);
}
export
{
DataTextureLoader
};
src/loaders/FileLoader.js
浏览文件 @
2a2a8a55
...
...
@@ -3,17 +3,15 @@ import { Loader } from './Loader.js';
const
loading
=
{};
function
FileLoader
(
manager
)
{
class
FileLoader
extends
Loader
{
Loader
.
call
(
this
,
manager
);
constructor
(
manager
)
{
}
FileLoader
.
prototype
=
Object
.
assign
(
Object
.
create
(
Loader
.
prototype
),
{
super
(
manager
);
constructor
:
FileLoader
,
}
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
load
(
url
,
onLoad
,
onProgress
,
onError
)
{
if
(
url
===
undefined
)
url
=
''
;
...
...
@@ -277,23 +275,23 @@ FileLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
return
request
;
}
,
}
setResponseType
:
function
(
value
)
{
setResponseType
(
value
)
{
this
.
responseType
=
value
;
return
this
;
}
,
}
setMimeType
:
function
(
value
)
{
setMimeType
(
value
)
{
this
.
mimeType
=
value
;
return
this
;
}
}
);
}
export
{
FileLoader
};
src/loaders/ImageBitmapLoader.js
浏览文件 @
2a2a8a55
import
{
Cache
}
from
'
./Cache.js
'
;
import
{
Loader
}
from
'
./Loader.js
'
;
function
ImageBitmapLoader
(
manager
)
{
class
ImageBitmapLoader
extends
Loader
{
if
(
typeof
createImageBitmap
===
'
undefined
'
)
{
constructor
(
manager
)
{
console
.
warn
(
'
THREE.ImageBitmapLoader: createImageBitmap() not supported.
'
);
super
(
manager
);
}
if
(
typeof
fetch
===
'
undefined
'
)
{
console
.
warn
(
'
THREE.ImageBitmapLoader: fetch() not supported.
'
);
if
(
typeof
createImageBitmap
===
'
undefined
'
)
{
}
console
.
warn
(
'
THREE.ImageBitmapLoader: createImageBitmap() not supported.
'
);
Loader
.
call
(
this
,
manager
);
}
this
.
options
=
{
premultiplyAlpha
:
'
none
'
};
if
(
typeof
fetch
===
'
undefined
'
)
{
}
console
.
warn
(
'
THREE.ImageBitmapLoader: fetch() not supported.
'
);
ImageBitmapLoader
.
prototype
=
Object
.
assign
(
Object
.
create
(
Loader
.
prototype
),
{
}
constructor
:
ImageBitmapLoader
,
this
.
options
=
{
premultiplyAlpha
:
'
none
'
};
isImageBitmapLoader
:
true
,
}
setOptions
:
function
setOptions
(
options
)
{
setOptions
(
options
)
{
this
.
options
=
options
;
return
this
;
}
,
}
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
load
(
url
,
onLoad
,
onProgress
,
onError
)
{
if
(
url
===
undefined
)
url
=
''
;
...
...
@@ -96,6 +92,8 @@ ImageBitmapLoader.prototype = Object.assign( Object.create( Loader.prototype ),
}
}
);
}
ImageBitmapLoader
.
prototype
.
isImageBitmapLoader
=
true
;
export
{
ImageBitmapLoader
};
src/loaders/Loader.js
浏览文件 @
2a2a8a55
import
{
DefaultLoadingManager
}
from
'
./LoadingManager.js
'
;
function
Loader
(
manager
)
{
class
Loader
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
DefaultLoadingManager
;
constructor
(
manager
)
{
this
.
crossOrigin
=
'
anonymous
'
;
this
.
withCredentials
=
false
;
this
.
path
=
''
;
this
.
resourcePath
=
''
;
this
.
requestHeader
=
{};
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
DefaultLoadingManager
;
}
this
.
crossOrigin
=
'
anonymous
'
;
this
.
withCredentials
=
false
;
this
.
path
=
''
;
this
.
resourcePath
=
''
;
this
.
requestHeader
=
{};
Object
.
assign
(
Loader
.
prototype
,
{
}
load
:
function
(
/* url, onLoad, onProgress, onError */
)
{},
load
(
/* url, onLoad, onProgress, onError */
)
{}
loadAsync
:
function
(
url
,
onProgress
)
{
loadAsync
(
url
,
onProgress
)
{
const
scope
=
this
;
...
...
@@ -26,45 +26,45 @@ Object.assign( Loader.prototype, {
}
);
}
,
}
parse
:
function
(
/* data */
)
{},
parse
(
/* data */
)
{}
setCrossOrigin
:
function
(
crossOrigin
)
{
setCrossOrigin
(
crossOrigin
)
{
this
.
crossOrigin
=
crossOrigin
;
return
this
;
}
,
}
setWithCredentials
:
function
(
value
)
{
setWithCredentials
(
value
)
{
this
.
withCredentials
=
value
;
return
this
;
}
,
}
setPath
:
function
(
path
)
{
setPath
(
path
)
{
this
.
path
=
path
;
return
this
;
}
,
}
setResourcePath
:
function
(
resourcePath
)
{
setResourcePath
(
resourcePath
)
{
this
.
resourcePath
=
resourcePath
;
return
this
;
}
,
}
setRequestHeader
:
function
(
requestHeader
)
{
setRequestHeader
(
requestHeader
)
{
this
.
requestHeader
=
requestHeader
;
return
this
;
}
}
);
}
export
{
Loader
};
src/loaders/LoaderUtils.js
浏览文件 @
2a2a8a55
c
onst
LoaderUtils
=
{
c
lass
LoaderUtils
{
decodeText
:
function
(
array
)
{
static
decodeText
(
array
)
{
if
(
typeof
TextDecoder
!==
'
undefined
'
)
{
...
...
@@ -32,9 +32,9 @@ const LoaderUtils = {
}
}
,
}
extractUrlBase
:
function
(
url
)
{
static
extractUrlBase
(
url
)
{
const
index
=
url
.
lastIndexOf
(
'
/
'
);
...
...
@@ -44,6 +44,6 @@ const LoaderUtils = {
}
}
;
}
export
{
LoaderUtils
};
src/loaders/LoadingManager.js
浏览文件 @
2a2a8a55
function
LoadingManager
(
onLoad
,
onProgress
,
onError
)
{
class
LoadingManager
{
const
scope
=
this
;
const
ructor
(
onLoad
,
onProgress
,
onError
)
{
let
isLoading
=
false
;
let
itemsLoaded
=
0
;
let
itemsTotal
=
0
;
let
urlModifier
=
undefined
;
const
handlers
=
[];
const
scope
=
this
;
// Refer to #5689 for the reason why we don't set .onStart
// in the constructor
let
isLoading
=
false
;
let
itemsLoaded
=
0
;
let
itemsTotal
=
0
;
let
urlModifier
=
undefined
;
const
handlers
=
[];
this
.
onStart
=
undefined
;
this
.
onLoad
=
onLoad
;
this
.
onProgress
=
onProgress
;
this
.
onError
=
onError
;
// Refer to #5689 for the reason why we don't set .onStart
// in the constructor
this
.
itemStart
=
function
(
url
)
{
this
.
onStart
=
undefined
;
this
.
onLoad
=
onLoad
;
this
.
onProgress
=
onProgress
;
this
.
onError
=
onError
;
itemsTotal
++
;
this
.
itemStart
=
function
(
url
)
{
if
(
isLoading
===
false
)
{
itemsTotal
++
;
if
(
scope
.
onStart
!==
undefined
)
{
if
(
isLoading
===
false
)
{
scope
.
onStart
(
url
,
itemsLoaded
,
itemsTotal
);
if
(
scope
.
onStart
!==
undefined
)
{
scope
.
onStart
(
url
,
itemsLoaded
,
itemsTotal
);
}
}
}
isLoading
=
true
;
isLoading
=
true
;
}
;
};
this
.
itemEnd
=
function
(
url
)
{
this
.
itemEnd
=
function
(
url
)
{
itemsLoaded
++
;
itemsLoaded
++
;
if
(
scope
.
onProgress
!==
undefined
)
{
if
(
scope
.
onProgress
!==
undefined
)
{
scope
.
onProgress
(
url
,
itemsLoaded
,
itemsTotal
);
scope
.
onProgress
(
url
,
itemsLoaded
,
itemsTotal
);
}
}
if
(
itemsLoaded
===
itemsTotal
)
{
if
(
itemsLoaded
===
itemsTotal
)
{
isLoading
=
false
;
isLoading
=
false
;
if
(
scope
.
onLoad
!==
undefined
)
{
if
(
scope
.
onLoad
!==
undefined
)
{
scope
.
onLoad
();
scope
.
onLoad
();
}
}
}
}
;
};
this
.
itemError
=
function
(
url
)
{
this
.
itemError
=
function
(
url
)
{
if
(
scope
.
onError
!==
undefined
)
{
if
(
scope
.
onError
!==
undefined
)
{
scope
.
onError
(
url
);
scope
.
onError
(
url
);
}
}
}
;
};
this
.
resolveURL
=
function
(
url
)
{
this
.
resolveURL
=
function
(
url
)
{
if
(
urlModifier
)
{
if
(
urlModifier
)
{
return
urlModifier
(
url
);
return
urlModifier
(
url
);
}
}
return
url
;
return
url
;
}
;
};
this
.
setURLModifier
=
function
(
transform
)
{
this
.
setURLModifier
=
function
(
transform
)
{
urlModifier
=
transform
;
urlModifier
=
transform
;
return
this
;
return
this
;
}
;
};
this
.
addHandler
=
function
(
regex
,
loader
)
{
this
.
addHandler
=
function
(
regex
,
loader
)
{
handlers
.
push
(
regex
,
loader
);
handlers
.
push
(
regex
,
loader
)
;
return
this
;
return
this
;
}
;
};
this
.
removeHandler
=
function
(
regex
)
{
this
.
removeHandler
=
function
(
regex
)
{
const
index
=
handlers
.
indexOf
(
regex
);
const
index
=
handlers
.
indexOf
(
regex
);
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
handlers
.
splice
(
index
,
2
);
handlers
.
splice
(
index
,
2
);
}
}
return
this
;
return
this
;
}
;
};
this
.
getHandler
=
function
(
file
)
{
this
.
getHandler
=
function
(
file
)
{
for
(
let
i
=
0
,
l
=
handlers
.
length
;
i
<
l
;
i
+=
2
)
{
for
(
let
i
=
0
,
l
=
handlers
.
length
;
i
<
l
;
i
+=
2
)
{
const
regex
=
handlers
[
i
];
const
loader
=
handlers
[
i
+
1
];
const
regex
=
handlers
[
i
];
const
loader
=
handlers
[
i
+
1
];
if
(
regex
.
global
)
regex
.
lastIndex
=
0
;
// see #17920
if
(
regex
.
global
)
regex
.
lastIndex
=
0
;
// see #17920
if
(
regex
.
test
(
file
)
)
{
if
(
regex
.
test
(
file
)
)
{
return
loader
;
return
loader
;
}
}
}
return
null
;
return
null
;
}
;
}
;
}
}
const
DefaultLoadingManager
=
new
LoadingManager
();
export
{
DefaultLoadingManager
,
LoadingManager
};
src/loaders/TextureLoader.js
浏览文件 @
2a2a8a55
...
...
@@ -3,17 +3,15 @@ import { ImageLoader } from './ImageLoader.js';
import
{
Texture
}
from
'
../textures/Texture.js
'
;
import
{
Loader
}
from
'
./Loader.js
'
;
function
TextureLoader
(
manager
)
{
class
TextureLoader
extends
Loader
{
Loader
.
call
(
this
,
manager
);
constructor
(
manager
)
{
}
TextureLoader
.
prototype
=
Object
.
assign
(
Object
.
create
(
Loader
.
prototype
),
{
super
(
manager
);
constructor
:
TextureLoader
,
}
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
load
(
url
,
onLoad
,
onProgress
,
onError
)
{
const
texture
=
new
Texture
();
...
...
@@ -43,7 +41,7 @@ TextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
}
}
);
}
export
{
TextureLoader
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录