Koala1
Koala1

Reputation: 1

Mesh with multiple animations

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:

Thanks for reading my questions !

PS : sorry for my english...

Upvotes: 0

Views: 1309

Answers (1)

user5041326
user5041326

Reputation:

(Main) question: When you are using Blender and if you create an animation, it automatically creates a name for the animation and you can change the name on action editor. Now it is possible to export multiple animations for a mesh. Inside the javascript code, you can call each animation by id (geometry.animations[id]).

Upvotes: 2

Related Questions