From ef19da1ce09577570f503f51889f0dde2e8d4cf2 Mon Sep 17 00:00:00 2001 From: moxitech Date: Sun, 24 Nov 2024 02:48:27 +0700 Subject: [PATCH] RC2 --- .../components/ObjectProps/FormComponent.tsx | 7 +++++ .../src/app/components/Player/Player.tsx | 30 ++++++++++++++++--- .../components/Threejs/ThreeJsInstance.tsx | 5 +++- .../src/app/pages/simulations/page.tsx | 2 +- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx b/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx index 1040b2a..18967f4 100644 --- a/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx +++ b/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx @@ -101,6 +101,13 @@ const FormComponent = ({ entity, onUpdate }: Form onChange={(e) => handleInputChange('signalRadius', +e.target.value)} /> +
+ + +
{'antennaDirection' in formData && (
diff --git a/src/usn-frontend/src/app/components/Player/Player.tsx b/src/usn-frontend/src/app/components/Player/Player.tsx index d0ebf17..a92407f 100644 --- a/src/usn-frontend/src/app/components/Player/Player.tsx +++ b/src/usn-frontend/src/app/components/Player/Player.tsx @@ -163,6 +163,7 @@ const PlayerTsInstance: React.FC = ({ const [drones, setDrones] = useState([]); const [baseStations, setBaseStations] = useState([]); const [isPlaying, setIsPlaying] = useState(false); // Флаг для управления анимацией + const [droneTrajectories, setDroneTrajectories] = useState>({}); const intervalRef = useRef(null); @@ -176,13 +177,26 @@ const PlayerTsInstance: React.FC = ({ const updateObjects = (timestamp: number) => { if (!Simulations) return; - const simulationStep = Simulations[timestamp]; + const timestampKey = timestamp.toString(); + const simulationStep = Simulations[timestampKey]; + if (simulationStep) { const updatedDrones = Object.values(simulationStep).map((drone) => ({ ...drone, })); - // @ts-ignore setDrones(updatedDrones); + + // Обновление траектории для каждого дрона + setDroneTrajectories((prevTrajectories) => { + const newTrajectories = { ...prevTrajectories }; + updatedDrones.forEach((drone) => { + if (!newTrajectories[drone.name]) { + newTrajectories[drone.name] = []; + } + newTrajectories[drone.name] = [...newTrajectories[drone.name], drone.position]; + }); + return newTrajectories; + }); } }; @@ -231,7 +245,7 @@ const PlayerTsInstance: React.FC = ({ ))} @@ -244,6 +258,15 @@ const PlayerTsInstance: React.FC = ({ droneName={drone.name} /> ))} + {Object.entries(droneTrajectories).map(([droneName, positions]) => ( + + ))}
@@ -262,7 +285,6 @@ const PlayerTsInstance: React.FC = ({ ); }; - // Модель карты const MapModel = () => { const { scene } = useGLTF('/map/map.glb'); diff --git a/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx b/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx index 4716df9..00269a5 100644 --- a/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx +++ b/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx @@ -1,6 +1,6 @@ "use client"; import { Canvas } from '@react-three/fiber'; -import { OrbitControls, useGLTF, Line, Text } from '@react-three/drei'; +import { OrbitControls, useGLTF, Line, Text, Box } from '@react-three/drei'; import { useState, useEffect, useRef } from 'react'; import { Drone, BaseStation } from './Models'; import { PlayCircleIcon } from '@heroicons/react/24/outline'; @@ -260,6 +260,9 @@ const DroneModel = ({ position, droneName, onClick, isSelected }: { position: [n )} + + + ); }; diff --git a/src/usn-frontend/src/app/pages/simulations/page.tsx b/src/usn-frontend/src/app/pages/simulations/page.tsx index 1485f90..9688c0e 100644 --- a/src/usn-frontend/src/app/pages/simulations/page.tsx +++ b/src/usn-frontend/src/app/pages/simulations/page.tsx @@ -21,7 +21,7 @@ const Simulations: React.FC = () => { position: drone.position, freq: drone.frequency, radius: drone.signalRadius, - endpoints: [[0, 5, 1], [10, 5, 1]], // TODO: статические значения + endpoints: [drone.position, [7, 5, 2], [9, 5, 2], [10, 5, 1]], // TODO: статические значения speed: 1 // TODO: можно изменить при необходимости }));