Can someone help me understand this specific example in Three.js? The link is . I am facing some difficulties with 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 ); // Having a question here
// Generating animations
for ( var i = 0; i < geometry.animations.length; ++i ) {
var animName = geometry.animations[ i ].name; // Another question here
scope.animations[ animName ] = new THREE.Animation( scope, geometry.animations[ i ] );
}
(...)
} );
};
I am curious about two things:
Main Question: How do animations with specific names already exist in the 3D object (in Three.js format)? In the for loop,
"geometry.animation[i].name"
shows names like"walk", "idle" and "run"
. I've tried creating animations in Maya and Blender (at a beginner level), but I am unsure about exporting multiple animations for the same mesh and assigning names to them.Less Important: This question is related to JavaScript syntax. Why assign
"var scope = this;"
? I attempted replacing"scope"
with"this"
in
, but that change caused it to stop functioning."THREE.SkinnedMesh.call(scope, geometry, originalMaterial);"
Thank you for taking the time to read and help me with my questions!
PS: Apologies for any language mistakes...