leota Posted July 19, 2018 Share Posted July 19, 2018 I've created a BoxGeometry and assigned it to a Mesh, then when I click on the Mesh I would like to trigger an update of the geometry, for example change its "size" parameter. Is there a method I need to call on the Mesh to update it? I can see that the size property of the geometry gets updated, but the Mesh is still using the cached version. This is probably an easy thing to do, but I'm struggling a bit as I'm very new to Babylon. I've created a PG here: http://www.babylonjs-playground.com/#JTA9RH Any help would be much appreciated Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 19, 2018 Share Posted July 19, 2018 I haven't used geometries. Will scaling on the box work for you? http://www.babylonjs-playground.com/#JTA9RH#1 Quote Link to comment Share on other sites More sharing options...
leota Posted July 19, 2018 Author Share Posted July 19, 2018 12 minutes ago, brianzinn said: I haven't used geometries. Will scaling on the box work for you? http://www.babylonjs-playground.com/#JTA9RH#1 mmh not really....I need to update geometry parameters. For example, if I use a CylinderGeometry I would need to change "diameterTop", so the scaling trick would not work. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 19, 2018 Share Posted July 19, 2018 Hello everything is here: http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh Here is an example: https://www.babylonjs-playground.com/#1UZIZC#6 If you want to use pure shape functions, I recommend to directly use the MeshBuilder: http://www.babylonjs-playground.com/#JTA9RH#2 Quote Link to comment Share on other sites More sharing options...
leota Posted July 19, 2018 Author Share Posted July 19, 2018 4 minutes ago, Deltakosh said: Hello everything is here: http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh Here is an example: https://www.babylonjs-playground.com/#1UZIZC#6 If you want to use pure shape functions, I recommend to directly use the MeshBuilder: http://www.babylonjs-playground.com/#JTA9RH#2 Ok so basically I need to reassign the "mesh" variable to a newly created mesh. Thought there was a method to explicitly trigger a mesh update, but that's fine too. Thx! Quote Link to comment Share on other sites More sharing options...
Guest Posted July 19, 2018 Share Posted July 19, 2018 There is (the one I used in the playground I mentioned) but it forces you to build the geometry manually. If you just want to recreate a new geometry, then this is the best way Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 19, 2018 Share Posted July 19, 2018 if you don't want to recreate the mesh - here is a way with box as your first example. boxes are easy, if you're using cylinders then it gets more involved: http://www.babylonjs-playground.com/#JTA9RH#5 Quote Link to comment Share on other sites More sharing options...
leota Posted July 19, 2018 Author Share Posted July 19, 2018 Thanks, I need a solution that work on any kind of geometry, so recreating and reassigning the mesh seems to be the best solution so far. GameMonetize 1 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.