Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ef19da1ce0 |
@ -101,6 +101,13 @@ const FormComponent = <T extends Drone | BaseStation>({ entity, onUpdate }: Form
|
||||
onChange={(e) => handleInputChange('signalRadius', +e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<label className="block mb-1 text-sm font-medium">Signal power:</label>
|
||||
<input
|
||||
className="w-full p-2 bg-gray-800 border border-gray-600 rounded focus:outline-none focus:border-blue-500"
|
||||
type="number"
|
||||
/>
|
||||
</div>
|
||||
{'antennaDirection' in formData && (
|
||||
<div className="mb-4">
|
||||
<label className="block mb-1 text-sm font-medium">Antenna Direction (x, y, z):</label>
|
||||
|
@ -163,6 +163,7 @@ const PlayerTsInstance: React.FC<IPlayerTsInstance> = ({
|
||||
const [drones, setDrones] = useState<DroneSim[]>([]);
|
||||
const [baseStations, setBaseStations] = useState<BaseStation[]>([]);
|
||||
const [isPlaying, setIsPlaying] = useState(false); // Флаг для управления анимацией
|
||||
const [droneTrajectories, setDroneTrajectories] = useState<Record<string, [number, number, number][]>>({});
|
||||
|
||||
const intervalRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
@ -176,13 +177,26 @@ const PlayerTsInstance: React.FC<IPlayerTsInstance> = ({
|
||||
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;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -244,6 +258,15 @@ const PlayerTsInstance: React.FC<IPlayerTsInstance> = ({
|
||||
droneName={drone.name}
|
||||
/>
|
||||
))}
|
||||
{Object.entries(droneTrajectories).map(([droneName, positions]) => (
|
||||
<Line
|
||||
key={droneName}
|
||||
points={positions} // массив позиций для линии
|
||||
color="red" // цвет линии
|
||||
lineWidth={2} // ширина линии
|
||||
dashed={false}
|
||||
/>
|
||||
))}
|
||||
</Canvas>
|
||||
</div>
|
||||
|
||||
@ -262,7 +285,6 @@ const PlayerTsInstance: React.FC<IPlayerTsInstance> = ({
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Модель карты
|
||||
const MapModel = () => {
|
||||
const { scene } = useGLTF('/map/map.glb');
|
||||
|
@ -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
|
||||
<meshBasicMaterial color="red" wireframe />
|
||||
</mesh>
|
||||
)}
|
||||
<Box position={position}>
|
||||
<meshBasicMaterial color="green" wireframe />
|
||||
</Box>
|
||||
</group>
|
||||
);
|
||||
};
|
||||
|
@ -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: можно изменить при необходимости
|
||||
}));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user