@@ -24,8 +24,6 @@ THREE.DRACOLoader = function(manager) {
24
24
this . verbosity = 0 ;
25
25
this . attributeOptions = { } ;
26
26
this . drawMode = THREE . TrianglesDrawMode ;
27
- // User defined unique id for attributes.
28
- this . attributeUniqueIdMap = { } ;
29
27
// Native Draco attribute type to Three.JS attribute type.
30
28
this . nativeAttributeMap = {
31
29
'position' : 'POSITION' ,
@@ -104,14 +102,15 @@ THREE.DRACOLoader.prototype = {
104
102
*/
105
103
decodeDracoFile : function ( rawBuffer , callback , attributeUniqueIdMap ) {
106
104
var scope = this ;
107
- this . attributeUniqueIdMap = attributeUniqueIdMap || { } ;
108
105
THREE . DRACOLoader . getDecoderModule ( )
109
106
. then ( function ( module ) {
110
- scope . decodeDracoFileInternal ( rawBuffer , module . decoder , callback ) ;
107
+ scope . decodeDracoFileInternal ( rawBuffer , module . decoder , callback ,
108
+ attributeUniqueIdMap ) ;
111
109
} ) ;
112
110
} ,
113
111
114
- decodeDracoFileInternal : function ( rawBuffer , dracoDecoder , callback ) {
112
+ decodeDracoFileInternal : function ( rawBuffer , dracoDecoder , callback ,
113
+ attributeUniqueIdMap ) {
115
114
/*
116
115
* Here is how to use Draco Javascript decoder and get the geometry.
117
116
*/
@@ -137,7 +136,7 @@ THREE.DRACOLoader.prototype = {
137
136
throw new Error ( errorMsg ) ;
138
137
}
139
138
callback ( this . convertDracoGeometryTo3JS ( dracoDecoder , decoder ,
140
- geometryType , buffer ) ) ;
139
+ geometryType , buffer , attributeUniqueIdMap ) ) ;
141
140
} ,
142
141
143
142
addAttributeToGeometry : function ( dracoDecoder , decoder , dracoGeometry ,
@@ -168,7 +167,7 @@ THREE.DRACOLoader.prototype = {
168
167
} ,
169
168
170
169
convertDracoGeometryTo3JS : function ( dracoDecoder , decoder , geometryType ,
171
- buffer ) {
170
+ buffer , attributeUniqueIdMap ) {
172
171
if ( this . getAttributeOptions ( 'position' ) . skipDequantization === true ) {
173
172
decoder . SkipAttributeTransform ( dracoDecoder . POSITION ) ;
174
173
}
@@ -236,7 +235,7 @@ THREE.DRACOLoader.prototype = {
236
235
for ( var attributeName in this . nativeAttributeMap ) {
237
236
// The native attribute type is only used when no unique Id is
238
237
// provided. For example, loading .drc files.
239
- if ( this . attributeUniqueIdMap [ attributeName ] === undefined ) {
238
+ if ( attributeUniqueIdMap [ attributeName ] === undefined ) {
240
239
var attId = decoder . GetAttributeId ( dracoGeometry ,
241
240
dracoDecoder [ this . nativeAttributeMap [ attributeName ] ] ) ;
242
241
if ( attId !== - 1 ) {
@@ -251,8 +250,8 @@ THREE.DRACOLoader.prototype = {
251
250
}
252
251
253
252
// Add attributes of user specified unique id. E.g. GLTF models.
254
- for ( var attributeName in this . attributeUniqueIdMap ) {
255
- var attributeId = this . attributeUniqueIdMap [ attributeName ] ;
253
+ for ( var attributeName in attributeUniqueIdMap ) {
254
+ var attributeId = attributeUniqueIdMap [ attributeName ] ;
256
255
var attribute = decoder . GetAttributeByUniqueId ( dracoGeometry ,
257
256
attributeId ) ;
258
257
this . addAttributeToGeometry ( dracoDecoder , decoder , dracoGeometry ,
0 commit comments