Refactor simulation paths to simulation states

- Updated all instances of `simulationPaths` to `simulationStates` across multiple components including copyPasteControls, duplicationControls, moveControls, rotateControls, selectionControls, and others.
- Adjusted related state management hooks in the store to reflect the change from `simulationPaths` to `simulationStates`.
- Ensured that all references to simulation paths in the simulation logic and UI components are consistent with the new naming convention.
This commit is contained in:
2025-04-05 10:12:28 +05:30
parent 42f0ae5317
commit e92345d820
22 changed files with 260 additions and 333 deletions

View File

@@ -1,5 +1,5 @@
// import { useMemo, useState } from 'react';
// import { useSelectedActionSphere, useToggleView, useSimulationPaths, useSelectedPath, useStartSimulation, useDrawMaterialPath } from '../../store/store';
// import { useSelectedActionSphere, useToggleView, useSimulationStates, useSelectedPath, useStartSimulation, useDrawMaterialPath } from '../../store/store';
// import * as THREE from 'three';
// import useModuleStore from '../../store/useModuleStore';
@@ -9,14 +9,14 @@
// const { startSimulation, setStartSimulation } = useStartSimulation();
// const { selectedActionSphere } = useSelectedActionSphere();
// const { selectedPath, setSelectedPath } = useSelectedPath();
// const { simulationPaths, setSimulationPaths } = useSimulationPaths();
// const { simulationStates, setSimulationStates } = useSimulationStates();
// const { drawMaterialPath, setDrawMaterialPath } = useDrawMaterialPath();
// const [activeButton, setActiveButton] = useState<string | null>(null);
// const handleAddAction = () => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) => {
// if (point.uuid === selectedActionSphere.points.uuid) {
@@ -37,13 +37,13 @@
// }),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleDeleteAction = (uuid: string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -52,13 +52,13 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleActionSelect = (uuid: string, actionType: string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -72,13 +72,13 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleMaterialSelect = (uuid: string, material: string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -92,13 +92,13 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleDelayChange = (uuid: string, delay: number | string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -112,13 +112,13 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleSpawnIntervalChange = (uuid: string, spawnInterval: number | string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -132,24 +132,24 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleSpeedChange = (speed: number) => {
// if (!selectedPath) return;
// const updatedPaths = simulationPaths.map((path) =>
// const updatedPaths = simulationStates.map((path) =>
// path.modeluuid === selectedPath.path.modeluuid ? { ...path, speed } : path
// );
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// setSelectedPath({ ...selectedPath, path: { ...selectedPath.path, speed } });
// };
// const handleAddTrigger = () => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) => {
// if (point.uuid === selectedActionSphere.points.uuid) {
@@ -167,13 +167,13 @@
// }),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleDeleteTrigger = (uuid: string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -182,13 +182,13 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleTriggerSelect = (uuid: string, triggerType: string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -202,7 +202,7 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleResetPath = () => {
@@ -214,7 +214,7 @@
// const handleActionToggle = (uuid: string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -229,13 +229,13 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const handleTriggerToggle = (uuid: string) => {
// if (!selectedActionSphere) return;
// const updatedPaths = simulationPaths.map((path) => ({
// const updatedPaths = simulationStates.map((path) => ({
// ...path,
// points: path.points.map((point) =>
// point.uuid === selectedActionSphere.points.uuid
@@ -250,13 +250,13 @@
// ),
// }));
// setSimulationPaths(updatedPaths);
// setSimulationStates(updatedPaths);
// };
// const selectedPoint = useMemo(() => {
// if (!selectedActionSphere) return null;
// return simulationPaths.flatMap((path) => path.points).find((point) => point.uuid === selectedActionSphere.points.uuid);
// }, [selectedActionSphere, simulationPaths]);
// return simulationStates.flatMap((path) => path.points).find((point) => point.uuid === selectedActionSphere.points.uuid);
// }, [selectedActionSphere, simulationStates]);
// const createPath = () => {
// setActiveButton(activeButton !== 'addMaterialPath' ? 'addMaterialPath' : null);