mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-13 00:59:03 +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;
|
||||
},
|
||||
|
||||
decodeDracoFile: ( function() {
|
||||
let dracoDecoder;
|
||||
|
||||
if (typeof DracoModule === 'function') {
|
||||
dracoDecoder = DracoModule();
|
||||
} else {
|
||||
console.error('THREE.DRACOLoader: DracoModule not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
return function(rawBuffer) {
|
||||
const scope = this;
|
||||
decodeDracoFile: function(rawBuffer) {
|
||||
const dracoDecoder = THREE.DRACOLoader.getDecoder();
|
||||
/*
|
||||
* Here is how to use Draco Javascript decoder and get the geometry.
|
||||
*/
|
||||
@ -80,13 +70,11 @@ THREE.DRACOLoader.prototype = {
|
||||
console.error(errorMsg);
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
return scope.convertDracoGeometryTo3JS(wrapper, geometryType, buffer,
|
||||
dracoDecoder);
|
||||
}
|
||||
} )(),
|
||||
return this.convertDracoGeometryTo3JS(wrapper, geometryType, buffer);
|
||||
},
|
||||
|
||||
convertDracoGeometryTo3JS: function(wrapper, geometryType, buffer,
|
||||
dracoDecoder) {
|
||||
convertDracoGeometryTo3JS: function(wrapper, geometryType, buffer) {
|
||||
const dracoDecoder = THREE.DRACOLoader.getDecoder();
|
||||
let dracoGeometry;
|
||||
const start_time = performance.now();
|
||||
if (geometryType == dracoDecoder.TRIANGULAR_MESH) {
|
||||
@ -273,5 +261,28 @@ THREE.DRACOLoader.prototype = {
|
||||
console.log('Import time: ' + this.import_time);
|
||||
}
|
||||
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