feat: Enhance vehicle simulation with draggable path points and interactive controls
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useSceneContext } from "../../scene/sceneContext";
|
||||
import { useProductContext } from "../products/productContext";
|
||||
import { determineExecutionMachineSequences } from "./functions/determineExecutionMachineSequences";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import { useSimulationManager } from "../../../store/rough/useSimulationManagerStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../builder/version/versionContext";
|
||||
import { updateSimulateData, saveSimulationData, getSimulationData } from "../../../components/layout/scenes/functions/simulationStorage";
|
||||
import { get } from "http";
|
||||
import { set } from "immer/dist/internal";
|
||||
import { useSimulateId } from "../../../store/builder/store";
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useSceneContext } from '../../scene/sceneContext';
|
||||
import { determineExecutionMachineSequences } from './functions/determineExecutionMachineSequences';
|
||||
import { usePlayButtonStore } from '../../../store/ui/usePlayButtonStore';
|
||||
import { useSimulationManager } from '../../../store/rough/useSimulationManagerStore';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useSimulateId } from '../../../store/builder/store';
|
||||
|
||||
interface SimulationUsageRecord {
|
||||
activeTime: number;
|
||||
isActive: boolean;
|
||||
@@ -36,14 +32,12 @@ interface ProjectSimulation {
|
||||
versions: VersionSimulation[];
|
||||
}
|
||||
const SimulationHandler = () => {
|
||||
const { materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore, productStore, craneStore, humanStore } = useSceneContext();
|
||||
const { materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore, productStore, craneStore, humanStore, versionStore } = useSceneContext();
|
||||
const { armBots, getArmBotById } = armBotStore();
|
||||
const { vehicles, getVehicleById } = vehicleStore();
|
||||
const { getConveyorById } = conveyorStore();
|
||||
const { materialHistory, materials } = materialStore();
|
||||
const { getProductById } = productStore();
|
||||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { getProductById, selectedProduct } = productStore();
|
||||
const { machines, getMachineById } = machineStore();
|
||||
const { getHumanById } = humanStore();
|
||||
const { getCraneById } = craneStore();
|
||||
@@ -51,8 +45,6 @@ const SimulationHandler = () => {
|
||||
const { isPlaying, setIsPlaying } = usePlayButtonStore();
|
||||
const { simulationRecords, addSimulationRecord } = useSimulationManager();
|
||||
const { projectId } = useParams();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const [simulationEntry, setSimulationEntry] = useState<any>();
|
||||
const { setSimulateId } = useSimulateId();
|
||||
const COST_RATES: Record<SimulationUsageRecord["type"], number> = {
|
||||
@@ -64,6 +56,7 @@ const SimulationHandler = () => {
|
||||
human: 4,
|
||||
machine: 3,
|
||||
};
|
||||
const { selectedVersion } = versionStore();
|
||||
|
||||
// Calculate totals for one product
|
||||
function calculateProductMetrics(product: ProductSimulation) {
|
||||
|
||||
@@ -1,28 +1,21 @@
|
||||
import { useEffect } from "react";
|
||||
import { useActionHandler } from "../actions/useActionHandler";
|
||||
import { usePlayButtonStore, useResetButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import { usePlayButtonStore, useResetButtonStore } from "../../../store/ui/usePlayButtonStore";
|
||||
import { determineExecutionOrder } from "./functions/determineExecutionOrder";
|
||||
import { useProductContext } from "../products/productContext";
|
||||
import { useSceneContext } from "../../scene/sceneContext";
|
||||
import SimulationHandler from "./SimulationHandler";
|
||||
import { getSimulationData, saveSimulationData } from "../../../components/layout/scenes/functions/simulationStorage";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../builder/version/versionContext";
|
||||
import { version } from "os";
|
||||
import { get } from "http";
|
||||
import { getSimulationData, saveSimulationData } from "../../../components/layout/scenes/functions/simulationStorage";
|
||||
import { useSimulationManager } from "../../../store/rough/useSimulationManagerStore";
|
||||
|
||||
function Simulator() {
|
||||
const { selectedProductStore } = useProductContext();
|
||||
const { productStore } = useSceneContext();
|
||||
const { products, getProductById } = productStore();
|
||||
const { productStore,versionStore } = useSceneContext();
|
||||
const { products, getProductById, selectedProduct } = productStore();
|
||||
const { handleAction } = useActionHandler();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { isReset } = useResetButtonStore();
|
||||
const { projectId } = useParams();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { selectedVersion } = versionStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPlaying || isReset || !selectedProduct.productUuid) return;
|
||||
|
||||
Reference in New Issue
Block a user