From 61912545e61caba79a406d7e6b8ed6bd543eca52 Mon Sep 17 00:00:00 2001 From: moxitech Date: Mon, 18 Nov 2024 16:45:14 +0700 Subject: [PATCH] RC1 --- .../components/ObjectProps/FormComponent.tsx | 9 ++++ .../src/app/components/Player/Model.tsx | 6 +-- .../src/app/components/Player/Player.tsx | 46 +++++++++---------- .../src/app/components/Threejs/Models.tsx | 1 + .../components/Threejs/ThreeJsInstance.tsx | 1 + 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx b/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx index 5ed5de7..1040b2a 100644 --- a/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx +++ b/src/usn-frontend/src/app/components/ObjectProps/FormComponent.tsx @@ -147,6 +147,15 @@ const FormComponent = ({ entity, onUpdate }: Form )} + {"speed" in formData && (
+ + handleInputChange('signalRadius', +e.target.value)} + /> +
)} ); }; diff --git a/src/usn-frontend/src/app/components/Player/Model.tsx b/src/usn-frontend/src/app/components/Player/Model.tsx index 22a9444..b378494 100644 --- a/src/usn-frontend/src/app/components/Player/Model.tsx +++ b/src/usn-frontend/src/app/components/Player/Model.tsx @@ -7,16 +7,16 @@ import { SimDrone } from "../Threejs/Models" // UAV?: SimDrone[] // беспилотные аппараты - DTO // } -export interface Drone { +export interface DroneSim { connected_to: string | null; frequency: number; name: string; position: [number, number, number]; - rssi: number | null; + rssi: number | undefined; } export interface IPlayerSimulationPart { [key: string]: { - [droneName: string]: Drone; + [droneName: string]: DroneSim; }; } diff --git a/src/usn-frontend/src/app/components/Player/Player.tsx b/src/usn-frontend/src/app/components/Player/Player.tsx index 757257c..d0ebf17 100644 --- a/src/usn-frontend/src/app/components/Player/Player.tsx +++ b/src/usn-frontend/src/app/components/Player/Player.tsx @@ -1,9 +1,9 @@ "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 React, { useState, useEffect, useRef } from 'react'; import { Drone, BaseStation, SimDrone } from '../Threejs/Models'; -import { IPlayerSimulationPart } from './Model'; +import { DroneSim, IPlayerSimulationPart } from './Model'; interface Player { @@ -150,29 +150,17 @@ interface IPlayerTsInstance { TimestampEnd?: number TimestampStep?: number Simulations?: IPlayerSimulationPart - //// IPlayerSimulationPart - часть симуляции - // interface Drone { - // connected_to: string | null; - // frequency: number; - // name: string; - // position: [number, number, number]; - // rssi: number | null; - // } - - // interface IPlayerSimulationPart { - // [key: string]: { - // [droneName: string]: Drone; - // }; - // } + BaseStations?: BaseStation[] } const PlayerTsInstance: React.FC = ({ TimestampEnd = 299, // Конечная временная метка TimestampStep = 1, // Шаг временной метки Simulations, + BaseStations, }) => { const [currentTimestamp, setCurrentTimestamp] = useState(0); - const [drones, setDrones] = useState([]); + const [drones, setDrones] = useState([]); const [baseStations, setBaseStations] = useState([]); const [isPlaying, setIsPlaying] = useState(false); // Флаг для управления анимацией @@ -252,6 +240,7 @@ const PlayerTsInstance: React.FC = ({ ))} @@ -280,7 +269,7 @@ const MapModel = () => { return ; }; // Модель дрона -const DroneModel = ({ position, droneName, onClick, isSelected }: { position: [number, number, number]; droneName?: string; onClick: () => void; isSelected: boolean }) => { +const DroneModel = ({ position, droneName, rssi, onClick, isSelected }: { position: [number, number, number]; droneName?: string; rssi?: number, onClick: () => void; isSelected: boolean }) => { const { scene } = useGLTF('/objects/drone.glb'); return ( @@ -294,17 +283,24 @@ const DroneModel = ({ position, droneName, onClick, isSelected }: { position: [n anchorY="middle" // Центровка текста по Y > {droneName} - + + + RSSI {rssi} + {isSelected && ( - - )} - - - - + )} + + + ); }; diff --git a/src/usn-frontend/src/app/components/Threejs/Models.tsx b/src/usn-frontend/src/app/components/Threejs/Models.tsx index c2e95a0..6e94a1e 100644 --- a/src/usn-frontend/src/app/components/Threejs/Models.tsx +++ b/src/usn-frontend/src/app/components/Threejs/Models.tsx @@ -4,6 +4,7 @@ export interface Drone { position: [number, number, number]; frequency: number; signalRadius: number; + speed: number } export interface BaseStation { diff --git a/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx b/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx index cc56cd6..4716df9 100644 --- a/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx +++ b/src/usn-frontend/src/app/components/Threejs/ThreeJsInstance.tsx @@ -45,6 +45,7 @@ const ThreeJsInstance : React.FC = ({Click}) => { position: [Math.random() * 10, 5, Math.random() * 10], frequency: Math.random() * 100 + 400, // Example frequency range between 400-500 signalRadius: Math.random() * 5 + 5, // Example signal radius between 5-10 + speed: 1, }, ]); };