2025-03-11 08:25:45 +00:00
|
|
|
<!--********************************************************************
|
|
|
|
* by jiawanlong
|
|
|
|
*********************************************************************-->
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8" />
|
2025-03-19 03:00:22 +00:00
|
|
|
<link rel="stylesheet" href="./../../libs/cesium/Cesium1.98/Widgets/widgets.css" />
|
|
|
|
<script type="text/javascript" src="./../../libs/cesium/Cesium1.98/Cesium.js"></script>
|
2025-03-11 08:25:45 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body style="
|
|
|
|
margin: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
background: #fff;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
">
|
|
|
|
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
|
|
|
|
|
|
|
|
<!-- ./video.mp4 -->
|
|
|
|
<script type="text/javascript">
|
|
|
|
Cesium.Ion.defaultAccessToken =
|
2025-05-29 02:59:44 +00:00
|
|
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyNDMxOTA2NS1lY2Q3LTQ0YmUtOTE1Mi1iNWE2OGYwZjc0MjkiLCJpZCI6MjM1NjMwLCJpYXQiOjE3MzA3MjQzMTJ9.Xhu-9FyVEyqBKWEr0V9Sybt-elTCWHt9peL9-mNh-4E";
|
2025-03-11 08:25:45 +00:00
|
|
|
const viewer = new Cesium.Viewer("map", {});
|
2025-05-17 11:30:00 +00:00
|
|
|
// 地图视野定位
|
|
|
|
viewer.camera.setView({
|
|
|
|
destination: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 3000),
|
2025-03-11 08:25:45 +00:00
|
|
|
});
|
|
|
|
|
2025-05-17 11:30:00 +00:00
|
|
|
let primitive;
|
|
|
|
|
|
|
|
let positions = {
|
|
|
|
x: -75.59777,
|
|
|
|
y: 40.03883,
|
|
|
|
z: 3000
|
|
|
|
}
|
|
|
|
initFrustum();
|
|
|
|
|
|
|
|
function initFrustum() {
|
|
|
|
// 初始参数
|
|
|
|
const fov = 45;
|
|
|
|
const aspectRatio = 1920 / 1080;
|
|
|
|
const near = 1.0;
|
|
|
|
const far = 2000.0;
|
|
|
|
|
|
|
|
var position = Cesium.Cartesian3.fromDegrees(positions.x, positions.y, positions.z);
|
|
|
|
var heading = Cesium.Math.toRadians(0);
|
|
|
|
var pitch = Cesium.Math.toRadians(0);
|
|
|
|
var roll = Cesium.Math.toRadians(135);
|
|
|
|
|
|
|
|
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
|
|
|
|
var orientation = Cesium.Transforms.headingPitchRollQuaternion(
|
|
|
|
position,
|
|
|
|
hpr
|
|
|
|
);
|
|
|
|
|
|
|
|
const frustum = new Cesium.PerspectiveFrustum({
|
2025-03-11 08:25:45 +00:00
|
|
|
fov: Cesium.Math.toRadians(fov),
|
|
|
|
aspectRatio: aspectRatio,
|
|
|
|
near: near,
|
2025-05-17 11:30:00 +00:00
|
|
|
far: far
|
2025-03-11 08:25:45 +00:00
|
|
|
});
|
2025-05-17 11:30:00 +00:00
|
|
|
|
|
|
|
const instanceGeo = new Cesium.GeometryInstance({
|
2025-03-11 08:25:45 +00:00
|
|
|
geometry: new Cesium.FrustumGeometry({
|
|
|
|
frustum: frustum,
|
2025-05-17 11:30:00 +00:00
|
|
|
origin: Cesium.Cartesian3.ZERO, // 原点
|
|
|
|
// orientation: Cesium.Quaternion.IDENTITY, // 初始无旋转
|
2025-03-11 08:25:45 +00:00
|
|
|
orientation: orientation,
|
2025-05-17 11:30:00 +00:00
|
|
|
vertexFormat: Cesium.VertexFormat.POSITION_ONLY
|
2025-03-11 08:25:45 +00:00
|
|
|
}),
|
|
|
|
attributes: {
|
|
|
|
color: Cesium.ColorGeometryInstanceAttribute.fromColor(
|
|
|
|
new Cesium.Color(1.0, 0.0, 0.0, 0.3)
|
2025-05-17 11:30:00 +00:00
|
|
|
)
|
|
|
|
}
|
2025-03-11 08:25:45 +00:00
|
|
|
});
|
|
|
|
|
2025-05-17 11:30:00 +00:00
|
|
|
const initialModelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
2025-03-11 08:25:45 +00:00
|
|
|
|
2025-05-17 11:30:00 +00:00
|
|
|
primitive = viewer.scene.primitives.add(new Cesium.Primitive({
|
|
|
|
geometryInstances: instanceGeo,
|
2025-03-11 08:25:45 +00:00
|
|
|
appearance: new Cesium.PerInstanceColorAppearance({
|
2025-05-17 11:30:00 +00:00
|
|
|
translucent: true,
|
|
|
|
closed: true
|
2025-03-11 08:25:45 +00:00
|
|
|
}),
|
2025-05-17 11:30:00 +00:00
|
|
|
modelMatrix: initialModelMatrix // 初始位置矩阵
|
|
|
|
}));
|
|
|
|
|
|
|
|
animate();
|
|
|
|
|
2025-03-11 08:25:45 +00:00
|
|
|
}
|
|
|
|
|
2025-05-17 11:30:00 +00:00
|
|
|
function animate() {
|
|
|
|
positions.y += 0.0001;
|
|
|
|
var newPosition = Cesium.Cartesian3.fromDegrees(positions.x, positions.y, positions.z);
|
|
|
|
primitive.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(newPosition);
|
|
|
|
requestAnimationFrame(animate);
|
2025-03-11 08:25:45 +00:00
|
|
|
}
|
2025-05-17 11:30:00 +00:00
|
|
|
|
2025-03-11 08:25:45 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|