SvenFrankson Posted February 14, 2018 Share Posted February 14, 2018 Hi everyone, I know it's possible and advised to use InstancedMesh when several meshes share the same geometry and the same material. Is there some recommended optimization to do when two meshes share the same geometry but have different materials ? For example with this case : http://playground.babylonjs.com/#T4Z2V9#1 (here VertexData object is already loaded) Is there something better than two calls to "applyToMesh" ? Like obj1.geometry = obj2.geometry, this kind of thing... (my question is based on the fact that Unity explicitly share the same geometry across objects, even when Materials are different. But perhaps it's only done to optimize data packing / loading and has no impact at runtime...) (I'm fairly sure I have already found this question somewhere, but can't remember the answer nor find where it was...) Thanks a lot for your inputs ! Have a nice day, Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted February 14, 2018 Share Posted February 14, 2018 clones share the geo, but can have different materials. Clone does deep copy most elements, but not animations. Elements (+children) included are: Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata"], ["_poseMatrix", "_source"]); Do something like: var original = whatever; var clone = original.clone(original.name + "01"); clone.material = someThingElse; GameMonetize and SvenFrankson 1 1 Quote Link to comment Share on other sites More sharing options...
SvenFrankson Posted February 15, 2018 Author Share Posted February 15, 2018 Thanks JC ! Seems like it will do the job 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.