When initializing the engine with adaptToDeviceRatio: true, the value of engine.adaptToDeviceRatio logs as false

When initializing the engine with adaptToDeviceRatio: true, the value of engine.adaptToDeviceRatio logs as false.

image

Hi,

The option is correctly taken into account for the Viewport, but the attribute is updated only if you do a new Engine(canvas, antialias, options, adaptToDeviceRatio)

Thanks for reporting!

This was an engine-side state mismatch: adaptToDeviceRatio from the options object was used for the initial hardware scaling calculation, but engine.adaptToDeviceRatio was saved before that option was merged, so it stayed false.

I opened a PR to fix it: Fix adaptToDeviceRatio option state by Popov72 · Pull Request #18492 · BabylonJS/Babylon.js · GitHub

Until that lands, the workaround is to pass the value as the fourth constructor argument if you need the public flag / resize-time behavior to be set: new BABYLON.Engine(canvas, antialias, options, true).

Nice catch tho @Yasinli29, as it probably had unexpected effect when calling engine.resize ; if you don’t want to change your use of EngineFactory, and you trust the process, you can add something like:

engine.adaptToDeviceRatio = true; // FIXME workaround waiting for true fix

as adaptToDeviceRatio is a public attribute :innocent: