Spaces:
Sleeping
Sleeping
File size: 805 Bytes
af60542 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import {
VRMHumanoid,
VRMLookAt,
VRMLookAtLoaderPlugin,
} from "@pixiv/three-vrm";
import { GLTF } from "three/examples/jsm/loaders/GLTFLoader";
import { VRMLookAtSmoother } from "./VRMLookAtSmoother";
export class VRMLookAtSmootherLoaderPlugin extends VRMLookAtLoaderPlugin {
public get name(): string {
return "VRMLookAtSmootherLoaderPlugin";
}
public async afterRoot(gltf: GLTF): Promise<void> {
await super.afterRoot(gltf);
const humanoid = gltf.userData.vrmHumanoid as VRMHumanoid | null;
const lookAt = gltf.userData.vrmLookAt as VRMLookAt | null;
if (humanoid != null && lookAt != null) {
const lookAtSmoother = new VRMLookAtSmoother(humanoid, lookAt.applier);
lookAtSmoother.copy(lookAt);
gltf.userData.vrmLookAt = lookAtSmoother;
}
}
}
|