mesh.clone() clones mesh.uniqueId

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:

Share this post

Link to post
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++;


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.