Jump to content

Bug / Strange behavior with Copy


KevinBLT
 Share

Recommended Posts

Hello folks,

 

after nearly over an hour of debug action, I found something strange.

 

I create an object out of some smaller objects using merge.

After that, I keep one "original" in background with "isVisible = false".

 

Then, if the settings change, I throw everything away and copy this "original".

Set material, size, etc...

Then I create instances of this.

 

But I always had an error within babylon while copy. 

 

The first time it works as expected.

But the second time I use copy with this "original" object, I have this error:

(Line 27524: CANNOT SET .references OF UNDEFINED #ERROR)

for (var kind in this._vertexBuffers) {  if (numOfMeshes === 1) {    this._vertexBuffers[kind].create();  }  this._vertexBuffers[kind]._buffer.references = numOfMeshes; <==== CANNOT SET .references OF UNDEFINED #ERROR  if (kind === BABYLON.VertexBuffer.PositionKind) {    mesh._resetPointsArrayCache();    var extend = BABYLON.Tools.ExtractMinAndMax(this._vertexBuffers[kind].getData(), 0, this._totalVertices);    mesh._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);    mesh._createGlobalSubMesh();    //bounding info was just created again, world matrix should be applied again.    mesh._updateBoundingInfo();  }}

I noticed, that after copy, in Mesh._geometry._meshes a mesh had been added.

This happend in the new copy as well as in the original one.

That's the reason the second round it has "numOfMeshes = 2" and runs into this error.

 

I have no idea why this happens or why the orignial mesh is affected by copy function?

 

I ended up with this (ugly) workaround:

function getBarType2() {  var Clone = window.BarType2.clone("Pfosten Typ 2");  window.BarType2._geometry._meshes.pop();  Clone.isVisible = true;    return Clone;}

With this, it works as expected!

Can anyone explain what happens here?

 

 

Have a nice day

 

Kevin

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