Question
Hello guys.
I have GLTF model and FBX animation from Mixamo.
-
FBX animation from Mixamo
Mixamo (name: Weight shift idle)
I want to load glb model and dynamically add fbx animations to it.
I was able to apply animation to the model,
but the model is drawn parallel to the Z axis direction.
How can we modify the model’s body position to keep it parallel to the Y-axis,
as it was before the animation was loaded?
Although changing the model’s rotate can control the body posture for the first drawing,
switching between multiple animations will cause the model’s rotate to revert back to its original state,
necessitating another method.
reference
-
Drawing only gltf models
-
Drawing only fbx models (include animation)
-
Code
// SCENE
const scene = new THREE.Scene();
// HELPER
const gridHelper = new THREE.GridHelper(50, 10);
scene.add(gridHelper);
const axesHelper = new THREE.AxesHelper(180);
scene.add(axesHelper);
// CAMERA
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.y = 5;
camera.position.z = 5;
camera.position.x = 0;
// RENDERER
let renderer: THREE.WebGLRenderer;
// CONTROLS
let orbitControls: OrbitControls;
// LIGHTS
light();
// MODEL WITH ANIMATIONS
let targetAnimation: THREE.AnimationAction;
let mixer: THREE.AnimationMixer;
// FIXME: Applying fbx animation to a gltf model causes the stance to be horizontal
function gltfWithFbxAnimation(){
new GLTFLoader().load(soldierModel, async function (gltf) {
new FBXLoader().load(fbxModel, async function (fbx: THREE.Group) {
const model = gltf.scene;
scene.add(gltf.scene);
mixer = new THREE.AnimationMixer(model);
targetAnimation = mixer.clipAction(fbx.animations[1]);
targetAnimation.play();
});
});
}
gltfWithFbxAnimation();
// ANIMATE
const clock = new THREE.Clock();
const animate = () => {
const mixerUpdateDelta = clock.getDelta();
mixer?.update(mixerUpdateDelta);
requestAnimationFrame(animate);
renderer.render(scene, camera);
};
thank you