This commit is contained in:
Aifeilong 2023-09-11 15:44:30 +08:00
parent fbf38619e1
commit 8ae3f47c1b
4 changed files with 67 additions and 29 deletions

View File

@ -6,7 +6,7 @@ function CustomClock({ start, stop }) {
return ( return (
<Clock <Clock
multiplier={1} multiplier={1}
shouldAnimate={true} shouldAnimate={false}
startTime={start.clone()} startTime={start.clone()}
stopTime={stop.clone()} stopTime={stop.clone()}
currentTime={start.clone()} currentTime={start.clone()}

View File

@ -1,25 +1,57 @@
import { CameraFlyTo, useCesium } from "resium"; import { Camera, useCesium } from "resium";
import { useEffect, useState } from "react";
function CustomFlyTo() { function CustomFlyTo() {
const { viewer } = useCesium(); const { viewer } = useCesium();
const { camera } = viewer;
const [destination, setDestination] = useState( function cameraFlyToLine(adjustPitch) {
Cesium.Cartesian3.fromDegrees(88, -89, 20000000) const antarcticalOptions = {
); destination: Cesium.Cartesian3.fromDegrees(88, -89, 1600000),
orientation: {
heading: Cesium.Math.toRadians(15.0),
pitch: Cesium.Math.toRadians(-60),
roll: 0.0,
},
duration: 10,
complete: function () {
setTimeout(() => {
camera.flyTo(plateauOptions);
}, 1000);
},
};
useEffect(() => { const plateauOptions = {
setTimeout(() => { destination: Cesium.Cartesian3.fromDegrees(90, 20, 1600000),
setDestination(Cesium.Cartesian3.fromDegrees(88, -89, 20000000)); duration: 10,
}, 1000); orientation: {
setTimeout(() => { heading: Cesium.Math.toRadians(-15.0),
setDestination(Cesium.Cartesian3.fromDegrees(88, 33, 20000000)); pitch: -Cesium.Math.PI_OVER_FOUR,
}, 4000); roll: 0.0,
setTimeout(() => { },
setDestination(Cesium.Cartesian3.fromDegrees(130, -10.5, 20000000)); complete: function () {
}, 7000); setTimeout(function () {
}, []); camera.flyTo(sideViewOptions);
return <CameraFlyTo destination={destination} />; }, 1000);
},
};
const sideViewOptions = {
destination: Cesium.Cartesian3.fromDegrees(130, -10.5, 20000000),
duration: 5,
complete: () => {
viewer.clock.shouldAnimate = true;
},
};
if (adjustPitch) {
antarcticalOptions.pitchAdjustHeight = 1000;
plateauOptions.pitchAdjustHeight = 1000;
sideViewOptions.pitchAdjustHeight = 1000;
}
camera.flyTo(antarcticalOptions);
}
cameraFlyToLine();
return <Camera />;
} }
export default CustomFlyTo; export default CustomFlyTo;

View File

@ -9,7 +9,7 @@ const height = 20000;
for (let index = 0; index < 120; index++) { for (let index = 0; index < 120; index++) {
data.push({ data.push({
longitude: 88, longitude: 88,
latitude: 35 - 120 + index, // latitude: 35 - 120 + index * 0.9874, //
// latitude: 33 -index, // // latitude: 33 -index, //
height: height:
index > 59 index > 59
@ -81,7 +81,8 @@ function Point({ start, stop }) {
}); });
} else if (value === "sideview") { } else if (value === "sideview") {
// //
viewer.trackedEntity = entityRef.current.cesiumElement; // viewer.trackedEntity = entityRef.current.cesiumElement;
viewer.trackedEntity = undefined;
viewer.camera.flyTo({ viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(130, -10.5, 20000000), destination: Cesium.Cartesian3.fromDegrees(130, -10.5, 20000000),
}); });
@ -92,12 +93,16 @@ function Point({ start, stop }) {
viewer.clock.currentTime viewer.clock.currentTime
); );
if (!destination) return; if (!destination) return;
const newDestination = new Cesium.Cartesian3(); const newDestination = Cesium.Cartesian3.clone(destination);
newDestination.x = destination.x; newDestination.y = destination.y + 1000000;
newDestination.y = destination.y + 3000000;
newDestination.z = destination.z;
viewer.camera.flyTo({ viewer.camera.flyTo({
destination: newDestination, destination: newDestination,
orientation: {
heading: Cesium.Math.toRadians(0.0),
pitch: -Cesium.Math.PI_OVER_FOUR,
roll: 0.0,
},
duration: 0,
}); });
} }
}; };
@ -109,7 +114,8 @@ function Point({ start, stop }) {
返回首页 返回首页
</div> </div>
<Select <Select
onSelect={handleChange} // onSelect={handleChange}
onChange={handleChange}
value={value} value={value}
getPopupContainer={(node) => node} getPopupContainer={(node) => node}
options={[ options={[
@ -130,7 +136,8 @@ function Point({ start, stop }) {
</div> </div>
<Entity <Entity
onDoubleClick={(e) => { onDoubleClick={(e) => {
if ((viewer.trackedEntity = undefined)) setValue("follow"); // if ((viewer.trackedEntity = undefined))
setValue("follow");
}} }}
ref={entityRef} ref={entityRef}
availability={ availability={

View File

@ -1,4 +1,4 @@
import { Viewer, Camera } from "resium"; import { Viewer } from "resium";
import PlateauPolygon from "./PlateauPolygon"; import PlateauPolygon from "./PlateauPolygon";
import AntarcticaPolygon from "./AntarcticaPolygon"; import AntarcticaPolygon from "./AntarcticaPolygon";
import Point from "./Point"; import Point from "./Point";
@ -27,12 +27,11 @@ function PolygonLayout() {
// animation={false} // animation={false}
shouldAnimate={true} shouldAnimate={true}
> >
<Camera defaultZoomAmount={0} /> <CustomClock start={start} stop={stop} />
<CustomFlyTo /> <CustomFlyTo />
<Point start={start} stop={stop} /> <Point start={start} stop={stop} />
<PlateauPolygon /> <PlateauPolygon />
<AntarcticaPolygon /> <AntarcticaPolygon />
<CustomClock start={start} stop={stop} />
</Viewer> </Viewer>
); );
} }