JSON geometry imported is not following the movement of the bones

After importing a model into my Three.js scene, I encountered an issue where the bones can be moved and rotated successfully, but the model's geometry does not follow these bone movements.

For importing the JSON file and adding it to the scene, here is the code that I used:

/*load JSON file*/
// instantiate a loader
var loader = new THREE.JSONLoader();
loader.load( 'https://cdn.rawgit.com/wpdildine/wpdildine.github.com/master/models/cylinder.json', addModel );

var helpset;
var scaleVal = 3;

function addModel( geometry,  materials ){

    materials.skinning = true;

    var cs = scaleVal * Math.random();

    mesh = new THREE.SkinnedMesh( geometry, new THREE.MeshFaceMaterial(materials) );

    scene.add(mesh);
    helpset = new THREE.SkeletonHelper(mesh);
    scene.add(helpset);     

}

The imported JSON files already include weights, so I assumed there was no need for me to manually add them. However, could there be an issue with binding the skeleton to the mesh?

Here is a link to view my code - https://jsfiddle.net/joeob61k/1/ (New link with scripts, thanks @Mr. Polywhirl)

In the GUI controls, you can observe that 'Bone_2' moves one of the bones but not the mesh.

EDIT: In attempting to access the bones of the mesh within the render() function, I employed the following line of code,

mesh.skeleton.bones[2].rotation = 0.1;

This resulted in the error message: 'Cannot read property 'skeleton' of undefined(…)', where 'undefined' represents the mesh variable. Is there a different method to access the bones of a SkinnedMesh that I should be using?

Answer №1

The issue was specifically related to this line of code:

materials.skinning = true;

To fix the problem, you should modify it as follows:

materials[0].skinning = true;

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

Class in ABAP that aids in the conversion to Odata primitive data types

Are there any available helper classes in ABAP that can assist with converting the Date time data type to Odata format? I am currently working on creating a JSON payload directly in ABAP to send to an HTTP REST API, and the service requires the date to b ...

ExpressJS: How to resolve the undefined error in Express session

After using express-generator to create my project, I installed the express-session package. Below is how express-session is ordered in my app: app.js var expressSession = require('express-session'); app.use(logger('dev')); app.use( ...

When pressing the next or previous button on the slider, an error message pops up saying "$curr[action] is not a

I found this interesting Js fiddle that I am currently following: http://jsfiddle.net/ryt3nu1v/10/ This is my current result: https://i.sstatic.net/VygSy.png My project involves creating a slider to display different ages from an array, such as 15, 25, ...

Is there a way to defer a for loop in Angular?

In my Angular project, I am working on a sorting visualizer using the chart.js bar chart. Currently, I am focusing on visualizing bubble sort and I want to incorporate a delay in each iteration of the inner loop. I assume you are familiar with the loop s ...

Guidelines on fetching API data in React JS

When attempting to retrieve data from the OpenWeather API, I encountered an issue. The API's response is expected to be in JSON format, but instead, I received an error message: SyntaxError: Unexpected token < in JSON at position 0 useEffect(() =& ...

Getting to the values within a JSON object that contains multiple arrays

Is there a way to retrieve array data from the json object data? const [data, setData] = useState([]) const getData = () => { axiosInstance .get(url + slug) .then(result => setData(result.data)) } useEffect(() = ...

The JavaScript function is not functioning properly, whereas another function is working as intended

I have created a HTML form with 2 buttons and a table. Each row in the table consists of a checkbox and 2 text fields. The buttons allow users to add and remove rows from the table. The remove button only applies to rows where their checkbox is checked. T ...

Encountering a 404 error while trying to refresh the page in a React App hosted on Her

After deploying a React App on Heroku, I encountered a frustrating issue: every time a page is refreshed, a 404 error appears, such as: Cannot GET /create In my search for a solution, I came across a related issue: Question about 404 with React Router ...

User-Preferred Dark Mode Toggle Using Material-UI and Fallback Option

I am working on implementing a toggle for "dark mode" that is functioning well. However, I want the initial state to reflect the user's dark/light preference. The problem is that prefersDarkMode seems to be set to false when the page loads. It only c ...

Tips for uploading images in Next.js using Firebase

While following a tutorial on Next.js, I encountered an issue with the outdated version of Firebase being used. Despite trying different solutions from the documentation and various sources, I am still facing an error message while attempting to upload ima ...

Establishing numerous websocket connections within a singular application

I am looking to conduct load testing on our websocket service. Is there a method to establish multiple websocket connections from one workstation? My attempt with npm ws and websocket modules in conjunction with NodeJS was successful for a single connecti ...

Why is my Feed2JS RSS feed functional locally but not operational after deployment on GitHub Pages?

I've been using feedtojs.org to display my Medium blog posts on my GitHub Pages website. Strangely enough, it works perfectly fine on my local server but not on the actual domain. The RSS feed is valid. Here's how it appears on my local server: ...

integrating an array into MongoDB using Angular and NodeJS

Encountering an issue with mlab (mongoose), angular.js, HTML, and JavaScript. When passing an array with values from an angular.js controller to the server side (node.js), it fails to insert the data into the schema in mlab. Below is my HTML code: <fo ...

Error encountered while connecting to SQL Server from node.js causing the express server to crash due to a ConnectionError

Encountering an issue with node.js tedious error ConnectionError: Failed to connect to sqlserverip:1433 causing unexpected crashes in my express server. Seeking suggestions on how to prevent such crashes. <a href="/cdn-cgi/l/email-protection" class="__ ...

"What is the best way to prevent a button from being enabled in Angular if a list or array is not

I am incorporating data from my service in the component: ngOnInit() { this._sharedService. getReceiptItem().takeUntil(this.ngUnsubscribe). subscribe(products => this.receiptItems = products); } Is there a way to deactivate a button if there ...

Activate a Dropdown Menu by Clicking in a React Application

I have a collapsible feature where you can click to expand or collapse a dropdown. Currently, the dropdown can only be clicked on where the radio button is located. I want the entire area to be clickable so that users can choose the dropdown by clicking an ...

Having trouble rendering to the framebuffer due to issues with the texture

In the process of incorporating shadow maps for shadows, I am attempting to render a scene to a separate framebuffer (texture). Despite my efforts, I have not been able to achieve the desired outcome. After simplifying my codebase, I am left with a set of ...

The process of altering a property in input data within Vue.js

I have a component called Input.vue that displays a label and an input field of some type. Here is how it looks: <template> <div class="form-element"> <label :for="inputId" :class="['form-element-tit ...

Strange behavior detected in TypeScript generic function when using a class as the generic parameter

class Class { } const f0 = <T extends typeof Class> (c:T): T => { return c } const call0 = f0 (Class) //ok const f1 = <T extends typeof Class> (c:T): T => { const a = new c() return a //TS2322: Type 'Class' is not assigna ...

Unlocking the request object within a GraphQL resolver with Apollo-Server-Express

My express server is standard and I'm using GraphQL with it const server = express(); server.use('/graphql', bodyParser.json(), graphqlExpress({ schema })); I am wondering how to access the request object within a resolver. Specifically, ...