Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
637fb106
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,发现更多精彩内容 >>
提交
637fb106
编写于
8月 14, 2017
作者:
D
Don McCurdy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[glTF] Clean up buffers/bufferViews.
上级
5ff4d48d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
84 deletion
+34
-84
examples/js/loaders/GLTF2Loader.js
examples/js/loaders/GLTF2Loader.js
+34
-84
未找到文件。
examples/js/loaders/GLTF2Loader.js
浏览文件 @
637fb106
...
...
@@ -196,8 +196,7 @@ THREE.GLTF2Loader = ( function () {
KHR_BINARY_GLTF
:
'
KHR_binary_glTF
'
,
KHR_LIGHTS
:
'
KHR_lights
'
,
KHR_MATERIALS_COMMON
:
'
KHR_materials_common
'
,
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS
:
'
KHR_materials_pbrSpecularGlossiness
'
,
KHR_TECHNIQUE_WEBGL
:
'
KHR_technique_webgl
'
,
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS
:
'
KHR_materials_pbrSpecularGlossiness
'
};
/**
...
...
@@ -746,7 +745,7 @@ THREE.GLTF2Loader = ( function () {
defines
.
USE_GLOSSINESSMAP
=
''
;
// set USE_ROUGHNESSMAP to enable vUv
defines
.
USE_ROUGHNESSMAP
=
''
defines
.
USE_ROUGHNESSMAP
=
''
;
}
...
...
@@ -1319,40 +1318,35 @@ THREE.GLTF2Loader = ( function () {
};
GLTFParser
.
prototype
.
loadBuffers
=
function
()
{
var
json
=
this
.
json
;
var
extensions
=
this
.
extensions
;
var
options
=
this
.
options
;
return
_each
(
json
.
buffers
,
function
(
buffer
,
name
)
{
if
(
buffer
.
type
===
'
arraybuffer
'
||
buffer
.
type
===
undefined
)
{
// If present, GLB container is required to be the first buffer.
if
(
buffer
.
uri
===
undefined
&&
name
===
0
)
{
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
* @param {number} bufferIndex
* @return {Promise<ArrayBuffer>}
*/
GLTFParser
.
prototype
.
loadBuffer
=
function
(
bufferIndex
)
{
return
extensions
[
EXTENSIONS
.
KHR_BINARY_GLTF
].
body
;
var
bufferDef
=
this
.
json
.
buffers
[
bufferIndex
]
;
}
if
(
bufferDef
.
type
&&
bufferDef
.
type
!==
'
arraybuffer
'
)
{
return
new
Promise
(
function
(
resolve
)
{
throw
new
Error
(
'
THREE.GLTF2Loader: %s buffer type is not supported.
'
,
bufferDef
.
type
);
var
loader
=
new
THREE
.
FileLoader
();
loader
.
setResponseType
(
'
arraybuffer
'
);
loader
.
load
(
resolveURL
(
buffer
.
uri
,
options
.
path
),
function
(
buffer
)
{
}
resolve
(
buffer
);
// If present, GLB container is required to be the first buffer.
if
(
bufferDef
.
uri
===
undefined
&&
bufferIndex
===
0
)
{
}
);
return
Promise
.
resolve
(
this
.
extensions
[
EXTENSIONS
.
KHR_BINARY_GLTF
].
body
);
}
);
}
}
else
{
var
options
=
this
.
options
;
console
.
warn
(
'
THREE.GLTF2Loader: %s buffer type is not supported.
'
,
buffer
.
type
);
return
new
Promise
(
function
(
resolve
)
{
}
var
loader
=
new
THREE
.
FileLoader
();
loader
.
setResponseType
(
'
arraybuffer
'
);
loader
.
load
(
resolveURL
(
bufferDef
.
uri
,
options
.
path
),
resolve
);
}
);
...
...
@@ -1365,39 +1359,13 @@ THREE.GLTF2Loader = ( function () {
*/
GLTFParser
.
prototype
.
loadBufferView
=
function
(
bufferViewIndex
)
{
return
this
.
_withDependencies
(
[
var
bufferViewDef
=
this
.
json
.
bufferViews
[
bufferViewIndex
];
'
bufferViews
'
return
this
.
getDependency
(
'
buffer
'
,
bufferViewDef
.
buffer
).
then
(
function
(
buffer
)
{
]
).
then
(
function
(
dependencies
)
{
return
dependencies
.
bufferViews
[
bufferViewIndex
];
}
);
};
/** @deprecated */
GLTFParser
.
prototype
.
loadBufferViews
=
function
()
{
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
'
buffers
'
]
).
then
(
function
(
dependencies
)
{
return
_each
(
json
.
bufferViews
,
function
(
bufferView
)
{
var
arraybuffer
=
dependencies
.
buffers
[
bufferView
.
buffer
];
var
byteLength
=
bufferView
.
byteLength
||
0
;
var
byteOffset
=
bufferView
.
byteOffset
||
0
;
return
arraybuffer
.
slice
(
byteOffset
,
byteOffset
+
byteLength
);
}
);
var
byteLength
=
bufferViewDef
.
byteLength
||
0
;
var
byteOffset
=
bufferViewDef
.
byteOffset
||
0
;
return
buffer
.
slice
(
byteOffset
,
byteOffset
+
byteLength
);
}
);
...
...
@@ -1405,17 +1373,13 @@ THREE.GLTF2Loader = ( function () {
GLTFParser
.
prototype
.
loadAccessors
=
function
()
{
var
parser
=
this
;
var
json
=
this
.
json
;
return
this
.
_withDependencies
(
[
'
bufferViews
'
return
_each
(
json
.
accessors
,
function
(
accessor
)
{
]
).
then
(
function
(
dependencies
)
{
return
parser
.
getDependency
(
'
bufferView
'
,
accessor
.
bufferView
).
then
(
function
(
bufferView
)
{
return
_each
(
json
.
accessors
,
function
(
accessor
)
{
var
arraybuffer
=
dependencies
.
bufferViews
[
accessor
.
bufferView
];
var
itemSize
=
WEBGL_TYPE_SIZES
[
accessor
.
type
];
var
TypedArray
=
WEBGL_COMPONENT_TYPES
[
accessor
.
componentType
];
...
...
@@ -1429,7 +1393,7 @@ THREE.GLTF2Loader = ( function () {
if
(
byteStride
&&
byteStride
!==
itemBytes
)
{
// Use the full buffer if it's interleaved.
array
=
new
TypedArray
(
arraybuffer
);
array
=
new
TypedArray
(
bufferView
);
// Integer parameters to IB/IBA are in array elements, not bytes.
var
ib
=
new
THREE
.
InterleavedBuffer
(
array
,
byteStride
/
elementBytes
);
...
...
@@ -1438,7 +1402,7 @@ THREE.GLTF2Loader = ( function () {
}
else
{
array
=
new
TypedArray
(
arraybuffer
,
accessor
.
byteOffset
,
accessor
.
count
*
itemSize
);
array
=
new
TypedArray
(
bufferView
,
accessor
.
byteOffset
,
accessor
.
count
*
itemSize
);
return
new
THREE
.
BufferAttribute
(
array
,
itemSize
);
...
...
@@ -1450,8 +1414,6 @@ THREE.GLTF2Loader = ( function () {
};
var
URL
=
window
.
URL
||
window
.
webkitURL
;
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
* @param {number} textureIndex
...
...
@@ -1463,14 +1425,9 @@ THREE.GLTF2Loader = ( function () {
var
json
=
this
.
json
;
var
options
=
this
.
options
;
var
textureDef
=
this
.
json
.
textures
[
textureIndex
];
if
(
textureDef
.
source
===
undefined
)
{
throw
new
Error
(
'
THREE.GLTF2Loader: Unknown texture for index
'
+
textureIndex
);
}
var
URL
=
window
.
URL
||
window
.
webkitURL
;
var
textureDef
=
json
.
textures
[
textureIndex
];
var
source
=
json
.
images
[
textureDef
.
source
];
var
sourceURI
=
source
.
uri
;
var
isObjectURL
=
false
;
...
...
@@ -1479,7 +1436,7 @@ THREE.GLTF2Loader = ( function () {
// Load binary image data from bufferView, if provided.
sourceURI
=
parser
.
loadBufferView
(
source
.
bufferView
)
sourceURI
=
parser
.
getDependency
(
'
bufferView
'
,
source
.
bufferView
)
.
then
(
function
(
bufferView
)
{
isObjectURL
=
true
;
...
...
@@ -1590,11 +1547,6 @@ THREE.GLTF2Loader = ( function () {
materialType
=
sgExtension
.
getMaterialType
(
material
);
pending
.
push
(
sgExtension
.
extendParams
(
materialParams
,
material
,
parser
)
);
}
else
if
(
materialExtensions
[
EXTENSIONS
.
KHR_TECHNIQUE_WEBGL
]
)
{
materialType
=
extensions
[
EXTENSIONS
.
KHR_TECHNIQUE_WEBGL
].
getMaterialType
(
material
);
extensions
[
EXTENSIONS
.
KHR_TECHNIQUE_WEBGL
].
extendParams
(
materialParams
,
material
,
dependencies
);
}
else
if
(
material
.
pbrMetallicRoughness
!==
undefined
)
{
// Specification:
...
...
@@ -1732,7 +1684,6 @@ THREE.GLTF2Loader = ( function () {
return
this
.
_withDependencies
(
[
'
accessors
'
,
'
bufferViews
'
,
]
).
then
(
function
(
dependencies
)
{
...
...
@@ -1821,7 +1772,6 @@ THREE.GLTF2Loader = ( function () {
return
this
.
_withDependencies
(
[
'
accessors
'
,
'
materials
'
]
).
then
(
function
(
dependencies
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录