Fixing DomElement position when camera zoom != 1

When the camera zoom is set to any other value than one, if a dom element origin
if set to anything other than 0, the final position of the DOM was incorrect.

I traced this back to the DOMElementCSSRenderer.
After some trial and error, I realized the translation needed to be applied after camera multiplication
and not at the beginning.

With this change, DOMElements are correctly positioned.
This commit is contained in:
David Négrier 2024-05-15 16:25:28 +02:00
parent 1ba01834ff
commit 0bcc71d469

View file

@ -85,7 +85,7 @@ var DOMElementCSSRenderer = function (renderer, src, camera, parentMatrix)
dx = (src.width) * src.originX;
dy = (src.height) * src.originY;
srcMatrix.applyITRS(src.x - dx, src.y - dy, src.rotation, src.scaleX, src.scaleY);
srcMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
camMatrix.copyFrom(camera.matrix);
@ -97,6 +97,9 @@ var DOMElementCSSRenderer = function (renderer, src, camera, parentMatrix)
// Multiply by the src matrix, store result in calcMatrix
camMatrix.multiply(srcMatrix, calcMatrix);
calcMatrix.e -= dx;
calcMatrix.f -= dy;
}
if (!src.transformOnly)