|
@@ -24,8 +24,6 @@ THREE.DRACOLoader = function(manager) {
|
|
this.verbosity = 0;
|
|
this.verbosity = 0;
|
|
this.attributeOptions = {};
|
|
this.attributeOptions = {};
|
|
this.drawMode = THREE.TrianglesDrawMode;
|
|
this.drawMode = THREE.TrianglesDrawMode;
|
|
- // User defined unique id for attributes.
|
|
|
|
- this.attributeUniqueIdMap = {};
|
|
|
|
// Native Draco attribute type to Three.JS attribute type.
|
|
// Native Draco attribute type to Three.JS attribute type.
|
|
this.nativeAttributeMap = {
|
|
this.nativeAttributeMap = {
|
|
'position' : 'POSITION',
|
|
'position' : 'POSITION',
|
|
@@ -104,14 +102,15 @@ THREE.DRACOLoader.prototype = {
|
|
*/
|
|
*/
|
|
decodeDracoFile: function(rawBuffer, callback, attributeUniqueIdMap) {
|
|
decodeDracoFile: function(rawBuffer, callback, attributeUniqueIdMap) {
|
|
var scope = this;
|
|
var scope = this;
|
|
- this.attributeUniqueIdMap = attributeUniqueIdMap || {};
|
|
|
|
THREE.DRACOLoader.getDecoderModule()
|
|
THREE.DRACOLoader.getDecoderModule()
|
|
.then( function ( module ) {
|
|
.then( function ( module ) {
|
|
- scope.decodeDracoFileInternal( rawBuffer, module.decoder, callback );
|
|
|
|
|
|
+ scope.decodeDracoFileInternal( rawBuffer, module.decoder, callback,
|
|
|
|
+ attributeUniqueIdMap );
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- decodeDracoFileInternal: function(rawBuffer, dracoDecoder, callback) {
|
|
|
|
|
|
+ decodeDracoFileInternal: function(rawBuffer, dracoDecoder, callback,
|
|
|
|
+ attributeUniqueIdMap) {
|
|
/*
|
|
/*
|
|
* Here is how to use Draco Javascript decoder and get the geometry.
|
|
* Here is how to use Draco Javascript decoder and get the geometry.
|
|
*/
|
|
*/
|
|
@@ -137,7 +136,7 @@ THREE.DRACOLoader.prototype = {
|
|
throw new Error(errorMsg);
|
|
throw new Error(errorMsg);
|
|
}
|
|
}
|
|
callback(this.convertDracoGeometryTo3JS(dracoDecoder, decoder,
|
|
callback(this.convertDracoGeometryTo3JS(dracoDecoder, decoder,
|
|
- geometryType, buffer));
|
|
|
|
|
|
+ geometryType, buffer, attributeUniqueIdMap));
|
|
},
|
|
},
|
|
|
|
|
|
addAttributeToGeometry: function(dracoDecoder, decoder, dracoGeometry,
|
|
addAttributeToGeometry: function(dracoDecoder, decoder, dracoGeometry,
|
|
@@ -168,7 +167,7 @@ THREE.DRACOLoader.prototype = {
|
|
},
|
|
},
|
|
|
|
|
|
convertDracoGeometryTo3JS: function(dracoDecoder, decoder, geometryType,
|
|
convertDracoGeometryTo3JS: function(dracoDecoder, decoder, geometryType,
|
|
- buffer) {
|
|
|
|
|
|
+ buffer, attributeUniqueIdMap) {
|
|
if (this.getAttributeOptions('position').skipDequantization === true) {
|
|
if (this.getAttributeOptions('position').skipDequantization === true) {
|
|
decoder.SkipAttributeTransform(dracoDecoder.POSITION);
|
|
decoder.SkipAttributeTransform(dracoDecoder.POSITION);
|
|
}
|
|
}
|
|
@@ -236,7 +235,7 @@ THREE.DRACOLoader.prototype = {
|
|
for (var attributeName in this.nativeAttributeMap) {
|
|
for (var attributeName in this.nativeAttributeMap) {
|
|
// The native attribute type is only used when no unique Id is
|
|
// The native attribute type is only used when no unique Id is
|
|
// provided. For example, loading .drc files.
|
|
// provided. For example, loading .drc files.
|
|
- if (this.attributeUniqueIdMap[attributeName] === undefined) {
|
|
|
|
|
|
+ if (attributeUniqueIdMap[attributeName] === undefined) {
|
|
var attId = decoder.GetAttributeId(dracoGeometry,
|
|
var attId = decoder.GetAttributeId(dracoGeometry,
|
|
dracoDecoder[this.nativeAttributeMap[attributeName]]);
|
|
dracoDecoder[this.nativeAttributeMap[attributeName]]);
|
|
if (attId !== -1) {
|
|
if (attId !== -1) {
|
|
@@ -251,8 +250,8 @@ THREE.DRACOLoader.prototype = {
|
|
}
|
|
}
|
|
|
|
|
|
// Add attributes of user specified unique id. E.g. GLTF models.
|
|
// Add attributes of user specified unique id. E.g. GLTF models.
|
|
- for (var attributeName in this.attributeUniqueIdMap) {
|
|
|
|
- var attributeId = this.attributeUniqueIdMap[attributeName];
|
|
|
|
|
|
+ for (var attributeName in attributeUniqueIdMap) {
|
|
|
|
+ var attributeId = attributeUniqueIdMap[attributeName];
|
|
var attribute = decoder.GetAttributeByUniqueId(dracoGeometry,
|
|
var attribute = decoder.GetAttributeByUniqueId(dracoGeometry,
|
|
attributeId);
|
|
attributeId);
|
|
this.addAttributeToGeometry(dracoDecoder, decoder, dracoGeometry,
|
|
this.addAttributeToGeometry(dracoDecoder, decoder, dracoGeometry,
|