1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

initial take on wire auto-rotation

This commit is contained in:
tobspr
2020-08-11 20:02:59 +02:00
parent a32c0530bb
commit f16ab2389a
18 changed files with 1022 additions and 811 deletions

View File

@@ -683,3 +683,33 @@ export function generateMatrixRotations(originalMatrix) {
return result;
}
/**
*
* @typedef {{
* top: any,
* right: any,
* bottom: any,
* left: any
* }} DirectionalObject
*/
/**
* Rotates a directional object
* @param {DirectionalObject} obj
* @returns {DirectionalObject}
*/
export function rotateDirectionalObject(obj, rotation) {
const queue = [obj.top, obj.right, obj.bottom, obj.left];
while (rotation !== 0) {
rotation -= 90;
queue.push(queue.shift());
}
return {
top: queue[0],
right: queue[1],
bottom: queue[2],
left: queue[3],
};
}