THREE.js JSON model brought to life through animation

The JSON model was crafted in Blender and the animation was developed within Blender using bones. However, upon attempting to play the animation in three.js, everything in the scene renders except for the fish. Despite my efforts to find a solution, I have yet to come across anything that resolves this issue. I am currently following along with the book 'Learning three.js' by Jos Dirksen. As a beginner in three.js, I am determined to troubleshoot this problem.

var loader = new THREE.JSONLoader();
var mesh;
loader.load('fish_anim1.json', function (model, mat) {
    mat[0] = new THREE.MeshLambertMaterial({color: 0x9ABF15, skinning: true});
    mesh = new THREE.SkinnedMesh(model, mat[0]);

    animation = new THREE.Animation(model, model.animations);

    mesh.position.set(0, 5, 0);
    mesh.scale.x = 3;
    mesh.scale.y = 3;
    mesh.scale.z = 4;
    mesh.rotation.y = Math.PI;
    mesh.name = 'fish'+fish_count;
    scene.add(mesh);

    animation.play();
});

Within the render loop, I include this line to ensure the animation updates:

THREE.AnimationHandler.update(delta);

Answer №1

Almost there! Remember, when using THREE.Animation, you only need to pass one animation as the second parameter, not all of them.

animation = new THREE.Animation(mesh, model.animations[0]); // UPDATE: Make sure the first parameter is the SKinnedMesh, not geometry.

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

Creating a multi-dimensional array in order to store multiple sets of data

To generate a multidimensional array similar to the example below: var serviceCoors = [ [50, 40], [50, 50], [50, 60], ]; We have elements with latitude and longitude data: <div data-latitude="10" data-longitude="20" clas ...

Would it be feasible to rename files uploaded to Firebase within an AngularJS controller using logic?

Is there a way to apply regex to rename uploaded files before saving them to firebase storage? It seems that firebase file metadata does not support this function. I am currently using angularjs and would appreciate any guidance on this matter. ...

Examine the state of each element within a div separately

I have a div containing elements with the class 'container'. Each of these container elements has multiple child divs with the class 'children'. I am looking to perform an action on the child divs when they become visible in the viewpor ...

There seems to be a problem in NodeJS that arises when utilizing the express session in

While working on my Node.js project, I initially used MemoryStore from express-session. However, upon switching to session with redis (connect-redis), I started encountering the error message ERR wrong number of arguments for 'set' command every ...

Tips and tricks for implementing pagination with jquery and jsp

I have a JSP page where I am displaying records fetched from an Oracle database. However, I want to show only a limited number of records at a time and implement pagination using jQuery and JSP. My goal is to display 1-10 records initially, and upon clic ...

Issue persists: Ajax functionality remains nonfunctional, prompting the need for

My goal is to use the post input, and upon hitting enter, I want to dynamically replace <div id="mainPagePosts"></div> with new data without causing a page refresh. However, even after submitting the post, the page still refreshes, although I d ...

Develop a precompiled library for Angular applications that utilizes Ahead-of-Time (AOT) compilation technology

My Angular 5 library is packaged for consumption by other apps in their node_modules. Currently, the app is compiled Just-in-Time(JIT) using rollup and gulp. I export it as a package, and developers use it in its JIT compiled form. After researching AOT ...

Angular: Experiencing difficulty in locating the position of an element within an array

I am facing an issue with the structure of my controller. Here is how it currently looks: MyControllers.controller('ContentCtrl', ['$scope', '$http', '$routeParams', function($scope, $http, $routeParams) { $htt ...

Stop the setTimeout function after redirecting in the controller

I am experiencing an issue with my AJAX call as it keeps triggering my controller repeatedly. AJAX function <script type="text/javascript> var stopTime =0; var scoreCheck = function () { $.ajax({ url: "<?php echo 'http:// ...

Guidelines for modifying a useState function containing an array with objects that dynamically update based on changes to input values in a React.js application

const [fvalues,setFvalues]=useState(data.map((ele,id)=>{ return( {mobile:'',age:'',emailId:'',destinationAddress:'',destinationPin:''} ); })); I am trying to update these objects whenever th ...

How the React Component Class Executes OnChange Event in a Closure

When working on my React code, I found myself creating a closure by calling "onChange." class CityInput extends React.Component { constructor( props ){ super( props ); this.state = { city : "", country : "" ...

Changes made to other arrays are automatically reflected in the C# jagged array

Encountered a strange issue while working on a C# web api program involving jagged arrays. Whenever I update a single dimension array, it mysteriously updates a jagged array with the same values without any explicit instruction to do so. What's even m ...

What is the reason for JWT tokens using Base64 encoding instead of UTF-8?

RFC 7515 Section 3 states: Both the JWS Protected Header, JWS Payload, and JWS Signature are base64url encoded in both serializations because JSON does not have a direct way of representing arbitrary octet sequences. What is the limitation that prevents ...

Automatically fill the drop-down list based on the selection made in

Looking at the JSP code snippet provided, there are two dropdowns - one for "make" and the other for "model". The goal is to select an option in the "make" dropdown and have the "model" dropdown autofilled with values from the database that correspond to t ...

Using Javascript within PHP

Below is the HTML and Javascript code I am working with: <noscript> <div id="player"> <h2>Warning! You should enable your JavaScript!</h2> </div> </noscript> <script type="text/javascript"> var vid ...

Restricting the azimuth angle of a camera by utilizing OrbitControls

I'm currently working on creating an architectural visualization using Three.js, and I want users to be able to click on items and orbit around them. However, I encountered an issue where the camera would clip through walls. To solve this problem, I a ...

How can I retrieve the line number of a code during runtime in JavaScript?

Is there a way to add a console.log statement that would indicate the line number it is on in JavaScript? For example: console.log ('Line:', [code to get the line]). The output in the console would be Line: [line number], helping me identify wher ...

When retrieving items from an object store in HTML, the result displayed is often [object Object]

Currently, I am in the process of iterating through all objects within the object store named "tasksStore". However, when attempting to display these objects in my HTML, only [object Object] is returned. Even if I try to specify a specific part of the obje ...

Verify the presence of installed software on the client's machine through ASP.Net

Does anyone have any recommendations on how to verify if an application is installed on the client side in an ASP.Net application? Since ASP.Net operates on the server side, I think it would need to be accomplished using some sort of client-side scripting ...

Using Javascript to take a screenshot of the HTML page and save it

Can you capture the displayed HTML page using JavaScript? I am interested in generating a "minimap" of an HTML page to allow for easy navigation. ...