From d9d8a7d3ea66d6f23c248a01dae3ed1e92cb25bd Mon Sep 17 00:00:00 2001 From: D8H Date: Sat, 16 May 2026 13:38:28 +0200 Subject: [PATCH] Fix a regression on the displayed position of custom objects (#8604) --- GDJS/Runtime/RuntimeCustomObjectLayer.ts | 3 ++- GDJS/Runtime/RuntimeLayer.ts | 9 +++++++++ GDJS/Runtime/pixi-renderers/layer-pixi-renderer.ts | 9 ++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/GDJS/Runtime/RuntimeCustomObjectLayer.ts b/GDJS/Runtime/RuntimeCustomObjectLayer.ts index 02442911f2..6767bd0e3c 100644 --- a/GDJS/Runtime/RuntimeCustomObjectLayer.ts +++ b/GDJS/Runtime/RuntimeCustomObjectLayer.ts @@ -25,7 +25,8 @@ namespace gdjs { // Let the renderer do its final set up: this._renderer.onCreated(); - this._renderer.updatePosition(); + // We don't call `this._renderer.updatePosition` because the camera has + // no effect unless it's moved. } override onGameResolutionResized( diff --git a/GDJS/Runtime/RuntimeLayer.ts b/GDJS/Runtime/RuntimeLayer.ts index e536a2a188..f14e70078a 100644 --- a/GDJS/Runtime/RuntimeLayer.ts +++ b/GDJS/Runtime/RuntimeLayer.ts @@ -281,9 +281,18 @@ namespace gdjs { * @returns the scene the layer belongs to directly or indirectly */ getRuntimeScene(): gdjs.RuntimeScene { + // TODO Check that method is not wrongly called instead of `getInstanceContainer`. return this._runtimeScene.getScene(); } + /** + * Returns the scene the layer directly belongs + * @returns the scene the layer directly belongs + */ + getInstanceContainer(): gdjs.RuntimeInstanceContainer { + return this._runtimeScene; + } + /** * Called at each frame, after events are run and before rendering. */ diff --git a/GDJS/Runtime/pixi-renderers/layer-pixi-renderer.ts b/GDJS/Runtime/pixi-renderers/layer-pixi-renderer.ts index a714b50521..d80f611b43 100644 --- a/GDJS/Runtime/pixi-renderers/layer-pixi-renderer.ts +++ b/GDJS/Runtime/pixi-renderers/layer-pixi-renderer.ts @@ -829,7 +829,8 @@ namespace gdjs { } updatePosition(): void { - const runtimeGame = this._layer.getRuntimeScene().getGame(); + const instanceContainer = this._layer.getInstanceContainer(); + const runtimeGame = instanceContainer.getGame(); // Update the 3D camera position and rotation. if (this._threeCamera) { @@ -921,8 +922,10 @@ namespace gdjs { const centerY = this._layer.getCameraX() * effectivePixiZoom * angleSinValue + this._layer.getCameraY() * effectivePixiZoom * angleCosValue; - this._pixiContainer.position.x = this._layer.getWidth() / 2 - centerX; - this._pixiContainer.position.y = this._layer.getHeight() / 2 - centerY; + this._pixiContainer.position.x = + instanceContainer.getViewportOriginX() - centerX; + this._pixiContainer.position.y = + instanceContainer.getViewportOriginY() - centerY; } // Pixel rounding for the Pixi rendering (be it for 2D only