Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
3d9a27a7
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,发现更多精彩内容 >>
提交
3d9a27a7
编写于
12月 07, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GLTFLoader: Removed .bind() craziness.
上级
67b4a111
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
77 addition
and
52 deletion
+77
-52
examples/js/loaders/GLTFLoader.js
examples/js/loaders/GLTFLoader.js
+77
-52
未找到文件。
examples/js/loaders/GLTFLoader.js
浏览文件 @
3d9a27a7
...
...
@@ -132,9 +132,7 @@ THREE.GLTFLoader = ( function () {
function
GLTFShader
(
targetNode
,
allNodes
)
{
var
scope
=
this
;
this
.
boundUniforms
=
{};
var
boundUniforms
=
{};
// bind each uniform to its source node
...
...
@@ -156,7 +154,7 @@ THREE.GLTFLoader = ( function () {
}
scope
.
boundUniforms
[
uniformId
]
=
{
boundUniforms
[
uniformId
]
=
{
semantic
:
uniform
.
semantic
,
sourceNode
:
sourceNode
,
targetNode
:
targetNode
,
...
...
@@ -167,6 +165,7 @@ THREE.GLTFLoader = ( function () {
}
this
.
boundUniforms
=
boundUniforms
;
this
.
_m4
=
new
THREE
.
Matrix4
();
}
...
...
@@ -614,6 +613,8 @@ THREE.GLTFLoader = ( function () {
GLTFParser
.
prototype
.
parse
=
function
(
callback
)
{
var
json
=
this
.
json
;
// Clear the loader cache
this
.
cache
.
removeAll
();
...
...
@@ -626,7 +627,7 @@ THREE.GLTFLoader = ( function () {
]
).
then
(
function
(
dependencies
)
{
var
scene
=
dependencies
.
scenes
[
this
.
json
.
scene
];
var
scene
=
dependencies
.
scenes
[
json
.
scene
];
var
cameras
=
[];
...
...
@@ -647,33 +648,39 @@ THREE.GLTFLoader = ( function () {
callback
(
scene
,
cameras
,
animations
);
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadShaders
=
function
()
{
return
_each
(
this
.
json
.
shaders
,
function
(
shader
)
{
var
json
=
this
.
json
;
var
options
=
this
.
options
;
return
_each
(
json
.
shaders
,
function
(
shader
)
{
return
new
Promise
(
function
(
resolve
)
{
var
loader
=
new
THREE
.
FileLoader
();
loader
.
responseType
=
'
text
'
;
loader
.
load
(
resolveURL
(
shader
.
uri
,
this
.
options
.
path
),
function
(
shaderText
)
{
loader
.
load
(
resolveURL
(
shader
.
uri
,
options
.
path
),
function
(
shaderText
)
{
resolve
(
shaderText
);
}
);
}
.
bind
(
this
)
);
}
);
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadBuffers
=
function
()
{
return
_each
(
this
.
json
.
buffers
,
function
(
buffer
)
{
var
json
=
this
.
json
;
var
options
=
this
.
options
;
return
_each
(
json
.
buffers
,
function
(
buffer
)
{
if
(
buffer
.
type
===
'
arraybuffer
'
)
{
...
...
@@ -681,29 +688,31 @@ THREE.GLTFLoader = ( function () {
var
loader
=
new
THREE
.
FileLoader
();
loader
.
responseType
=
'
arraybuffer
'
;
loader
.
load
(
resolveURL
(
buffer
.
uri
,
this
.
options
.
path
),
function
(
buffer
)
{
loader
.
load
(
resolveURL
(
buffer
.
uri
,
options
.
path
),
function
(
buffer
)
{
resolve
(
buffer
);
}
);
}
.
bind
(
this
)
);
}
);
}
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadBufferViews
=
function
()
{
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
"
buffers
"
]
).
then
(
function
(
dependencies
)
{
return
_each
(
this
.
json
.
bufferViews
,
function
(
bufferView
)
{
return
_each
(
json
.
bufferViews
,
function
(
bufferView
)
{
var
arraybuffer
=
dependencies
.
buffers
[
bufferView
.
buffer
];
...
...
@@ -711,19 +720,21 @@ THREE.GLTFLoader = ( function () {
}
);
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadAccessors
=
function
()
{
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
"
bufferViews
"
]
).
then
(
function
(
dependencies
)
{
return
_each
(
this
.
json
.
accessors
,
function
(
accessor
)
{
return
_each
(
json
.
accessors
,
function
(
accessor
)
{
var
arraybuffer
=
dependencies
.
bufferViews
[
accessor
.
bufferView
];
var
itemSize
=
WEBGL_TYPE_SIZES
[
accessor
.
type
];
...
...
@@ -754,19 +765,22 @@ THREE.GLTFLoader = ( function () {
}
);
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadTextures
=
function
()
{
return
_each
(
this
.
json
.
textures
,
function
(
texture
)
{
var
json
=
this
.
json
;
var
options
=
this
.
options
;
return
_each
(
json
.
textures
,
function
(
texture
)
{
if
(
texture
.
source
)
{
return
new
Promise
(
function
(
resolve
)
{
var
source
=
this
.
json
.
images
[
texture
.
source
];
var
source
=
json
.
images
[
texture
.
source
];
var
textureLoader
=
THREE
.
Loader
.
Handlers
.
get
(
source
.
uri
);
...
...
@@ -776,15 +790,15 @@ THREE.GLTFLoader = ( function () {
}
textureLoader
.
crossOrigin
=
this
.
options
.
crossOrigin
||
false
;
textureLoader
.
crossOrigin
=
options
.
crossOrigin
||
false
;
textureLoader
.
load
(
resolveURL
(
source
.
uri
,
this
.
options
.
path
),
function
(
_texture
)
{
textureLoader
.
load
(
resolveURL
(
source
.
uri
,
options
.
path
),
function
(
_texture
)
{
_texture
.
flipY
=
false
;
if
(
texture
.
sampler
)
{
var
sampler
=
this
.
json
.
samplers
[
texture
.
sampler
];
var
sampler
=
json
.
samplers
[
texture
.
sampler
];
_texture
.
magFilter
=
WEBGL_FILTERS
[
sampler
.
magFilter
];
_texture
.
minFilter
=
WEBGL_FILTERS
[
sampler
.
minFilter
];
...
...
@@ -795,22 +809,24 @@ THREE.GLTFLoader = ( function () {
resolve
(
_texture
);
}
.
bind
(
this
)
,
undefined
,
function
()
{
},
undefined
,
function
()
{
resolve
();
}
);
}
.
bind
(
this
)
);
}
);
}
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadMaterials
=
function
()
{
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
"
shaders
"
,
...
...
@@ -818,7 +834,7 @@ THREE.GLTFLoader = ( function () {
]
).
then
(
function
(
dependencies
)
{
return
_each
(
this
.
json
.
materials
,
function
(
material
)
{
return
_each
(
json
.
materials
,
function
(
material
)
{
var
materialType
;
var
materialValues
=
{};
...
...
@@ -830,9 +846,9 @@ THREE.GLTFLoader = ( function () {
khr_material
=
material
.
extensions
.
KHR_materials_common
;
}
else
if
(
this
.
json
.
extensions
&&
this
.
json
.
extensions
.
KHR_materials_common
)
{
}
else
if
(
json
.
extensions
&&
json
.
extensions
.
KHR_materials_common
)
{
khr_material
=
this
.
json
.
extensions
.
KHR_materials_common
;
khr_material
=
json
.
extensions
.
KHR_materials_common
;
}
...
...
@@ -881,11 +897,11 @@ THREE.GLTFLoader = ( function () {
materialType
=
DeferredShaderMaterial
;
var
technique
=
this
.
json
.
techniques
[
material
.
technique
];
var
technique
=
json
.
techniques
[
material
.
technique
];
materialParams
.
uniforms
=
{};
var
program
=
this
.
json
.
programs
[
technique
.
program
];
var
program
=
json
.
programs
[
technique
.
program
];
if
(
program
)
{
...
...
@@ -1090,14 +1106,16 @@ THREE.GLTFLoader = ( function () {
return
_material
;
}
.
bind
(
this
)
);
}
);
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadMeshes
=
function
()
{
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
"
accessors
"
,
...
...
@@ -1105,7 +1123,7 @@ THREE.GLTFLoader = ( function () {
]
).
then
(
function
(
dependencies
)
{
return
_each
(
this
.
json
.
meshes
,
function
(
mesh
)
{
return
_each
(
json
.
meshes
,
function
(
mesh
)
{
var
group
=
new
THREE
.
Object3D
();
group
.
name
=
mesh
.
name
;
...
...
@@ -1196,13 +1214,15 @@ THREE.GLTFLoader = ( function () {
}
);
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadCameras
=
function
()
{
return
_each
(
this
.
json
.
cameras
,
function
(
camera
)
{
var
json
=
this
.
json
;
return
_each
(
json
.
cameras
,
function
(
camera
)
{
if
(
camera
.
type
==
"
perspective
"
&&
camera
.
perspective
)
{
...
...
@@ -1232,13 +1252,13 @@ THREE.GLTFLoader = ( function () {
}
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadSkins
=
function
()
{
var
scope
=
this
;
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
...
...
@@ -1246,7 +1266,7 @@ THREE.GLTFLoader = ( function () {
]
).
then
(
function
(
dependencies
)
{
return
_each
(
scope
.
json
.
skins
,
function
(
skin
)
{
return
_each
(
json
.
skins
,
function
(
skin
)
{
var
_skin
=
{
bindShapeMatrix
:
new
THREE
.
Matrix4
().
fromArray
(
skin
.
bindShapeMatrix
),
...
...
@@ -1264,7 +1284,7 @@ THREE.GLTFLoader = ( function () {
GLTFParser
.
prototype
.
loadAnimations
=
function
()
{
var
scope
=
this
;
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
...
...
@@ -1273,7 +1293,7 @@ THREE.GLTFLoader = ( function () {
]
).
then
(
function
(
dependencies
)
{
return
_each
(
scope
.
json
.
animations
,
function
(
animation
,
animationId
)
{
return
_each
(
json
.
animations
,
function
(
animation
,
animationId
)
{
var
interps
=
[];
...
...
@@ -1322,7 +1342,10 @@ THREE.GLTFLoader = ( function () {
GLTFParser
.
prototype
.
loadNodes
=
function
()
{
return
_each
(
this
.
json
.
nodes
,
function
(
node
)
{
var
json
=
this
.
json
;
var
scope
=
this
;
return
_each
(
json
.
nodes
,
function
(
node
)
{
var
matrix
=
new
THREE
.
Matrix4
();
...
...
@@ -1372,9 +1395,9 @@ THREE.GLTFLoader = ( function () {
return
_node
;
}
.
bind
(
this
)
).
then
(
function
(
__nodes
)
{
}
).
then
(
function
(
__nodes
)
{
return
this
.
_withDependencies
(
[
return
scope
.
_withDependencies
(
[
"
meshes
"
,
"
skins
"
,
...
...
@@ -1385,7 +1408,7 @@ THREE.GLTFLoader = ( function () {
return
_each
(
__nodes
,
function
(
_node
,
nodeId
)
{
var
node
=
this
.
json
.
nodes
[
nodeId
];
var
node
=
json
.
nodes
[
nodeId
];
if
(
node
.
meshes
!==
undefined
)
{
...
...
@@ -1491,17 +1514,19 @@ THREE.GLTFLoader = ( function () {
return
_node
;
}
.
bind
(
this
)
);
}
);
}
.
bind
(
this
)
);
}
);
}
.
bind
(
this
)
);
}
);
};
GLTFParser
.
prototype
.
loadExtensions
=
function
()
{
return
_each
(
this
.
json
.
extensions
,
function
(
extension
,
extensionId
)
{
var
json
=
this
.
json
;
return
_each
(
json
.
extensions
,
function
(
extension
,
extensionId
)
{
switch
(
extensionId
)
{
...
...
@@ -1563,7 +1588,7 @@ THREE.GLTFLoader = ( function () {
GLTFParser
.
prototype
.
loadScenes
=
function
()
{
var
scope
=
this
;
var
json
=
this
.
json
;
// scene node hierachy builder
...
...
@@ -1572,7 +1597,7 @@ THREE.GLTFLoader = ( function () {
var
_node
=
allNodes
[
nodeId
];
parentObject
.
add
(
_node
);
var
node
=
scope
.
json
.
nodes
[
nodeId
];
var
node
=
json
.
nodes
[
nodeId
];
if
(
node
.
children
)
{
...
...
@@ -1595,7 +1620,7 @@ THREE.GLTFLoader = ( function () {
]
).
then
(
function
(
dependencies
)
{
return
_each
(
scope
.
json
.
scenes
,
function
(
scene
)
{
return
_each
(
json
.
scenes
,
function
(
scene
)
{
var
_scene
=
new
THREE
.
Scene
();
_scene
.
name
=
scene
.
name
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录