Changing targetScreenOffset of clone, changes it on the clone origin

I just found a small bug, when creating a clone of an ArcRotateCamera and updating the targetScreenOffset, to reproduce:

  • Create ArcRotateCamera
  • Clone the camera
  • Log targetScreenOffset of source camera
  • Update targetScreenOffset on cloned camera
  • Log targetScreenOffset of source camera

The value of the second log changed, although it was updated on the cloned camera. Probably the original and clone hold a reference to the same Vector2

Playground (check the console logs):

1 Like

thanks a lot for the thorough report I ll fix it tonight :slight_smile:


I believe, the targetScreenOffset property is incorrectly identified by the serializable decorator and it marks the property as a value based so it doesn’t clone the object just sets the reference on the clone to the existing Vector2:


The author of the code will help more here! :slight_smile:

:stuck_out_tongue: I am late :smiley:

Should be fixed in the next nightly Fix camera targetScreenOffset serialization by sebavan · Pull Request #12078 · BabylonJS/Babylon.js · GitHub

1 Like

Yeah sure! I was reliefed I finally found the bug I was hunting for an hour :grimacing: Thanks for the quick fix and keep up the good work :+1:


Enjoy the cake! I had my first anniversary yesterday and had a real cake to celebrate :smiley:

1 Like