Jump to content

mesh.clone() clones mesh.uniqueId


haestflod
 Share

Recommended Posts

Hi I was using uniqueId to uniquely represent a mesh and I noticed if I use a cloned mesh ( mesh.clone() ) their uniqueId would be the same.

After debugging the code the cloned mesh has a uniqueId after this line:
 

super(name, scene);

But after the line:

Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances", "parent"], ["_poseMatrix"]);

They now have the same uniqueId

Which can be seen here:
http://playground.babylonjs.com/#27FBML#0

Link to comment
Share on other sites

Yes, I had to patch this in my version since months.
Cannon js collisions do not work on cloned meshes without this.
(dirty hack :()

BABYLON.Mesh.prototype.clone_h_ = BABYLON.Mesh.prototype.clone;
BABYLON.Mesh.prototype.clone = function() {
	var m = BABYLON.Mesh.prototype.clone_h_.apply(this,arguments);
	m.uniqueId = m.getScene()._uniqueIdCounter++;
	return(m);
	};

 

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...