Skip to content

Commit

Permalink
feat: enable meshopt decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
ericjansenrpm committed Jul 9, 2024
1 parent 721d2c4 commit da97f22
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 0 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"npm": "8.6.0"
},
"dependencies": {
"gltfpack": "^0.21.0",
"jotai": "^2.2.2"
}
}
2 changes: 2 additions & 0 deletions src/services/Animation.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AnimationClip, Group } from 'three';

import { FBXLoader, GLTFLoader } from 'three-stdlib';
import { MeshoptDecoder } from './meshopt_decoder';

interface ClipWithType {
group: Group;
Expand All @@ -13,6 +14,7 @@ const MIXAMO_SCALE = 0.01;

const fbxLoader = new FBXLoader();
const gltfLoader = new GLTFLoader();
gltfLoader.setMeshoptDecoder(MeshoptDecoder);

function normaliseFbxAnimation(fbx: Group, index: number = 0) {
const { tracks } = fbx.animations[index];
Expand Down
3 changes: 3 additions & 0 deletions src/services/Models.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { GLTF, GLTFLoader, DRACOLoader } from 'three-stdlib';
import { suspend } from 'suspend-react';
import { Emotion } from 'src/components/Avatar/Avatar.component';
import { BloomConfiguration } from 'src/types';
import { MeshoptDecoder } from './meshopt_decoder';

export interface CustomNode extends Object3D {
geometry: BufferGeometry;
Expand Down Expand Up @@ -211,6 +212,8 @@ export const useEmotion = (nodes: ObjectMap['nodes'], emotion?: Emotion) => {
};

const loader = new GLTFLoader();
loader.setMeshoptDecoder(MeshoptDecoder);

const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.5/');
loader.setDRACOLoader(dracoLoader);
Expand Down
Loading

0 comments on commit da97f22

Please sign in to comment.