mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-09-13 06:03:13 +08:00
DRACOLoader: Support requests for multiple files in parallel.
This commit is contained in:
parent
3ea3cd8b20
commit
6c954eac60
@ -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) {
|
for (var attributeName in attributeUniqueIdMap) {
|
||||||
var attributeId = this.attributeUniqueIdMap[attributeName];
|
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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user