Skip to content

Commit

Permalink
Merge branch 'dev' into barclah/context-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay committed Nov 9, 2024
2 parents fc474d9 + 9a27ecf commit ad6cb23
Show file tree
Hide file tree
Showing 71 changed files with 2,353 additions and 1,091 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def readFromDesign(self) -> "ExporterOptions":
for field in fields(self):
attribute = designAttributes.itemByName(INTERNAL_ID, field.name)
if attribute:
attrJsonData = makeObjectFromJson(field.type, json.loads(attribute.value))
attrJsonData = makeObjectFromJson(type(field.type), json.loads(attribute.value))
setattr(self, field.name, attrJsonData)

return self
Expand Down
2 changes: 1 addition & 1 deletion exporter/SynthesisFusionAddin/src/Types.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def makeObjectFromJson(objType: type, data: Any) -> Any:
assert is_dataclass(obj) and isinstance(data, dict), "Found unsupported type to decode."
for field in fields(obj):
if field.name in data:
setattr(obj, field.name, makeObjectFromJson(field.type, data[field.name]))
setattr(obj, field.name, makeObjectFromJson(type(field.type), data[field.name]))
else:
setattr(obj, field.name, field.default_factory if field.default_factory is not MISSING else field.default)

Expand Down
4 changes: 3 additions & 1 deletion fission/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"jsdom": "^24.1.0",
Expand All @@ -73,10 +74,11 @@
"prettier": "3.3.2",
"protobufjs": "^7.2.6",
"protobufjs-cli": "^1.1.2",
"rollup": "^4.22.4",
"tailwindcss": "^3.3.3",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.4.5",
"vite": "^5.1.4",
"vite": "5.2.14",
"vite-plugin-glsl": "^1.3.0",
"vite-plugin-singlefile": "^0.13.5",
"vitest": "^1.5.3"
Expand Down
10 changes: 4 additions & 6 deletions fission/src/Synthesis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ import ChooseInputSchemePanel from "./ui/panels/configuring/ChooseInputSchemePan
import ProgressNotifications from "./ui/components/ProgressNotification.tsx"
import SceneOverlay from "./ui/components/SceneOverlay.tsx"

import WPILibWSWorker from "@/systems/simulation/wpilib_brain/WPILibWSWorker.ts?worker"
import WSViewPanel from "./ui/panels/WSViewPanel.tsx"
import Lazy from "./util/Lazy.ts"

import RCConfigPWMGroupModal from "@/modals/configuring/rio-config/RCConfigPWMGroupModal.tsx"
import RCConfigCANGroupModal from "@/modals/configuring/rio-config/RCConfigCANGroupModal.tsx"
Expand All @@ -62,8 +60,8 @@ import APSManagementModal from "./ui/modals/APSManagementModal.tsx"
import ConfigurePanel from "./ui/panels/configuring/assembly-config/ConfigurePanel.tsx"
import CameraSelectionPanel from "./ui/panels/configuring/CameraSelectionPanel.tsx"
import ContextMenu from "./ui/components/ContextMenu.tsx"

const worker = new Lazy<Worker>(() => new WPILibWSWorker())
import GlobalUIComponent from "./ui/components/GlobalUIComponent.tsx"
import InitialConfigPanel from "./ui/panels/configuring/initial-config/InitialConfigPanel.tsx"

function Synthesis() {
const { openModal, closeModal, getActiveModalElement } = useModalManager(initialModals)
Expand Down Expand Up @@ -95,8 +93,6 @@ function Synthesis() {
setConsentPopupDisable(false)
}

worker.getValue()

let mainLoopHandle = 0
const mainLoop = () => {
mainLoopHandle = requestAnimationFrame(mainLoop)
Expand Down Expand Up @@ -164,6 +160,7 @@ function Synthesis() {
closeAllPanels={closeAllPanels}
>
<ToastProvider key="toast-provider">
<GlobalUIComponent />
<Scene useStats={import.meta.env.DEV} key="scene-in-toast-provider" />
<SceneOverlay />
<ContextMenu />
Expand Down Expand Up @@ -232,6 +229,7 @@ const initialPanels: ReactElement[] = [
<DebugPanel key="debug" panelId="debug" />,
<ConfigurePanel key="configure" panelId="configure" />,
<CameraSelectionPanel key="camera-select" panelId="camera-select" />,
<InitialConfigPanel key="initial-config" panelId="initial-config" />,
]

export default Synthesis
26 changes: 13 additions & 13 deletions fission/src/aps/APS.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import World from "@/systems/World"
import { MainHUD_AddToast } from "@/ui/components/MainHUD"
import { Global_AddToast } from "@/ui/components/GlobalUIControls"
import { Mutex } from "async-mutex"

const APS_AUTH_KEY = "aps_auth"
Expand All @@ -14,7 +14,7 @@ export const ENDPOINT_SYNTHESIS_CHALLENGE = `/api/aps/challenge`

const ENDPOINT_AUTODESK_AUTHENTICATION_AUTHORIZE = "https://developer.api.autodesk.com/authentication/v2/authorize"
const ENDPOINT_AUTODESK_AUTHENTICATION_TOKEN = "https://developer.api.autodesk.com/authentication/v2/token"
const ENDPOINT_AUTODESK_REVOKE_TOKEN = "https://developer.api.autodesk.com/authentication/v2/revoke"
const ENDPOINT_AUTODESK_AUTHENTICATION_REVOKE = "https://developer.api.autodesk.com/authentication/v2/revoke"
const ENDPOINT_AUTODESK_USERINFO = "https://api.userprofile.autodesk.com/userinfo"

export interface APSAuth {
Expand Down Expand Up @@ -163,7 +163,7 @@ class APS {
["client_id", CLIENT_ID],
] as string[][]),
}
const res = await fetch(ENDPOINT_AUTODESK_REVOKE_TOKEN, opts)
const res = await fetch(ENDPOINT_AUTODESK_AUTHENTICATION_REVOKE, opts)
if (!res.ok) {
console.log("Failed to revoke auth token:\n")
return false
Expand Down Expand Up @@ -205,7 +205,7 @@ class APS {
} catch (e) {
console.error(e)
World.AnalyticsSystem?.Exception("APS Login Failure")
MainHUD_AddToast("error", "Error signing in.", "Please try again.")
Global_AddToast?.("error", "Error signing in.", "Please try again.")
}
})
}
Expand Down Expand Up @@ -236,7 +236,7 @@ class APS {
const json = await res.json()
if (!res.ok) {
if (shouldRelog) {
MainHUD_AddToast("warning", "Must Re-signin.", json.userMessage)
Global_AddToast?.("warning", "Must Re-signin.", json.userMessage)
this.auth = undefined
await this.requestAuthCode()
return false
Expand All @@ -249,13 +249,13 @@ class APS {
if (this.auth) {
await this.loadUserInfo(this.auth)
if (APS.userInfo) {
MainHUD_AddToast("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
Global_AddToast?.("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
}
}
return true
} catch (e) {
World.AnalyticsSystem?.Exception("APS Login Failure")
MainHUD_AddToast("error", "Error signing in.", "Please try again.")
Global_AddToast?.("error", "Error signing in.", "Please try again.")
this.auth = undefined
await this.requestAuthCode()
return false
Expand All @@ -281,7 +281,7 @@ class APS {
const json = await res.json()
if (!res.ok) {
World.AnalyticsSystem?.Exception("APS Login Failure")
MainHUD_AddToast("error", "Error signing in.", json.userMessage)
Global_AddToast?.("error", "Error signing in.", json.userMessage)
this.auth = undefined
return
}
Expand All @@ -293,7 +293,7 @@ class APS {
if (auth) {
await this.loadUserInfo(auth)
if (APS.userInfo) {
MainHUD_AddToast("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
Global_AddToast?.("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
}
} else {
console.error("Couldn't get auth data.")
Expand All @@ -306,7 +306,7 @@ class APS {
if (retry_login) {
this.auth = undefined
World.AnalyticsSystem?.Exception("APS Login Failure")
MainHUD_AddToast("error", "Error signing in.", "Please try again.")
Global_AddToast?.("error", "Error signing in.", "Please try again.")
}
}

Expand All @@ -327,7 +327,7 @@ class APS {
const json = await res.json()
if (!res.ok) {
World.AnalyticsSystem?.Exception("APS Failure: User Info")
MainHUD_AddToast("error", "Error fetching user data.", json.userMessage)
Global_AddToast?.("error", "Error fetching user data.", json.userMessage)
this.auth = undefined
await this.requestAuthCode()
return
Expand All @@ -347,7 +347,7 @@ class APS {
} catch (e) {
console.error(e)
World.AnalyticsSystem?.Exception("APS Login Failure: User Info")
MainHUD_AddToast("error", "Error signing in.", "Please try again.")
Global_AddToast?.("error", "Error signing in.", "Please try again.")
this.auth = undefined
}
}
Expand All @@ -363,7 +363,7 @@ class APS {
} catch (e) {
console.error(e)
World.AnalyticsSystem?.Exception("APS Login Failure: Code Challenge")
MainHUD_AddToast("error", "Error signing in.", "Please try again.")
Global_AddToast?.("error", "Error signing in.", "Please try again.")
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions fission/src/aps/APSDataManagement.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { MainHUD_AddToast } from "@/ui/components/MainHUD"
import { Global_AddToast } from "@/ui/components/GlobalUIControls"
import APS from "./APS"
import TaskStatus from "@/util/TaskStatus"
import { Mutex } from "async-mutex"
Expand Down Expand Up @@ -140,9 +140,9 @@ export async function getHubs(): Promise<Hub[] | undefined> {
console.log(auth)
console.log(APS.userInfo)
if (e instanceof APSDataError) {
MainHUD_AddToast("error", e.title, e.detail)
Global_AddToast?.("error", e.title, e.detail)
} else if (e instanceof Error) {
MainHUD_AddToast("error", "Failed to get hubs.", e.message)
Global_AddToast?.("error", "Failed to get hubs.", e.message)
}
return undefined
}
Expand Down Expand Up @@ -179,7 +179,7 @@ export async function getProjects(hub: Hub): Promise<Project[] | undefined> {
} catch (e) {
console.error("Failed to get hubs")
if (e instanceof Error) {
MainHUD_AddToast("error", "Failed to get hubs.", e.message)
Global_AddToast?.("error", "Failed to get hubs.", e.message)
}
return undefined
}
Expand Down Expand Up @@ -224,7 +224,7 @@ export async function getFolderData(project: Project, folder: Folder): Promise<D
} catch (e) {
console.error("Failed to get folder data")
if (e instanceof Error) {
MainHUD_AddToast("error", "Failed to get folder data.", e.message)
Global_AddToast?.("error", "Failed to get folder data.", e.message)
}
return undefined
}
Expand All @@ -250,7 +250,7 @@ export async function searchFolder(project: Project, folder: Folder, filters?: F
},
})
if (!res.ok) {
MainHUD_AddToast("error", "Error getting cloud files.", "Please sign in again.")
Global_AddToast?.("error", "Error getting cloud files.", "Please sign in again.")
return []
}
const json = await res.json()
Expand Down
2 changes: 0 additions & 2 deletions fission/src/mirabuf/MirabufInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ class MirabufInstance {
}
}

console.debug(batchMap)

// Construct batched meshes
batchMap.forEach((materialBodyMap, material) => {
const count = countMap.get(material)!
Expand Down
Loading

0 comments on commit ad6cb23

Please sign in to comment.