`PIXI 8` tilemap moves the wrong distance when `app.stage.position` updated
I added the following code in examples/demo/basic.js to make it support mouse dragging, but the tilemap moved incorrectly by twice the distance.
await app.init({
width: 800,
height: 600,
preference: searchParams.get('preference') || 'webgl',
hello: true
});
const tilemap = new PIXI.tilemap.CompositeTilemap();
// ------------------------------------------------- added code -------------------------------------------------
let panPos = undefined;
app.canvas.addEventListener('mousemove', (e) => {
if (!panPos) return;
app.stage.position.x += e.pageX - panPos.x;
app.stage.position.y += e.pageY - panPos.y;
panPos = { x: e.pageX, y: e.pageY };
});
app.canvas.addEventListener('mousedown', (e) => {
panPos = { x: e.pageX, y: e.pageY };
});
app.canvas.addEventListener('mouseup', (e) => {
panPos = undefined;
});
// ------------------------------------------------- added code end -------------------------------------------------
document.body.appendChild(app.canvas);
app.stage.addChild(tilemap);
examples of issue
It can be found that the Sprite added directly on the stage can follow the movement of the mouse very well, but the tilemap moves at twice the distance. After my test, modifying the stage.scale also has similar problems.
I also hit this issue and the related PR fixes this. The composite tilemap wasn't following parent camera container position as it was previously. It only seemed to be an issue when I was changing the zIndex higher than the 'player' it was tracking against though which was unusual.
I also hit this issue with a completely different scenario. If you add some pixi filter to a sprite, all CompositeTilemap sprites with a higher zIndex will be inverted offset of the filtered sprite. The PR referenced in this fix also resolves the issue.
https://github.com/user-attachments/assets/f52b5c20-f14d-4040-97f4-9d816b5b90ce