When material skinning is enabled, the skinned animation mesh in Three.js mysteriously vanishes

After exporting an animated model from Blender, I encountered an issue with instantiating it in my project. Although I was able to create the THREE.Animation and model, I found that the animation was not working. I soon discovered that I needed to set skinning to true on each material. However, when I made this change, the entire mesh disappeared.

Here is the code I quickly put together in an attempt to fix the issue:

function loadModel() {
        var loader = new THREE.JSONLoader();
        loader.load('assets/models/Robot.js', function(geom, mat) {
            _mesh = new THREE.Object3D();
            _scene.add(_mesh);

            geom.computeBoundingBox();

            ensureLoop(geom.animation);
            THREE.AnimationHandler.add(geom.animation);

            for (var i = 0; i < mat.length; i++) {
                var m = mat[i];
                //m.skinning = true; <-- Uncommenting this makes the model disappear
                //m.morphTargets = true; <-- This causes all sorts of WebGL warnings

                m.wrapAround = true;
            }

            var mesh = new THREE.SkinnedMesh(geom, new THREE.MeshFaceMaterial(mat));
            mesh.scale.set(400, 400, 400);
            mesh.position.set(0, -200, 0);
            mesh.rotation.set(Utils.toRadians(-90), 0, 0);
            _mesh.add(mesh);
            _robot = mesh;
            Render.startRender(loop);

            var animation = new THREE.Animation(mesh, geom.animation.name);
            animation.JITCompile = false;
            animation.interpolationType = THREE.AnimationHandler.LINEAR;
            animation.play();

        });
    }

It seems that I am correctly updating the AnimationHandler in my loop:

function loop() {
    _mesh.rotation.y += 0.01;

    var delta = 0.75 * _clock.getDelta();
    THREE.AnimationHandler.update(delta);
} 

Answer №1

Is the number of morphTargets and bones greater than 0 in the metadata section of the JSON file you exported?

It seems like you may have followed the example provided here:

This example showcases an animated model that utilizes Morph Target and Skeletal Animation (refer to Wikipedia for more theoretical concepts).

If the animated model only uses Skeletal Animation, similar to this example

you need to create a THREE.SkinnedMesh Object and then set the m.skinning property to true.

Answer №2

Recently, I encountered a similar issue. I found a solution by recreating the model with the correct scale and ensuring keyframes were set for LocRotScale, not just location.

Answer №3

Recently, I faced a problem with my mesh disappearing during the process of exporting a Blender skinning animation to JSON. It turned out that my mesh had double vertices, with one vertex hiding another. Everything seemed fine while setting up vertex groups and animations in Blender, but the mesh would disappear in Three.js as soon as the animation began. Essentially, if even one vertex is omitted from the vertex groups, this disappearing issue occurs. To avoid this problem, I now use Blender's "remove doubles" function to ensure the integrity of the mesh before exporting it to JSON. You may have encountered the same issue and reworking your mesh could solve it. Although this question is dated, the topic remains relevant today, so I hope this updated information helps someone in need...

Peace INF1

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

Ways to reach component method via router

When making an Ajax request and displaying the data in a table component, I encounter an issue where I need to extract the clicked data for use in another Ajax request within a different component that is called through React-Router. The challenge lies in ...

Understanding the mechanisms of Promise functionality within Typescript can be challenging, particularly when encountering error messages such as "type void is not

Recently, I've delved into the world of Typescript. Despite my efforts to stay true to the typing system, I've encountered a challenge that forces me to resort to using the any type: The issue arises with a function that returns a promise: sav ...

Encountering difficulties in constructing next.js version 14.1.0

When attempting to build my next.js application, I use the command npm run build Upon running this command, I encountered several errorshttps://i.sstatic.net/5jezCKHO.png Do I need to address each warning individually or is there a way to bypass them? B ...

Unable to establish communication with server. Facing issues in connecting AngularJS with NodeJS

I am currently working on establishing a communication process between my server and client to receive either a "success" or "failure" response. The server is being developed using node.js with the express framework, while the client is built using angular ...

I am looking to remove identical innerText values from two arrays using JavaScript

Is it possible to use JavaScript to remove the "added" className of an element with the same innerText when the delete button (.btn-wrap>li>button) is clicked? <div class="table"> <ul> <li class="added">l ...

How can I create an efficient chat system using Ajax and settimeout without causing excessive virtual memory usage?

I'm in the process of creating a chat application using AJAX that fetches data every second with setTimeout. I have drafted a basic code where there is a number that increments each second by the number retrieved from the PHP page2. Upon testing it on ...

Ways to resolve the issue of data-bs-target not functioning properly in Bootstrap version 5

While viewing the Job screen in the following image, I attempted to click on "Personal," but it remained stuck on the Job screen. ...

Encountering ECONNREFUSED error when making requests to an external API in a NextJS application integrated with Auth

Currently, I have integrated Auth0 authentication into my NextJS application by following their documentation. Now, I am in the process of calling an external ExpressJS application using the guidelines provided here: https://github.com/auth0/nextjs-auth0/b ...

Blending an HTML jQuery toggle

Is there a way to make the current headline fade out while simultaneously fading in a new one when switching to the next div using a jQuery .html switch? Check out the codepen example: https://codepen.io/balke/pen/JpNNve $(window).scroll(function() { ...

Utilizing jQuery to execute functions from various files simultaneously with a single load statement

My goal is to achieve a basic include with jQuery, which involves loading functions from multiple files when the DOM is ready. However, this task proved to be more complex than anticipated: index.html <script type="text/javascript" src="res/scripts.js ...

Exploring the capabilities of incorporating multiple nested if-else statements in an AJAX/JavaScript function

Can anyone help me with this code issue? I am trying to run a function with data received from a CI controller to ajax, but having trouble with multiple if else statements. The code works fine with one if else statement, but not with nested or multiple one ...

Automatically calculate the product of two columns in a gridview

Greetings, I am currently working on a project that involves calculating values from two textboxes within a gridview and displaying the result in a third textbox using JavaScript. The calculation should occur as soon as a value is entered into the second ...

suggesting options comparable to addthis or sharethis

Could you please check out ? There is a sharing box in the bottom right corner that resembles ShareThis. However, as far as I know, ShareThis does not have options for embedding or submitting content. Does anyone happen to know which plugin is being used ...

Is there a way to remotely access and read text files stored on a server using either JavaScript or Ajax from an IIS6.0 Virtual directory?

Is it possible to use JavaScript or Ajax to read the text from a file on a remote machine (from IIS6.0 Virtual directory) and then copy it into a specific folder on the client machine? ...

successful callback after passport registration

router.post('/register', function(req, res, next){ var name = req.body.name; var email = req.body.email; var username = req.body.username; var password = req.body.password; var password2 ...

The protected routes within a React JS application consistently result in an undefined value

In my ProtectedRoute component for my react application, I am facing an issue with user authentication. I am using react-router-dom v6 to access the token from localStorage, but no matter what, the user variable always returns undefined. import { Outlet, N ...

Align elements on the left side with some space between them

Having trouble displaying a list of images inline within a div. When I float them left, they leave a lot of space and do not display properly. Can anyone help me with this issue? See screenshot below: Here is my html code: <div class="col75"> & ...

How to prevent text from overflowing outside the Material UI Container/Box?

One issue I'm facing is with an Alert that displays long strings on my website. Here's the code snippet in question: <Container maxWidth="md"> <Box sx={{ mt: 3, border:1}}> <Box> {hasSubmitted ? ...

Encountering an issue with Masonry's container.append that is causing an Uncaught TypeError: Object does not possess the filter method

I have implemented infinite scroll on my website to display images. The images are arranged using a tool called masonry. Initially, I only load 10 images into the #container div when the page loads. These images are aligned perfectly with no errors in the ...

Can HTML5 and JavaScript be used to clip a portion of a video and upload it directly to a server?

Currently, I am using Filereader to read a local video file (mp4) in order to display it in a video tag. However, I am looking to cut a specific part of the mp4 file (for example, from 5 to 10 seconds) and then upload it to a server. My current approach: ...