Combining a variety of animations within a mesh

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

    "THREE.SkinnedMesh.call(scope, geometry, originalMaterial);"
    , but that change caused it to stop functioning.

Thank you for taking the time to read and help me with my questions!

PS: Apologies for any language mistakes...

Answer №1

(Primary) inquiry: In the process of utilizing Blender, when generating an animation, the software will automatically assign a name to the animation. However, users have the flexibility to alter the name in the action editor. It is now feasible to export numerous animations for a single mesh. Within the JavaScript code, individual animations can be referenced using their respective IDs (geometry.animations[id]).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Changes to the Vuex state are made using a specific function to mutate it, not a general function

I am utilizing a storage provided by LokiJS to update the Vuex state through mutations in the autoloadCallback. The LokiJS storage setup: var db = new loki('mydatabase', { autoupdate: true, autoload: true, autoloadCallback: setupHandler } ...

Update the JSON data based on the specifications outlined in my project

class Transformation { constructor() { this.colHeaders = { error_description: "Description", error_status: "Status", error_code: "Error Code" }; } getColHeader() { return this.colHeaders; } } var jsonData = { error ...

The returned state from setState(prev) seems to be in the opposite order when referencing another useState variable within a useEffect

As part of my interactive chat simulation project, I have implemented a feature where users can click on a button named obj4 to start their chat session. Initially, everything functions smoothly, displaying messages 1-4 in the correct order. However, when ...

Having trouble entering text into a textbox in Reactjs when the state is empty

I am currently working on integrating a newsletter submit form using Reactjs/nextjs. However, I am facing an issue where once I submit the form, I am unable to type anything in the textbox. I have tried making the "state" empty but it did not resolve the ...

I wonder, who is the one executing the function?

In my application, I have encountered an unusual issue. Within my controller, I have two functions - one to add a tab, and one to remove a tab. Below is the code snippet: $scope.createTab = function(){ $scope.addTab("New Tab",50,0); co ...

Error Encountered: Invalid Parameter Type when Retrieving Item from AWS Dynamo

I've been facing issues when trying to establish a connection between my ReactJS application and AWS DynamoDB. Despite confirming the correctness of the API key, secret key, and region, I keep encountering an InvalidParameterType error. I have even at ...

Iterate over Observable data, add to an array, and showcase all outcomes from the array in typescript

Is there a way to iterate through the data I've subscribed to as an Observable, store it in an array, and then display the entire dataset from the array rather than just page by page? Currently, my code only shows data from each individual "page" but ...

Implement lazy loading functionality in Django to dynamically load data as the user scrolls

Currently, I am developing a web application using Django to showcase the interface and how content is loaded. In my database, there could potentially be thousands of entries, and I am looking for a way to load only a certain number at a time to minimize ...

Error: The function of Bootstrap toggle is not defined

Currently, I am working on a Django application for warehouses and stockists. My goal is to create a list of stockists per warehouse in a button list format. When this button is clicked, a modal window should appear displaying the name, position, and permi ...

Tips for activating the default 500 error page in Next.js

I'm having trouble getting Next.js to display its default 500 error page. While most sources discuss creating a custom error page, the Next.js documentation only briefly references their built-in 500 error page. I want the default page to show up when ...

Binding attributes in knockoutjs following an AJAX request

The objective Incorporate the attr binding of KnockoutJS following an AJAX call. The dilemma Check out the code snippet below: $.ajax({ url: "/Products/List?Output=JSON", dataType: "json", success: function (data) { $.each(data, fun ...

JavaScript code not functioning properly when accessing all information retrieved from Django Model

When I retrieve the endDate field from a Django model using a for loop on an HTML page, I want to verify if all the end dates are earlier than today's date. To achieve this, I am utilizing JavaScript code. Although my code successfully checks the fir ...

Developing a unique JavaScript object by extracting information from a jQuery AJAX response

Is there a recommended approach for creating a custom JavaScript object that contains data retrieved from a jQuery AJAX request? I'm considering two methods, but unsure which is the most appropriate. The first method involves including the AJAX reques ...

What is the best way to target all elements sharing a common class?

Currently, I have a Boolean variable stored in a hidden input field. When the user is signed in, it's set to false; otherwise, it's set to true. I have download buttons that should link to a file for download. My goal is to hide these buttons an ...

Cipher/decipher URL Redirect Parameter

While sending the return URL as a query string parameter, it looks like this: http://localhost:50316/TripNestFinal/Login.aspx?ReturnUrl=~/Account/AccountSettings.aspx However, I am seeking a way to encode ~/Account/AccountSettings.aspx in a manner that wi ...

Updating the geometry of vertices after rotating or moving an object

I've been experimenting with using position and rotation values to transform a mesh, but now I'd like to modify the geometry vertices directly in x, y, and z coordinates while freeing or resetting the rotation and position values. I'm not qu ...

What is the best way to change the orientation of a vector map?

Is there a straightforward method for rotating a vector-based map on CANVAS in order to integrate it into a browser navigation system? ...

Having trouble populating Extjs Grid with JSON data

In this simple grid, I am attempting to display three columns - Subject ID, Subject Name, and Subject Short Name by obtaining JSON data. The data is stored in a variable called myData in JSON format, which has been received from the server. Despite pasting ...

jinja2.exceptions.UndefinedError: The variable 'asset' has not been defined

Currently in my project, I am using a Python backend to fetch data from an API and then rendering it through Flask to the Vue.js frontend. However, I have encountered an error titled that is causing some issues. I have double-checked and printed the varia ...

Concealing URL parameters in ui-sref (using ui.router)

Here is the HTML code I am working with: <a ui-sref="videoParent.Display.video({videoName:'[[sVid.slug]]', videoId:'[[sVid.videoID]]'})"><p>[[sVid.name]]</p></a> The parameters videoName and videoId are retriev ...