From 7b8c524ea2a7a12b8cf42dbb9797f3b9c75c2ff9 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Thu, 27 Jun 2024 14:54:56 -0700 Subject: [PATCH] refactored assetpack script --- fission/package.json | 4 +- fission/src/Synthesis.tsx | 10 ++-- fission/src/systems/input/InputSystem.ts | 7 ++- .../simulation/behavior/GenericArmBehavior.ts | 8 ++-- .../behavior/GenericElevatorBehavior.ts | 6 +-- .../src/systems/simulation/driver/Driver.ts | 4 +- .../systems/simulation/driver/HingeDriver.ts | 4 +- .../systems/simulation/driver/SliderDriver.ts | 46 +++++++++---------- fission/src/ui/components/MainHUD.tsx | 6 +-- .../mirabuf/ImportLocalMirabufModal.tsx | 42 +++++++++-------- 10 files changed, 66 insertions(+), 71 deletions(-) diff --git a/fission/package.json b/fission/package.json index ebad07f4fa..cf0709ab36 100644 --- a/fission/package.json +++ b/fission/package.json @@ -14,9 +14,7 @@ "prettier:fix": "bun run prettier --write || npm run prettier --write", "format": "(bun run prettier:fix && bun run lint:fix) || (npm run prettier:fix && npm run lint:fix)", "build:prod": "tsc && vite build --base=/fission/", - "assetpack": "run-script-os", - "assetpack:nix": "curl -o public/assetpack.zip https://synthesis.autodesk.com/Downloadables/assetpack.zip && unzip -o public/assetpack.zip -d public/", - "assetpack:win32": "curl -o public/assetpack.zip https://synthesis.autodesk.com/Downloadables/assetpack.zip && tar -xf public/assetpack.zip -C public/" + "assetpack": "curl -o public/assetpack.zip https://synthesis.autodesk.com/Downloadables/assetpack.zip && tar -xf public/assetpack.zip -C public/" }, "dependencies": { "@barclah/jolt-physics": "^0.19.3", diff --git a/fission/src/Synthesis.tsx b/fission/src/Synthesis.tsx index daefd9f9be..b8fe36241f 100644 --- a/fission/src/Synthesis.tsx +++ b/fission/src/Synthesis.tsx @@ -49,11 +49,11 @@ import ScoringZonesPanel from "@/panels/configuring/scoring/ScoringZonesPanel" import ZoneConfigPanel from "@/panels/configuring/scoring/ZoneConfigPanel" import ScoreboardPanel from "@/panels/information/ScoreboardPanel" import DriverStationPanel from "@/panels/simulation/DriverStationPanel" -import ManageAssembliesModal from '@/modals/spawning/ManageAssembliesModal.tsx'; -import World from '@/systems/World.ts'; -import { AddRobotsModal, AddFieldsModal, SpawningModal } from '@/modals/spawning/SpawningModals.tsx'; -import ImportMirabufModal from '@/modals/mirabuf/ImportMirabufModal.tsx'; -import ImportLocalMirabufModal from '@/modals/mirabuf/ImportLocalMirabufModal.tsx'; +import ManageAssembliesModal from "@/modals/spawning/ManageAssembliesModal.tsx" +import World from "@/systems/World.ts" +import { AddRobotsModal, AddFieldsModal, SpawningModal } from "@/modals/spawning/SpawningModals.tsx" +import ImportMirabufModal from "@/modals/mirabuf/ImportMirabufModal.tsx" +import ImportLocalMirabufModal from "@/modals/mirabuf/ImportLocalMirabufModal.tsx" const DEFAULT_MIRA_PATH = "/api/mira/Robots/Team 2471 (2018)_v7.mira" diff --git a/fission/src/systems/input/InputSystem.ts b/fission/src/systems/input/InputSystem.ts index 8535301569..e6cc14e498 100644 --- a/fission/src/systems/input/InputSystem.ts +++ b/fission/src/systems/input/InputSystem.ts @@ -121,10 +121,9 @@ class InputSystem extends WorldSystem { } // Returns true if two modifier states are identical - private static CompareModifiers(state1: ModifierState, state2: ModifierState) : boolean { - if (!state1 || !state2) - return false; - + private static CompareModifiers(state1: ModifierState, state2: ModifierState): boolean { + if (!state1 || !state2) return false + return ( state1.alt == state2.alt && state1.ctrl == state2.ctrl && diff --git a/fission/src/systems/simulation/behavior/GenericArmBehavior.ts b/fission/src/systems/simulation/behavior/GenericArmBehavior.ts index 5f38eb14c6..890dfb4325 100644 --- a/fission/src/systems/simulation/behavior/GenericArmBehavior.ts +++ b/fission/src/systems/simulation/behavior/GenericArmBehavior.ts @@ -6,10 +6,10 @@ import InputSystem, { emptyModifierState } from "@/systems/input/InputSystem" class GenericArmBehavior extends Behavior { private _hingeDriver: HingeDriver - private _positiveInput: string; - private _negativeInput: string; - - private _rotationalSpeed = 6; + private _positiveInput: string + private _negativeInput: string + + private _rotationalSpeed = 6 constructor(hingeDriver: HingeDriver, hingeStimulus: HingeStimulus, jointIndex: number) { super([hingeDriver], [hingeStimulus]) diff --git a/fission/src/systems/simulation/behavior/GenericElevatorBehavior.ts b/fission/src/systems/simulation/behavior/GenericElevatorBehavior.ts index 2b9f41936b..e31282a28c 100644 --- a/fission/src/systems/simulation/behavior/GenericElevatorBehavior.ts +++ b/fission/src/systems/simulation/behavior/GenericElevatorBehavior.ts @@ -9,7 +9,7 @@ class GenericElevatorBehavior extends Behavior { private _positiveInput: string private _negativeInput: string - private _linearSpeed = 2.5; + private _linearSpeed = 2.5 constructor(sliderDriver: SliderDriver, sliderStimulus: SliderStimulus, jointIndex: number) { super([sliderDriver], [sliderStimulus]) @@ -35,11 +35,11 @@ class GenericElevatorBehavior extends Behavior { // Changes the elevators target position moveElevator(linearVelocity: number) { - this._sliderDriver.targetVelocity = linearVelocity; + this._sliderDriver.targetVelocity = linearVelocity } public Update(_: number): void { - this.moveElevator(InputSystem.GetAxis(this._positiveInput, this._negativeInput)*this._linearSpeed); + this.moveElevator(InputSystem.GetAxis(this._positiveInput, this._negativeInput) * this._linearSpeed) } } diff --git a/fission/src/systems/simulation/driver/Driver.ts b/fission/src/systems/simulation/driver/Driver.ts index 400b7bde30..d7c27e292e 100644 --- a/fission/src/systems/simulation/driver/Driver.ts +++ b/fission/src/systems/simulation/driver/Driver.ts @@ -4,7 +4,7 @@ abstract class Driver { export enum DriverControlMode { Velocity = 0, - Position = 1 + Position = 1, } -export default Driver; \ No newline at end of file +export default Driver diff --git a/fission/src/systems/simulation/driver/HingeDriver.ts b/fission/src/systems/simulation/driver/HingeDriver.ts index 4500508490..d092e67296 100644 --- a/fission/src/systems/simulation/driver/HingeDriver.ts +++ b/fission/src/systems/simulation/driver/HingeDriver.ts @@ -21,7 +21,7 @@ class HingeDriver extends Driver { return this._targetAngle } public set targetAngle(rads: number) { - this._targetAngle = Math.max(this._constraint.GetLimitsMin(), Math.min(this._constraint.GetLimitsMax(), rads)); + this._targetAngle = Math.max(this._constraint.GetLimitsMin(), Math.min(this._constraint.GetLimitsMax(), rads)) } public set minTorqueLimit(nm: number) { @@ -82,4 +82,4 @@ class HingeDriver extends Driver { } } -export default HingeDriver \ No newline at end of file +export default HingeDriver diff --git a/fission/src/systems/simulation/driver/SliderDriver.ts b/fission/src/systems/simulation/driver/SliderDriver.ts index 2ad547a831..5f05a9adca 100644 --- a/fission/src/systems/simulation/driver/SliderDriver.ts +++ b/fission/src/systems/simulation/driver/SliderDriver.ts @@ -1,21 +1,20 @@ -import Jolt from "@barclah/jolt-physics"; -import Driver, { DriverControlMode } from "./Driver"; -import { SIMULATION_PERIOD } from "@/systems/physics/PhysicsSystem"; -import JOLT from "@/util/loading/JoltSyncLoader"; +import Jolt from "@barclah/jolt-physics" +import Driver, { DriverControlMode } from "./Driver" +import { SIMULATION_PERIOD } from "@/systems/physics/PhysicsSystem" +import JOLT from "@/util/loading/JoltSyncLoader" class SliderDriver extends Driver { + private _constraint: Jolt.SliderConstraint - private _constraint: Jolt.SliderConstraint; - - private _controlMode: DriverControlMode = DriverControlMode.Velocity; - private _targetVelocity: number = 0.0; - private _targetPosition: number = 0.0; + private _controlMode: DriverControlMode = DriverControlMode.Velocity + private _targetVelocity: number = 0.0 + private _targetPosition: number = 0.0 public get targetVelocity(): number { - return this._targetVelocity; + return this._targetVelocity } public set targetVelocity(radsPerSec: number) { - this._targetVelocity = radsPerSec; + this._targetVelocity = radsPerSec } public get targetPosition(): number { @@ -38,21 +37,21 @@ class SliderDriver extends Driver { } public get controlMode(): DriverControlMode { - return this._controlMode; + return this._controlMode } - + public set controlMode(mode: DriverControlMode) { - this._controlMode = mode; + this._controlMode = mode switch (mode) { case DriverControlMode.Velocity: - this._constraint.SetMotorState(JOLT.EMotorState_Velocity); - break; + this._constraint.SetMotorState(JOLT.EMotorState_Velocity) + break case DriverControlMode.Position: - this._constraint.SetMotorState(JOLT.EMotorState_Position); - break; + this._constraint.SetMotorState(JOLT.EMotorState_Position) + break default: // idk - break; + break } } @@ -71,13 +70,14 @@ class SliderDriver extends Driver { motorSettings.mMaxForceLimit = 900.0 this._constraint.SetMotorState(JOLT.EMotorState_Velocity) - this.controlMode = DriverControlMode.Velocity; + this.controlMode = DriverControlMode.Velocity } - public Update(_: number): void {if (this._controlMode == DriverControlMode.Velocity) { - this._constraint.SetTargetVelocity(this._targetVelocity); + public Update(_: number): void { + if (this._controlMode == DriverControlMode.Velocity) { + this._constraint.SetTargetVelocity(this._targetVelocity) } else if (this._controlMode == DriverControlMode.Position) { - this._constraint.SetTargetPosition(this._targetPosition); + this._constraint.SetTargetPosition(this._targetPosition) } } } diff --git a/fission/src/ui/components/MainHUD.tsx b/fission/src/ui/components/MainHUD.tsx index 64b9e88c0f..16d9d98070 100644 --- a/fission/src/ui/components/MainHUD.tsx +++ b/fission/src/ui/components/MainHUD.tsx @@ -125,11 +125,7 @@ const MainHUD: React.FC = () => { icon={} onClick={() => openModal("import-local-mirabuf")} /> - } - onClick={TestGodMode} - /> + } onClick={TestGodMode} />
= ({ modalId }) => { modalId={modalId} acceptEnabled={selectedFile !== undefined} onAccept={() => { - if (selectedFile) { - console.log(`Mira: '${selectedFile}'`) - showTooltip("controls", [ - { control: "WASD", description: "Drive" }, - { control: "E", description: "Intake" }, - { control: "Q", description: "Dispense" }, - ]) + if (selectedFile) { + console.log(`Mira: '${selectedFile}'`) + showTooltip("controls", [ + { control: "WASD", description: "Drive" }, + { control: "E", description: "Intake" }, + { control: "Q", description: "Dispense" }, + ]) - CreateMirabufFromUrl(URL.createObjectURL(selectedFile)).then(x => { - if (x) { - World.SceneRenderer.RegisterSceneObject(x) - } - }) - } + CreateMirabufFromUrl(URL.createObjectURL(selectedFile)).then(x => { + if (x) { + World.SceneRenderer.RegisterSceneObject(x) + } + }) } - } + }} >
) } -export default ImportLocalMirabufModal \ No newline at end of file +export default ImportLocalMirabufModal