Struggling to connect the animation to the mesh?

As a beginner in three.js, I encountered an issue while trying to attach animation to the mesh. Utilizing JSONLoader for this purpose, I generated the js file using a Maya plug-in available at this link.

Having successfully loaded the mesh and textures, I faced a situation where only the skeleton was moving during animation playback, leaving the mesh static.

If anyone could provide guidance or assistance, it would be greatly appreciated!

Below is the script snippet:

if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

        var container, stats;
        var camera, scene, renderer, objects, mesh;
        var clock;

        // initialize loader
        var imageLoader = new THREE.ImageLoader();

        var loader = new THREE.JSONLoader();
        loader.load( 'elephant2.js', function (geometry, materials)  {

            geometry.computeVertexNormals();
            geometry.computeBoundingBox();
            ensureLoop( geometry.animation );

            var material1 = new THREE.MeshPhongMaterial({map:THREE.ImageUtils.loadTexture( "textures/CH_NPC_MOB_Elephant_A01_D_GRN.jpg" )});
            var material2 = new THREE.MeshPhongMaterial( { map: THREE.ImageUtils.loadTexture('textures/CH_NPC_MOB_Elephant_A01_N_GRN.jpg') } );
            var material3 = new THREE.MeshPhongMaterial( { map: THREE.ImageUtils.loadTexture('textures/CH_NPC_MOB_Elephant_A01_SP_GRN.jpg') } );

            var materials = [material1, material2, material3];
            var meshFaceMaterial = new THREE.MeshFaceMaterial( materials );

            var mesh = new THREE.SkinnedMesh( geometry, meshFaceMaterial );
            mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.015;
            mesh.updateMatrix();

            var animation = new THREE.Animation( mesh, geometry.animation);
            animation.play();

            init(mesh);
            animate();

        } );

        function ensureLoop( animation ) {

            for ( var i = 0; i < animation.hierarchy.length; i ++ ) {

                var bone = animation.hierarchy[ i ];

                var first = bone.keys[ 0 ];
                var last = bone.keys[ bone.keys.length - 1 ];

                last.pos = first.pos;
                last.rot = first.rot;
                last.scl = first.scl;

            }

        }
        // Rest of the script goes here...

Answer â„–1

After some investigation, I have identified the issue. It appears that every material.skinning attribute must be set to true in order for proper functionality.

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

An Angular application running on an Azure App Service experiences crashes exclusively when accessed through the Chrome browser

My webapi/angular site is hosted on the same Azure app service, with authentication token and other APIs located at /site/api and the angular app at /site/app. Everything works fine on our staging environment, which is a Windows 2012 VM with IIS 7. The an ...

Utilizing React.hydrate in conjunction with Vue: A Beginner's Guide

Wondering about a unique scenario here - I have a website built with Vue and now I aim to showcase a library I developed in React. In order to steer clear of server-side rendering (SSR), I can simply wrap ReactDOM.hydrate(ReactApp, document.getElementById( ...

Storing HTML tags in a database using CKEditor

Implemented ckeditor in my web admin panel <textarea name="stateinformation" id="editor1" rows="10" cols="80"> This is the textarea that will be replaced with CKEditor. </textarea> <script> // Replace the <textarea id="editor1 ...

A beginner's guide to using Jasmine to test $http requests in AngularJS

I'm struggling with testing the data received from an $http request in my controller as I don't have much experience with Angular. Whenever I try to access $scope, it always comes back as undefined. Additionally, fetching the data from the test ...

Storing data or a page in a list within a React Native application

As a newcomer to React Native, I'm facing an issue. I have two pages called rockSetting.js and myFavoriteSetting.js. In the rockSetting page, I want to implement an onButtonPress function that will generate a list in the myFavoriteSettings page with ...

When working within a module using node.js and three.js, you may encounter an error message stating that "document

Currently, I am utilizing an app to execute various functions that I created in another .js file, where these functions are defined to facilitate drawing objects on a canvas. app.get('/visualization.html', function(req, res) { //Setting ...

The Discord bot appears to be online, however, it is not reacting to any commands sent on the platform. To check its responsiveness, we are currently conducting a test using a

I've been experimenting with a unique syntax to create a Discord bot and integrating various commands. One of the commands I tried adding was "fees.js", but unfortunately, the bot wasn't responding to this command. Surprisingly, it also didn&apos ...

AngularJS: ng-show causing flickering issue upon page refresh

Recently, I encountered an issue with my code snippet: <body> <ng-view></ng-view> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script> <script src="http://ajax.googleapis.com/ajax/ ...

Tips on how to bring in .js that has brought in .json from an html file

English is not my first language, and I struggle with it, but I did my best. I am attempting to include a js file that imports json from an html .js import menus from '../json/menus.json'; (function () { function parseMenu(ul, menu) { fo ...

Axios encounters difficulty retrieving the response data following a POST request

When using axios to post data and fetch a response, I am encountering an issue where the data is successfully posted but the response data cannot be printed. This works correctly in Postman, so I'm not sure if the problem lies with the backend or fron ...

Reposition the camera in three.js to capture various angles around the Earth

When repositioning a camera on a three.js globe by clicking on a country, I retrieve the country's latitude and longitude coordinates. However, after moving the camera to the new position, it ends up inside the surface of the globe. I have to zoom out ...

Initiating a quick route refresh - Redirecting the traffic

Is it possible to change the URL address while processing a request in Express? I am looking for a simple redirect implementation that allows me to modify the current URL and restart the route matching process. Here's an example of what I'd like ...

Assign the ng-init value of the select-controller in Angular using disabled options

I am encountering an issue with this code: <div class="year-divider"> <select style="width:70px;" class="form-control year-selector" id="{{'playerYearSelector'}}" name="playerCurrYear" data-ng-model="user.pla ...

Adding Angular directives to the DOM after the document has finished loading does not function properly in conjunction with ngAnimate

I've been working on developing an Angular service that can dynamically append a notification box to the DOM and display it without the need to manually add HTML code or write show/hide logic. This service, named $notify, can be used as follows: $no ...

What is the reason behind genNewColor function's malfunction?

I'm having trouble with this code that is supposed to generate a random color. The CSS formatting works perfectly, but I suspect there might be an issue with the function itself. When I try to run the code, it doesn't produce any error messages â ...

Certain sections within a Formik form are failing to update as intended

I have successfully implemented a custom TextField wrapper for Material-UI fields, but I am facing an issue with native Material UI fields not updating the form data upon submission. Below is the relevant code snippet along with a link to a code sandbox d ...

JQuery method for extracting a specific span's content from a div

I am faced with extracting specific text from a span within a div element. Below is the code snippet for my Div: '<div class="dvDynamic_' + pid + '"><p hidden="true">'+pid+'</p><span class="count_' + pid ...

What is the process for adjusting settings through selected options in a pop-up menu?

Here are the choices available: <form> <select id="poSelect" > <option selected disabled>Choose here</option> <option id="buyeroption" value="100101">I am a Buyer</option> ...

Determining the correct type for a recursive function

I have created a function that is capable of recursively traversing through a nested or non-nested object to search for a specific key and extract its value. const findName = <T extends object>(obj: T, keyToFind: string): T[] => { return Object ...

What is the best way to update setState when triggering an onChange event?

Here is the code snippet for a React component that handles cryptocurrency selection: import React, { Component } from 'react'; import { Select } from 'antd'; import { connect } from "react-redux"; class SelecionarCrypto extends Compo ...