Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
28606a29
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
28606a29
编写于
10月 19, 2018
作者:
D
Don McCurdy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GLTFLoader+DRACOLoader: Fix attribute ID resolution, and primitive-related bugs.
上级
521222b9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
41 deletion
+53
-41
examples/js/loaders/DRACOLoader.js
examples/js/loaders/DRACOLoader.js
+36
-27
examples/js/loaders/GLTFLoader.js
examples/js/loaders/GLTFLoader.js
+17
-14
未找到文件。
examples/js/loaders/DRACOLoader.js
浏览文件 @
28606a29
...
...
@@ -84,18 +84,19 @@ THREE.DRACOLoader.prototype = {
},
/**
* |attributeUniqueIdMap| specifies attribute unique id for an attribute in
* the geometry to be decoded. The name of the attribute must be one of the
* supported attribute type in Three.JS, including:
* 'position',
* 'color',
* 'normal',
* 'uv',
* 'uv2',
* 'skinIndex',
* 'skinWeight'.
* The format is:
* attributeUniqueIdMap[attributeName] = attributeId
* Decompresses a Draco buffer. Names of attributes (for ID and type maps)
* must be one of the supported three.js types, including: position, color,
* normal, uv, uv2, skinIndex, skinWeight.
*
* @param {ArrayBuffer} rawBuffer
* @param {Function} callback
* @param {Object|undefined} attributeUniqueIdMap Provides a pre-defined ID
* for each attribute in the geometry to be decoded. If given,
* `attributeTypeMap` is required and `nativeAttributeMap` will be
* ignored.
* @param {Object|undefined} attributeTypeMap Provides a predefined data
* type (as a typed array constructor) for each attribute in the
* geometry to be decoded.
*/
decodeDracoFile
:
function
(
rawBuffer
,
callback
,
attributeUniqueIdMap
,
attributeTypeMap
)
{
...
...
@@ -103,7 +104,7 @@ THREE.DRACOLoader.prototype = {
THREE
.
DRACOLoader
.
getDecoderModule
()
.
then
(
function
(
module
)
{
scope
.
decodeDracoFileInternal
(
rawBuffer
,
module
.
decoder
,
callback
,
attributeUniqueIdMap
||
{},
attributeTypeMap
||
{}
);
attributeUniqueIdMap
,
attributeTypeMap
);
});
},
...
...
@@ -231,6 +232,7 @@ THREE.DRACOLoader.prototype = {
convertDracoGeometryTo3JS
:
function
(
dracoDecoder
,
decoder
,
geometryType
,
buffer
,
attributeUniqueIdMap
,
attributeTypeMap
)
{
// TODO: Should not assume native Draco attribute IDs apply.
if
(
this
.
getAttributeOptions
(
'
position
'
).
skipDequantization
===
true
)
{
decoder
.
SkipAttributeTransform
(
dracoDecoder
.
POSITION
);
}
...
...
@@ -278,6 +280,7 @@ THREE.DRACOLoader.prototype = {
}
// Verify if there is position attribute.
// TODO: Should not assume native Draco attribute IDs apply.
var
posAttId
=
decoder
.
GetAttributeId
(
dracoGeometry
,
dracoDecoder
.
POSITION
);
if
(
posAttId
==
-
1
)
{
...
...
@@ -294,11 +297,23 @@ THREE.DRACOLoader.prototype = {
// Import data to Three JS geometry.
var
geometry
=
new
THREE
.
BufferGeometry
();
// Add native Draco attribute type to geometry.
for
(
var
attributeName
in
this
.
nativeAttributeMap
)
{
// The native attribute type is only used when no unique Id is
// provided. For example, loading .drc files.
if
(
attributeUniqueIdMap
[
attributeName
]
===
undefined
)
{
// Do not use both the native attribute map and a provided (e.g. glTF) map.
if
(
attributeUniqueIdMap
)
{
// Add attributes of user specified unique id. E.g. GLTF models.
for
(
var
attributeName
in
attributeUniqueIdMap
)
{
var
attributeType
=
attributeTypeMap
[
attributeName
];
var
attributeId
=
attributeUniqueIdMap
[
attributeName
];
var
attribute
=
decoder
.
GetAttributeByUniqueId
(
dracoGeometry
,
attributeId
);
this
.
addAttributeToGeometry
(
dracoDecoder
,
decoder
,
dracoGeometry
,
attributeName
,
attributeType
,
attribute
,
geometry
,
geometryBuffer
);
}
}
else
{
// Add native Draco attribute type to geometry.
for
(
var
attributeName
in
this
.
nativeAttributeMap
)
{
var
attId
=
decoder
.
GetAttributeId
(
dracoGeometry
,
dracoDecoder
[
this
.
nativeAttributeMap
[
attributeName
]]);
if
(
attId
!==
-
1
)
{
...
...
@@ -310,16 +325,7 @@ THREE.DRACOLoader.prototype = {
attributeName
,
Float32Array
,
attribute
,
geometry
,
geometryBuffer
);
}
}
}
// Add attributes of user specified unique id. E.g. GLTF models.
for
(
var
attributeName
in
attributeUniqueIdMap
)
{
var
attributeType
=
attributeTypeMap
[
attributeName
]
||
Float32Array
;
var
attributeId
=
attributeUniqueIdMap
[
attributeName
];
var
attribute
=
decoder
.
GetAttributeByUniqueId
(
dracoGeometry
,
attributeId
);
this
.
addAttributeToGeometry
(
dracoDecoder
,
decoder
,
dracoGeometry
,
attributeName
,
attributeType
,
attribute
,
geometry
,
geometryBuffer
);
}
// For mesh, we need to generate the faces.
...
...
@@ -354,6 +360,9 @@ THREE.DRACOLoader.prototype = {
THREE
.
Uint32BufferAttribute
:
THREE
.
Uint16BufferAttribute
)
(
geometryBuffer
.
indices
,
1
));
}
// TODO: Should not assume native Draco attribute IDs apply.
// TODO: Can other attribute types be quantized?
var
posTransform
=
new
dracoDecoder
.
AttributeQuantizationTransform
();
if
(
posTransform
.
InitFromAttribute
(
posAttribute
))
{
// Quantized attribute. Store the quantization parameters into the
...
...
examples/js/loaders/GLTFLoader.js
浏览文件 @
28606a29
...
...
@@ -1136,16 +1136,10 @@ THREE.GLTFLoader = ( function () {
POSITION
:
'
position
'
,
NORMAL
:
'
normal
'
,
TEXCOORD_0
:
'
uv
'
,
TEXCOORD0
:
'
uv
'
,
// deprecated
TEXCOORD
:
'
uv
'
,
// deprecated
TEXCOORD_1
:
'
uv2
'
,
COLOR_0
:
'
color
'
,
COLOR0
:
'
color
'
,
// deprecated
COLOR
:
'
color
'
,
// deprecated
WEIGHTS_0
:
'
skinWeight
'
,
WEIGHT
:
'
skinWeight
'
,
// deprecated
JOINTS_0
:
'
skinIndex
'
,
JOINT
:
'
skinIndex
'
// deprecated
};
var
PATH_PROPERTIES
=
{
...
...
@@ -1296,6 +1290,7 @@ THREE.GLTFLoader = ( function () {
if
(
hasMorphPosition
)
{
// TODO: Error-prone use of a callback inside a loop.
var
accessor
=
target
.
POSITION
!==
undefined
?
parser
.
getDependency
(
'
accessor
'
,
target
.
POSITION
)
.
then
(
function
(
accessor
)
{
...
...
@@ -1310,6 +1305,7 @@ THREE.GLTFLoader = ( function () {
if
(
hasMorphNormal
)
{
// TODO: Error-prone use of a callback inside a loop.
var
accessor
=
target
.
NORMAL
!==
undefined
?
parser
.
getDependency
(
'
accessor
'
,
target
.
NORMAL
)
.
then
(
function
(
accessor
)
{
...
...
@@ -1848,6 +1844,7 @@ THREE.GLTFLoader = ( function () {
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
;
...
...
@@ -1939,7 +1936,7 @@ THREE.GLTFLoader = ( function () {
// Ignore empty accessors, which may be used to declare runtime
// information about attributes coming from another source (e.g. Draco
// compression extension).
return
null
;
return
Promise
.
resolve
(
null
)
;
}
...
...
@@ -2435,6 +2432,18 @@ THREE.GLTFLoader = ( function () {
}
function
createDracoPrimitive
(
primitive
)
{
return
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
.
decodePrimitive
(
primitive
,
parser
)
.
then
(
function
(
geometry
)
{
return
addPrimitiveAttributes
(
geometry
,
primitive
,
parser
);
}
);
}
var
pending
=
[];
for
(
var
i
=
0
,
il
=
primitives
.
length
;
i
<
il
;
i
++
)
{
...
...
@@ -2456,13 +2465,7 @@ THREE.GLTFLoader = ( function () {
if
(
primitive
.
extensions
&&
primitive
.
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
)
{
// Use DRACO geometry if available
geometryPromise
=
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
.
decodePrimitive
(
primitive
,
parser
)
.
then
(
function
(
geometry
)
{
return
addPrimitiveAttributes
(
geometry
,
primitive
,
parser
);
}
);
geometryPromise
=
createDracoPrimitive
(
primitive
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录