Jump to content

Sharing geometry accross meshes with different materials


SvenFrankson
 Share

Recommended Posts

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,

Link to comment
Share on other sites

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;

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...