Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMD motion load's empty track #107

Open
Bekbo01 opened this issue Feb 10, 2025 · 3 comments
Open

VMD motion load's empty track #107

Bekbo01 opened this issue Feb 10, 2025 · 3 comments

Comments

@Bekbo01
Copy link

Bekbo01 commented Feb 10, 2025

Hi I tried load vrm model and load vmd animation (i need face motion too, no need bvh)
And it loads model and motion. But there is one problem the animation clip's track is empty list (tracks: [])

AnimationClip {name: '', tracks: Array(0), duration: 0, blendMode: 2500, uuid: '7EA29B7E-07C1-4FEC-99B8-AAFFD4A8A779'}
blendMode: 2500
duration: 2
name: ""
tracks: []
uuid: "7EA29B7E-07C1-4FEC-99B8-AAFFD4A8A779"

 const loader = new GLTFLoader();
            loader.register((parser) => {
                return new VRMLoaderPlugin(parser);
            });
            loader.load(
                './models/avatar.vrm',
                (gltf) => {
                    const vrm = gltf.userData.vrm;
                    scene.add(vrm.scene);
                    applyVMDMotion(vrm);

                },
                (progress) => {
                    console.log(`Загрузка VRM: ${((progress.loaded / progress.total) * 100).toFixed(2)}%`);
                },
                (error) => {
                    console.error('Ошибка загрузки VRM:', error);
                }
            );

 function applyVMDMotion(vrm) {
                const mmdLoader = new MMDLoader();
                const helper = new MMDAnimationHelper({afterglow: 2.0, physics: false});
                const mixer = new THREE.AnimationMixer(vrm.scene);
                const skinnedMesh = vrm.scene.getObjectByProperty('type', 'SkinnedMesh');
                if (skinnedMesh) {
                    mmdLoader.loadAnimation("./models/motion_2.vmd", skinnedMesh, function (animation) {
                        if (!animation) {
                            console.error("Failed to load VMD motion.");
                            return;
                        } else {
                            helper.add(camera, {
                                animation: animation,
                                physics: false, 
                            });
                            helper.setAnimation(camera, animation);
                            helper.play(camera);
                        }
                    });
                } else {
                    console.error("Не удалось найти SkinnedMesh в VRM модели.");
                }
            }
@ButzYung
Copy link
Owner

Well it looks like you are writing your own codes rather than using XR Animator. XR Animator uses its own MMD loader by the way.

@Bekbo01
Copy link
Author

Bekbo01 commented Feb 11, 2025

Well it looks like you are writing your own codes rather than using XR Animator. XR Animator uses its own MMD loader by the way.
@ButzYung yeah, that's it. How can I use it?

@ButzYung
Copy link
Owner

You can't directly apply VMD motion on VRM model, because the bone naming and struture are different between MMD and VRM model. You need retargeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants