1
0

add vrm mode

This commit is contained in:
2026-03-07 14:35:30 +09:00
parent d1929396ba
commit f60961a963
6 changed files with 125 additions and 20 deletions

View File

@@ -9,7 +9,6 @@ import * as THREE from 'three';
import { keys, adminMode } from './controls/KeyInput';
const BASE_URL = import.meta.env.BASE_URL;
const VRM_URL = `${BASE_URL}model/ai.vrm`;
export const VRMA_FILES = [
{ name: 'idle', label: '待機', file: 'idle.vrma', loop: true },
@@ -54,14 +53,15 @@ function trimClip(clip, duration, addLoopPose) {
return clip;
}
export default function VrmCharacter({ selectedAnimation: animState }) {
export default function VrmCharacter({ selectedAnimation: animState, vrmModel = 'ai.vrm' }) {
const selectedAnimation = animState?.name || animState;
const mixerRef = useRef(null);
const vrmRef = useRef(null);
const actionsRef = useRef({});
const currentActionRef = useRef(null);
const gltf = useLoader(GLTFLoader, VRM_URL, (loader) => {
const vrmUrl = `${BASE_URL}model/${vrmModel}`;
const gltf = useLoader(GLTFLoader, vrmUrl, (loader) => {
loader.register((parser) => new VRMLoaderPlugin(parser));
});