-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
Version
- Phaser Version: v3.90.0
- Operating system: Windows 11
- Browser: Electron 33.2.1
Description
Light positions become offset when the main camera rotation is set to any value other than 0.
In LightPipeline.js:200-202, the light position calculation applies scroll and zoom factors manually after using cameraMatrix.transformPoint(). This double-transformation causes incorrect positioning when the camera is rotated, since the camera matrix already handles rotation, scroll, and zoom together.
Additional Information
Current problematic code:
cameraMatrix.transformPoint(light.x, light.y, tempVec2);
this.set2f(lightName + 'position', tempVec2.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (tempVec2.y - (camera.scrollY * light.scrollFactorY) * camera.zoom));
Expected behavior: Lights should maintain their correct world positions regardless of camera rotation.
Actual behavior: Lights appear to drift/offset as the camera moves when camera.setRotation() is non-zero.
Fix: Apply scroll factors before matrix transformation when camera is rotated, letting the camera matrix handle all transformations together.