Skip to content

Commit

Permalink
Use matching versions of Draco and Basis libraries from CDN.
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Oct 15, 2021
1 parent 1d4e562 commit d428e8f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 188 deletions.
21 changes: 0 additions & 21 deletions assets/wasm/basis_transcoder.js

This file was deleted.

Binary file removed assets/wasm/basis_transcoder.wasm
Binary file not shown.
48 changes: 0 additions & 48 deletions assets/wasm/draco_decoder.js

This file was deleted.

Binary file removed assets/wasm/draco_decoder.wasm
Binary file not shown.
104 changes: 0 additions & 104 deletions assets/wasm/draco_wasm_wrapper.js

This file was deleted.

25 changes: 10 additions & 15 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
AxesHelper,
Box3,
Cache,
CubeTextureLoader,
DirectionalLight,
GridHelper,
HemisphereLight,
Expand All @@ -13,7 +12,7 @@ import {
LoadingManager,
PMREMGenerator,
PerspectiveCamera,
RGBFormat,
REVISION,
Scene,
SkeletonHelper,
UnsignedByteType,
Expand All @@ -28,7 +27,6 @@ import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
// import { RoughnessMipmapper } from 'three/examples/jsm/utils/RoughnessMipmapper.js';

import { GUI } from 'dat.gui';

Expand All @@ -37,6 +35,11 @@ import { createBackground } from '../lib/three-vignette.js';

const DEFAULT_CAMERA = '[default]';

const MANAGER = new LoadingManager();
const THREE_PATH = `https://unpkg.com/three@0.${REVISION}.x`
const DRACO_LOADER = new DRACOLoader( MANAGER ).setDecoderPath( `${THREE_PATH}/examples/js/libs/draco/gltf/` );
const KTX2_LOADER = new KTX2Loader( MANAGER ).setTranscoderPath( `${THREE_PATH}/examples/js/libs/basis/` );

const IS_IOS = isIOS();

// glTF texture types. `envMap` is deliberately omitted, as it's used internally
Expand Down Expand Up @@ -197,10 +200,8 @@ export class Viewer {
// Load.
return new Promise((resolve, reject) => {

const manager = new LoadingManager();

// Intercept and override relative URLs.
manager.setURLModifier((url, path) => {
MANAGER.setURLModifier((url, path) => {

// URIs in a glTF file may be escaped, or not. Assume that assetMap is
// from an un-escaped source, and decode all URIs before lookups.
Expand All @@ -220,16 +221,10 @@ export class Viewer {

});

const loader = new GLTFLoader( manager )
const loader = new GLTFLoader( MANAGER )
.setCrossOrigin('anonymous')
.setDRACOLoader(
new DRACOLoader( manager ).setDecoderPath( 'assets/wasm/' )
)
.setKTX2Loader(
new KTX2Loader( manager )
.setTranscoderPath( 'assets/wasm/' )
.detectSupport( this.renderer )
)
.setDRACOLoader( DRACO_LOADER )
.setKTX2Loader( KTX2_LOADER.detectSupport( this.renderer ) )
.setMeshoptDecoder( MeshoptDecoder );

const blobURLs = [];
Expand Down

0 comments on commit d428e8f

Please sign in to comment.