Closed hulf closed 9 years ago
geometry.animations[0]
I changed the line to geometry.animations[0].hierarchy.length. The output is: TypeError: a.hierarchy is undefined three.min.js:682
I don't think this is an issue with three.js. I load hundreds of models with about 8 skeletal animations each and they all work fine (though it would be nice if the exporter supported inverse kinematics).
There was a bug that is now fixed in the dev version where if you had multiple meshes with the same animation only one would work but it sounds like you are only trying one model so that is probably not the cause.
Exporting a three.js animation from blender is kind of a pain. You have to make sure the mesh is in rest pose, on the first animation frame and a whole bunch of other "rules".
The code in this link to load and the play the animation in three.js is outdated however the blender export rules are the same.
Also, this should probably be on Stackoverflow.
Thanks, I din't know that were any rules for making a animation in blender, since I did it exactly like on one of the tutorials on youtube. I will go trough the tutorial and hopefully I find what im doing wrong. I thought someone would see it from the JSON attached.
Still no luck. I think I did all exactly like in the howto:
My code:
var animationK = new THREE.Animation(meshK, geometry.animations[0]);
I tryed animations to ( picture when I used my json ):
I assume that the JSON posted at top is not made like described in the given tutorial. The latest JSON I used in the tests above is: http://s000.tinyupload.com/?file_id=78634483427461751222 I sincerely sorry, the model is 1.27 MB big and on some 3 party host. The link for the knight.js is: http://threejs.org/examples/models/skinned/knight.js.
There is no animations in your latest json knight.js has single bone animation plased in "animation" property (old format)
Upsy, you are right. Before I made the Blender model I played around with dev-exporter. It checked out the export skeleton option. The right JSON is: http://s000.tinyupload.com/?file_id=40733641668787747062 The output now is: console.log(geometry.animations[0].hierarchy.length) returns 1. console.log(geometry.animations[0].name) returns the name.
I already gave you the correct syntax var animationK = new THREE.Animation(meshK, geometry.animations[0]);
Right, no more errors. The animation still doesn't play, must be something else; you solved my exporting problem, and my syntax. Thanks for your time and I hope it also helps someone else.
When trying to export any animation from blender and load it with JSONLoader, the geometry.animation is undefined. When I load a JSON that is in the three.js example/models ... lets say knights.js it works.
loader.load('models/123.js', function (geometry, materials) { makeIT(geometry,materials)}); function makeIT(geometry,material) {console.log(geometry.animation.hierarchy.length);}
the json: