Skip to content

Commit 7d0ad62

Browse files
committed
fix(soba): adjust type for gltfloader onLoad and allows preLoad to pass in onLoad
1 parent 536aa05 commit 7d0ad62

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ function _injectGLTF<TUrl extends string | string[] | Record<string, string>>(
4242
useMeshOpt?: boolean;
4343
injector?: Injector;
4444
extensions?: (loader: GLTFLoader) => void;
45-
onLoad?: (data: GLTF & NgtObjectMap) => void;
45+
onLoad?: (data: NgtLoaderResults<TUrl, GLTF & NgtObjectMap>) => void;
4646
} = {},
4747
): Signal<NgtLoaderResults<TUrl, GLTF & NgtObjectMap> | null> & { scene: Signal<GLTF['scene'] | null> } {
4848
return assertInjector(_injectGLTF, injector, () => {
4949
const result = injectLoader(() => GLTFLoader, path, {
5050
extensions: _extensions(useDraco, useMeshOpt, extensions),
51+
// @ts-expect-error - we know the type of the data
5152
onLoad,
5253
});
5354

@@ -69,9 +70,21 @@ _injectGLTF.preload = <TUrl extends string | string[] | Record<string, string>>(
6970
useDraco = true,
7071
useMeshOpt = true,
7172
extensions,
72-
}: { useDraco?: boolean | string; useMeshOpt?: boolean; extensions?: (loader: GLTFLoader) => void } = {},
73+
onLoad,
74+
}: {
75+
useDraco?: boolean | string;
76+
useMeshOpt?: boolean;
77+
extensions?: (loader: GLTFLoader) => void;
78+
onLoad?: (data: NgtLoaderResults<TUrl, GLTF & NgtObjectMap>) => void;
79+
} = {},
7380
) => {
74-
injectLoader.preload(() => GLTFLoader, path, _extensions(useDraco, useMeshOpt, extensions) as any);
81+
injectLoader.preload(
82+
() => GLTFLoader,
83+
path,
84+
_extensions(useDraco, useMeshOpt, extensions) as any,
85+
// @ts-expect-error - we know the type of the data
86+
onLoad,
87+
);
7588
};
7689

7790
_injectGLTF.setDecoderPath = (path: string) => {

0 commit comments

Comments
 (0)