Chrome not displaying Skeletal Animation in Three.js GLB files

I am attempting to implement basic embedded skeletal animation in a .glb model using Three.js

The workaround I found is from a discussion on this forum:

I have written the simplest code possible. The animation is being located (can be logged into the console). However, the animation does not play.


    let file, scale, backgroundColor;

    window.onload = loader;

    function loader (){
        file =  "Fox.glb";
        scale = 1;
        backgroundColor = 0x000000;

        init();
    }

    function init(){
        //RENDERER
        myCanvas = document.getElementById('myCanvas');

        renderer = new THREE.WebGLRenderer({
            canvas: myCanvas,
            antialias: true
        });
        renderer.setClearColor(backgroundColor);
        renderer.setPixelRatio(window.devicePixelRatio);
        renderer.setSize(window.innerWidth, window.innerHeight);

        //CAMERA
        camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 1000 );

        //SCENE
        scene = new THREE.Scene();

        let controls = new THREE.OrbitControls(camera, renderer.domElement);
        camera.position.set( 0, 20, 100 );
        controls.update();

        //LIGHTS
        let light = new THREE.AmbientLight(0xffffff, 0.5);
        scene.add(light);

        let light2 = new THREE.PointLight(0xffffff, 0.5);
        scene.add(light2);

        let loader = new THREE.GLTFLoader();

        loader.load(file, handle_load);

        let mesh;

        function handle_load(gltf) {
            mesh = gltf.scene;
            
            //ANIMATION
            let mixer = new THREE.AnimationMixer( gltf.scene );
            let action = mixer.clipAction( gltf.animations[ 0 ] );
            action.play();
   
            //PREPARING DISPLAY
            mesh.children[0].material = new THREE.MeshLambertMaterial();
            mesh.children[0].scale.set(1,1,1,)
            scene.add( mesh );
            mesh.position.z = -10;
        }
        render();

        function render() {
            renderer.render(scene, camera);
            requestAnimationFrame(render);
        }

What could be causing the issue?

Answer №1

Your animation loop is missing an update to the animation mixer. Make sure to include this line in your render() function:

function render() {
    renderer.render(scene, camera);

    const delta = clock.getDelta();

    if (mixer) mixer.update(delta);

    requestAnimationFrame(render);
}

To make sure everything works correctly, remember that the clock variable needs to be defined as an instance of THREE.Clock. Keep it in the same scope as your renderer, camera, and scene.

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

Transform a string into a boolean value for a checkbox

When using v-model to show checked or unchecked checkboxes, the following code is being utilized: <template v-for="(item, index) in myFields"> <v-checkbox v-model="myArray[item.code]" :label="item.name" ...

How can I retrieve an updated object array within an extended class in JavaScript?

Hey everyone, I am new to working with ES6 classes. Currently, I am trying to inherit an initialized object (this._obj) with updated data in the class B, but I am encountering an issue where I am getting the length of the initialized object instead of the ...

Set a restriction on the Bootstrap DatePicker to only show dates within a

My application features StartDate and EndDate datepickers, and I need to implement a 30-day limit on the selection range to prevent performance issues caused by loading too much data. I'm looking for a functionality where if the user picks today as t ...

Is there an implicit transformation or action involved when the promise chain is resolved or rejected in $q?

Is there an intrinsic digest/apply included when the promise chain is resolved/rejected in $q? I recently switched from using $q to q in my code and it seems like a digest is no longer happening, leading to different outcomes. What could be causing this c ...

Is there a method to access a website, trigger JavaScript functions, and subsequently retrieve the HTML content using PHP?

I am currently exploring options to access a webpage, execute JavaScript functions on it (thus altering the HTML content), and eventually save the modified version of the page. I'm uncertain if this approach is feasible, and if not, are there alternat ...

When using ngClick with a parameter, the parameter is not being successfully passed

My table resembles a tree structure with two ng-repeats. <table> <tr ng-repeat-start="am in anArray"> <td><button ng-click="TheFunction(am)"></button></td> </tr> <tr ng-repeat-start="em in anotherArray"> < ...

Is it possible to avoid passing each individual Vue prop by destructuring them?

Essentially, I am working with a component <Device> v-for="device in devices" :key="device.name" :device="device" :name="device.name" :number="device.number" :type="device.type" :status=&qu ...

What's the best way to integrate Bootstrap into my HTML document?

Hey there, I'm new to the coding world and just started learning. I could use some assistance with including Bootstrap v5.1 in my HTML code. The online course I'm taking is using an older version of Bootstrap, so I'm having trouble finding t ...

Retrieve data from the database by selecting an option from the dropdown menu

I am currently facing a minor issue with the filtering system I am developing. The problem arises when selecting the "All" category from a dropdown menu, which is not part of the database but a separate HTML option. Here is a visual representation of the ...

grabbing data from different domains using jQuery

I attempted to implement cross-domain AJAX examples, but unfortunately, it did not function as expected. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <meta http-equiv="Content-Type" content="text/ht ...

Summing Values with Linq.js Filter

Can you apply a filter in Linq.JS using SUM? This is my attempt: var query = Enumerable .From(self.data()) .Where("$$.Sum($.percent) > 100") .ToArray(); Issue encountered: linq.js: Uncaught TypeError: $$.Sum is ...

Error: The function clickHandler has been referenced before it was declared or it has already been declared

Since I started using JSLint, I have encountered the common issues of "used before defined" and "is already defined." While I found solutions for some problems, I am currently stuck. Here is a snippet of my code: var foo; foo = addEventListener("click" ...

What is the process for AngularJS to automatically populate the initial tag value in an SVG template?

I'm currently working on an AngularJS directive that needs to update different attributes within an svg tag. angular.module("complexNumbers") .directive("cartesianPlane", function() { return { restrict: "E", scope: { }, templateUrl: " ...

What is the best way to generate a fresh set of data from a search parameter?

I have received data from an API call that needs to be filtered. I am utilizing Redux instead of local state for this task. Below are the actions I have defined: import ActionTypes from '../constants/ActionTypes'; export const passengersDataAc ...

The markers from KML exported from My Maps are not showing up on the Google Maps JavaScript API

I have a map on Google My Maps that I want to showcase through the Google Maps JavaScript API. This way, I can easily merge multiple maps into one and add paths/markers without needing to code it all manually. Test out the map I'm using by clicking t ...

Tips for inputting information without redundancy after selecting a specific designation

I'm experiencing a challenge with this code as it repeats when already chosen. My goal is to add data in the database once something has been selected. When I click on spin, the randomizer will choose a name and update their status to "done". Subsequ ...

Error message: "Uncaught ReferenceError: $ is not defined in BackboneJS and RequireJS"

In my Backbone application, I am using RequireJS. However, I keep encountering the error message Uncaught ReferenceError: $ is not defined, indicating that my libraries may not be loading properly. This is what my RequireJS config looks like: require.con ...

Mirror the content of my div code onto a two-dimensional plane using an A-frame

Query I am currently developing a 3D scene using A-Frame () and I am in need of a solution to mirror an HTML div onto a plane within the A-Frame environment. For instance, imagine a scenario where there is a div at the bottom left corner of the screen fun ...

Verify whether an HTML element lies within another HTML element

Consider this example: <div id="President"> <div id="Congressman"> <div id="Senator"> <div id="Major"></div> </div> </div> </div> Is there a simple way in JavaScript or jQuery to determine ...

There seems to be an issue with the audioElement.src, which I used to run and play different songs. However, it is now displaying a 404

Array.from(document.getElementsByClassName('songItemPlay')).forEach(function (item) { item.addEventListener('click', (evt) => { playAllSongs(); position = parseInt(evt.target.id); evt.target.classList.re ...