phil1234 Posted October 6, 2015 Share Posted October 6, 2015 hi everyone, I need to load a mesh, and duplicate it, but with different materials, so createInstance(), seems a little bit limited in that case also if I load a mesh with Append, it is added to the scene, but if I load a mesh with a Load, how do I append it to the scene ? thanks Quote Link to comment Share on other sites More sharing options...
iiceman Posted October 6, 2015 Share Posted October 6, 2015 is the .clone() method what you want? http://doc.babylonjs.com/classes/2.1/Mesh#clone-name-newparent-donotclonechildren-rarr-mesh-classes-mesh- Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 6, 2015 Author Share Posted October 6, 2015 is the .clone() method what you want? http://doc.babylonjs.com/classes/2.1/Mesh#clone-name-newparent-donotclonechildren-rarr-mesh-classes-mesh- ok, but does it link the mesh automaticaly to the scene(graph) or do I have to do it ? Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 6, 2015 Author Share Posted October 6, 2015 ok it does it automaticaly Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted October 7, 2015 Share Posted October 7, 2015 If you load a scene with Load, you'll then need to copy by hand every mesh/skeleton/etc from the resulting scene to your previous existing scene. Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 7, 2015 Author Share Posted October 7, 2015 If you load a scene with Load, you'll then need to copy by hand every mesh/skeleton/etc from the resulting scene to your previous existing scene.yes, hence my question "how do I append it to the scene ?" Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted October 7, 2015 Share Posted October 7, 2015 Hmm ?? Hence my answer : to append it to the scene, you need to copy it from the resulting scene in the Load function to your "real" scene Or maybe I don't understand your question Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 7, 2015 Share Posted October 7, 2015 Then use SceneLoader.Append() instead of SceneLoader.Load().https://github.com/BabylonJS/Babylon.js/blob/master/src/Loading/babylon.sceneLoader.ts#L139 Not sure what this has to with cloning though Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 7, 2015 Share Posted October 7, 2015 ok, cloning deep copies everything but the material & skeleton if there is one. If you wish to clone the skeleton as well:var myClone = origMesh.clone();if (origMesh.skeleton){ myClone.skeleton = origMesh.skeleton.clone("name", "id");} 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.