Rotate landscape 180 degrees
This commit is contained in:
1 parent
6eff1aaa9c
commit
dc8e745ed4
1 file changed
+12
-2
+12
-2
@@ -37,6 +37,15 @@
|
||||
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);
|
||||
resize();
|
||||
|
||||
@@ -52,9 +61,10 @@
|
||||
}
|
||||
|
||||
project() {
|
||||
const rotated = rotatePoint(this, Math.PI);
|
||||
const scale = camera.fov / (camera.fov + this.z);
|
||||
const xIso = this.x - this.z;
|
||||
const yIso = (this.x + this.z) * 0.5;
|
||||
const xIso = rotated.x - rotated.z;
|
||||
const yIso = (rotated.x + rotated.z) * 0.5;
|
||||
const x2d = xIso * scale + width / 2;
|
||||
const y2d = yIso * scale + height / 2;
|
||||
return { x: x2d, y: y2d, scale: scale };
|
||||
|
||||
Reference in new issue
Block a user