summaryrefslogtreecommitdiff
path: root/client/splash/vendor/DRACOLoader.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-01-27 17:27:14 +0100
committerJules Laplace <julescarbon@gmail.com>2019-01-27 17:27:14 +0100
commit3f16cb26e6a5e7858c9c3db10d02bec9c18b9511 (patch)
tree2f3b5533d4ff2ddb1138bf7793143635c46115bc /client/splash/vendor/DRACOLoader.js
parentc9d476e421a50aa5e3e20389365263d5c36e5696 (diff)
remove dependencies from DRACO and MeshLine
Diffstat (limited to 'client/splash/vendor/DRACOLoader.js')
-rw-r--r--client/splash/vendor/DRACOLoader.js59
1 files changed, 31 insertions, 28 deletions
diff --git a/client/splash/vendor/DRACOLoader.js b/client/splash/vendor/DRACOLoader.js
index 03fecb6b..64e6d801 100644
--- a/client/splash/vendor/DRACOLoader.js
+++ b/client/splash/vendor/DRACOLoader.js
@@ -12,12 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-'use strict';
+
+import * as THREE from 'three';
/**
* @param {THREE.LoadingManager} manager
*/
-THREE.DRACOLoader = function(manager) {
+DRACOLoader = function(manager) {
this.timeLoaded = 0;
this.manager = manager || THREE.DefaultLoadingManager;
this.materials = null;
@@ -33,9 +34,9 @@ THREE.DRACOLoader = function(manager) {
};
};
-THREE.DRACOLoader.prototype = {
+DRACOLoader.prototype = {
- constructor: THREE.DRACOLoader,
+ constructor: DRACOLoader,
load: function(url, onLoad, onProgress, onError) {
var scope = this;
@@ -103,7 +104,7 @@ THREE.DRACOLoader.prototype = {
decodeDracoFile: function(rawBuffer, callback, attributeUniqueIdMap,
attributeTypeMap) {
var scope = this;
- THREE.DRACOLoader.getDecoderModule()
+ DRACOLoader.getDecoderModule()
.then( function ( module ) {
scope.decodeDracoFileInternal( rawBuffer, module.decoder, callback,
attributeUniqueIdMap || {}, attributeTypeMap || {});
@@ -386,7 +387,7 @@ THREE.DRACOLoader.prototype = {
},
isVersionSupported: function(version, callback) {
- THREE.DRACOLoader.getDecoderModule()
+ DRACOLoader.getDecoderModule()
.then( function ( module ) {
callback( module.decoder.isVersionSupported( version ) );
});
@@ -399,16 +400,16 @@ THREE.DRACOLoader.prototype = {
}
};
-THREE.DRACOLoader.decoderPath = './';
-THREE.DRACOLoader.decoderConfig = {};
-THREE.DRACOLoader.decoderModulePromise = null;
+DRACOLoader.decoderPath = './';
+DRACOLoader.decoderConfig = {};
+DRACOLoader.decoderModulePromise = null;
/**
* Sets the base path for decoder source files.
* @param {string} path
*/
-THREE.DRACOLoader.setDecoderPath = function ( path ) {
- THREE.DRACOLoader.decoderPath = path;
+DRACOLoader.setDecoderPath = function ( path ) {
+ DRACOLoader.decoderPath = path;
};
/**
@@ -416,21 +417,21 @@ THREE.DRACOLoader.setDecoderPath = function ( path ) {
* will be recreated with the next decoding call.
* @param {Object} config
*/
-THREE.DRACOLoader.setDecoderConfig = function ( config ) {
- var wasmBinary = THREE.DRACOLoader.decoderConfig.wasmBinary;
- THREE.DRACOLoader.decoderConfig = config || {};
- THREE.DRACOLoader.releaseDecoderModule();
+DRACOLoader.setDecoderConfig = function ( config ) {
+ var wasmBinary = DRACOLoader.decoderConfig.wasmBinary;
+ DRACOLoader.decoderConfig = config || {};
+ DRACOLoader.releaseDecoderModule();
// Reuse WASM binary.
- if ( wasmBinary ) THREE.DRACOLoader.decoderConfig.wasmBinary = wasmBinary;
+ if ( wasmBinary ) DRACOLoader.decoderConfig.wasmBinary = wasmBinary;
};
/**
* Releases the singleton DracoDecoderModule instance. Module will be recreated
* with the next decoding call.
*/
-THREE.DRACOLoader.releaseDecoderModule = function () {
- THREE.DRACOLoader.decoderModulePromise = null;
+DRACOLoader.releaseDecoderModule = function () {
+ DRACOLoader.decoderModulePromise = null;
};
/**
@@ -439,11 +440,11 @@ THREE.DRACOLoader.releaseDecoderModule = function () {
* module is available.
* @return {Promise<{decoder: DracoDecoderModule}>}
*/
-THREE.DRACOLoader.getDecoderModule = function () {
+DRACOLoader.getDecoderModule = function () {
var scope = this;
- var path = THREE.DRACOLoader.decoderPath;
- var config = THREE.DRACOLoader.decoderConfig;
- var promise = THREE.DRACOLoader.decoderModulePromise;
+ var path = DRACOLoader.decoderPath;
+ var config = DRACOLoader.decoderConfig;
+ var promise = DRACOLoader.decoderModulePromise;
if ( promise ) return promise;
@@ -453,13 +454,13 @@ THREE.DRACOLoader.getDecoderModule = function () {
promise = Promise.resolve();
} else if ( typeof WebAssembly !== 'object' || config.type === 'js' ) {
// Load with asm.js.
- promise = THREE.DRACOLoader._loadScript( path + 'draco_decoder.js' );
+ promise = DRACOLoader._loadScript( path + 'draco_decoder.js' );
} else {
// Load with WebAssembly.
config.wasmBinaryFile = path + 'draco_decoder.wasm';
- promise = THREE.DRACOLoader._loadScript( path + 'draco_wasm_wrapper.js' )
+ promise = DRACOLoader._loadScript( path + 'draco_wasm_wrapper.js' )
.then( function () {
- return THREE.DRACOLoader._loadArrayBuffer( config.wasmBinaryFile );
+ return DRACOLoader._loadArrayBuffer( config.wasmBinaryFile );
} )
.then( function ( wasmBinary ) {
config.wasmBinary = wasmBinary;
@@ -478,7 +479,7 @@ THREE.DRACOLoader.getDecoderModule = function () {
} );
} );
- THREE.DRACOLoader.decoderModulePromise = promise;
+ DRACOLoader.decoderModulePromise = promise;
return promise;
};
@@ -486,7 +487,7 @@ THREE.DRACOLoader.getDecoderModule = function () {
* @param {string} src
* @return {Promise}
*/
-THREE.DRACOLoader._loadScript = function ( src ) {
+DRACOLoader._loadScript = function ( src ) {
var prevScript = document.getElementById( 'decoder_script' );
if ( prevScript !== null ) {
prevScript.parentNode.removeChild( prevScript );
@@ -506,10 +507,12 @@ THREE.DRACOLoader._loadScript = function ( src ) {
* @param {string} src
* @return {Promise}
*/
-THREE.DRACOLoader._loadArrayBuffer = function ( src ) {
+DRACOLoader._loadArrayBuffer = function ( src ) {
var loader = new THREE.FileLoader();
loader.setResponseType( 'arraybuffer' );
return new Promise( function( resolve, reject ) {
loader.load( src, resolve, undefined, reject );
});
};
+
+export default DRACOLoader