From 6b92b6c23550d5ed8d3047529ff5a20646cbf035 Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Thu, 27 Mar 2025 10:02:44 +0530 Subject: [PATCH] Refactor simulation components and UI integration --- app/src/modules/scene/scene.tsx | 3 +-- app/src/modules/simulation/simulationUI.tsx | 15 +++++++++++++-- .../simulation/simulationtemp/path/pathFlow.tsx | 4 ++-- app/src/pages/Project.tsx | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/src/modules/scene/scene.tsx b/app/src/modules/scene/scene.tsx index df1246a..e86b9f2 100644 --- a/app/src/modules/scene/scene.tsx +++ b/app/src/modules/scene/scene.tsx @@ -15,7 +15,7 @@ import background from "../../assets/textures/hdr/mudroadpuresky2k.hdr"; import SelectionControls from "./controls/selection/selectionControls"; import MeasurementTool from "./tools/measurementTool"; import Simulation from "../simulation/simulation"; -// import Simulation from "./simulationtemp/simulation"; +// import Simulation from "../simulation/simulationtemp/simulation"; export default function Scene() { @@ -41,7 +41,6 @@ export default function Scene() { - {/* */} diff --git a/app/src/modules/simulation/simulationUI.tsx b/app/src/modules/simulation/simulationUI.tsx index e7d1834..3a84134 100644 --- a/app/src/modules/simulation/simulationUI.tsx +++ b/app/src/modules/simulation/simulationUI.tsx @@ -1,5 +1,5 @@ import { useMemo, useState } from 'react'; -import { useSelectedActionSphere, useToggleView, useSimulationPaths, useSelectedPath, useStartSimulation } from '../../store/store'; +import { useSelectedActionSphere, useToggleView, useSimulationPaths, useSelectedPath, useStartSimulation, useDrawMaterialPath } from '../../store/store'; import * as THREE from 'three'; import useModuleStore from '../../store/useModuleStore'; @@ -10,6 +10,8 @@ function SimulationUI() { const { selectedActionSphere } = useSelectedActionSphere(); const { selectedPath, setSelectedPath } = useSelectedPath(); const { simulationPaths, setSimulationPaths } = useSimulationPaths(); + const { drawMaterialPath, setDrawMaterialPath } = useDrawMaterialPath(); + const [activeButton, setActiveButton] = useState(null); const handleAddAction = () => { if (!selectedActionSphere) return; @@ -256,10 +258,15 @@ function SimulationUI() { return simulationPaths.flatMap((path) => path.points).find((point) => point.uuid === selectedActionSphere.point.uuid); }, [selectedActionSphere, simulationPaths]); + const createPath = () => { + setActiveButton(activeButton !== 'addMaterialPath' ? 'addMaterialPath' : null); + setDrawMaterialPath(!drawMaterialPath); + } + return ( <> {activeModule === "simulation" && ( -
+
{!ToggleView && ( <> } +
+ {selectedPath && (
diff --git a/app/src/modules/simulation/simulationtemp/path/pathFlow.tsx b/app/src/modules/simulation/simulationtemp/path/pathFlow.tsx index 63d38e2..586fd3a 100644 --- a/app/src/modules/simulation/simulationtemp/path/pathFlow.tsx +++ b/app/src/modules/simulation/simulationtemp/path/pathFlow.tsx @@ -2,7 +2,7 @@ import * as THREE from 'three'; import { useState, useEffect, useRef, useMemo } from "react"; import { useLoader, useFrame } from "@react-three/fiber"; import { GLTFLoader } from "three-stdlib"; -import crate from "../../../../assets/models/gltf-glb/crate_box.glb"; +import crate from "../../../../assets/gltf-glb/crate_box.glb"; import { useOrganization } from '../../../../store/store'; import { useControls } from 'leva'; @@ -47,7 +47,7 @@ export default function PathFlow({ path, connections }: PathFlowProps) { }; useFrame(() => { - if (organization !== 'hexrfactory' || isStopped || !path) return; + if (isStopped || !path) return; const now = performance.now(); diff --git a/app/src/pages/Project.tsx b/app/src/pages/Project.tsx index 8a48516..e65c2a2 100644 --- a/app/src/pages/Project.tsx +++ b/app/src/pages/Project.tsx @@ -16,7 +16,7 @@ import { useLoadingProgress, } from "../store/store"; import { useNavigate } from "react-router-dom"; -// import SimulationUI from "../modules/simulation/simulationUI"; +import SimulationUI from "../modules/simulation/simulationUI"; import LoadingPage from "../components/templates/LoadingPage"; const Project: React.FC = () => { @@ -55,7 +55,7 @@ const Project: React.FC = () => { {activeModule !== "market" && } - {/* */} +
); };