1
0

loadVRMAnimation.ts 615 B

12345678910111213141516
  1. import { VRMAnimation } from './VRMAnimation';
  2. import { VRMAnimationLoaderPlugin } from './VRMAnimationLoaderPlugin';
  3. import { GLTFParser, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
  4. const loader = new GLTFLoader();
  5. loader.register((parser: GLTFParser) => new VRMAnimationLoaderPlugin(parser));
  6. export async function loadVRMAnimation(url: string): Promise<VRMAnimation | null> {
  7. const gltf = await loader.loadAsync(url);
  8. const vrmAnimations: VRMAnimation[] = gltf.userData.vrmAnimations;
  9. const vrmAnimation: VRMAnimation | undefined = vrmAnimations[0];
  10. return vrmAnimation ?? null;
  11. }