= ({ modalId }) => {
icon={}
modalId={modalId}
onAccept={() => {
- // showTooltip("controls", [
- // { control: "WASD", description: "Drive" },
- // { control: "E", description: "Intake" },
- // { control: "Q", description: "Dispense" },
- // ]);
- }
- }
+ // showTooltip("controls", [
+ // { control: "WASD", description: "Drive" },
+ // { control: "E", description: "Intake" },
+ // { control: "Q", description: "Dispense" },
+ // ]);
+ }}
>
- {
- selectedHub
- ? selectedFolder
- ? <>
- {
- !selectedHub
- ? hubs?.map(x => ItemCard({ name: x.name, id: x.id, buttonText: '>', onClick: () => setSelectedHub(x) }))
- : !selectedProject
- ? projects?.map(x => ItemCard({ name: x.name, id: x.id, buttonText: '>', onClick: () => setSelectedProject(x) }))
- : folderData?.map(x => x instanceof Folder
- ? ItemCard({ name: `DIR: ${x.displayName}`, id: x.id, buttonText: '>', onClick: () => setSelectedFolder(x) })
+ {!selectedHub
+ ? hubs?.map(x =>
+ ItemCard({
+ name: x.name,
+ id: x.id,
+ buttonText: ">",
+ onClick: () => setSelectedHub(x),
+ })
+ )
+ : !selectedProject
+ ? projects?.map(x =>
+ ItemCard({
+ name: x.name,
+ id: x.id,
+ buttonText: ">",
+ onClick: () => setSelectedProject(x),
+ })
+ )
+ : folderData?.map(x =>
+ x instanceof Folder
+ ? ItemCard({
+ name: `DIR: ${x.displayName}`,
+ id: x.id,
+ buttonText: ">",
+ onClick: () => setSelectedFolder(x),
+ })
: x instanceof Item
- ? ItemCard({ name: `${x.displayName}`, id: x.id, buttonText: 'import', onClick: () => { console.log(`Selecting ${x.displayName} (${x.id})`) } })
- : ItemCard({ name: `${x.type}: ${x.id}`, id: x.id, buttonText: '---', onClick: () => { console.log(`Selecting (${x.id})`) } })
- )
- }
+ ? ItemCard({
+ name: `${x.displayName}`,
+ id: x.id,
+ buttonText: "import",
+ onClick: () => {
+ console.log(`Selecting ${x.displayName} (${x.id})`)
+ },
+ })
+ : ItemCard({
+ name: `${x.type}: ${x.id}`,
+ id: x.id,
+ buttonText: "---",
+ onClick: () => {
+ console.log(`Selecting (${x.id})`)
+ },
+ })
+ )}
)
diff --git a/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx b/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx
index 7ae40b40c2..3031aec4c9 100644
--- a/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx
+++ b/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx
@@ -1,23 +1,29 @@
import React, { useReducer } from "react"
import Modal, { ModalPropsImpl } from "@/components/Modal"
import { FaPlus } from "react-icons/fa6"
-import Button from "@/components/Button";
-import Label, { LabelSize } from "@/components/Label";
-import World from "@/systems/World";
-import MirabufSceneObject from "@/mirabuf/MirabufSceneObject";
+import Button from "@/components/Button"
+import Label, { LabelSize } from "@/components/Label"
+import World from "@/systems/World"
+import MirabufSceneObject from "@/mirabuf/MirabufSceneObject"
interface AssemblyCardProps {
- id: number;
- update: React.DispatchWithoutAction;
+ id: number
+ update: React.DispatchWithoutAction
}
const AssemblyCard: React.FC = ({ id, update }) => {
return (
-
+
{ World.SceneRenderer.RemoveSceneObject(id); update() }}
+ onClick={() => {
+ World.SceneRenderer.RemoveSceneObject(id)
+ update()
+ }}
/>
)
@@ -27,9 +33,14 @@ const ManageAssembliesModal: React.FC
= ({ modalId }) => {
// update tooltip based on type of drivetrain, receive message from Synthesis
// const { showTooltip } = useTooltipControlContext()
- const [_, update] = useReducer((x) => !x, false)
+ const [_, update] = useReducer(x => !x, false)
- const assemblies = [...World.SceneRenderer.sceneObjects.entries()].filter(x => { const y = (x[1] instanceof MirabufSceneObject); return y }).map(x => x[0])
+ const assemblies = [...World.SceneRenderer.sceneObjects.entries()]
+ .filter(x => {
+ const y = x[1] instanceof MirabufSceneObject
+ return y
+ })
+ .map(x => x[0])
return (
= ({ modalId }) => {
icon={}
modalId={modalId}
onAccept={() => {
- // showTooltip("controls", [
- // { control: "WASD", description: "Drive" },
- // { control: "E", description: "Intake" },
- // { control: "Q", description: "Dispense" },
- // ]);
- }
- }
+ // showTooltip("controls", [
+ // { control: "WASD", description: "Drive" },
+ // { control: "E", description: "Intake" },
+ // { control: "Q", description: "Dispense" },
+ // ]);
+ }}
>
-
- {
- assemblies.map(x => AssemblyCard({id: x, update: update}))
- }
+
+ {assemblies.map(x => AssemblyCard({ id: x, update: update }))}
)
diff --git a/fission/src/ui/modals/spawning/SpawningModals.tsx b/fission/src/ui/modals/spawning/SpawningModals.tsx
index 3e716adc69..25d25efba2 100644
--- a/fission/src/ui/modals/spawning/SpawningModals.tsx
+++ b/fission/src/ui/modals/spawning/SpawningModals.tsx
@@ -10,23 +10,23 @@ import World from "@/systems/World"
import { useTooltipControlContext } from "@/ui/TooltipContext"
interface MirabufEntry {
- displayName: string;
- src: string;
+ displayName: string
+ src: string
}
interface MirabufCardProps {
- entry: MirabufEntry;
- select: (entry: MirabufEntry) => void;
+ entry: MirabufEntry
+ select: (entry: MirabufEntry) => void
}
const MirabufCard: React.FC = ({ entry, select }) => {
return (
-
+
- select(entry)}
- />
+ select(entry)} />
)
}
@@ -35,23 +35,31 @@ export const AddRobotsModal: React.FC
= ({ modalId }) => {
const { showTooltip } = useTooltipControlContext()
const { closeModal } = useModalControlContext()
- const [remoteRobots, setRemoteRobots] = useState(null);
+ const [remoteRobots, setRemoteRobots] = useState(null)
useEffect(() => {
(async () => {
- fetch('/api/mira/manifest.json').then(x => x.json()).then(x => {
- const robots: MirabufEntry[] = [];
- for (const src of x['robots']) {
- if (typeof(src) == 'string') {
- robots.push({ src: `/api/mira/Robots/${src}`, displayName: src })
- } else {
- robots.push({ src: src['src'], displayName: src['displayName'] })
+ fetch("/api/mira/manifest.json")
+ .then(x => x.json())
+ .then(x => {
+ const robots: MirabufEntry[] = []
+ for (const src of x["robots"]) {
+ if (typeof src == "string") {
+ robots.push({
+ src: `/api/mira/Robots/${src}`,
+ displayName: src,
+ })
+ } else {
+ robots.push({
+ src: src["src"],
+ displayName: src["displayName"],
+ })
+ }
}
- }
- setRemoteRobots(robots)
- })
+ setRemoteRobots(robots)
+ })
})()
- }, []);
+ }, [])
const selectRobot = (entry: MirabufEntry) => {
console.log(`Mira: '${entry.src}'`)
@@ -71,19 +79,12 @@ export const AddRobotsModal: React.FC = ({ modalId }) => {
}
return (
- }
- modalId={modalId}
- acceptEnabled={false}
- >
+ } modalId={modalId} acceptEnabled={false}>
-
- {
- remoteRobots
- ? remoteRobots!.map(x => MirabufCard({entry: x, select: selectRobot}))
- : (<>>)
- }
+
+ {remoteRobots ? remoteRobots!.map(x => MirabufCard({ entry: x, select: selectRobot })) : <>>}
)
@@ -92,23 +93,31 @@ export const AddRobotsModal: React.FC = ({ modalId }) => {
export const AddFieldsModal: React.FC = ({ modalId }) => {
const { closeModal } = useModalControlContext()
- const [remoteFields, setRemoteFields] = useState(null);
+ const [remoteFields, setRemoteFields] = useState(null)
useEffect(() => {
(async () => {
- fetch('/api/mira/manifest.json').then(x => x.json()).then(x => {
- const fields: MirabufEntry[] = [];
- for (const src of x['fields']) {
- if (typeof(src) == 'string') {
- fields.push({ src: `/api/mira/Fields/${src}`, displayName: src })
- } else {
- fields.push({ src: src['src'], displayName: src['displayName'] })
+ fetch("/api/mira/manifest.json")
+ .then(x => x.json())
+ .then(x => {
+ const fields: MirabufEntry[] = []
+ for (const src of x["fields"]) {
+ if (typeof src == "string") {
+ fields.push({
+ src: `/api/mira/Fields/${src}`,
+ displayName: src,
+ })
+ } else {
+ fields.push({
+ src: src["src"],
+ displayName: src["displayName"],
+ })
+ }
}
- }
- setRemoteFields(fields)
- })
+ setRemoteFields(fields)
+ })
})()
- }, []);
+ }, [])
const selectField = (entry: MirabufEntry) => {
console.log(`Mira: '${entry.src}'`)
@@ -122,19 +131,12 @@ export const AddFieldsModal: React.FC = ({ modalId }) => {
}
return (
- }
- modalId={modalId}
- acceptEnabled={false}
- >
+ } modalId={modalId} acceptEnabled={false}>
-
- {
- remoteFields
- ? remoteFields!.map(x => MirabufCard({entry: x, select: selectField}))
- : (<>>)
- }
+
+ {remoteFields ? remoteFields!.map(x => MirabufCard({ entry: x, select: selectField })) : <>>}
)
diff --git a/fission/src/ui/panels/RobotSwitchPanel.tsx b/fission/src/ui/panels/RobotSwitchPanel.tsx
index e440053589..d32ecba3f4 100644
--- a/fission/src/ui/panels/RobotSwitchPanel.tsx
+++ b/fission/src/ui/panels/RobotSwitchPanel.tsx
@@ -7,15 +7,18 @@ import Button from "@/components/Button"
import { useModalControlContext } from "@/ui/ModalContext"
import Checkbox from "@/components/Checkbox"
-const RobotSwitchPanel: React.FC = ({ panelId }) => {
- const [robots, setRobots] = useState([
- "Dozer_v9_0",
- "Team 2471 (2018) v7_0",
- ])
+const RobotSwitchPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
+ const [robots, setRobots] = useState(["Dozer_v9_0", "Team 2471 (2018) v7_0"])
const [selected, setSelected] = useState(0)
const { openModal } = useModalControlContext()
return (
- } panelId={panelId}>
+ }
+ panelId={panelId}
+ openLocation={openLocation}
+ sidePadding={sidePadding}
+ >
openModal("robots")} />
-
- setRobots(robots.filter(r => r !== robots[selected]))
- }
- />
+ setRobots(robots.filter(r => r !== robots[selected]))} />
)
diff --git a/fission/src/ui/panels/SpawnLocationPanel.tsx b/fission/src/ui/panels/SpawnLocationPanel.tsx
index 9e4a58f449..60b5718a18 100644
--- a/fission/src/ui/panels/SpawnLocationPanel.tsx
+++ b/fission/src/ui/panels/SpawnLocationPanel.tsx
@@ -2,7 +2,7 @@ import { useTooltipControlContext } from "@/ui/TooltipContext"
import Button from "@/components/Button"
import Panel, { PanelPropsImpl } from "@/components/Panel"
-const SpawnLocationsPanel: React.FC = ({ panelId }) => {
+const SpawnLocationsPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
const robotsPerAlliance = 3
const alliances = 2
@@ -13,7 +13,7 @@ const SpawnLocationsPanel: React.FC = ({ panelId }) => {
])
return (
-
+
{Array(alliances)
@@ -25,13 +25,9 @@ const SpawnLocationsPanel: React.FC = ({ panelId }) => {
.map((o: number, j: number) => (
|
))}
diff --git a/fission/src/ui/panels/configuring/ConfigureGamepiecePickupPanel.tsx b/fission/src/ui/panels/configuring/ConfigureGamepiecePickupPanel.tsx
index 97345d453b..534f9a54ab 100644
--- a/fission/src/ui/panels/configuring/ConfigureGamepiecePickupPanel.tsx
+++ b/fission/src/ui/panels/configuring/ConfigureGamepiecePickupPanel.tsx
@@ -4,9 +4,7 @@ import Panel, { PanelPropsImpl } from "@/components/Panel"
import SelectButton from "@/components/SelectButton"
import Slider from "@/components/Slider"
-const ConfigureGamepiecePickupPanel: React.FC = ({
- panelId,
-}) => {
+const ConfigureGamepiecePickupPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
const defaultZoneSize = 0.5
const [, setNode] = useState("Click to select")
const [, setZoneSize] = useState(defaultZoneSize)
@@ -16,6 +14,8 @@ const ConfigureGamepiecePickupPanel: React.FC = ({
name="Configure Pickup"
icon={}
panelId={panelId}
+ openLocation={openLocation}
+ sidePadding={sidePadding}
onAccept={() => {
// send zone config
}}
diff --git a/fission/src/ui/panels/configuring/ConfigureShotTrajectoryPanel.tsx b/fission/src/ui/panels/configuring/ConfigureShotTrajectoryPanel.tsx
index 2955bd35cc..29f493200b 100644
--- a/fission/src/ui/panels/configuring/ConfigureShotTrajectoryPanel.tsx
+++ b/fission/src/ui/panels/configuring/ConfigureShotTrajectoryPanel.tsx
@@ -4,9 +4,7 @@ import Panel, { PanelPropsImpl } from "@/components/Panel"
import SelectButton from "@/components/SelectButton"
import Slider from "@/components/Slider"
-const ConfigureShotTrajectoryPanel: React.FC = ({
- panelId,
-}) => {
+const ConfigureShotTrajectoryPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
const defaultShootSpeed = 5
const [, setNode] = useState("Click to select")
const [, setShootSpeed] = useState(defaultShootSpeed)
@@ -16,6 +14,8 @@ const ConfigureShotTrajectoryPanel: React.FC = ({
name="Configure Shooting"
icon={}
panelId={panelId}
+ openLocation={openLocation}
+ sidePadding={sidePadding}
onAccept={() => {
// send node and speed config
}}
diff --git a/fission/src/ui/panels/configuring/scoring/ScoringZonesPanel.tsx b/fission/src/ui/panels/configuring/scoring/ScoringZonesPanel.tsx
index c0aeaf7a76..f2f2bf32fb 100644
--- a/fission/src/ui/panels/configuring/scoring/ScoringZonesPanel.tsx
+++ b/fission/src/ui/panels/configuring/scoring/ScoringZonesPanel.tsx
@@ -13,42 +13,19 @@ type ScoringZoneRowProps = {
deleteZone: () => void
}
-const ScoringZoneRow: React.FC = ({
- zone,
- openPanel,
- deleteZone,
-}) => {
+const ScoringZoneRow: React.FC = ({ zone, openPanel, deleteZone }) => {
return (
-
-
-
-
+
+
+
+
-
+
openPanel("zone-config")} />
@@ -56,7 +33,7 @@ const ScoringZoneRow: React.FC = ({
)
}
-const ScoringZonesPanel: React.FC = ({ panelId }) => {
+const ScoringZonesPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
const { openPanel } = usePanelControlContext()
const [zones, setZones] = useState([
{
@@ -227,6 +204,8 @@ const ScoringZonesPanel: React.FC = ({ panelId }) => {
@@ -242,11 +221,7 @@ const ScoringZonesPanel: React.FC = ({ panelId }) => {
/>
))}
- openPanel("zone-config")}
- className="px-36 w-full"
- />
+ openPanel("zone-config")} className="px-36 w-full" />
)
}
diff --git a/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx b/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx
index e92c73d689..4fe84b26cf 100644
--- a/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx
+++ b/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx
@@ -5,6 +5,7 @@ import Button from "@/components/Button"
import SelectButton from "@/components/SelectButton"
import Checkbox from "@/components/Checkbox"
import Slider from "@/components/Slider"
+import NumberInput from "@/components/NumberInput"
export type ScoringZone = {
name: string
@@ -16,7 +17,7 @@ export type ScoringZone = {
scale: [number, number, number]
}
-const ZoneConfigPanel: React.FC = ({ panelId }) => {
+const ZoneConfigPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
// somehow get and store which zone is being edited
// maybe a global ConfigProvider in App.tsx?
// then set all default values to the state of the zone
@@ -29,40 +30,17 @@ const ZoneConfigPanel: React.FC = ({ panelId }) => {
const [, setScale] = useState<[number, number, number]>([1, 1, 1])
return (
-
-
+
+
setAlliance(alliance == "blue" ? "red" : "blue")}
- colorClass={`bg-match-${alliance}-alliance`}
- />
- setParent(p)}
- />
- setPoints(parseInt(v))}
- numeric
- />
-
-
+ setParent(p)} />
+ setPoints(v || 1)} />
+
+
= ({ panelId }) => {
+const ScoreboardPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
const [redScore] = useState(0)
const [blueScore] = useState(0)
const [initialTime, setInitialTime] = useState(-1)
@@ -39,6 +39,8 @@ const ScoreboardPanel: React.FC = ({ panelId }) => {
return (
= ({ panelId }) => {
)}
-
+
diff --git a/fission/src/ui/panels/simulation/DriverStationPanel.tsx b/fission/src/ui/panels/simulation/DriverStationPanel.tsx
index 1d239c9e6e..43c4262f2d 100644
--- a/fission/src/ui/panels/simulation/DriverStationPanel.tsx
+++ b/fission/src/ui/panels/simulation/DriverStationPanel.tsx
@@ -5,7 +5,7 @@ import Stack, { StackDirection } from "@/components/Stack"
import Button from "@/components/Button"
import Dropdown from "@/components/Dropdown"
-const DriverStationPanel: React.FC
= ({ panelId }) => {
+const DriverStationPanel: React.FC = ({ panelId, openLocation, sidePadding }) => {
const [enabled, setEnabled] = useState(false)
return (
@@ -13,12 +13,11 @@ const DriverStationPanel: React.FC = ({ panelId }) => {
name="Driver Station (Not Connected)"
icon={}
panelId={panelId}
+ openLocation={openLocation}
+ sidePadding={sidePadding}
>
- setEnabled(!enabled)}
- />
+ setEnabled(!enabled)} />
{}} />
diff --git a/fission/src/util/Queue.ts b/fission/src/util/Queue.ts
index 631a632035..96d511d198 100644
--- a/fission/src/util/Queue.ts
+++ b/fission/src/util/Queue.ts
@@ -1,57 +1,58 @@
class Queue {
-
- private _head?: LinkedNode;
- private _tail?: LinkedNode;
- private _size: number = 0;
+ private _head?: LinkedNode
+ private _tail?: LinkedNode
+ private _size: number = 0
- public get size() { return this._size; }
+ public get size() {
+ return this._size
+ }
- constructor() { }
+ constructor() {}
public Enqueue(...items: T[]) {
for (const item of items) {
- const node = new LinkedNode(item);
+ const node = new LinkedNode(item)
if (this._head) {
- this._tail!.next = node;
+ this._tail!.next = node
} else {
- this._head = node;
+ this._head = node
}
- this._tail = node;
+ this._tail = node
- this._size++;
+ this._size++
}
}
public Dequeue(): T | undefined {
- let retVal: T | undefined;
+ let retVal: T | undefined
if (this._head) {
- retVal = this._head.value;
- this._head = this._head.next;
- !this._head && (this._tail = undefined);
- this._size--;
+ retVal = this._head.value
+ this._head = this._head.next
+ !this._head && (this._tail = undefined)
+ this._size--
}
- return retVal;
+ return retVal
}
public Clone(): Queue {
- const queue = new Queue();
- let node = this._head;
+ const queue = new Queue()
+ let node = this._head
while (node != null) {
- queue.Enqueue(node.value);
- node = node.next;
+ queue.Enqueue(node.value)
+ node = node.next
}
- return queue;
+ return queue
}
}
class LinkedNode {
- public value: T;
- public next?: LinkedNode;
+ public value: T
+ public next?: LinkedNode
constructor(value: T, next?: LinkedNode) {
- this.value = value;
- this.next = next;
+ this.value = value
+ this.next = next
}
}
-export default Queue;
\ No newline at end of file
+export default Queue
diff --git a/fission/src/util/Random.ts b/fission/src/util/Random.ts
index 15ad2d9003..29b01d9326 100644
--- a/fission/src/util/Random.ts
+++ b/fission/src/util/Random.ts
@@ -1,23 +1,23 @@
-let seed = Date.now();
+let seed = Date.now()
/**
* Set the seed used when randomly generating a number.
* Default is Date.now() when this module is created.
- *
+ *
* @param newSeed New seed to use when generating random numbers.
* Must be greater than or equal to 1.0
*/
export function SeedRandomGen(newSeed: number) {
- seed = newSeed >= 1.0 ? newSeed : 1.0;
+ seed = newSeed >= 1.0 ? newSeed : 1.0
}
/**
* Generate a random number.
- *
+ *
* @returns Gives a random number x where, 0.0 <= x < 1.0
*/
export function Random() {
- seed++;
- const x = Math.abs(Math.sin(seed + 997) * 1425);
- return x - Math.floor(x);
-}
\ No newline at end of file
+ seed++
+ const x = Math.abs(Math.sin(seed + 997) * 1425)
+ return x - Math.floor(x)
+}
diff --git a/fission/src/util/TypeConversions.ts b/fission/src/util/TypeConversions.ts
index 78e63b18e1..0122710a77 100644
--- a/fission/src/util/TypeConversions.ts
+++ b/fission/src/util/TypeConversions.ts
@@ -1,55 +1,50 @@
-import * as THREE from 'three';
-import JOLT from './loading/JoltSyncLoader';
-import Jolt from '@barclah/jolt-physics';
-import { mirabuf } from "../proto/mirabuf";
+import * as THREE from "three"
+import JOLT from "./loading/JoltSyncLoader"
+import Jolt from "@barclah/jolt-physics"
+import { mirabuf } from "../proto/mirabuf"
export function _JoltQuat(a: THREE.Euler | THREE.Quaternion | undefined) {
if (a instanceof THREE.Euler) {
- return ThreeEuler_JoltQuat(a as THREE.Euler);
+ return ThreeEuler_JoltQuat(a as THREE.Euler)
} else if (a instanceof THREE.Quaternion) {
- return ThreeQuaternion_JoltQuat(a as THREE.Quaternion);
+ return ThreeQuaternion_JoltQuat(a as THREE.Quaternion)
} else {
- return new JOLT.Quat(0, 0, 0, 1);
+ return new JOLT.Quat(0, 0, 0, 1)
}
}
export function ThreeEuler_JoltQuat(euler: THREE.Euler) {
- const quat = new THREE.Quaternion();
- quat.setFromEuler(euler);
- return ThreeQuaternion_JoltQuat(quat);
+ const quat = new THREE.Quaternion()
+ quat.setFromEuler(euler)
+ return ThreeQuaternion_JoltQuat(quat)
}
export function ThreeQuaternion_JoltQuat(quat: THREE.Quaternion) {
- return new JOLT.Quat(quat.x, quat.y, quat.z, quat.w);
+ return new JOLT.Quat(quat.x, quat.y, quat.z, quat.w)
}
export function ThreeVector3_JoltVec3(vec: THREE.Vector3) {
- return new JOLT.Vec3(vec.x, vec.y, vec.z);
+ return new JOLT.Vec3(vec.x, vec.y, vec.z)
}
export function ThreeMatrix4_JoltMat44(m: THREE.Matrix4) {
- const jMat = new JOLT.Mat44();
- const threeArr = m.toArray();
+ const jMat = new JOLT.Mat44()
+ const threeArr = m.toArray()
for (let c = 0; c < 4; c++) {
- const column = new JOLT.Vec4(
- threeArr[4 * c + 0],
- threeArr[4 * c + 1],
- threeArr[4 * c + 2],
- threeArr[4 * c + 3]
- );
- jMat.SetColumn4(c, column);
- JOLT.destroy(column);
+ const column = new JOLT.Vec4(threeArr[4 * c + 0], threeArr[4 * c + 1], threeArr[4 * c + 2], threeArr[4 * c + 3])
+ jMat.SetColumn4(c, column)
+ JOLT.destroy(column)
}
- return jMat;
+ return jMat
}
export function JoltVec3_ThreeVector3(vec: Jolt.Vec3 | Jolt.RVec3) {
- return new THREE.Vector3(vec.GetX(), vec.GetY(), vec.GetZ());
+ return new THREE.Vector3(vec.GetX(), vec.GetY(), vec.GetZ())
}
export function JoltQuat_ThreeQuaternion(quat: Jolt.Quat) {
- return new THREE.Quaternion(quat.GetX(), quat.GetY(), quat.GetZ(), quat.GetW());
+ return new THREE.Quaternion(quat.GetX(), quat.GetY(), quat.GetZ(), quat.GetW())
}
export function JoltMat44_ThreeMatrix4(m: Jolt.RMat44): THREE.Matrix4 {
@@ -57,34 +52,34 @@ export function JoltMat44_ThreeMatrix4(m: Jolt.RMat44): THREE.Matrix4 {
JoltVec3_ThreeVector3(m.GetTranslation()),
JoltQuat_ThreeQuaternion(m.GetQuaternion()),
new THREE.Vector3(1, 1, 1)
- );
+ )
}
export function MirabufTransform_ThreeMatrix4(m: mirabuf.ITransform): THREE.Matrix4 {
- const arr = m.spatialMatrix!;
- const pos = new THREE.Vector3(arr[3] * 0.01, arr[7] * 0.01, arr[11] * 0.01);
- const mat = new THREE.Matrix4().fromArray(arr);
- const onlyRotation = new THREE.Matrix4().extractRotation(mat).transpose();
- const quat = new THREE.Quaternion().setFromRotationMatrix(onlyRotation);
- return new THREE.Matrix4().compose(pos, quat, new THREE.Vector3(1, 1, 1));
+ const arr = m.spatialMatrix!
+ const pos = new THREE.Vector3(arr[3] * 0.01, arr[7] * 0.01, arr[11] * 0.01)
+ const mat = new THREE.Matrix4().fromArray(arr)
+ const onlyRotation = new THREE.Matrix4().extractRotation(mat).transpose()
+ const quat = new THREE.Quaternion().setFromRotationMatrix(onlyRotation)
+ return new THREE.Matrix4().compose(pos, quat, new THREE.Vector3(1, 1, 1))
}
export function MirabufVector3_ThreeVector3(v: mirabuf.Vector3): THREE.Vector3 {
- return new THREE.Vector3(v.x / 100.0, v.y / 100.0, v.z / 100.0);
+ return new THREE.Vector3(v.x / 100.0, v.y / 100.0, v.z / 100.0)
}
export function MirabufVector3_JoltVec3(v: mirabuf.Vector3): Jolt.Vec3 {
- return new JOLT.Vec3(v.x / 100.0, v.y / 100.0, v.z / 100.0);
+ return new JOLT.Vec3(v.x / 100.0, v.y / 100.0, v.z / 100.0)
}
export function MirabufFloatArr_JoltVec3(v: number[], offsetIndex: number): Jolt.Vec3 {
- return new JOLT.Vec3(v[offsetIndex] / 100.0, v[offsetIndex + 1] / 100.0, v[offsetIndex + 2] / 100.0);
+ return new JOLT.Vec3(v[offsetIndex] / 100.0, v[offsetIndex + 1] / 100.0, v[offsetIndex + 2] / 100.0)
}
export function MirabufFloatArr_JoltVec3Arr(v: number[]): Jolt.Vec3[] {
- const arr = [];
+ const arr = []
for (let i = 0; i < v.length; i += 3) {
- arr.push(MirabufFloatArr_JoltVec3(v, i));
+ arr.push(MirabufFloatArr_JoltVec3(v, i))
}
- return arr;
-}
\ No newline at end of file
+ return arr
+}
diff --git a/fission/src/util/Utility.ts b/fission/src/util/Utility.ts
index d6234cb0c9..f0e62c88d4 100644
--- a/fission/src/util/Utility.ts
+++ b/fission/src/util/Utility.ts
@@ -1,3 +1,3 @@
export function ternaryOnce(obj: A | undefined, ifTrue: (x: A) => B, ifFalse: () => B): B {
return obj ? ifTrue(obj) : ifFalse()
-}
\ No newline at end of file
+}
diff --git a/fission/src/util/debug/DebugPrint.ts b/fission/src/util/debug/DebugPrint.ts
index 19070973b1..b81b2a3b89 100644
--- a/fission/src/util/debug/DebugPrint.ts
+++ b/fission/src/util/debug/DebugPrint.ts
@@ -1,39 +1,43 @@
-import { RigidNodeReadOnly } from "@/mirabuf/MirabufParser";
-import { mirabuf } from "@/proto/mirabuf";
-import Jolt from "@barclah/jolt-physics";
+import { RigidNodeReadOnly } from "@/mirabuf/MirabufParser"
+import { mirabuf } from "@/proto/mirabuf"
+import Jolt from "@barclah/jolt-physics"
export function printRigidNodeParts(nodes: RigidNodeReadOnly[], mira: mirabuf.Assembly) {
nodes.forEach(x => {
- console.log(`[ ${x.id} ]:`);
- x.parts.forEach(y => console.log(`-> '${mira.data!.parts!.partInstances![y]!.info!.name!}'`));
- console.log('');
- });
+ console.log(`[ ${x.id} ]:`)
+ x.parts.forEach(y => console.log(`-> '${mira.data!.parts!.partInstances![y]!.info!.name!}'`))
+ console.log("")
+ })
}
export function threeMatrix4ToString(mat: THREE.Matrix4) {
- const arr = mat.toArray();
- return `[\n${arr[0].toFixed(4)}, ${arr[4].toFixed(4)}, ${arr[8].toFixed(4)}, ${arr[12].toFixed(4)},\n`
- + `${arr[1].toFixed(4)}, ${arr[5].toFixed(4)}, ${arr[9].toFixed(4)}, ${arr[13].toFixed(4)},\n`
- + `${arr[2].toFixed(4)}, ${arr[6].toFixed(4)}, ${arr[10].toFixed(4)}, ${arr[14].toFixed(4)},\n`
- + `${arr[3].toFixed(4)}, ${arr[7].toFixed(4)}, ${arr[11].toFixed(4)}, ${arr[15].toFixed(4)},\n]`
+ const arr = mat.toArray()
+ return (
+ `[\n${arr[0].toFixed(4)}, ${arr[4].toFixed(4)}, ${arr[8].toFixed(4)}, ${arr[12].toFixed(4)},\n` +
+ `${arr[1].toFixed(4)}, ${arr[5].toFixed(4)}, ${arr[9].toFixed(4)}, ${arr[13].toFixed(4)},\n` +
+ `${arr[2].toFixed(4)}, ${arr[6].toFixed(4)}, ${arr[10].toFixed(4)}, ${arr[14].toFixed(4)},\n` +
+ `${arr[3].toFixed(4)}, ${arr[7].toFixed(4)}, ${arr[11].toFixed(4)}, ${arr[15].toFixed(4)},\n]`
+ )
}
export function mirabufTransformToString(mat: mirabuf.ITransform) {
- const arr = mat.spatialMatrix!;
- return `[\n${arr[0].toFixed(4)}, ${arr[1].toFixed(4)}, ${arr[2].toFixed(4)}, ${arr[3].toFixed(4)},\n`
- + `${arr[4].toFixed(4)}, ${arr[5].toFixed(4)}, ${arr[6].toFixed(4)}, ${arr[7].toFixed(4)},\n`
- + `${arr[8].toFixed(4)}, ${arr[9].toFixed(4)}, ${arr[10].toFixed(4)}, ${arr[11].toFixed(4)},\n`
- + `${arr[12].toFixed(4)}, ${arr[13].toFixed(4)}, ${arr[14].toFixed(4)}, ${arr[15].toFixed(4)},\n]`
+ const arr = mat.spatialMatrix!
+ return (
+ `[\n${arr[0].toFixed(4)}, ${arr[1].toFixed(4)}, ${arr[2].toFixed(4)}, ${arr[3].toFixed(4)},\n` +
+ `${arr[4].toFixed(4)}, ${arr[5].toFixed(4)}, ${arr[6].toFixed(4)}, ${arr[7].toFixed(4)},\n` +
+ `${arr[8].toFixed(4)}, ${arr[9].toFixed(4)}, ${arr[10].toFixed(4)}, ${arr[11].toFixed(4)},\n` +
+ `${arr[12].toFixed(4)}, ${arr[13].toFixed(4)}, ${arr[14].toFixed(4)}, ${arr[15].toFixed(4)},\n]`
+ )
}
export function mirabufVector3ToString(v: mirabuf.Vector3, units: number = 3) {
- return `(${v.x.toFixed(units)}, ${v.y.toFixed(units)}, ${v.z.toFixed(units)})`;
+ return `(${v.x.toFixed(units)}, ${v.y.toFixed(units)}, ${v.z.toFixed(units)})`
}
export function threeVector3ToString(v: THREE.Vector3, units: number = 3) {
- return `(${v.x.toFixed(units)}, ${v.y.toFixed(units)}, ${v.z.toFixed(units)})`;
+ return `(${v.x.toFixed(units)}, ${v.y.toFixed(units)}, ${v.z.toFixed(units)})`
}
export function joltVec3ToString(v: Jolt.Vec3 | Jolt.RVec3, units: number = 3) {
- return `(${v.GetX().toFixed(units)}, ${v.GetY().toFixed(units)}, ${v.GetZ().toFixed(units)})`;
-}
\ No newline at end of file
+ return `(${v.GetX().toFixed(units)}, ${v.GetY().toFixed(units)}, ${v.GetZ().toFixed(units)})`
+}
diff --git a/fission/src/util/dom.ts b/fission/src/util/dom.ts
index e401ea4fbc..2eeb77dd60 100644
--- a/fission/src/util/dom.ts
+++ b/fission/src/util/dom.ts
@@ -1,31 +1,31 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
export const click = (btn: number, x: number, y: number) => {
- const el = document.elementFromPoint(x, y);
+ const el = document.elementFromPoint(x, y)
const event = new MouseEvent("click", {
clientX: x,
clientY: y,
bubbles: true,
- button: btn
+ button: btn,
})
el?.dispatchEvent(event)
}
export const mousePosition = (x: number, y: number) => {
- const el = document.elementFromPoint(x, y);
+ const el = document.elementFromPoint(x, y)
- const event = new MouseEvent('mouseover', {
+ const event = new MouseEvent("mouseover", {
view: window,
bubbles: true,
- cancelable: true
+ cancelable: true,
})
- el?.dispatchEvent(event);
+ el?.dispatchEvent(event)
}
export const addGlobalFunc = (name: string, func: (...args: any[]) => T) => {
- (window as any)[name] = func;
+ (window as any)[name] = func
}
-addGlobalFunc('click', click);
-addGlobalFunc('mousePosition', mousePosition);
+addGlobalFunc("click", click)
+addGlobalFunc("mousePosition", mousePosition)
diff --git a/fission/src/util/loading/FileLoading.mjs b/fission/src/util/loading/FileLoading.mjs
index 423af99d44..9a68e2372e 100644
--- a/fission/src/util/loading/FileLoading.mjs
+++ b/fission/src/util/loading/FileLoading.mjs
@@ -1,13 +1,17 @@
export async function getBinaryFile(src) {
- const get_file_array = (file) => {
+ const get_file_array = file => {
return new Promise((acc, _) => {
- const reader = new FileReader();
- reader.onload = (event) => { acc(event.target.result) };
- reader.onerror = (err) => { err(err) };
- reader.readAsArrayBuffer(file);
- });
+ const reader = new FileReader()
+ reader.onload = event => {
+ acc(event.target.result)
+ }
+ reader.onerror = err => {
+ err(err)
+ }
+ reader.readAsArrayBuffer(file)
+ })
}
- const miraFile = await fetch(src, {cache: "no-store"}).then((x) => x.blob());
- const temp = await get_file_array(miraFile);
- return new Uint8Array(temp);
+ const miraFile = await fetch(src, { cache: "no-store" }).then(x => x.blob())
+ const temp = await get_file_array(miraFile)
+ return new Uint8Array(temp)
}
diff --git a/fission/src/util/loading/JoltAsyncLoader.ts b/fission/src/util/loading/JoltAsyncLoader.ts
index 473c0e5bb4..208dea339f 100644
--- a/fission/src/util/loading/JoltAsyncLoader.ts
+++ b/fission/src/util/loading/JoltAsyncLoader.ts
@@ -1,6 +1,6 @@
-import * as j from '@barclah/jolt-physics/wasm-compat';
+import * as j from "@barclah/jolt-physics/wasm-compat"
-let JOLT: typeof j.default | undefined = undefined;
-export const JOLT_TYPES = j.default;
-export const joltInit = j.default().then(jolt => JOLT = jolt);
-export default JOLT;
\ No newline at end of file
+let JOLT: typeof j.default | undefined = undefined
+export const JOLT_TYPES = j.default
+export const joltInit = j.default().then(jolt => (JOLT = jolt))
+export default JOLT
diff --git a/fission/src/util/loading/JoltSyncLoader.ts b/fission/src/util/loading/JoltSyncLoader.ts
index b428e7858b..2f135976a1 100644
--- a/fission/src/util/loading/JoltSyncLoader.ts
+++ b/fission/src/util/loading/JoltSyncLoader.ts
@@ -3,7 +3,7 @@
* customizable control over when it is initialized.
*/
-import * as j from '@barclah/jolt-physics/wasm-compat';
+import * as j from "@barclah/jolt-physics/wasm-compat"
-const JOLT = await j.default();
-export default JOLT;
\ No newline at end of file
+const JOLT = await j.default()
+export default JOLT
diff --git a/fission/src/util/threejs/MeshCreation.ts b/fission/src/util/threejs/MeshCreation.ts
index 3342d4898e..01d6250c08 100644
--- a/fission/src/util/threejs/MeshCreation.ts
+++ b/fission/src/util/threejs/MeshCreation.ts
@@ -1,86 +1,110 @@
-import JOLT from '../loading/JoltSyncLoader.ts';
-import Jolt from '@barclah/jolt-physics';
-import * as THREE from 'three';
-import { JoltVec3_ThreeVector3, JoltQuat_ThreeQuaternion } from '../TypeConversions.ts';
+import JOLT from "../loading/JoltSyncLoader.ts"
+import Jolt from "@barclah/jolt-physics"
+import * as THREE from "three"
+import { JoltVec3_ThreeVector3, JoltQuat_ThreeQuaternion } from "../TypeConversions.ts"
-export const LAYER_NOT_MOVING = 0;
-export const LAYER_MOVING = 1;
-export const COUNT_OBJECT_LAYERS = 2;
+export const LAYER_NOT_MOVING = 0
+export const LAYER_MOVING = 1
+export const COUNT_OBJECT_LAYERS = 2
export function createMeshForShape(shape: Jolt.Shape) {
- const scale = new JOLT.Vec3(1, 1, 1);
- const triangleContext = new JOLT.ShapeGetTriangles(shape, JOLT.AABox.prototype.sBiggest(), shape.GetCenterOfMass(), JOLT.Quat.prototype.sIdentity(), scale);
- JOLT.destroy(scale);
+ const scale = new JOLT.Vec3(1, 1, 1)
+ const triangleContext = new JOLT.ShapeGetTriangles(
+ shape,
+ JOLT.AABox.prototype.sBiggest(),
+ shape.GetCenterOfMass(),
+ JOLT.Quat.prototype.sIdentity(),
+ scale
+ )
+ JOLT.destroy(scale)
- const vertices = new Float32Array(JOLT.HEAP32.buffer, triangleContext.GetVerticesData(), triangleContext.GetVerticesSize() / Float32Array.BYTES_PER_ELEMENT);
- const buffer = new THREE.BufferAttribute(vertices, 3).clone();
- JOLT.destroy(triangleContext);
+ const vertices = new Float32Array(
+ JOLT.HEAP32.buffer,
+ triangleContext.GetVerticesData(),
+ triangleContext.GetVerticesSize() / Float32Array.BYTES_PER_ELEMENT
+ )
+ const buffer = new THREE.BufferAttribute(vertices, 3).clone()
+ JOLT.destroy(triangleContext)
- const geometry = new THREE.BufferGeometry();
- geometry.setAttribute('position', buffer);
- geometry.computeVertexNormals();
+ const geometry = new THREE.BufferGeometry()
+ geometry.setAttribute("position", buffer)
+ geometry.computeVertexNormals()
- return geometry;
+ return geometry
}
export function getThreeObjForBody(body: Jolt.Body, color: THREE.Color) {
- const material = new THREE.MeshPhongMaterial({ color: color, shininess: 0.1 });
- let threeObj;
- const shape = body.GetShape();
+ const material = new THREE.MeshPhongMaterial({
+ color: color,
+ shininess: 0.1,
+ })
+ let threeObj
+ const shape = body.GetShape()
switch (shape.GetSubType()) {
case JOLT.EShapeSubType_Box: {
- const boxShape = JOLT.castObject(shape, JOLT.BoxShape);
- const extent = JoltVec3_ThreeVector3(boxShape.GetHalfExtent()).multiplyScalar(2);
- threeObj = new THREE.Mesh(new THREE.BoxGeometry(extent.x, extent.y, extent.z, 1, 1, 1), material);
- threeObj.receiveShadow = true;
- threeObj.castShadow = true;
- break;
+ const boxShape = JOLT.castObject(shape, JOLT.BoxShape)
+ const extent = JoltVec3_ThreeVector3(boxShape.GetHalfExtent()).multiplyScalar(2)
+ threeObj = new THREE.Mesh(new THREE.BoxGeometry(extent.x, extent.y, extent.z, 1, 1, 1), material)
+ threeObj.receiveShadow = true
+ threeObj.castShadow = true
+ break
}
case JOLT.EShapeSubType_Capsule:
// TODO
- break;
+ break
case JOLT.EShapeSubType_Cylinder:
// TODO
- break;
+ break
case JOLT.EShapeSubType_Sphere:
// TODO
- break;
+ break
default:
- threeObj = new THREE.Mesh(createMeshForShape(shape), material);
- threeObj.receiveShadow = true;
- threeObj.castShadow = true;
- break;
+ threeObj = new THREE.Mesh(createMeshForShape(shape), material)
+ threeObj.receiveShadow = true
+ threeObj.castShadow = true
+ break
}
- if (!threeObj) return undefined;
+ if (!threeObj) return undefined
- threeObj.position.copy(JoltVec3_ThreeVector3(body.GetPosition()));
- threeObj.quaternion.copy(JoltQuat_ThreeQuaternion(body.GetRotation()));
+ threeObj.position.copy(JoltVec3_ThreeVector3(body.GetPosition()))
+ threeObj.quaternion.copy(JoltQuat_ThreeQuaternion(body.GetRotation()))
- return threeObj;
+ return threeObj
}
export function addToThreeScene(scene: THREE.Scene, body: Jolt.Body, color: THREE.Color, dynamicObjects: THREE.Mesh[]) {
- const threeObj = getThreeObjForBody(body, color);
- if (!threeObj) return;
- threeObj.userData.body = body;
- scene.add(threeObj);
- dynamicObjects.push(threeObj);
+ const threeObj = getThreeObjForBody(body, color)
+ if (!threeObj) return
+ threeObj.userData.body = body
+ scene.add(threeObj)
+ dynamicObjects.push(threeObj)
}
-export function addToScene(scene: THREE.Scene, body: Jolt.Body, color: THREE.Color, bodyInterface: Jolt.BodyInterface, dynamicObjects: THREE.Mesh[]) {
- bodyInterface.AddBody(body.GetID(), JOLT.EActivation_Activate);
- addToThreeScene(scene, body, color, dynamicObjects);
+export function addToScene(
+ scene: THREE.Scene,
+ body: Jolt.Body,
+ color: THREE.Color,
+ bodyInterface: Jolt.BodyInterface,
+ dynamicObjects: THREE.Mesh[]
+) {
+ bodyInterface.AddBody(body.GetID(), JOLT.EActivation_Activate)
+ addToThreeScene(scene, body, color, dynamicObjects)
}
-export function removeFromScene(scene: THREE.Scene, threeObject: THREE.Mesh, bodyInterface: Jolt.BodyInterface, dynamicObjects: THREE.Mesh[]) {
- const id = threeObject.userData.body.GetID();
- bodyInterface.RemoveBody(id);
- bodyInterface.DestroyBody(id);
- delete threeObject.userData.body;
+export function removeFromScene(
+ scene: THREE.Scene,
+ threeObject: THREE.Mesh,
+ bodyInterface: Jolt.BodyInterface,
+ dynamicObjects: THREE.Mesh[]
+) {
+ const id = threeObject.userData.body.GetID()
+ bodyInterface.RemoveBody(id)
+ bodyInterface.DestroyBody(id)
+ delete threeObject.userData.body
- scene.remove(threeObject);
- const idx = dynamicObjects.indexOf(threeObject);
- dynamicObjects.splice(idx, 1);
-}
\ No newline at end of file
+ scene.remove(threeObject)
+ const idx = dynamicObjects.indexOf(threeObject)
+ dynamicObjects.splice(idx, 1)
+}
diff --git a/fission/tailwind.config.js b/fission/tailwind.config.js
index f68ff1ef70..c91cfbff0f 100644
--- a/fission/tailwind.config.js
+++ b/fission/tailwind.config.js
@@ -35,7 +35,7 @@ let safelist = Object.keys(colors).map(c => "bg-" + c);
export default {
content: [
"./index.html",
- "./src/**/*.{js,jsx,ts,tsx}",
+ "./src/**/*.{js,jsx,ts,tsx}"
],
theme: {
fontFamily: {