The Snow Irbix Posted November 26, 2014 Share Posted November 26, 2014 Hello everybody !Thank you to take your time to try to help me,I've got a problem with subdivide mesh, i would like to explode a mesh by subdivide it.var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);sphere.subdivide(4);var mesh = sphere.subMeshes[0].getMesh();alert(mesh.position + sphere.subMeshes[0].position); // return : {X: 0 Y:0 Z:0}undefinedI would like to change position of subMeshes but i don't find how to change it. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 26, 2014 Share Posted November 26, 2014 You can not totalize a vector3 as you do here: alert(mesh.position + sphere.subMeshes[0].position): try: add(otherVector) → {BABYLON.Vector3}var newVector = mesh.position.add(sphere.subMeshes[0].position);alert(newVector); Quote Link to comment Share on other sites More sharing options...
The Snow Irbix Posted November 26, 2014 Author Share Posted November 26, 2014 It is just a test to show that submeshes position is undefined, and when i try to get the mesh with the method getMesh(), it return the parent mesh whereas i would like to get the submesh to move only a part of the origin mesh that i have cut. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 26, 2014 Share Posted November 26, 2014 The problem here is sphere.subMeshes[0]. the sphere has no submesh. see : console.log(sphere); Quote Link to comment Share on other sites More sharing options...
The Snow Irbix Posted November 26, 2014 Author Share Posted November 26, 2014 But how can i divide the sphere ? Have you an other idea ? The documentation say : subdivide(count)Subdivide this mesh by creating "count" submeshes stored in this.subMeshes when we add :sphere.showSubMeshesBoundingBox = true;we see the four BoundingBox of the subMeshes Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 26, 2014 Share Posted November 26, 2014 Excuse me, you have reasons. look here, it works right:http://www.babylonjs-playground.com/#1XCKCL#2 Quote Link to comment Share on other sites More sharing options...
The Snow Irbix Posted November 26, 2014 Author Share Posted November 26, 2014 So when I change the X position value, I would like to translate only a part of the sphere and not the whole sphere, is it possible ? And if it is, how can I do that ?http://www.babylonjs-playground.com/#1XCKCL#4 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 26, 2014 Share Posted November 26, 2014 I think you should use the class CSG:http://doc.babylonjs.com/page.php?p=24736 some info here on this class:https://github.com/CraigFeldspar/BabylonCSG This class will allow you to separate your sphere into several objects you can move then. Quote Link to comment Share on other sites More sharing options...
The Snow Irbix Posted November 26, 2014 Author Share Posted November 26, 2014 It seems to be what I search ! I will try to explode a cube on mouse picking thanks to CSG !Thanks a lot to your help ! 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.