Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/gameobjects/domelement/DOMElementCSSRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ var DOMElementCSSRenderer = function (renderer, src, camera, parentMatrix)
var srcMatrix = tempMatrix2;
var calcMatrix = tempMatrix3;

var dx = src.width * src.originX;
var dy = src.height * src.originY;
// Bake the (scale-aware) origin offset into the matrix and keep `transform-origin` at 0,0.
// This is what the `parentMatrix` branch already did; applying it to scene-level elements too
// keeps both paths consistent. Previously the scene-level (else) branch set
// `transform-origin: (100 * origin)%` while ALSO baking the offset into the matrix below,
// applying the origin offset twice. The two only cancel at camera zoom 1, so under camera
// zoom the element drifted by `origin * size * (1 - zoom)`.
var dx = src.width * src.originX * src.scaleX;
var dy = src.height * src.originY * src.scaleY;

var tx = '0%';
var ty = '0%';
Expand All @@ -76,13 +82,6 @@ var DOMElementCSSRenderer = function (renderer, src, camera, parentMatrix)
if (parentMatrix)
{
camMatrix.multiply(parentMatrix);
dx *= src.scaleX;
dy *= src.scaleY;
}
else
{
tx = (100 * src.originX) + '%';
ty = (100 * src.originY) + '%';
}

camMatrix.translate(-dx, -dy);
Expand Down