Eelis Posted March 13, 2016 Share Posted March 13, 2016 Suppose I want to make a triangle and animate its three corner positions, to make it move/deform. What is the best way to do that? Thanks Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 13, 2016 Share Posted March 13, 2016 Hello, you can use getVerticesData and updateVerticesData functions. Here is a cool example using a ribbon: http://www.babylonjs-playground.com/#16NCF0#7 Quote Link to comment Share on other sites More sharing options...
Eelis Posted March 13, 2016 Author Share Posted March 13, 2016 27 minutes ago, Deltakosh said: you can use getVerticesData and updateVerticesData functions. Here is a cool example using a ribbon: http://www.babylonjs-playground.com/#16NCF0#7 Thanks Deltakosh! I see that that demo uses registerBeforeRender and constantly updates the mesh. Do I understand correctly that this implies constant reuploading of vertex data to the GPU, and that this solution might not scale well to lots of triangles? Ideally, I would like to upload 6 Vector3s per triangle to the GPU: 3 for the initial position of the triangle, and 3 for the final position. Then, I would like to be able to animate the triangle at linearly interpolated positions, /without/ constantly reuploading vertex data. Is that doable? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 13, 2016 Share Posted March 13, 2016 it is and you understand correctly You can mark your mesh as updatable to get a special vertex buffer which is faster regarding updates THe best option in your case would be to use a vertex shader though Quote Link to comment Share on other sites More sharing options...
Eelis Posted March 13, 2016 Author Share Posted March 13, 2016 Great, thanks for the suggestions! I will try them out. Quote Link to comment Share on other sites More sharing options...
jerome Posted March 13, 2016 Share Posted March 13, 2016 Another lead is to use the SPS and to design each triangle as different particles. http://doc.babylonjs.com/overviews/Solid_Particle_System Have a look please at the function updateParticleVertex() : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape You particle model could be a disc tessellated at 3 : http://doc.babylonjs.com/overviews/Mesh_CreateXXX_Methods_With_Options_Parameter#disc This will trigger only one draw call to the GPU GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Eelis Posted June 26, 2016 Author Share Posted June 26, 2016 Thanks again guys, the updateVerticesData approach worked out well for me. (I use it here: http://eel.is/GrappleMap/composer/index.html?332,191,213,418,419,483,573,495 ) Cheers! jerome 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 26, 2016 Share Posted June 26, 2016 nice scene ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.