Rotate landscape 180 degrees

This commit is contained in:
Richard Zink committed 2026-10-06 15:53:09 +02:00
1 parent 6eff1aaa9c
commit dc8e745ed4
1 file changed
+12 -2
+12 -2
View File
@@ -37,6 +37,15 @@
height = canvas.height = window.innerHeight; height = canvas.height = window.innerHeight;
} }
function rotatePoint(point, angle) {
const cos = Math.cos(angle);
const sin = Math.sin(angle);
return {
x: point.x * cos - point.z * sin,
z: point.x * sin + point.z * cos
};
}
window.addEventListener('resize', resize); window.addEventListener('resize', resize);
resize(); resize();
@@ -52,9 +61,10 @@
} }
project() { project() {
const rotated = rotatePoint(this, Math.PI);
const scale = camera.fov / (camera.fov + this.z); const scale = camera.fov / (camera.fov + this.z);
const xIso = this.x - this.z; const xIso = rotated.x - rotated.z;
const yIso = (this.x + this.z) * 0.5; const yIso = (rotated.x + rotated.z) * 0.5;
const x2d = xIso * scale + width / 2; const x2d = xIso * scale + width / 2;
const y2d = yIso * scale + height / 2; const y2d = yIso * scale + height / 2;
return { x: x2d, y: y2d, scale: scale }; return { x: x2d, y: y2d, scale: scale };