mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-14 06:26:05 +08:00
Expose .isVersionSupported() method on THREE.DRACOLoader. (#85)
* Expose .isVersionSupported() method on THREE.DRACOLoader.
This commit is contained in:
parent
c7a5e903e5
commit
4dac78e622
@ -44,18 +44,8 @@ THREE.DRACOLoader.prototype = {
|
|||||||
this.verbosity = level;
|
this.verbosity = level;
|
||||||
},
|
},
|
||||||
|
|
||||||
decodeDracoFile: ( function() {
|
decodeDracoFile: function(rawBuffer) {
|
||||||
let dracoDecoder;
|
const dracoDecoder = THREE.DRACOLoader.getDecoder();
|
||||||
|
|
||||||
if (typeof DracoModule === 'function') {
|
|
||||||
dracoDecoder = DracoModule();
|
|
||||||
} else {
|
|
||||||
console.error('THREE.DRACOLoader: DracoModule not found.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return function(rawBuffer) {
|
|
||||||
const scope = this;
|
|
||||||
/*
|
/*
|
||||||
* Here is how to use Draco Javascript decoder and get the geometry.
|
* Here is how to use Draco Javascript decoder and get the geometry.
|
||||||
*/
|
*/
|
||||||
@ -80,13 +70,11 @@ THREE.DRACOLoader.prototype = {
|
|||||||
console.error(errorMsg);
|
console.error(errorMsg);
|
||||||
throw new Error(errorMsg);
|
throw new Error(errorMsg);
|
||||||
}
|
}
|
||||||
return scope.convertDracoGeometryTo3JS(wrapper, geometryType, buffer,
|
return this.convertDracoGeometryTo3JS(wrapper, geometryType, buffer);
|
||||||
dracoDecoder);
|
},
|
||||||
}
|
|
||||||
} )(),
|
|
||||||
|
|
||||||
convertDracoGeometryTo3JS: function(wrapper, geometryType, buffer,
|
convertDracoGeometryTo3JS: function(wrapper, geometryType, buffer) {
|
||||||
dracoDecoder) {
|
const dracoDecoder = THREE.DRACOLoader.getDecoder();
|
||||||
let dracoGeometry;
|
let dracoGeometry;
|
||||||
const start_time = performance.now();
|
const start_time = performance.now();
|
||||||
if (geometryType == dracoDecoder.TRIANGULAR_MESH) {
|
if (geometryType == dracoDecoder.TRIANGULAR_MESH) {
|
||||||
@ -273,5 +261,28 @@ THREE.DRACOLoader.prototype = {
|
|||||||
console.log('Import time: ' + this.import_time);
|
console.log('Import time: ' + this.import_time);
|
||||||
}
|
}
|
||||||
return geometry;
|
return geometry;
|
||||||
|
},
|
||||||
|
|
||||||
|
isVersionSupported: function(version) {
|
||||||
|
return THREE.DRACOLoader.getDecoder().isVersionSupported(version);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a singleton instance of the DracoModule decoder. Creating multiple
|
||||||
|
* copies of the decoder is expensive.
|
||||||
|
*/
|
||||||
|
THREE.DRACOLoader.getDecoder = (function() {
|
||||||
|
let decoder;
|
||||||
|
|
||||||
|
return function() {
|
||||||
|
if (typeof DracoModule === 'undefined') {
|
||||||
|
throw new Error('THREE.DRACOLoader: DracoModule not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
decoder = decoder || DracoModule();
|
||||||
|
|
||||||
|
return decoder;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user