Skip to content

Commit ebc77eb

Browse files
committed
v4.0.2
1 parent b2119ae commit ebc77eb

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## v4.0.2 - 2025-10-24
4+
5+
### Fixed
6+
- **Orthographic camera resize handling**: Fixed window resize listener to properly update orthographic cameras
7+
- Resize event now updates orthographic camera frustum (left, right, top, bottom) based on new window dimensions
8+
- Previously only perspective cameras were updated on resize, causing 2D games to stretch when window was resized
9+
- `camera_2d()` cameras now maintain correct aspect ratio and scale across all window sizes
10+
311
## v4.0.1 - 2025-10-24
412

513
### Fixed

gleam.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "tiramisu"
2-
version = "4.0.1"
2+
version = "4.0.2"
33
target = "javascript"
44
description = "A 3D game framework for building performant web games in Gleam"
55
licences = ["MIT"]

src/threejs.ffi.mjs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,23 @@ export function createRenderer(options) {
158158
renderer.setSize(window.innerWidth, window.innerHeight);
159159
renderer.setPixelRatio(window.devicePixelRatio || 1);
160160

161-
// Update active camera aspect ratio if it exists
161+
// Update active camera if it exists
162162
const camera = getActiveCamera();
163-
if (camera && camera.isPerspectiveCamera) {
164-
camera.aspect = window.innerWidth / window.innerHeight;
165-
camera.updateProjectionMatrix();
163+
if (camera) {
164+
if (camera.isPerspectiveCamera) {
165+
// Update perspective camera aspect ratio
166+
camera.aspect = window.innerWidth / window.innerHeight;
167+
camera.updateProjectionMatrix();
168+
} else if (camera.isOrthographicCamera) {
169+
// Update orthographic camera frustum
170+
const width = window.innerWidth;
171+
const height = window.innerHeight;
172+
camera.left = -width / 2;
173+
camera.right = width / 2;
174+
camera.top = height / 2;
175+
camera.bottom = -height / 2;
176+
camera.updateProjectionMatrix();
177+
}
166178
}
167179
});
168180
}

0 commit comments

Comments
 (0)