KevinBLT Posted September 4, 2015 Share Posted September 4, 2015 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 Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 4, 2015 Share Posted September 4, 2015 Hi, To prevent terms confusion (for example, I assume copy means clone?) could you create a playground that reproduces this error? It seems like, for some reason, merging causes it to malfunction. 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.