Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fission/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"noUselessCatch": "error",
"noUselessEscapeInRegex": "error",
"noUselessThisAlias": "error",
"noUselessTypeConstraint": "error"
"noUselessTypeConstraint": "error",
"noUselessFragments": "error"
},
"correctness": {
"noConstAssign": "error",
Expand Down
22 changes: 10 additions & 12 deletions fission/src/ui/UIProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,16 @@ export const UIProvider: React.FC<UIProviderProps> = ({ children }) => {
const addToast = useCallback(
(variant: VariantType, ...contents: SnackbarMessage[]) => {
enqueueSnackbar(
contents.length <= 1 ? (
<>{...contents}</>
) : (
<>
{...contents.map(child => (
<>
{child}
<br />
</>
))}
</>
),
contents.length <= 1
? { ...contents }
: {
...contents.map(child => (
<>
{child}
<br />
</>
)),
},
{ variant, action: snackbarAction }
)
},
Expand Down
6 changes: 3 additions & 3 deletions fission/src/ui/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const ContextMenu: React.FC = () => {
})
}, [])

return !state ? (
<></>
) : (
if (!state) return null

return (
<Stack
key="CANCEL"
component="div"
Expand Down
6 changes: 3 additions & 3 deletions fission/src/ui/components/DragModeIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const DragModeIndicator: React.FC = () => {
globalAddToast("info", "Drag Mode", "Drag mode has been disabled")
}

return enabled ? (
if (!enabled) return null

return (
<Stack
className="select-none absolute left-1 bottom-1 py-2 px-4 rounded-lg gap-2 cursor-pointer hover:opacity-80 transition-opacity"
direction="row"
Expand All @@ -32,8 +34,6 @@ const DragModeIndicator: React.FC = () => {
Drag Mode
</Label>
</Stack>
) : (
<></>
)
}

Expand Down
2 changes: 1 addition & 1 deletion fission/src/ui/components/ProgressNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const ProgressNotifications: React.FC = () => {
gap: "0.5rem",
}}
>
{progressElements ?? <></>}
{progressElements}
</Box>
)
}
Expand Down
2 changes: 1 addition & 1 deletion fission/src/ui/components/SceneOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SceneOverlay: React.FC = () => {

/* h1 text for each tagMap tag */
const [components, updateComponents] = useReducer(() => {
if (isDisabled) return <></> // if the overlay is disabled, return nothing
if (isDisabled) return null

return [...tagMap.values()].map(x => (
<div
Expand Down
40 changes: 20 additions & 20 deletions fission/src/ui/components/TransformGizmoControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@ const TransformGizmoControl: React.FC<TransformGizmoControlProps> = ({
}, [gizmo, onAccept, onCancel])

// If there are no modes enabled, consider the UI pointless.
return disableOptions ? undefined : (
<>
<ToggleButtonGroup
value={mode}
exclusive
onChange={(_, v) => {
if (v == null) return
if (disableOptions) return null

setMode(v)
gizmo?.setMode(v)
}}
sx={{
...(sx ?? {}),
alignSelf: "center",
display: "flex",
justifyContent: "center",
}}
>
{buttons}
</ToggleButtonGroup>
</>
return (
<ToggleButtonGroup
value={mode}
exclusive
onChange={(_, v) => {
if (v == null) return

setMode(v)
gizmo?.setMode(v)
}}
sx={{
...(sx ?? {}),
alignSelf: "center",
display: "flex",
justifyContent: "center",
}}
>
{buttons}
</ToggleButtonGroup>
)
}

Expand Down
52 changes: 25 additions & 27 deletions fission/src/ui/modals/configuring/inputs/NewInputSchemeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,31 @@ const NewInputSchemeModal: React.FC<ModalImplProps<void, void>> = ({ modal }) =>
}

return (
<>
<Stack gap={2}>
<TextField
label="Name"
placeholder=""
value={name}
onChange={handleNameChange}
error={nameError}
helperText={nameErrorText}
/>
<FormControl fullWidth>
<InputLabel id="drive-type-label">Drive Type</InputLabel>
<Select
labelId="drive-type-label"
label="Drive Type"
value={type}
onChange={e => setType(e.target.value as DriveType)}
>
{[DriveType.TANK, DriveType.ARCADE, DriveType.SWERVE, DriveType.MECANUM].map(dt => (
<MenuItem key={dt} value={dt}>
{dt}
</MenuItem>
))}
</Select>
</FormControl>
</Stack>
</>
<Stack gap={2}>
<TextField
label="Name"
placeholder=""
value={name}
onChange={handleNameChange}
error={nameError}
helperText={nameErrorText}
/>
<FormControl fullWidth>
<InputLabel id="drive-type-label">Drive Type</InputLabel>
<Select
labelId="drive-type-label"
label="Drive Type"
value={type}
onChange={e => setType(e.target.value as DriveType)}
>
{[DriveType.TANK, DriveType.ARCADE, DriveType.SWERVE, DriveType.MECANUM].map(dt => (
<MenuItem key={dt} value={dt}>
{dt}
</MenuItem>
))}
</Select>
</FormControl>
</Stack>
)
}

Expand Down
4 changes: 1 addition & 3 deletions fission/src/ui/panels/WsViewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const WSViewPanel: React.FC<PanelImplProps<void, void>> = ({ panel }) => {
))}
</Select>
{/* {deviceSelect} */}
{selectedDevice ? (
{selectedDevice && (
<Box>
<TextField placeholder="Field Name" onChange={e => setField(e.target.value)} />
<TextField placeholder="Value" onChange={e => setValue(e.target.value)} />
Expand All @@ -196,8 +196,6 @@ const WSViewPanel: React.FC<PanelImplProps<void, void>> = ({ panel }) => {
Set
</Button>
</Box>
) : (
<></>
)}
</Stack>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,48 +124,48 @@ const ConfigureGamepieceEjectorInterface: ConfigurationSubpanelComponent = ({
}, [])

const gizmoComponent = useMemo(() => {
if (selectedAssembly?.ejectorPreferences) {
const postGizmoCreation = (gizmo: GizmoSceneObject) => {
const material = (gizmo.obj as THREE.Mesh).material as THREE.Material
material.depthTest = false

const deltaTransformation = convertArrayToThreeMatrix4(
selectedAssembly.ejectorPreferences!.deltaTransformation
)

let nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(
selectedAssembly.ejectorPreferences!.parentNode ?? selectedAssembly.rootNodeId
)
if (!nodeBodyId) {
// In the event that something about the id generation for the rigid nodes changes and parent node id is no longer in use
nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(selectedAssembly.rootNodeId)!
}

/** W = L x R. See save() for math details */
const robotTransformation = convertJoltMat44ToThreeMatrix4(
World.physicsSystem.getBody(nodeBodyId)!.GetWorldTransform()
)
const gizmoTransformation = deltaTransformation.premultiply(robotTransformation)

gizmo.obj.position.setFromMatrixPosition(gizmoTransformation)
gizmo.obj.rotation.setFromRotationMatrix(gizmoTransformation)
if (!selectedAssembly?.ejectorPreferences) {
gizmoRef.current = undefined
return null
}

const postGizmoCreation = (gizmo: GizmoSceneObject) => {
const material = (gizmo.obj as THREE.Mesh).material as THREE.Material
material.depthTest = false

const deltaTransformation = convertArrayToThreeMatrix4(
selectedAssembly.ejectorPreferences!.deltaTransformation
)

let nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(
selectedAssembly.ejectorPreferences!.parentNode ?? selectedAssembly.rootNodeId
)
if (!nodeBodyId) {
// In the event that something about the id generation for the rigid nodes changes and parent node id is no longer in use
nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(selectedAssembly.rootNodeId)!
}

return (
<TransformGizmoControl
key="shot-transform-gizmo"
size={1.5}
gizmoRef={gizmoRef}
defaultMode="translate"
defaultMesh={placeholderMesh}
scaleDisabled={true}
postGizmoCreation={postGizmoCreation}
/>
/** W = L x R. See save() for math details */
const robotTransformation = convertJoltMat44ToThreeMatrix4(
World.physicsSystem.getBody(nodeBodyId)!.GetWorldTransform()
)
} else {
gizmoRef.current = undefined
return <></>
const gizmoTransformation = deltaTransformation.premultiply(robotTransformation)

gizmo.obj.position.setFromMatrixPosition(gizmoTransformation)
gizmo.obj.rotation.setFromRotationMatrix(gizmoTransformation)
}

return (
<TransformGizmoControl
key="shot-transform-gizmo"
size={1.5}
gizmoRef={gizmoRef}
defaultMode="translate"
defaultMesh={placeholderMesh}
scaleDisabled={true}
postGizmoCreation={postGizmoCreation}
/>
)
}, [
placeholderMesh,
selectedAssembly.ejectorPreferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,48 +147,48 @@ const ConfigureGamepieceIntakeInterface: ConfigurationSubpanelComponent = ({
}, [])

const gizmoComponent = useMemo(() => {
if (selectedAssembly?.intakePreferences) {
const postGizmoCreation = (gizmo: GizmoSceneObject) => {
const material = (gizmo.obj as THREE.Mesh).material as THREE.Material
material.depthTest = false

const deltaTransformation = convertArrayToThreeMatrix4(
selectedAssembly.intakePreferences!.deltaTransformation
)

let nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(
selectedAssembly.intakePreferences!.parentNode ?? selectedAssembly.rootNodeId
)
if (!nodeBodyId) {
// In the event that something about the id generation for the rigid nodes changes and parent node id is no longer in use
nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(selectedAssembly.rootNodeId)!
}

/** W = L x R. See save() for math details */
const robotTransformation = convertJoltMat44ToThreeMatrix4(
World.physicsSystem.getBody(nodeBodyId)!.GetWorldTransform()
)
const gizmoTransformation = deltaTransformation.premultiply(robotTransformation)

gizmo.setTransform(gizmoTransformation)
if (!selectedAssembly?.intakePreferences) {
gizmoRef.current = undefined
return null
}

const postGizmoCreation = (gizmo: GizmoSceneObject) => {
const material = (gizmo.obj as THREE.Mesh).material as THREE.Material
material.depthTest = false

const deltaTransformation = convertArrayToThreeMatrix4(
selectedAssembly.intakePreferences!.deltaTransformation
)

let nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(
selectedAssembly.intakePreferences!.parentNode ?? selectedAssembly.rootNodeId
)
if (!nodeBodyId) {
// In the event that something about the id generation for the rigid nodes changes and parent node id is no longer in use
nodeBodyId = selectedAssembly.mechanism.nodeToBody.get(selectedAssembly.rootNodeId)!
}

return (
<TransformGizmoControl
key="pickup-transform-gizmo"
size={1.5}
gizmoRef={gizmoRef}
defaultMode="translate"
defaultMesh={placeholderMesh}
scaleDisabled={true}
rotateDisabled={true}
postGizmoCreation={postGizmoCreation}
/>
/** W = L x R. See save() for math details */
const robotTransformation = convertJoltMat44ToThreeMatrix4(
World.physicsSystem.getBody(nodeBodyId)!.GetWorldTransform()
)
} else {
gizmoRef.current = undefined
return <></>
const gizmoTransformation = deltaTransformation.premultiply(robotTransformation)

gizmo.setTransform(gizmoTransformation)
}

return (
<TransformGizmoControl
key="pickup-transform-gizmo"
size={1.5}
gizmoRef={gizmoRef}
defaultMode="translate"
defaultMesh={placeholderMesh}
scaleDisabled={true}
rotateDisabled={true}
postGizmoCreation={postGizmoCreation}
/>
)
}, [
selectedAssembly.intakePreferences,
placeholderMesh,
Expand Down
Loading
Loading