brianzinn

[Solved] BJS 3.0

Recommended Posts

Hi,

I'm trying out the new 3.0 Preview -- upgrading from BJS 2.5.  I have managed to work through some breaking changes and am stuck with an error:

Uncaught TypeError: Cannot set property source of [object Object] which has only a getter
    at Function.t.DeepCopy (...)
    at new r (...)
    at r.clone (...)

I tried to reproduce with a PG and was expecting it to produce the above error on line 39 where I am cloning a mesh:

http://babylonjs-playground.com/#NQHEE#0

So, my question is.  Is there a difference between latest github preview (31efb0f commit) (https://github.com/BabylonJS/Babylon.js/tree/master/dist/preview release) and PG 3.0-alpha?  If they are the same then I will need to work harder to reproduce in a PG or fix!

babylon.max.js line 6518 (destination[prop] = cloneValue(sourceValue, destination);

It's happening on the property 'source'.

Thanks.

Share this post


Link to post
Share on other sites

I see no error in the PG. the object is cloned. Maybe with the browser cache cleaning will correct your problem.

By cons mesh.clone(??) takes as argument, the new name of the object to clone.

Share this post


Link to post
Share on other sites

Hello,

The alpha version we're pushing on our website is normally corresponding the last version of the code we've pushed on the github, it should behave the same. 

Using the exact same code as the PG locally on your machine is failing with TypeError?

David

Share this post


Link to post
Share on other sites

I added a new name argument as Dad72 suggested, but that has had no effect.  I have updated the PG with more code, but the PG is still working: http://babylonjs-playground.com/#NQHEE#1 .  In other words, I cannot reproduce on the PG!  My code is failing with TypeError on line 58 of the PG.

 

I can however, easily change babylon.max.js to get it working...

My guess would be line 23645 of babylon.max.js creates a property that DeepCopy is unable to set:

Object.defineProperty(Mesh.prototype, "source", {

            get: function () {

                return this._source;

            },

            enumerable: true,

            configurable: true

        });

With a workaround that is obviously not usable - adding in DeepCopy this everything does work:

var propDescriptor = Object.getOwnPropertyDescriptor(destination, prop)

                  if (propDescriptor  === undefined && destination instanceof BABYLON.Mesh) {

                    propDescriptor = Object.getOwnPropertyDescriptor(BABYLON.Mesh.prototype, prop)

                    if (propDescriptor === undefined && destination instanceof BABYLON.AbstractMesh) {

                      propDescriptor = Object.getOwnPropertyDescriptor(BABYLON.AbstractMesh.prototype, prop)

                    }

                  }

                  if (propDescriptor === undefined || propDescriptor.writable === true) {

                    destination[prop] = sourceValue; // also need above guard code for destination[prop] = cloneValue(sourceValue, destination);

                  }

I will mark as solved, since I am the only one experiencing this. Chrome Version 57.0.2987.133 (64-bit)

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.