I'm trying to understand this example in Three.js: http://threejs.org/examples/#webgl_animation_skinning_blending. I have some problems with this part of code (the BlendCharacter.js file).
this.load = function ( url, onLoad ) {
var scope = this;
var loader = new THREE.JSONLoader();
loader.load( url, function( geometry, materials ) {
var originalMaterial = materials[ 0 ];
originalMaterial.skinning = true;
THREE.SkinnedMesh.call( scope, geometry, originalMaterial ); // QUESTION (2)
// Create the animations
for ( var i = 0; i < geometry.animations.length; ++i ) {
var animName = geometry.animations[ i ].name; // QUESTION (1)
scope.animations[ animName ] = new THREE.Animation( scope, geometry.animations[ i ] );
}
(...)
} );
};
I have two questions:
(Main) How does the 3D object (in Three.js format) already has animations with names? In the for loop,
"geometry.animation[i].name"
is"walk", "idle" and "run"
. I made animations with maya and blender (beginner level), but I do not see how to export multiple animations on the same mesh, and how to name them.(Less) This is a matter of JavaScript syntax. Why
"var scope = this;"
? I tried to replace"scope"
by"this"
in"THREE.SkinnedMesh.call(scope, geometry, originalMaterial);"
, but this make it no longer works.
Thanks for reading my questions !
PS : sorry for my english...