提交 f99a9e31 编写于 作者: D Don McCurdy

Update DRACOLoader and draco_decoder.

Adds isVersionSupported() method.
上级 19b3e0db
......@@ -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;
};
})();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册