Controlling Fabric in Three.JS

(I'm still learning so forgive me if this is a beginner question.) I'm currently working on fitting a cloth material to a character model in Three.JS. What would be the most effective approach for this? Should I create a complete garment as cloth geometry, place it on the model, and then apply a physics library? Or is it better to define a set of constraints where the cloth is "pinned" to the model while letting the rest flow freely?

For guidance, I looked into the code for Three's cloth example. However, I could only find references to pin variables in the code, without clear implementation outside of their assignment functions:

/* testing cloth simulation */

var pinsFormation = [];
var pins = [6];

pinsFormation.push(pins);

pins = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
pinsFormation.push(pins);

pins = [0];
pinsFormation.push(pins);

pins = []; // cut the rope ;)
pinsFormation.push(pins);

pins = [0, cloth.w]; // classic 2 pins
pinsFormation.push(pins);

pins = pinsFormation[1];


function togglePins() {

  pins = pinsFormation[~~(Math.random() * pinsFormation.length)];

}

Has anyone encountered similar challenges in their work before?

I came across this question, but the answer was quite basic ("collision detection") and didn't clarify the example code that confused me.

I'm still a beginner in this field, so I appreciate any guidance available. Thank you!

Answer №1

Instead of trying to simulate the cloth onto the shirt, it might be better to just dress the model in the 3D program you are using and then deform the model with the clothes on. Simulating cloth for every vertex can greatly reduce performance, so it's more practical to focus on creating a player model with clothes included and using bone deformations for animation.

Take a look at this example to see the difference. The player model does not have simulated cloth, but rather clothes integrated into the model with bone deformations for animation, resulting in a great look.

Starting with simpler methods like dressing the model in the 3D program is a good approach for beginners or experts alike. Creating dynamic cloth interactions with complex meshes can be challenging, and may not offer significant advantages unless it is purely for simulation purposes where real-time performance is not a priority.

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

`vue.js pagination for loading nested arrays`

I am currently working on implementing the vue-paginate component from this source: https://www.npmjs.com/package/vue-paginate . My goal is to set up pagination for questions retrieved from firebase. Here is the initial setup: new Vue({ el: '#app& ...

What is preventing me from retrieving WP custom fields value or post ID using Ajax?

After successfully generating a link based on the visitor's location, I encountered an issue with caching when using full-page caching. To address this problem, I decided to implement AJAX to dynamically load the link. While my code worked well in ret ...

What are the steps to live stream a webGL canvas using WebRTC?

I have a webGL canvas displaying a 3D hologram image using Three.js and I am interested in ways to stream it as a video to another computer. After attempting the code provided below without success, I am left wondering if there is an alternative method to ...

What are the steps to resolve the error 'content-type missing boundary' and encountering the issue with getBoundary not being recognized as a function?

fetchCarouselData: async (params) => { let bodyFormData = new FormData(); for (let prop in params) { bodyFormData.append(prop, params[prop]); } return axios({ method: "post", url: `${baseURL}/fetchCarouselData`, data: b ...

Create a Discord.js bot that automatically deletes any URLs that are posted in the server

Seeking advice on how to have my bot delete any URLs posted by members. I am unsure of how to accurately detect when a URL has been shared, especially since they can begin with https, www, or some other format entirely. Any insights would be greatly apprec ...

Iterating over an object in a React component

i'm trying to generate an object using iteration like this: opts = [{label:1, value:1}, {label:4, value:4}] the values for this object are coming from an array portArray = [1,4] I'm attempting to do const portArray = [1,4]; return { ...

Show PDF within the browser using ajax technology

I've come across this question multiple times in various forms, but I still can't seem to find a satisfactory answer. When using the mpdf library to generate PDFs, I send some hidden field data to a PHP script via ajax. Below are snippets of the ...

Getting the percentage of code coverage in Selenium tests in relation to the web application code

I need to track the code coverage of my selenium tests in relation to the source code of the server (web application source code) that they cover. For instance, I want the tests for the login feature to measure how much of the web application's code ...

Transferring a zipped file between a Node.js server and a Node.js client

I am facing an issue with sending a zip file from a node.js server to a node.js client. The problem is that when I try to save the zip file, it becomes corrupted and cannot be opened. To create and send the zip file to the client, I am using the adm-zip l ...

What is the best way to send an array of grouped data to a table

Here's how I organized the array: { "2023-10-01": [ { "emp_id": 1, "name": "Aruna", "code": "DO", "date": "2023-10-01" }, { &qu ...

Tips for allowing divs to be dragged and resized within table cells and rows

UPDATE I believe that utilizing Jquery is the most appropriate solution for resolving my issue with the demo. Your assistance in making it work would be greatly appreciated. Thank you. My goal is to develop a scheduler application. https://i.sstatic.net ...

How can I trigger an audio element to play using onKeyPress and onClick in ReactJS?

While attempting to construct the Drum Machine project for freeCodeCamp, I encountered a perplexing issue involving the audio element. Despite my code being error-free, the audio fails to play when I click on the div with the class "drum-pad." Even though ...

Guide on duplicating a Select2 element integrated with Django and Python

I am facing an issue where the select element inside a div is not cloning correctly. The Select2 element does not retain the loaded values from the Django code when cloned. Is there a way to clone the div with all the Select2 element values intact? Current ...

My data is not appearing with ng-repeat or ng-bind

One issue I am encountering is that my ng-repeat / ng-bind is not displaying the data within $scope.articles, even though I am getting the expected data in the console. To help identify the problem more easily, I have created a code snippet below: var A ...

Is there a way to refresh a webpage without the need to reload it

Imagine a scenario where a tab on a website triggers the loading of a specific part of the webpage placed within a div. For example, clicking on a tab may trigger the loading of a file named "hive/index.php". Now, if a user selects an option from an auto ...

Sending form submission data with useFormik via React Router's Link component is a common task in web development. By

My goal is to transfer form data generated through the useFormik and yup hooks to another component using React Router DOM's 'Link' feature. However, I have encountered two issues in this process. Issue 1: I am struggling to pass the useFor ...

Foundation 4 - image hover effect to display alternate image

I am a newcomer to Foundation 4, but I have some coding experience. Currently, I am in the process of transitioning my photography blog (www.momentaryawe.com/blog) from Wordpress with a custom theme to a custom theme built on Foundation 4. Most aspects of ...

In Cypress, I am trying to specifically choose only numerical values from a dropdown menu. However, the list contains a mix of alphanumeric and numeric values

Looking to streamline: This is my code: cy.get('[role=presentation]') cy.get('[role=row]').find('td') .get('[role=gridcell]').eq(9).click().wait(2000) cy.get('[role=listbox]').get('[role=option]& ...

Encountered an error while web crawling in JavaScript: Error - Connection timeout

I encountered an error while following a tutorial on web crawling using JavaScript. When I execute the script, I receive the following errors: Visiting page https://arstechnica.com/ testcrawl ...

SinonJS - Retrieving Property Value Prior to Stub Invocation

Currently leveraging sinon.js for stubbing functionalities where it is feasible to stub and spy on methods but not properties based on my observations. I'm interested in knowing if there's a way to verify whether state.searchText gets assigned t ...