Skip to content

Commit

Permalink
fix: imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-rpm committed Sep 17, 2024
1 parent 54a13b0 commit e7e1b4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/components/Avatar/Avatar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import Loader from 'src/components/Loader';
import Bloom from 'src/components/Bloom/Bloom.component';
import { BlendFunction } from 'postprocessing';
import Lights from 'src/components/Lights/Lights.component';
import { spawnState } from '../../state/spawnAtom';
import { MultipleAnimationModel } from '../Models/MultipleAnimationModel/MultipleAnimationModel.component';
import { MultipleAnimationModel } from 'src/components/Models/MultipleAnimationModel/MultipleAnimationModel.component';
import { spawnState } from 'src/state/spawnAtom';

export const CAMERA = {
TARGET: {
Expand Down
38 changes: 15 additions & 23 deletions src/services/Models.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,31 +220,23 @@ dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5
loader.setDRACOLoader(dracoLoader);

export const useGltfLoader = (source: Blob | string): GLTF => {
const cachedGltf = useRef<GLTF | null>(null);
const prevSource = useRef<Blob | string | null>(null);
const cachedGltf = useRef<Map<string, GLTF>>(new Map<string, GLTF>());

return suspend(
async (): Promise<GLTF> => {
if (source === prevSource.current && cachedGltf.current) {
return cachedGltf.current;
}

let gltf: GLTF;
if (source instanceof Blob) {
const buffer = await source.arrayBuffer();
gltf = (await loader.parseAsync(buffer, '')) as GLTF;
} else {
gltf = await loader.loadAsync(source);
}

cachedGltf.current = gltf;
prevSource.current = source;
return suspend(async (): Promise<GLTF> => {
if (cachedGltf.current.has(source as string)) {
return cachedGltf.current.get(source as string)!;
}
let result: GLTF;
if (source instanceof Blob) {
const buffer = await source.arrayBuffer();
result = (await loader.parseAsync(buffer, '')) as GLTF;
} else {
result = await loader.loadAsync(source);
}

return gltf;
},
[source],
{ lifespan: 100 }
);
cachedGltf.current.set(source as string, result);
return result;
}, [source]);
};

export function usePersistantRotation(scene: Group) {
Expand Down

0 comments on commit e7e1b4a

Please sign in to comment.