Given
<canvas
width='100' height='100'
style='padding:100px'
></canvas>
Expected
engine.getRenderWidth() // 100
Actual
engine.getRenderWidth() // 300
CSS paddings is just a deco, it should not interfere with buffer size, right?
Given
<canvas
width='100' height='100'
style='padding:100px'
></canvas>
Expected
engine.getRenderWidth() // 100
Actual
engine.getRenderWidth() // 300
CSS paddings is just a deco, it should not interfere with buffer size, right?
The engine is using the clientREct to get the size of the buffer:
yes, here’s the problem, .clientWidth
includes paddings!
Imagine that window .innerWidth
is 1000px
canvas is 50vw wide (=500px), with paddings 25vw (=250px each)
canvas.clientWidth // 1000 (paddings included)
engine.getRenderWidth() // 1000 (paddings included)
Is it expected, or a mis-calc?
(I expected that render width should be 500px)
It is expected…Since the origin of babylon.js (7 years ago) ;D