Skip to content

Commit

Permalink
refactored assetpack script (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Jun 28, 2024
2 parents 3df3929 + b825c05 commit 8037724
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 71 deletions.
4 changes: 1 addition & 3 deletions fission/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
"playwright:install": "bun x playwright install || npx playwright install"
},
"dependencies": {
Expand Down
10 changes: 5 additions & 5 deletions fission/src/Synthesis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 3 additions & 4 deletions fission/src/systems/input/InputSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
8 changes: 4 additions & 4 deletions fission/src/systems/simulation/behavior/GenericArmBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions fission/src/systems/simulation/driver/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ abstract class Driver {

export enum DriverControlMode {
Velocity = 0,
Position = 1
Position = 1,
}

export default Driver;
export default Driver
4 changes: 2 additions & 2 deletions fission/src/systems/simulation/driver/HingeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -82,4 +82,4 @@ class HingeDriver extends Driver {
}
}

export default HingeDriver
export default HingeDriver
46 changes: 23 additions & 23 deletions fission/src/systems/simulation/driver/SliderDriver.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}
}

Expand All @@ -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)
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions fission/src/ui/components/MainHUD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ const MainHUD: React.FC = () => {
icon={<IoPeople />}
onClick={() => openModal("import-local-mirabuf")}
/>
<MainHUDButton
value={"Test God Mode"}
icon={<IoGameControllerOutline />}
onClick={TestGodMode}
/>
<MainHUDButton value={"Test God Mode"} icon={<IoGameControllerOutline />} onClick={TestGodMode} />
</div>
<div className="flex flex-col gap-0 bg-background w-full rounded-3xl">
<MainHUDButton
Expand Down
42 changes: 22 additions & 20 deletions fission/src/ui/modals/mirabuf/ImportLocalMirabufModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,36 @@ const ImportLocalMirabufModal: React.FC<ModalPropsImpl> = ({ 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)
}
})
}
}
}}
>
<div className="flex flex-col items-center gap-5">
<input ref={fileUploadRef} onChange={onInputChanged} type="file" hidden={true} />
<Button value="Upload" size={ButtonSize.Large} onClick={uploadClicked} />
{
selectedFile
? (<Label className="text-center" size={LabelSize.Medium}>{`Selected File: ${selectedFile.name}`}</Label>)
: (<></>)
}
{selectedFile ? (
<Label
className="text-center"
size={LabelSize.Medium}
>{`Selected File: ${selectedFile.name}`}</Label>
) : (
<></>
)}
</div>
</Modal>
)
}

export default ImportLocalMirabufModal
export default ImportLocalMirabufModal

0 comments on commit 8037724

Please sign in to comment.