As shown in the above example, I have a GLB file that contains a PerspectiveCamera and its lens animations. I loaded them into the scene and ran them:
loader.load("./_demo/Cmaera_T.glb", function (gltf) {
const PerspectiveCamera = gltf.scene.children[0];
console.log("Mesh", gltf);
cameraRef.current.copy(PerspectiveCamera);
// scene.add(mesh);
const clip = THREE.AnimationClip.findByName(
gltf.animations,
"All Animations"
);
console.log("clip", clip);
mixerRef.current = new THREE.AnimationMixer(cameraRef.current);
// mixerRef.current
// .clipAction(gltf.animations[0])
// .setDuration(1)
// .play();
const action = mixerRef.current.clipAction(clip);
action.play();
});
But there is one problem, which is that the camera is facing the wrong direction during the movement. I am confused if my code was written incorrectly. Please help me take a look and give me some help. Thank you!