You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[JS] new Vector3() instanceof Vector3 true
[JS] new Vector3().constructor === Vector3 true
[JS] this.position instanceof Vector3 true
But if I first do anything with this.position:
exportdefaultclassTestextendsNode3D{_ready(): void{this.position;// Do nothing with it, just reference itconsole.log("new Vector3() instanceof Vector3",newVector3()instanceofVector3);console.log("new Vector3().constructor === Vector3",newVector3().constructor===Vector3);console.log("this.position instanceof Vector3",this.positioninstanceofVector3);}}
I incorrectly get:
[JS] new Vector3() instanceof Vector3 false
[JS] new Vector3().constructor === Vector3 false
[JS] this.position instanceof Vector3 false
And if I just instantiate a Vector3 before both of these:
exportdefaultclassTestextendsNode3D{_ready(): void{newVector3();// Do nothing with it, just instantiate itthis.position;// Do nothing with it, just reference itconsole.log("new Vector3() instanceof Vector3",newVector3()instanceofVector3);console.log("new Vector3().constructor === Vector3",newVector3().constructor===Vector3);console.log("this.position instanceof Vector3",this.positioninstanceofVector3);}}
I once again correctly get:
[JS] new Vector3() instanceof Vector3 true
[JS] new Vector3().constructor === Vector3 true
[JS] this.position instanceof Vector3 true
My guess from this behaviour:
I wonder if accessing this.position first is internally causing the creation of a Vector3 type that's somehow different than the Vector3 that's imported? And maybe that's being cached so that subsequent new Vector3() calls return that cached class rather than the Vector3 from the import? And if we do new Vector3() first, then that's what gets saved to the cache (and so this.position matches the imported Vector3)?
The text was updated successfully, but these errors were encountered:
It may caused by the same problem in #12. The prototype.constructor is unexpectedly changed after ObjectTemplate.GetFunction, I'm tracing it but haven't got any meaningful clues.
Using the main branch, and v8 runtime, if I have a script like:
When loaded, correctly prints:
But if I first do anything with
this.position
:I incorrectly get:
And if I just instantiate a Vector3 before both of these:
I once again correctly get:
My guess from this behaviour:
I wonder if accessing
this.position
first is internally causing the creation of a Vector3 type that's somehow different than the Vector3 that's imported? And maybe that's being cached so that subsequentnew Vector3()
calls return that cached class rather than theVector3
from the import? And if we donew Vector3()
first, then that's what gets saved to the cache (and sothis.position
matches the importedVector3
)?The text was updated successfully, but these errors were encountered: