Last active
November 12, 2021 15:43
-
-
Save dinosoeren/37a22743b73dbc953d18f3fabaff4ef4 to your computer and use it in GitHub Desktop.
mirrorEventsX - mirror ats choreo events and switch handedness (AudioTrip)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as ATS from '@hn3000/ats-types' | |
/** | |
* Mirrors ats choreo events X-pos across Y-axis and switches handedness. | |
* Works for all gems including ribbons! also rotates drums and dirgems. | |
*/ | |
export const mirrorEventsX = (events: ATS.IChoreoEvent[]): ATS.IChoreoEvent[] => { | |
const newEvents: ATS.IChoreoEvent[] = []; | |
for (let i = 0; i < events.length; i++) { | |
const t = events[i].type; | |
newEvents.push({ | |
type: t === 0 ? 0 : (t % 2 === 1 ? t + 1 : t - 1), | |
hasGuide: events[i].hasGuide, | |
time: events[i].time, | |
beatDivision: events[i].beatDivision, | |
position: { | |
x: -events[i].position.x, | |
y: events[i].position.y, | |
z: events[i].position.z, | |
}, | |
subPositions: events[i].subPositions.map( | |
(subPos: {x: number, y: number, z: number}) => | |
({ | |
x: t < 5 ? -subPos.x : subPos.x, // rotate drums and dirgems | |
y: t < 5 ? subPos.y : -subPos.y, // rotate drums and dirgems | |
z: subPos.z, | |
}) | |
), | |
broadcastEventID: events[i].broadcastEventID, | |
}); | |
} | |
return newEvents; | |
}; | |
/** | |
* Mirrors ats choreo events X-pos across Y-axis *without* switching handedness. | |
* Works for all gems including ribbons! also rotates drums and dirgems. | |
*/ | |
export const mirrorEventsXNoHands = (events: ATS.IChoreoEvent[]): ATS.IChoreoEvent[] => { | |
const newEvents: ATS.IChoreoEvent[] = []; | |
for (let i = 0; i < events.length; i++) { | |
const t = events[i].type; | |
newEvents.push({ | |
type: t, | |
hasGuide: events[i].hasGuide, | |
time: events[i].time, | |
beatDivision: events[i].beatDivision, | |
position: { | |
x: -events[i].position.x, | |
y: events[i].position.y, | |
z: events[i].position.z, | |
}, | |
subPositions: events[i].subPositions.map( | |
(subPos: {x: number, y: number, z: number}) => | |
({ | |
x: t < 5 ? -subPos.x : subPos.x, // rotate drums and dirgems | |
y: t < 5 ? subPos.y : -subPos.y, // rotate drums and dirgems | |
z: subPos.z, | |
}) | |
), | |
broadcastEventID: events[i].broadcastEventID, | |
}); | |
} | |
return newEvents; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment