Skip to content

Commit cbe0cc4

Browse files
committed
feat(soba): allow set global decoder path
1 parent 27ca571 commit cbe0cc4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

libs/soba/loaders/src/gltf-loader/gltf-loader.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { injectNgtLoader, type NgtLoaderResults, type NgtObjectMap } from 'angul
33
import { DRACOLoader, GLTFLoader, MeshoptDecoder, type GLTF } from 'three-stdlib';
44

55
let dracoLoader: DRACOLoader | null = null;
6+
let decoderPath = 'https://www.gstatic.com/draco/versioned/decoders/1.5.5/';
67

78
function _extensions(useDraco: boolean | string, useMeshOpt: boolean, extensions?: (loader: GLTFLoader) => void) {
89
return (loader: THREE.Loader) => {
@@ -15,12 +16,9 @@ function _extensions(useDraco: boolean | string, useMeshOpt: boolean, extensions
1516
dracoLoader = new DRACOLoader();
1617
}
1718

18-
dracoLoader.setDecoderPath(
19-
typeof useDraco === 'string' ? useDraco : 'https://www.gstatic.com/draco/versioned/decoders/1.5.5/',
20-
);
19+
dracoLoader.setDecoderPath(typeof useDraco === 'string' ? useDraco : decoderPath);
2120
(loader as GLTFLoader).setDRACOLoader(dracoLoader);
2221
}
23-
2422
if (useMeshOpt) {
2523
(loader as GLTFLoader).setMeshoptDecoder(
2624
typeof MeshoptDecoder === 'function' ? MeshoptDecoder() : MeshoptDecoder,
@@ -65,3 +63,6 @@ injectNgtsGLTFLoader['preload'] = <TUrl extends string | string[] | Record<strin
6563
) => {
6664
(injectNgtLoader as any)['preload'](() => GLTFLoader, path, _extensions(useDraco, useMeshOpt, extensions));
6765
};
66+
injectNgtsGLTFLoader['setDecoderPath'] = (path: string) => {
67+
decoderPath = path;
68+
};

0 commit comments

Comments
 (0)