How to change 3d model dynamically

Hi!

I want to create a model from vertices for my game and I want to dynamically transform it’s vertices in update function.
How can I do this?

For example I want to create a 3d ball which would behave like jelly and will react to physics. I understand how can I do the physics part more or less, but I don’t know how to change mesh.

1 Like

Hi @Dmitry_Diamond!

See if this helps out - https://developer.playcanvas.com/en/api/pc.Model.html

Hi @Dmitry_Diamond,

Here is a great tutorial on how to create/edit a model/mesh:

https://developer.playcanvas.com/en/tutorials/terrain-generation/

Though I don’t think it is going to be fast, even for simple models, to be done per frame. Since you will have to lock the thread to push the new vertices and indices to the gpu. Most likely you will have to write a vertex shader and do the manipulation directly in the GPU.

If you have a solution regarding physics and you can decouple the rendered mesh from the physics simulation, then definitely try the vertex shader approach.

2 Likes