RC1
This commit is contained in:
parent
af1cefc71c
commit
61912545e6
@ -147,6 +147,15 @@ const FormComponent = <T extends Drone | BaseStation>({ entity, onUpdate }: Form
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{"speed" in formData && (<div className="mb-4">
|
||||
<label className="block mb-1 text-sm font-medium">Speed:</label>
|
||||
<input
|
||||
className="w-full p-2 bg-gray-800 border border-gray-600 rounded focus:outline-none focus:border-blue-500"
|
||||
type="number"
|
||||
value={formData.speed}
|
||||
onChange={(e) => handleInputChange('signalRadius', +e.target.value)}
|
||||
/>
|
||||
</div>)}
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
@ -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<IPlayerTsInstance> = ({
|
||||
TimestampEnd = 299, // Конечная временная метка
|
||||
TimestampStep = 1, // Шаг временной метки
|
||||
Simulations,
|
||||
BaseStations,
|
||||
}) => {
|
||||
const [currentTimestamp, setCurrentTimestamp] = useState(0);
|
||||
const [drones, setDrones] = useState<Drone[]>([]);
|
||||
const [drones, setDrones] = useState<DroneSim[]>([]);
|
||||
const [baseStations, setBaseStations] = useState<BaseStation[]>([]);
|
||||
const [isPlaying, setIsPlaying] = useState(false); // Флаг для управления анимацией
|
||||
|
||||
@ -252,6 +240,7 @@ const PlayerTsInstance: React.FC<IPlayerTsInstance> = ({
|
||||
<DroneModel
|
||||
key={drone.name}
|
||||
position={drone.position}
|
||||
rssi={drone.rssi}
|
||||
droneName={drone.name}
|
||||
/>
|
||||
))}
|
||||
@ -280,7 +269,7 @@ const MapModel = () => {
|
||||
return <primitive object={scene} scale={[2, 2, 2]} />;
|
||||
};
|
||||
// Модель дрона
|
||||
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 (
|
||||
<group onClick={onClick}>
|
||||
@ -294,17 +283,24 @@ const DroneModel = ({ position, droneName, onClick, isSelected }: { position: [n
|
||||
anchorY="middle" // Центровка текста по Y
|
||||
>
|
||||
{droneName}
|
||||
</Text>
|
||||
</Text >
|
||||
<Text
|
||||
position={[position[0], position[1] + 6, position[2]]} // Позиционируем текст над дроном
|
||||
fontSize={1}
|
||||
color="yellow" // Цвет текста
|
||||
anchorX="center" // Центровка текста по X
|
||||
anchorY="middle" // Центровка текста по Y
|
||||
>
|
||||
RSSI {rssi}
|
||||
</Text >
|
||||
{isSelected && (
|
||||
<mesh position={position}>
|
||||
<sphereGeometry args={[1, 16, 16]} />
|
||||
<meshBasicMaterial color="red" wireframe />
|
||||
</mesh>
|
||||
)}
|
||||
<mesh position={position}>
|
||||
<sphereGeometry args={[1, 16, 16]} />
|
||||
<meshBasicMaterial color="red" wireframe />
|
||||
</mesh>
|
||||
</mesh>)}
|
||||
<Box position={position}>
|
||||
<meshBasicMaterial color="green" wireframe />
|
||||
</Box>
|
||||
</group>
|
||||
);
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ export interface Drone {
|
||||
position: [number, number, number];
|
||||
frequency: number;
|
||||
signalRadius: number;
|
||||
speed: number
|
||||
}
|
||||
|
||||
export interface BaseStation {
|
||||
|
@ -45,6 +45,7 @@ const ThreeJsInstance : React.FC<IThreeJsInstance> = ({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,
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user