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:
@@ -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],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user