Modifying meshes in runtime

Hello,

I am wondering how could I achieve this - I’ll try to explain on Weapons demo: Babylon.js Playground

I have a dagger, and I would like to change curvature of the blade, without having multiple models prepared (there would be problem if I wanted to change more things on the blade for instance the cutout near the handle, there would need to be to many models for this to be practical)

Is there any good way how to prepare models like this dagger and modify them by some control points in runtime dynamicaly?

Where should I start with this?

Hi there and welcome to the Babylon community.

In order to do this you would need to modify the vertices of the faces on the mesh.

If you look at the picture you can use the inspector to see all the normals.

Here’s some documentation we have on updating those vertices. :slight_smile:

1 Like

Hello Jarek!

There is an effect like you described on the axe in the weapons demo, achieved by using morph targets: The Power of Morph Targets - YouTube. But it does require having “ready” shapes from which to interpolate between.

Another approach could be using bone animation, which is another very commonly used technique for deforming and animating meshes. Bones and Skeletons | Babylon.js Documentation
In this case, by changing the position and orientations of the bones, the mesh is automatically “deformed” according to each bone’s influence.

6 Likes