I recently updated my (large nontrivial) project from Babylon 5.2.0
to 5.13.2
, and I started seeing an occasional bug. About 50% of the time, when the scene first initializes it looks like the camera is weirdly zoomed in on the lower-left part of the scene. The issue seems to be related to canvas
properties, because if I change the width or height of the canvas that Babylon is rendering into, the scene starts rendering correctly.
In trying to isolate the bug, I noticed by accident that running the following code also fixes the issue:
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')
ctx.clearRect(0, 0, canvas.width, canvas.height)
var url = canvas.toDataURL('image/png')
That code isn’t touching babylon at all, so I suppose something magical may be going on - perhaps related to babylon listening for DOM events related to canvas elements, or similar.
Does anyone have any idea what might be going on? I never had the issue in 5.2
, so I suppose it’s related to a relatively recent update.
Thanks!