// import { useMemo, useState } from 'react'; // import { useSelectedActionSphere, useToggleView, useSimulationPaths, useSelectedPath, useStartSimulation, useDrawMaterialPath } from '../../store/store'; // import * as THREE from 'three'; // import useModuleStore from '../../store/useModuleStore'; // function SimulationUI() { // const { ToggleView } = useToggleView(); // const { activeModule } = useModuleStore(); // const { startSimulation, setStartSimulation } = useStartSimulation(); // 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; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => { // if (point.uuid === selectedActionSphere.point.uuid) { // const actionIndex = point.actions.length; // const newAction = { // uuid: THREE.MathUtils.generateUUID(), // name: `Action ${actionIndex + 1}`, // Assign action name based on index // type: 'Inherit', // material: 'Inherit', // delay: 'Inherit', // spawnInterval: 'Inherit', // isUsed: false // }; // return { ...point, actions: [...point.actions, newAction] }; // } // return point; // }), // })); // setSimulationPaths(updatedPaths); // }; // const handleDeleteAction = (uuid: string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { ...point, actions: point.actions.filter(action => action.uuid !== uuid) } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleActionSelect = (uuid: string, actionType: string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { // ...point, // actions: point.actions.map((action) => // action.uuid === uuid ? { ...action, type: actionType } : action // ), // } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleMaterialSelect = (uuid: string, material: string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { // ...point, // actions: point.actions.map((action) => // action.uuid === uuid ? { ...action, material } : action // ), // } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleDelayChange = (uuid: string, delay: number | string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { // ...point, // actions: point.actions.map((action) => // action.uuid === uuid ? { ...action, delay } : action // ), // } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleSpawnIntervalChange = (uuid: string, spawnInterval: number | string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { // ...point, // actions: point.actions.map((action) => // action.uuid === uuid ? { ...action, spawnInterval } : action // ), // } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleSpeedChange = (speed: number) => { // if (!selectedPath) return; // const updatedPaths = simulationPaths.map((path) => // path.modeluuid === selectedPath.path.modeluuid ? { ...path, speed } : path // ); // setSimulationPaths(updatedPaths); // setSelectedPath({ ...selectedPath, path: { ...selectedPath.path, speed } }); // }; // const handleAddTrigger = () => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => { // if (point.uuid === selectedActionSphere.point.uuid) { // const triggerIndex = point.triggers.length; // const newTrigger = { // uuid: THREE.MathUtils.generateUUID(), // name: `Trigger ${triggerIndex + 1}`, // Assign name based on index // type: '', // isUsed: false // }; // return { ...point, triggers: [...point.triggers, newTrigger] }; // } // return point; // }), // })); // setSimulationPaths(updatedPaths); // }; // const handleDeleteTrigger = (uuid: string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { ...point, triggers: point.triggers.filter(trigger => trigger.uuid !== uuid) } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleTriggerSelect = (uuid: string, triggerType: string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { // ...point, // triggers: point.triggers.map((trigger) => // trigger.uuid === uuid ? { ...trigger, type: triggerType } : trigger // ), // } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleResetPath = () => { // if (!selectedPath) return; // }; // const handleActionToggle = (uuid: string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { // ...point, // actions: point.actions.map((action) => ({ // ...action, // isUsed: action.uuid === uuid ? !action.isUsed : false, // })), // } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const handleTriggerToggle = (uuid: string) => { // if (!selectedActionSphere) return; // const updatedPaths = simulationPaths.map((path) => ({ // ...path, // points: path.points.map((point) => // point.uuid === selectedActionSphere.point.uuid // ? { // ...point, // triggers: point.triggers.map((trigger) => ({ // ...trigger, // isUsed: trigger.uuid === uuid ? !trigger.isUsed : false, // })), // } // : point // ), // })); // setSimulationPaths(updatedPaths); // }; // const selectedPoint = useMemo(() => { // if (!selectedActionSphere) return null; // 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 && ( // <> // //
// {!ToggleView && } //
// {selectedPath && ( //
// // handleSpeedChange(parseFloat(e.target.value))} // /> //
// )} // {selectedActionSphere && ( //
// // // {selectedPoint?.actions.map((action) => ( //
// // // // {(action.type === 'Spawn' || action.type === 'Swap') && ( //
// //
// )} // {action.type === 'Delay' && ( //
// // handleDelayChange(action.uuid, parseInt(e.target.value) || 'Inherit')} // /> //
// )} // {action.type === 'Spawn' && ( //
// // handleSpawnIntervalChange(action.uuid, parseInt(e.target.value) || 'Inherit')} // /> //
// )} //
//
// ))} //
// {selectedPoint?.triggers.map((trigger) => ( //
// // // //
//
// ))} //
// )} // {selectedPath && ( //
// //
// )} // // )} //
// )} // // ); // } // export default SimulationUI;