Could someone help me out with exporting a mesh with an animation from blender? I’ve seen a few tutorials but three.js has changed so much especially with how the animation system works since those tutorials. What I’m doing is selecting only the mesh then going to File > Export > Three.js. I’m using these export settings but the .json file that the exporter gives me doesn’t contain any references to the animation that I’ve given to the mesh. It looks like this:
It seems there is an issue with the export geometry type. The export option for buffergeometry skinning animations is not working, it has to be Geometry.
Plus, the armature needs to be in the “Rest Position” before it can be exported.
Thanks so much for the response! It appears the animation data is now exporting correctly. However, I can’t help but feel like something is still not right because I can’t get the animation to play. Here is a minimal code example would you or anyone else know what’s wrong?
<html>
<head>
<title>Animation Testing</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<script src="three.js"></script>
<script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
camera.position.set(2, 2, 2);
camera.lookAt(new THREE.Vector3(0, 1, 0));
var clock = new THREE.Clock();
var loader = new THREE.JSONLoader;
var mixer;
var set = false;
loader.load("./player.json", function(geometry) {
var material = new THREE.MeshBasicMaterial({skinning: true});
var skinnedMesh = new THREE.SkinnedMesh(geometry, material);
scene.add(skinnedMesh);
mixer = new THREE.AnimationMixer(skinnedMesh);
var walkAction = mixer.clipAction(geometry.animations[0]);
walkAction.play();
set = true;
});
function render() {
if(set)
mixer.update(clock.getDelta());
renderer.render(scene, camera);
requestAnimationFrame(render);
};
render();
</script>
</body>
After a bit of investigation, if you leave the armature in pose position and uncheck “Apply Modifiers” in the export settings, it appears to work correctly.