# How to Implement Cloth Simulation with PlayCanvas

**URL:** <https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484>\
**Category:** Help & Support\
**Created:** [June 3, 2020, 12:40pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484 "2020-06-03T12:40:06Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![will](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/will/32/4560_2.png) [@will](https://forum.playcanvas.com/u/will)\
**Post date:** [June 3, 2020, 12:40pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/1 "2020-06-03T12:40:06Z")

</div>

We’re super-excited to announce some new experimental PlayCanvas technology that simulates cloth physics.

[//forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/5/52356b17b1b90f4e3f3d258c149b978b532f9994.mp4](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/5/52356b17b1b90f4e3f3d258c149b978b532f9994.mp4)

Read all about it here:

> **[Implementing Cloth Simulation in WebGLPlayCanvas](https://blog.playcanvas.com/implementing-cloth-simulation-in-webgl/)**
>
> The PlayCanvas WebGL game engine integrates with ammo.js – a JavaScript/WebAssembly port of the powerful Bullet physics engine – to enable rigid body physics simulation. We have recently been working out how to extend PlayCanvas’ capabilities by...

Can you help us spread the word on Twitter?

> <https://twitter.com/playcanvas/status/1268159168931860482>

😃 🙏

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [June 3, 2020, 5:17pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/2 "2020-06-03T17:17:17Z")

</div>

Ooh, nice feature!

That last image reminded me something…

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/4/4d12e01fcfaac5d9a99a56f5d1675905ee702257.jpeg)

---

<div class="post-metadata">

**Author:** ![Leonidas](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/leonidas/32/6495_2.png) [@Leonidas](https://forum.playcanvas.com/u/Leonidas)\
**Post date:** [June 3, 2020, 5:18pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/3 "2020-06-03T17:18:14Z")

</div>

😇

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/8/8129926d15cfd08305b0ed70d02f6916b45053a5.jpeg)

---

<div class="post-metadata">

**Author:** ![will](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/will/32/4560_2.png) [@will](https://forum.playcanvas.com/u/will)\
**Post date:** [June 4, 2020, 10:27am UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/4 "2020-06-04T10:27:42Z")

</div>

Here’s a funny riff on the cloth tech we announced yesterday - The Emperor dancing to hip hop!

[//forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/b/ba2a9fa449ac6b33f90289274b3742055a48d4be.mp4](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/b/ba2a9fa449ac6b33f90289274b3742055a48d4be.mp4)

Here’s the demo:

> **[Emperor Cloth Simulation Demo](https://playcanv.as/p/EEHymtVR/)**
>
> A prototype implementation of cloth simulation. It uses the soft body dynamics support in ammo.js.

And here’s @ray’s tweet!

> <https://twitter.com/RayT_uk/status/1268480924586516481>

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [June 4, 2020, 10:29am UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/5 "2020-06-04T10:29:44Z")

</div>

He has the moves! That was refreshing 🙂 Thank you for making my day!

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [June 4, 2020, 2:12pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/6 "2020-06-04T14:12:40Z")

</div>

If one would want to test it in his own project, would patching the shader chunk as in the example suffice?

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [June 4, 2020, 2:25pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/7 "2020-06-04T14:25:47Z")

</div>

Pinging @ray 🙂

---

<div class="post-metadata">

**Author:** ![ray](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://forum.playcanvas.com/u/ray)\
**Post date:** [June 4, 2020, 3:40pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/8 "2020-06-04T15:40:57Z")

</div>

@LeXXik - yes it should/could work in your own project if you add the money-patch,js script to patch the transform shader chunk and the cloth-sim.js script process your character - your character would also need vertex colors set up on it (as shown in the dev blog article posted by @will above).

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [June 4, 2020, 4:44pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/9 "2020-06-04T16:44:50Z")

</div>

Yep, got it, thank you, @ray!

---

<div class="post-metadata">

**Author:** ![Grimmy](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/grimmy/32/4776_2.png) [@Grimmy](https://forum.playcanvas.com/u/Grimmy)\
**Post date:** [June 12, 2020, 4:06pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/10 "2020-06-12T16:06:17Z")

</div>

I tried all this with my own model but I just get an error: Cannot read property ‘length’ of null from cloth-sim.js. Any ideas?

---

<div class="post-metadata">

**Author:** ![Luis\_Mb](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/luis_mb/32/3431_2.png) [@Luis\_Mb](https://forum.playcanvas.com/u/Luis_Mb)\
**Post date:** [April 7, 2021, 4:59pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/11 "2021-04-07T16:59:04Z")

</div>

Impressive!! It’s great!! However, now I am trying to replace the model with another that has some vertex painted as well, but it doesn’t really work. Are there any additional settings that I need to add to the model? TNX IN ADVANCE 🙂!!..

---

<div class="post-metadata">

**Author:** ![ray](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://forum.playcanvas.com/u/ray)\
**Post date:** [April 7, 2021, 5:15pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/12 "2021-04-07T17:15:24Z")

</div>

@Luis_Mb - if you are just swapping out the example character model for a new one, the additional painted vertex color is all that should be needed - does the character model you are trying to use import and render and animate correctly? What is the error you are getting?

Something to try is to import the example character model into your 3D package, modify it and export using the same settings you use for your own character model. I can also help take a look at your character model if you are able to allow me access?

---

<div class="post-metadata">

**Author:** ![Luis\_Mb](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/luis_mb/32/3431_2.png) [@Luis\_Mb](https://forum.playcanvas.com/u/Luis_Mb)\
**Post date:** [April 8, 2021, 2:49am UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/13 "2021-04-08T02:49:16Z")

</div>

> [@ray](#):
>
> I can also help take a look at your character model if you are able to allow me access?

Thanks. This is my model [Sketchfab](https://sketchfab.com/3d-models/cloth1fbx-603cdfe41728494da5acf5ae69cbfd32)

---

<div class="post-metadata">

**Author:** ![ray](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://forum.playcanvas.com/u/ray)\
**Post date:** [April 8, 2021, 8:32am UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/14 "2021-04-08T08:32:58Z")

</div>

@Luis_Mb - I can’t seem to access the model on sketchfab? I guess it’s not public - if you prefer, you could give me read access to your PlayCanvas project - and I can look at your source model there? My PlayCanvas username is: rtuk

---

<div class="post-metadata">

**Author:** ![Luis\_Mb](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/luis_mb/32/3431_2.png) [@Luis\_Mb](https://forum.playcanvas.com/u/Luis_Mb)\
**Post date:** [April 8, 2021, 3:22pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/15 "2021-04-08T15:22:05Z")

</div>

Sorry 😅 Now is public!

---

<div class="post-metadata">

**Author:** ![Mi\_Be](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/mi_be/32/15335_2.png) [@Mi\_Be](https://forum.playcanvas.com/u/Mi_Be)\
**Post date:** [September 29, 2021, 4:10pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/16 "2021-09-29T16:10:04Z")

</div>

Hello Guys.

**Use cloth in Playcanvas is really awesome.** 💃  
I have had some problems trying to upload my own models  
Some advance in the project?

---

<div class="post-metadata">

**Author:** ![Astra](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/astra/32/23328_2.png) [@Astra](https://forum.playcanvas.com/u/Astra)\
**Post date:** [February 15, 2023, 3:53pm UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/17 "2023-02-15T15:53:34Z")

</div>

Also stumbled on this project recently, and it would be rly rly cool to use this in some of our projects!

I see in the blog post there is talk about improving the system and making it more easy to implement. Has there been any such patches?? If so, where do I look to implement this?

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [February 20, 2023, 9:49am UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/18 "2023-02-20T09:49:40Z")

</div>

Unfortunately, we’ve not made progress to adding this to the core engine so the only methods to do this have been mentioned in the blog post above.

---

<div class="post-metadata">

**Author:** ![dandingmaycry](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/dandingmaycry/32/27106_2.png) [@dandingmaycry](https://forum.playcanvas.com/u/dandingmaycry)\
**Post date:** [June 5, 2023, 6:52am UTC](https://forum.playcanvas.com/t/how-to-implement-cloth-simulation-with-playcanvas/13484/19 "2023-06-05T06:52:19Z")

</div>

@will hi, how can i exportr the cloth simulation animation in glb files. I want to do some cloth simulation using playcanvas’s script to handle thounds cloth. Is it possible for me to use script to export the cloth sumulation animation?
