From d9fa003518be808ed7d665f2fda1ddc508bbf75f Mon Sep 17 00:00:00 2001 From: Hunter Barclay Date: Wed, 22 May 2024 20:04:21 -0600 Subject: [PATCH 1/7] Tweaking styling, adding Artifakt font --- fission/index.html | 1 + fission/src/components/Modal.tsx | 2 +- fission/src/index.css | 3 ++- fission/src/modals/SpawningModal.tsx | 8 +++++-- fission/src/modals/spawning/AddRobotModal.tsx | 24 +++++++++++++++++-- fission/tailwind.config.js | 11 ++++++--- 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/fission/index.html b/fission/index.html index 906d342d14..7a1e816061 100644 --- a/fission/index.html +++ b/fission/index.html @@ -3,6 +3,7 @@ + Fission | Synthesis diff --git a/fission/src/components/Modal.tsx b/fission/src/components/Modal.tsx index ba30a157a3..5def5f2f5a 100644 --- a/fission/src/components/Modal.tsx +++ b/fission/src/components/Modal.tsx @@ -78,7 +78,7 @@ const Modal: React.FC = ({ + ) +} const RobotsModal: React.FC = ({ modalId }) => { // update tooltip based on type of drivetrain, receive message from Synthesis @@ -12,6 +27,8 @@ const RobotsModal: React.FC = ({ modalId }) => { let selectedRobot: string | null = null; + const robots = ["Dozer_v2.mira", "Team_2471_(2018)_v7.mira"] + return ( = ({ modalId }) => { } } > - + {robots.map(x => RobotCard({robot: x}))} + + {/* { selectedRobot = op; }} - /> + /> */} ) } diff --git a/fission/tailwind.config.js b/fission/tailwind.config.js index a8d01e4a25..77f1fabcbd 100644 --- a/fission/tailwind.config.js +++ b/fission/tailwind.config.js @@ -1,5 +1,3 @@ -/** @type {import('tailwindcss').Config} */ - let colors = { 'interactive-element-solid': 'var(--interactive-element-solid)', 'interactive-element-left': 'var(--interactive-element-left)', @@ -33,17 +31,24 @@ let colors = { let safelist = Object.keys(colors).map(c => "bg-" + c); +/** @type {import('tailwindcss').Config} */ export default { content: [ "./index.html", "./src/**/*.{js,jsx,ts,tsx}", ], theme: { + fontFamily: { + 'artifakt': 'Artifakt', + }, + fontWeight: { + 'reg': '400', + }, extend: { colors: colors, maxHeight: { '70vh': '70vh', - } + }, }, }, safelist: safelist, From a9c18f9d6bb46d420a6a0a38f7d751a4dadf0a1e Mon Sep 17 00:00:00 2001 From: Hunter Barclay Date: Wed, 22 May 2024 21:50:32 -0600 Subject: [PATCH 2/7] Tweaking a bit more styling, redid how the robots and fields are listed --- fission/src/components/Modal.tsx | 2 +- fission/src/modals/spawning/AddFieldModal.tsx | 57 ++++++++++++++---- fission/src/modals/spawning/AddRobotModal.tsx | 60 +++++++++---------- fission/tailwind.config.js | 8 ++- 4 files changed, 81 insertions(+), 46 deletions(-) diff --git a/fission/src/components/Modal.tsx b/fission/src/components/Modal.tsx index 5def5f2f5a..4d822ff1cf 100644 --- a/fission/src/components/Modal.tsx +++ b/fission/src/components/Modal.tsx @@ -64,7 +64,7 @@ const Modal: React.FC = ({ {iconEl && iconEl} -

+

{name}

diff --git a/fission/src/modals/spawning/AddFieldModal.tsx b/fission/src/modals/spawning/AddFieldModal.tsx index f79c8dfd08..a66c9a12d2 100644 --- a/fission/src/modals/spawning/AddFieldModal.tsx +++ b/fission/src/modals/spawning/AddFieldModal.tsx @@ -1,21 +1,54 @@ import React from "react" import Modal, { ModalPropsImpl } from "../../components/Modal" import { FaPlus } from "react-icons/fa6" -import Dropdown from "../../components/Dropdown" +import World from "@/systems/World" +import { CreateMirabufFromUrl } from "@/mirabuf/MirabufSceneObject" +import { useModalControlContext } from "@/ModalContext" +import Label from "@/components/Label" +import Button from "@/components/Button" -const FieldsModal: React.FC = ({ modalId }) => { +interface FieldCardProps { + field: string; + select: (field: string) => void; +} + +const FieldCard: React.FC = ({ field, select }) => { return ( - } modalId={modalId}> - {}} +
+ +
+ ) +} + +const FieldsModal: React.FC = ({ modalId }) => { + const { closeModal } = useModalControlContext() + + const fields = ["FRC_Field_2018_v14.mira"] + + const selectField = (field: string) => { + CreateMirabufFromUrl(`test_mira/${field}`).then(x => { + if (x) { + World.SceneRenderer.RegisterSceneObject(x) + } + }) + + closeModal() + } + + return ( + } + modalId={modalId} + acceptEnabled={false} + > +
+ {fields.map(x => FieldCard({field: x, select: selectField}))} +
) } diff --git a/fission/src/modals/spawning/AddRobotModal.tsx b/fission/src/modals/spawning/AddRobotModal.tsx index 4d249529a9..e74510cd0b 100644 --- a/fission/src/modals/spawning/AddRobotModal.tsx +++ b/fission/src/modals/spawning/AddRobotModal.tsx @@ -1,22 +1,26 @@ import React from "react" import Modal, { ModalPropsImpl } from "../../components/Modal" import { FaPlus } from "react-icons/fa6" -import Dropdown from "../../components/Dropdown" import { useTooltipControlContext } from "@/TooltipContext" import { CreateMirabufFromUrl } from "@/mirabuf/MirabufSceneObject" import World from "@/systems/World" import Button from "@/components/Button" import Label from "@/components/Label" +import { useModalControlContext } from "@/ModalContext" interface RobotCardProps { robot: string; + select: (robot: string) => void; } -const RobotCard: React.FC = ({ robot }) => { +const RobotCard: React.FC = ({ robot, select }) => { return ( -
- - +
+ +
) } @@ -24,42 +28,36 @@ const RobotCard: React.FC = ({ robot }) => { const RobotsModal: React.FC = ({ modalId }) => { // update tooltip based on type of drivetrain, receive message from Synthesis const { showTooltip } = useTooltipControlContext() - - let selectedRobot: string | null = null; + const { closeModal } = useModalControlContext() const robots = ["Dozer_v2.mira", "Team_2471_(2018)_v7.mira"] + const selectRobot = (robot: string) => { + showTooltip("controls", [ + { control: "WASD", description: "Drive" }, + { control: "E", description: "Intake" }, + { control: "Q", description: "Dispense" }, + ]) + + CreateMirabufFromUrl(`test_mira/${robot}`).then(x => { + if (x) { + World.SceneRenderer.RegisterSceneObject(x) + } + }) + + closeModal() + } + return ( } modalId={modalId} - onAccept={() => { - showTooltip("controls", [ - { control: "WASD", description: "Drive" }, - { control: "E", description: "Intake" }, - { control: "Q", description: "Dispense" }, - ]); - - if (selectedRobot) { - CreateMirabufFromUrl(`test_mira/${selectedRobot}`).then(x => { - if (x) { - World.SceneRenderer.RegisterSceneObject(x); - } - }); - } - } - } + acceptEnabled={false} > -
- {robots.map(x => RobotCard({robot: x}))} +
+ {robots.map(x => RobotCard({robot: x, select: selectRobot}))}
- {/* { - selectedRobot = op; - }} - /> */} ) } diff --git a/fission/tailwind.config.js b/fission/tailwind.config.js index 77f1fabcbd..cff09dd793 100644 --- a/fission/tailwind.config.js +++ b/fission/tailwind.config.js @@ -39,16 +39,20 @@ export default { ], theme: { fontFamily: { - 'artifakt': 'Artifakt', + 'artifakt-normal': 'Artifakt', }, fontWeight: { - 'reg': '400', + 'regular': '400', + 'medium': '700', }, extend: { colors: colors, maxHeight: { '70vh': '70vh', }, + spacing: { + '20vw': '20vw', + } }, }, safelist: safelist, From d69a11fd209f31698d55242b382a0dd2c60f9acc Mon Sep 17 00:00:00 2001 From: Hunter Barclay Date: Thu, 23 May 2024 14:06:52 -0600 Subject: [PATCH 3/7] Changing up some colors --- fission/src/modals/spawning/AddFieldModal.tsx | 4 ++-- fission/src/modals/spawning/AddRobotModal.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fission/src/modals/spawning/AddFieldModal.tsx b/fission/src/modals/spawning/AddFieldModal.tsx index a66c9a12d2..0e60290758 100644 --- a/fission/src/modals/spawning/AddFieldModal.tsx +++ b/fission/src/modals/spawning/AddFieldModal.tsx @@ -14,7 +14,7 @@ interface FieldCardProps { const FieldCard: React.FC = ({ field, select }) => { return ( -
+
+ ) +} + +export const AddFieldsModal: React.FC = ({ modalId }) => { + const { closeModal } = useModalControlContext() + + const [fields, setFields] = useState(null); + + useEffect(() => { + (async () => { + fetch('/api/mira/manifest.json').then(x => x.json()).then(x => { + const fields: FieldEntry[] = []; + 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'] }) + } + } + setFields(fields) + }) + })() + }, []); + + const selectField = (entry: FieldEntry) => { + console.log(`Mira: '${entry.src}'`) + CreateMirabufFromUrl(entry.src).then(x => { + if (x) { + World.SceneRenderer.RegisterSceneObject(x) + } + }) + + closeModal() + } -const SpawningModal: React.FC = ({ modalId }) => { - const { openModal } = useModalControlContext() return ( } modalId={modalId} acceptEnabled={false} > - -
- ) -} - -const FieldsModal: React.FC = ({ modalId }) => { - const { closeModal } = useModalControlContext() - - const fields = ["FRC_Field_2018_v14.mira"] - - const selectField = (field: string) => { - CreateMirabufFromUrl(`test_mira/${field}`).then(x => { - if (x) { - World.SceneRenderer.RegisterSceneObject(x) - } - }) - - closeModal() - } - - return ( - } - modalId={modalId} - acceptEnabled={false} - > -
- {fields.map(x => FieldCard({field: x, select: selectField}))} -
-
- ) -} - -export default FieldsModal diff --git a/fission/src/modals/spawning/AddRobotModal.tsx b/fission/src/modals/spawning/AddRobotModal.tsx deleted file mode 100644 index bb4eb139c9..0000000000 --- a/fission/src/modals/spawning/AddRobotModal.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import React from "react" -import Modal, { ModalPropsImpl } from "../../components/Modal" -import { FaPlus } from "react-icons/fa6" -import { useTooltipControlContext } from "@/TooltipContext" -import { CreateMirabufFromUrl } from "@/mirabuf/MirabufSceneObject" -import World from "@/systems/World" -import Button from "@/components/Button" -import Label from "@/components/Label" -import { useModalControlContext } from "@/ModalContext" - -interface RobotCardProps { - robot: string; - select: (robot: string) => void; -} - -const RobotCard: React.FC = ({ robot, select }) => { - return ( -
- -
- ) -} - -const RobotsModal: React.FC = ({ modalId }) => { - // update tooltip based on type of drivetrain, receive message from Synthesis - const { showTooltip } = useTooltipControlContext() - const { closeModal } = useModalControlContext() - - const robots = ["Dozer_v2.mira", "Team_2471_(2018)_v7.mira"] - - const selectRobot = (robot: string) => { - showTooltip("controls", [ - { control: "WASD", description: "Drive" }, - { control: "E", description: "Intake" }, - { control: "Q", description: "Dispense" }, - ]) - - CreateMirabufFromUrl(`test_mira/${robot}`).then(x => { - if (x) { - World.SceneRenderer.RegisterSceneObject(x) - } - }) - - closeModal() - } - - return ( - } - modalId={modalId} - acceptEnabled={false} - > -
- {robots.map(x => RobotCard({robot: x, select: selectRobot}))} -
-
- ) -} - -export default RobotsModal diff --git a/fission/src/modals/spawning/ManageAssembliesModal.tsx b/fission/src/modals/spawning/ManageAssembliesModal.tsx index 02e492e0d9..71dbafedda 100644 --- a/fission/src/modals/spawning/ManageAssembliesModal.tsx +++ b/fission/src/modals/spawning/ManageAssembliesModal.tsx @@ -2,24 +2,32 @@ import React, { RefObject, useEffect, useRef } from "react" import Modal, { ModalPropsImpl } from "../../components/Modal" import { FaPlus } from "react-icons/fa6" import ScrollView from "@/components/ScrollView" +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; +} + +const AssemblyCard: React.FC = ({ id }) => { + return ( +
+ +
+ ) +} const ManageAssembliesModal: React.FC = ({ modalId }) => { // update tooltip based on type of drivetrain, receive message from Synthesis // const { showTooltip } = useTooltipControlContext() - const refs: Array> = new Array(2); - for (let i = 0; i < refs.length; i++) { - // eslint-disable-next-line react-hooks/rules-of-hooks - refs[i] = useRef(null); - } - - useEffect(() => { - refs.forEach((x, i) => { - if (x.current) { - x.current.innerHTML = `Item ${i}`; - } - }); - }); + const assemblies = [...World.SceneRenderer.sceneObjects.entries()].filter(x => { const y = (x[1] instanceof MirabufSceneObject); return y }).map(x => x[0]) return ( = ({ modalId }) => { } } > - - {refs.map(x =>
)} -
- }> - +
+ + { + assemblies.map(x => AssemblyCard({id: x})) + } +
) } diff --git a/fission/src/modals/spawning/SpawningModal.tsx b/fission/src/modals/spawning/SpawningModals.tsx similarity index 95% rename from fission/src/modals/spawning/SpawningModal.tsx rename to fission/src/modals/spawning/SpawningModals.tsx index 1fbe3af420..ac01357931 100644 --- a/fission/src/modals/spawning/SpawningModal.tsx +++ b/fission/src/modals/spawning/SpawningModals.tsx @@ -78,11 +78,11 @@ export const AddRobotsModal: React.FC = ({ modalId }) => { acceptEnabled={false} >
- + { remoteRobots ? remoteRobots!.map(x => MirabufCard({entry: x, select: selectRobot})) - : 'no fields' + : (<>) }
@@ -129,11 +129,11 @@ export const AddFieldsModal: React.FC = ({ modalId }) => { acceptEnabled={false} >
- + { remoteFields ? remoteFields!.map(x => MirabufCard({entry: x, select: selectField})) - : 'no fields' + : (<>) }
diff --git a/fission/src/systems/physics/Mechanism.ts b/fission/src/systems/physics/Mechanism.ts index 9a0a40ca4b..1aaa31cfec 100644 --- a/fission/src/systems/physics/Mechanism.ts +++ b/fission/src/systems/physics/Mechanism.ts @@ -11,12 +11,14 @@ class Mechanism { public rootBody: string; public nodeToBody: Map; public constraints: Array; + public stepListeners: Array; public layerReserve: LayerReserve | undefined; public constructor(rootBody: string, bodyMap: Map, layerReserve?: LayerReserve) { this.rootBody = rootBody; this.nodeToBody = bodyMap; this.constraints = []; + this.stepListeners = []; this.layerReserve = layerReserve; } @@ -24,6 +26,10 @@ class Mechanism { this.constraints.push(mechConstraint); } + public AddStepListener(listener: Jolt.PhysicsStepListener) { + this.stepListeners.push(listener) + } + public GetBodyByNodeId(nodeId: string) { return this.nodeToBody.get(nodeId); } diff --git a/fission/src/systems/physics/PhysicsSystem.ts b/fission/src/systems/physics/PhysicsSystem.ts index a50f82350f..235b3abb75 100644 --- a/fission/src/systems/physics/PhysicsSystem.ts +++ b/fission/src/systems/physics/PhysicsSystem.ts @@ -155,8 +155,10 @@ class PhysicsSystem extends WorldSystem { return settings.Create(); } - public CreateMechanismFromParser(parser: MirabufParser) { - const layer = parser.assembly.dynamic ? new LayerReserve(): undefined; + public CreateMechanismFromParser(parser: MirabufParser): Mechanism { + const layer = parser.assembly.dynamic ? new LayerReserve() : undefined; + // const layer = undefined; + console.log(`Using layer ${layer?.layer}`) const bodyMap = this.CreateBodiesFromParser(parser, layer); const rootBody = parser.rootNode; const mechanism = new Mechanism(rootBody, bodyMap, layer); @@ -197,30 +199,41 @@ class PhysicsSystem extends WorldSystem { const bodyA = this.GetBody(bodyIdA); const bodyB = this.GetBody(bodyIdB); - let constraint: Jolt.Constraint | undefined = undefined; + const constraints: Jolt.Constraint[] = [] + let listener: Jolt.PhysicsStepListener | undefined = undefined; switch (jDef.jointMotionType!) { case mirabuf.joint.JointMotion.REVOLUTE: if (this.IsWheel(jDef)) { if (parser.directedGraph.GetAdjacencyList(rnA.id).length > 0) { - constraint = this.CreateWheelConstraint(jInst, jDef, bodyA, bodyB, parser.assembly.info!.version!)[1]; + const res = this.CreateWheelConstraint(jInst, jDef, bodyA, bodyB, parser.assembly.info!.version!); + constraints.push(res[0]) + constraints.push(res[1]) + listener = res[2] } else { - constraint = this.CreateWheelConstraint(jInst, jDef, bodyB, bodyA, parser.assembly.info!.version!)[1]; + const res = this.CreateWheelConstraint(jInst, jDef, bodyB, bodyA, parser.assembly.info!.version!); + constraints.push(res[0]) + constraints.push(res[1]) + listener = res[2] } } else { - constraint = this.CreateHingeConstraint(jInst, jDef, bodyA, bodyB, parser.assembly.info!.version!); + constraints.push(this.CreateHingeConstraint(jInst, jDef, bodyA, bodyB, parser.assembly.info!.version!)); } break; case mirabuf.joint.JointMotion.SLIDER: - constraint = this.CreateSliderConstraint(jInst, jDef, bodyA, bodyB); + constraints.push(this.CreateSliderConstraint(jInst, jDef, bodyA, bodyB)); break; default: console.debug('Unsupported joint detected. Skipping...'); break; } - if (constraint) - mechanism.AddConstraint({ parentBody: bodyIdA, childBody: bodyIdB, constraint: constraint }); + if (constraints.length > 0) { + constraints.forEach(x => mechanism.AddConstraint({ parentBody: bodyIdA, childBody: bodyIdB, constraint: x })) + } + if (listener) { + mechanism.AddStepListener(listener) + } } } @@ -351,7 +364,7 @@ class PhysicsSystem extends WorldSystem { public CreateWheelConstraint( jointInstance: mirabuf.joint.JointInstance, jointDefinition: mirabuf.joint.Joint, - bodyMain: Jolt.Body, bodyWheel: Jolt.Body, versionNum: number): [Jolt.Constraint, Jolt.VehicleConstraint] { + bodyMain: Jolt.Body, bodyWheel: Jolt.Body, versionNum: number): [Jolt.Constraint, Jolt.VehicleConstraint, Jolt.PhysicsStepListener] { // HINGE CONSTRAINT const fixedSettings = new JOLT.FixedConstraintSettings(); @@ -416,14 +429,14 @@ class PhysicsSystem extends WorldSystem { // Wheel Collision Tester const tester = new JOLT.VehicleCollisionTesterCastCylinder(bodyWheel.GetObjectLayer(), 0.05); vehicleConstraint.SetVehicleCollisionTester(tester); - this._joltPhysSystem.AddStepListener(new JOLT.VehicleConstraintStepListener(vehicleConstraint)); - + const listener = new JOLT.VehicleConstraintStepListener(vehicleConstraint); + this._joltPhysSystem.AddStepListener(listener); this._joltPhysSystem.AddConstraint(vehicleConstraint); this._joltPhysSystem.AddConstraint(fixedConstraint); this._constraints.push(fixedConstraint, vehicleConstraint); - return [fixedConstraint, vehicleConstraint]; + return [fixedConstraint, vehicleConstraint, listener]; } private IsWheel(jDef: mirabuf.joint.Joint) { @@ -615,11 +628,17 @@ class PhysicsSystem extends WorldSystem { } public DestroyMechanism(mech: Mechanism) { - mech.constraints.forEach(x => this._joltPhysSystem.RemoveConstraint(x.constraint)); + mech.stepListeners.forEach(x => { + this._joltPhysSystem.RemoveStepListener(x) + }) + mech.constraints.forEach(x => { + this._joltPhysSystem.RemoveConstraint(x.constraint) + }); mech.nodeToBody.forEach(x => { this._joltBodyInterface.RemoveBody(x); - this._joltBodyInterface.DestroyBody(x); + // this._joltBodyInterface.DestroyBody(x); }); + console.log('Mechanism destroyed') } public GetBody(bodyId: Jolt.BodyID) { @@ -650,18 +669,20 @@ export class LayerReserve { private _layer: number; private _isReleased: boolean; - public get layer() { return this._layer; } - public get isReleased() { return this._isReleased; } + public get layer() { return this._layer } + public get isReleased() { return this._isReleased } public constructor() { - this._layer = RobotLayers.pop()!; - this._isReleased = false; + this._layer = RobotLayers.shift()! + console.log(`Layer ${this._layer} Popped`) + this._isReleased = false } public Release() { if (!this._isReleased) { RobotLayers.push(this._layer); this._isReleased = true; + console.log(`Layer ${this._layer} Released`) } } } diff --git a/fission/src/systems/scene/SceneRenderer.ts b/fission/src/systems/scene/SceneRenderer.ts index 13c203ebe9..94cd545b36 100644 --- a/fission/src/systems/scene/SceneRenderer.ts +++ b/fission/src/systems/scene/SceneRenderer.ts @@ -14,6 +14,10 @@ class SceneRenderer extends WorldSystem { private _sceneObjects: Map; + public get sceneObjects() { + return this._sceneObjects; + } + public get mainCamera() { return this._mainCamera; } @@ -94,7 +98,7 @@ class SceneRenderer extends WorldSystem { } public Destroy(): void { - + this.RemoveAllSceneObjects() } public RegisterSceneObject(obj: T): number { @@ -102,6 +106,9 @@ class SceneRenderer extends WorldSystem { obj.id = id; this._sceneObjects.set(id, obj); obj.Setup(); + + console.debug(obj); + return id; } @@ -110,6 +117,13 @@ class SceneRenderer extends WorldSystem { this._sceneObjects.clear(); } + public RemoveSceneObject(id: number) { + const obj = this._sceneObjects.get(id) + if (this._sceneObjects.delete(id)) { + obj!.Dispose(); + } + } + public CreateSphere(radius: number, material?: THREE.Material | undefined): THREE.Mesh { const geo = new THREE.SphereGeometry(radius); if (material) { diff --git a/fission/src/systems/simulation/SimulationSystem.ts b/fission/src/systems/simulation/SimulationSystem.ts index 5580f8001f..ce95d15d46 100644 --- a/fission/src/systems/simulation/SimulationSystem.ts +++ b/fission/src/systems/simulation/SimulationSystem.ts @@ -42,6 +42,16 @@ class SimulationSystem extends WorldSystem { this._simMechanisms.clear(); } + public UnregisterMechanism(mech: Mechanism): boolean { + const layer = this._simMechanisms.get(mech); + if (this._simMechanisms.delete(mech)) { + layer?.SetBrain(undefined) + return true; + } else { + return false; + } + } + } class SimulationLayer { From e075988767fd75efbd2d2e19c518b97f32f3cafa Mon Sep 17 00:00:00 2001 From: Hunter Barclay Date: Tue, 28 May 2024 19:18:38 -0600 Subject: [PATCH 7/7] Janky updating --- .../src/modals/spawning/ManageAssembliesModal.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fission/src/modals/spawning/ManageAssembliesModal.tsx b/fission/src/modals/spawning/ManageAssembliesModal.tsx index 71dbafedda..c08a9417fb 100644 --- a/fission/src/modals/spawning/ManageAssembliesModal.tsx +++ b/fission/src/modals/spawning/ManageAssembliesModal.tsx @@ -1,7 +1,6 @@ -import React, { RefObject, useEffect, useRef } from "react" +import React, { useReducer } from "react" import Modal, { ModalPropsImpl } from "../../components/Modal" import { FaPlus } from "react-icons/fa6" -import ScrollView from "@/components/ScrollView" import Button from "@/components/Button"; import Label, { LabelSize } from "@/components/Label"; import World from "@/systems/World"; @@ -9,15 +8,16 @@ import MirabufSceneObject from "@/mirabuf/MirabufSceneObject"; interface AssemblyCardProps { id: number; + update: React.DispatchWithoutAction; } -const AssemblyCard: React.FC = ({ id }) => { +const AssemblyCard: React.FC = ({ id, update }) => { return (
) @@ -27,6 +27,8 @@ 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 assemblies = [...World.SceneRenderer.sceneObjects.entries()].filter(x => { const y = (x[1] instanceof MirabufSceneObject); return y }).map(x => x[0]) return ( @@ -46,7 +48,7 @@ const ManageAssembliesModal: React.FC = ({ modalId }) => {
{ - assemblies.map(x => AssemblyCard({id: x})) + assemblies.map(x => AssemblyCard({id: x, update: update})) }