解决了一下 机器转向的问题
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||
import carImg from '../assets/images/car.png';
|
||||
import carImg from '../assets/images/carplane.png';
|
||||
import inspectImg from "../assets/images/inspectCar.png"
|
||||
import planeImg from '../assets/images/plane.png';
|
||||
import planeImg from '../assets/images/planeicon.png';
|
||||
import cameraImg from '../assets/images/camera.png';
|
||||
import droneInspectImg from '../assets/images/xunjiancar.png';
|
||||
import gecocar from '../assets/images/gecaocar.png';
|
||||
@@ -65,6 +65,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
const realtimeCarEntityRef = useRef(null);
|
||||
const realtimeLastPointRef = useRef(null);
|
||||
const realtimeHiddenRef = useRef(false);
|
||||
const focusEntityRef = useRef(null);
|
||||
|
||||
|
||||
const yellowCircleCanvas = useMemo(
|
||||
() => createYellowCircleCanvas(30),
|
||||
@@ -290,6 +292,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (viewerRef.current) {
|
||||
drawTrackLine(points);
|
||||
@@ -722,8 +725,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
position,
|
||||
billboard: {
|
||||
image: carImg,
|
||||
width: 60,
|
||||
height: 60,
|
||||
width: 30,
|
||||
height: 30,
|
||||
verticalOrigin: window.Cesium.VerticalOrigin.BOTTOM,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
||||
},
|
||||
@@ -784,7 +787,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
};
|
||||
}, []);
|
||||
|
||||
const focusEntityRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
// 如果有 realtimePosition,不显示 focusEntity
|
||||
@@ -824,8 +826,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
position: Cesium.Cartesian3.fromDegrees(Number(focusLocation.lon), Number(focusLocation.lat), 0),
|
||||
billboard: {
|
||||
image: image,
|
||||
width: 60,
|
||||
height: 60,
|
||||
width: 30,
|
||||
height: 30,
|
||||
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
},
|
||||
@@ -963,8 +965,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
orientation: orientation,
|
||||
billboard: {
|
||||
image: carImg,
|
||||
width: 50,
|
||||
height: 50,
|
||||
width: 30,
|
||||
height: 30,
|
||||
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
color: Cesium.Color.YELLOW.withAlpha(0.8),
|
||||
@@ -1153,9 +1155,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
// ==============================
|
||||
|
||||
let image = carImg;
|
||||
let width = 60;
|
||||
let height = 60;
|
||||
const carsize = device?.productId == 138 ? 40 : 60;
|
||||
let width = 30;
|
||||
let height = 30;
|
||||
const carsize = device?.productId == 138 ? 30 : 30;
|
||||
|
||||
|
||||
|
||||
@@ -1180,14 +1182,14 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
device?.type === "plane" ||
|
||||
device?.type === "drone" ||
|
||||
device?.type === "drone-inspect"
|
||||
? 70
|
||||
? 30
|
||||
: carsize;
|
||||
|
||||
height =
|
||||
device?.type === "plane" ||
|
||||
device?.type === "drone" ||
|
||||
device?.type === "drone-inspect"
|
||||
? 70
|
||||
? 30
|
||||
: carsize;
|
||||
|
||||
}
|
||||
@@ -1554,9 +1556,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
const dx = last.lon - lon;
|
||||
const dy = last.lat - lat;
|
||||
const dist = Math.sqrt(dx * dx + dy * dy);
|
||||
if (dist < 0.0000001) {
|
||||
shouldAdd = false;
|
||||
}
|
||||
//if (dist < 0.0000001) {
|
||||
// shouldAdd = false;
|
||||
//}
|
||||
}
|
||||
|
||||
if (shouldAdd && drawRealTime) {
|
||||
@@ -1585,14 +1587,18 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
// 无人机图标
|
||||
const img = realtimeType === 'plane' || realtimeType === 'drone' ? planeImg : carImg;
|
||||
const imgWidth = 70;
|
||||
const imgHeight = 70;
|
||||
const imgWidth = 30;
|
||||
const imgHeight = 30;
|
||||
|
||||
// 如果有航向角,设置旋转
|
||||
let rotation = 0;
|
||||
|
||||
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
||||
let headingDeg = Number(realtimePosition.heading);
|
||||
rotation = Cesium.Math.toRadians(headingDeg);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//rotation = Cesium.Math.toRadians(-3.17);
|
||||
@@ -1707,16 +1713,17 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
// 机器人图标
|
||||
const img = carImg;
|
||||
const imgWidth = 60;
|
||||
const imgHeight = 60;
|
||||
const imgWidth = 30;
|
||||
const imgHeight = 30;
|
||||
|
||||
// 如果有航向角,设置旋转
|
||||
let rotation = 0;
|
||||
|
||||
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
||||
let headingDeg = Number(realtimePosition.heading);
|
||||
|
||||
rotation = Cesium.Math.toRadians(headingDeg);
|
||||
}
|
||||
|
||||
if (!realtimeCarEntityRef.current) {
|
||||
realtimeCarEntityRef.current = viewer.entities.add({
|
||||
position: position,
|
||||
|
||||
Reference in New Issue
Block a user