Spaces:
Sleeping
Sleeping
Download src/lib/VRMLookAtSmootherLoaderPlugin/VRMLookAtSmootherLoaderPlugin.ts from ratalai/chatvrm_for_desh: direct link, hf CLI and curl.
- Browser
- Download file 805 Bytes
-
https://huggingface.co/spaces/ratalai/chatvrm_for_desh/resolve/main/src/lib/VRMLookAtSmootherLoaderPlugin/VRMLookAtSmootherLoaderPlugin.ts
- Command line
-
hf download hf://spaces/ratalai/chatvrm_for_desh/src/lib/VRMLookAtSmootherLoaderPlugin/VRMLookAtSmootherLoaderPlugin.ts
-
curl -L -o VRMLookAtSmootherLoaderPlugin.ts https://huggingface.co/spaces/ratalai/chatvrm_for_desh/resolve/main/src/lib/VRMLookAtSmootherLoaderPlugin/VRMLookAtSmootherLoaderPlugin.ts
805 Bytes
| 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; | |
| } | |
| } | |
| } | |