Skip to content

Commit

Permalink
Revert all this madness
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonPacewic committed Jun 21, 2024
1 parent 1eaa4a2 commit 5814e58
Show file tree
Hide file tree
Showing 107 changed files with 9,349 additions and 9,103 deletions.
4 changes: 2 additions & 2 deletions fission/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ npm i
| `lint` | Runs eslint on the project. |
| `lint:fix` | Attempts to fix issues found with eslint. |
| `prettier` | Runs prettier on the project as a check. |
| `prettier:fix` | Runs prettier on the project to fix any issues with formating. |
| `format` | Runs `prettier:fix` and `lint:fix`. |
| `prettier:fix` | Runs prettier on the project to fix any issues with formating. **DO NOT USE**, I don't like the current format it uses. |
| `format` | Runs `prettier:fix` and `lint:fix`. **Do not use** for the same reasons as `prettier:fix`. |
| `assetpack` | Downloads the assetpack and unzips/installs it in the correct location. |

### Autodesk Platform Services
Expand Down
Binary file modified fission/bun.lockb
Binary file not shown.
185 changes: 88 additions & 97 deletions fission/package-lock.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions fission/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
},
"dependencies": {
"@barclah/jolt-physics": "^0.19.3",
"@mui/base": "^5.0.0-beta.40",
"@mui/icons-material": "^5.15.20",
"@mui/system": "^5.15.20",
"@react-three/drei": "^9.96.5",
"@react-three/fiber": "^8.15.15",
"@vitest/coverage-v8": "^1.6.0",
Expand Down
1 change: 0 additions & 1 deletion fission/prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const config = {
bracketSpacing: true,
bracketSameLine: false,
arrowParens: "avoid",
printWidth: 120
}

export default config;
269 changes: 175 additions & 94 deletions fission/src/Synthesis.tsx
Original file line number Diff line number Diff line change
@@ -1,71 +1,74 @@
import Scene from "./components/Scene.tsx"
import MirabufSceneObject from "./mirabuf/MirabufSceneObject.ts"
import { LoadMirabufRemote } from "./mirabuf/MirabufLoader.ts"
import { mirabuf } from "./proto/mirabuf"
import MirabufParser, { ParseErrorSeverity } from "./mirabuf/MirabufParser.ts"
import MirabufInstance from "./mirabuf/MirabufInstance.ts"
import { AnimatePresence } from "framer-motion"
import Scene from '@/components/Scene.tsx';
import MirabufSceneObject from './mirabuf/MirabufSceneObject.ts';
import { LoadMirabufRemote } from './mirabuf/MirabufLoader.ts';
import { mirabuf } from './proto/mirabuf';
import MirabufParser, { ParseErrorSeverity } from './mirabuf/MirabufParser.ts';
import MirabufInstance from './mirabuf/MirabufInstance.ts';
import { AnimatePresence, motion } from "framer-motion"
import { ReactElement, useEffect } from "react"
import { ModalControlProvider, useModalManager } from "./ModalContext"
import { PanelControlProvider, usePanelManager } from "./PanelContext"
import { useTheme } from "./ThemeContext"
import { ToastContainer, ToastProvider } from "./ToastContext"
import { ModalControlProvider, useModalManager } from "@/ui/ModalContext"
import { PanelControlProvider, usePanelManager } from "@/ui/PanelContext"
import { useTheme } from "@/ui/ThemeContext"
import { ToastContainer, ToastProvider } from "@/ui/ToastContext"
import {
TOOLTIP_DURATION,
TooltipControl,
TooltipControlProvider,
TooltipType,
useTooltipManager,
} from "./TooltipContext"
import MainHUD from "./components/MainHUD"
import DownloadAssetsModal from "./modals/DownloadAssetsModal"
import ExitSynthesisModal from "./modals/ExitSynthesisModal"
import MatchResultsModal from "./modals/MatchResultsModal"
import UpdateAvailableModal from "./modals/UpdateAvailableModal"
import ViewModal from "./modals/ViewModal"
import ConnectToMultiplayerModal from "./modals/aether/ConnectToMultiplayerModal"
import ServerHostingModal from "./modals/aether/ServerHostingModal"
import ChangeInputsModal from "./modals/configuring/ChangeInputsModal"
import ChooseMultiplayerModeModal from "./modals/configuring/ChooseMultiplayerModeModal"
import ChooseSingleplayerModeModal from "./modals/configuring/ChooseSingleplayerModeModal"
import ConfigMotorModal from "./modals/configuring/ConfigMotorModal"
import DrivetrainModal from "./modals/configuring/DrivetrainModal"
import PracticeSettingsModal from "./modals/configuring/PracticeSettingsModal"
import RoboRIOModal from "./modals/configuring/RoboRIOModal"
import SettingsModal from "./modals/configuring/SettingsModal"
import RCConfigEncoderModal from "./modals/configuring/rio-config/RCConfigEncoderModal"
import RCConfigPwmGroupModal from "./modals/configuring/rio-config/RCConfigPwmGroupModal"
import RCCreateDeviceModal from "./modals/configuring/rio-config/RCCreateDeviceModal"
import DeleteAllThemesModal from "./modals/configuring/theme-editor/DeleteAllThemesModal"
import DeleteThemeModal from "./modals/configuring/theme-editor/DeleteThemeModal"
import NewThemeModal from "./modals/configuring/theme-editor/NewThemeModal"
import ThemeEditorModal from "./modals/configuring/theme-editor/ThemeEditorModal"
import MatchModeModal from "./modals/spawning/MatchModeModal"
import RobotSwitchPanel from "./panels/RobotSwitchPanel"
import SpawnLocationsPanel from "./panels/SpawnLocationPanel"
import ConfigureGamepiecePickupPanel from "./panels/configuring/ConfigureGamepiecePickupPanel"
import ConfigureShotTrajectoryPanel from "./panels/configuring/ConfigureShotTrajectoryPanel"
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"

const DEFAULT_MIRA_PATH = "/api/mira/Robots/Team 2471 (2018)_v7.mira"
} from "@/ui/TooltipContext"
import MainHUD from "@/components/MainHUD"
import DownloadAssetsModal from "@/modals/DownloadAssetsModal"
import ExitSynthesisModal from "@/modals/ExitSynthesisModal"
import MatchResultsModal from "@/modals/MatchResultsModal"
import UpdateAvailableModal from "@/modals/UpdateAvailableModal"
import ViewModal from "@/modals/ViewModal"
import ConnectToMultiplayerModal from "@/modals/aether/ConnectToMultiplayerModal"
import ServerHostingModal from "@/modals/aether/ServerHostingModal"
import ChangeInputsModal from "@/modals/configuring/ChangeInputsModal"
import ChooseMultiplayerModeModal from "@/modals/configuring/ChooseMultiplayerModeModal"
import ChooseSingleplayerModeModal from "@/modals/configuring/ChooseSingleplayerModeModal"
import ConfigMotorModal from "@/modals/configuring/ConfigMotorModal"
import DrivetrainModal from "@/modals/configuring/DrivetrainModal"
import PracticeSettingsModal from "@/modals/configuring/PracticeSettingsModal"
import RoboRIOModal from "@/modals/configuring/RoboRIOModal"
import SettingsModal from "@/modals/configuring/SettingsModal"
import RCConfigEncoderModal from "@/modals/configuring/rio-config/RCConfigEncoderModal"
import RCConfigPwmGroupModal from "@/modals/configuring/rio-config/RCConfigPwmGroupModal"
import RCCreateDeviceModal from "@/modals/configuring/rio-config/RCCreateDeviceModal"
import DeleteAllThemesModal from "@/modals/configuring/theme-editor/DeleteAllThemesModal"
import DeleteThemeModal from "@/modals/configuring/theme-editor/DeleteThemeModal"
import NewThemeModal from "@/modals/configuring/theme-editor/NewThemeModal"
import ThemeEditorModal from "@/modals/configuring/theme-editor/ThemeEditorModal"
import MatchModeModal from "@/modals/spawning/MatchModeModal"
import RobotSwitchPanel from "@/panels/RobotSwitchPanel"
import SpawnLocationsPanel from "@/panels/SpawnLocationPanel"
import ConfigureGamepiecePickupPanel from "@/panels/configuring/ConfigureGamepiecePickupPanel"
import ConfigureShotTrajectoryPanel from "@/panels/configuring/ConfigureShotTrajectoryPanel"
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';

const DEFAULT_MIRA_PATH = '/api/mira/Robots/Team 2471 (2018)_v7.mira';

function Synthesis() {
const urlParams = new URLSearchParams(document.location.search)
if (urlParams.has("code")) {
const code = urlParams.get("code")

const urlParams = new URLSearchParams(document.location.search);
if (urlParams.has('code')) {
const code = urlParams.get('code')
window.opener?.setAuthCode(code)
window.close()
}

const { openModal, closeModal, getActiveModalElement } = useModalManager(initialModals)
const { openPanel, closePanel, closeAllPanels, getActivePanelElements } = usePanelManager(initialPanels)

const { openModal, closeModal, getActiveModalElement } =
useModalManager(initialModals)
const { openPanel, closePanel, closeAllPanels, getActivePanelElements } =
usePanelManager(initialPanels)
const { showTooltip } = useTooltipManager()

const { currentTheme, applyTheme } = useTheme()
Expand All @@ -74,64 +77,141 @@ function Synthesis() {
applyTheme(currentTheme)
}, [currentTheme, applyTheme])


const panelElements = getActivePanelElements()

const motionPanelElements = panelElements.map((el, i) => (
<motion.div
initial={{
scale: 0,
opacity: 0,
width: "min-content",
height: "min-content",
}}
animate={{
scale: 1,
opacity: 1,
width: "min-content",
height: "min-content",
}}
exit={{
scale: 0,
opacity: 0,
width: "min-content",
height: "min-content",
}}
transition={{
type: "spring",
stiffness: 300,
damping: 20,
}}
style={{ translateX: "-50%", translateY: "-50%" }}
className="absolute left-1/2 top-1/2"
key={"panel-" + i}
>
{el}
</motion.div>
))

const modalElement = getActiveModalElement()
const motionModalElement =
modalElement == null ? null : (
<motion.div
initial={{
scale: 0,
opacity: 0,
width: "min-content",
height: "min-content",
}}
animate={{
scale: 1,
opacity: 1,
width: "min-content",
height: "min-content",
}}
exit={{
scale: 0,
opacity: 0,
width: "min-content",
height: "min-content",
}}
transition={{
type: "spring",
stiffness: 300,
damping: 25,
}}
style={{ translateX: "-50%", translateY: "-50%" }}
className="absolute left-1/2 top-1/2"
key={"modal"}
>
{getActiveModalElement()}
</motion.div>
)

useEffect(() => {
World.InitWorld()


useEffect(() => {

World.InitWorld();

let mira_path = DEFAULT_MIRA_PATH
let mira_path = DEFAULT_MIRA_PATH;

const urlParams = new URLSearchParams(document.location.search)
const urlParams = new URLSearchParams(document.location.search);

if (urlParams.has("mira")) {
mira_path = `test_mira/${urlParams.get("mira")!}`
console.debug(`Selected Mirabuf File: ${mira_path}`)
mira_path = `test_mira/${urlParams.get("mira")!}`;
console.debug(`Selected Mirabuf File: ${mira_path}`);
}
console.log(urlParams)

const setup = async () => {
const miraAssembly = await LoadMirabufRemote(mira_path)
.catch(_ => LoadMirabufRemote(DEFAULT_MIRA_PATH))
.catch(console.error)
const setup = async () => {

const miraAssembly = await LoadMirabufRemote(mira_path)
.catch(
_ => LoadMirabufRemote(DEFAULT_MIRA_PATH)
).catch(console.error);

await (async () => {
if (!miraAssembly || !(miraAssembly instanceof mirabuf.Assembly)) {
return
return;
}

const parser = new MirabufParser(miraAssembly)
const parser = new MirabufParser(miraAssembly);
if (parser.maxErrorSeverity >= ParseErrorSeverity.Unimportable) {
console.error(`Assembly Parser produced significant errors for '${miraAssembly.info!.name!}'`)
return
console.error(`Assembly Parser produced significant errors for '${miraAssembly.info!.name!}'`);
return;
}

const mirabufSceneObject = new MirabufSceneObject(new MirabufInstance(parser));
World.SceneRenderer.RegisterSceneObject(mirabufSceneObject);
})();
};
setup();

const mirabufSceneObject = new MirabufSceneObject(new MirabufInstance(parser))
World.SceneRenderer.RegisterSceneObject(mirabufSceneObject)
})()
}
setup()

let mainLoopHandle = 0
const mainLoop = () => {
mainLoopHandle = requestAnimationFrame(mainLoop)

World.UpdateWorld()
}
mainLoop()
let mainLoopHandle = 0;
const mainLoop = () => {
mainLoopHandle = requestAnimationFrame(mainLoop);

World.UpdateWorld();
};
mainLoop();
// Cleanup
return () => {
// TODO: Teardown literally everything
cancelAnimationFrame(mainLoopHandle)
World.DestroyWorld()
cancelAnimationFrame(mainLoopHandle);
World.DestroyWorld();
// World.SceneRenderer.RemoveAllSceneObjects();
}
}, [])
};
}, []);

return (
<AnimatePresence>
<TooltipControlProvider
showTooltip={(type: TooltipType, controls?: TooltipControl[], duration: number = TOOLTIP_DURATION) => {
showTooltip={(
type: TooltipType,
controls?: TooltipControl[],
duration: number = TOOLTIP_DURATION
) => {
showTooltip(type, controls, duration)
}}
>
Expand All @@ -149,10 +229,11 @@ function Synthesis() {
}}
>
<ToastProvider>
<Scene useStats={true} />
<Scene useStats={true} />
<MainHUD />
{panelElements.length > 0 && panelElements}
{modalElement && <div className="absolute w-full h-full left-0 top-0">{modalElement}</div>}
{motionPanelElements.length > 0 &&
motionPanelElements}
{motionModalElement && motionModalElement}
<ToastContainer />
</ToastProvider>
</PanelControlProvider>
Expand Down Expand Up @@ -195,7 +276,7 @@ const initialModals = [
]

const initialPanels: ReactElement[] = [
<RobotSwitchPanel panelId="multibot" openLocation="right" sidePadding={8} />,
<RobotSwitchPanel panelId="multibot" />,
<DriverStationPanel panelId="driver-station" />,
<SpawnLocationsPanel panelId="spawn-locations" />,
<ScoreboardPanel panelId="scoreboard" />,
Expand All @@ -205,4 +286,4 @@ const initialPanels: ReactElement[] = [
<ZoneConfigPanel panelId="zone-config" />,
]

export default Synthesis
export default Synthesis;
4 changes: 2 additions & 2 deletions fission/src/Window.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare interface Window {
setAuthCode(code: string): void
}
setAuthCode(code: string): void;
}
Loading

0 comments on commit 5814e58

Please sign in to comment.