Cesium-Examples/examples/cesiumEx/4.3.2、视频投射.html

98 lines
3.0 KiB
HTML
Raw Normal View History

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
<script src="./video.js"></script>
<script src="./turf.min.js"></script>
<script src="./lodash.min.js"></script>
<style>
#menu {
position: absolute;
top: 20px;
left: 0;
color: #ffffff;
background: rgba(0, 0, 0, 0.4);
z-index: 9999;
}
#video_dom {
display: none;
position: absolute;
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
}
</style>
</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>
<div id="menu">
</div>
<video id="video_dom" preload="auto" autoPlay loop>
<source src="./video.mp4" type="video/mp4" />
Your browser does not support the <code>video</code> element.
</video>
<!-- ./video.mp4 -->
<script type="text/javascript">
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3ZjQ5ZGUzNC1jNWYwLTQ1ZTMtYmNjYS05YTY4ZTVmN2I2MDkiLCJpZCI6MTE3MTM4LCJpYXQiOjE2NzY0NDUyODB9.ZaNSBIfc1sGLhQd_xqhiSsc0yr8oS0wt1hAo9gbke6M'
const viewer = new Cesium.Viewer('map', {
contextOptions: {
requestWebgl1: true,
},
});
viewer.scene.debugShowFramesPerSecond = true;
viewer.scene.globe.depthTestAgainstTerrain = true;
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(85.788705, 45.163394, 2000),
});
var options = {
horizontalViewAngle: 60,
verticalViewAngle: 40,
video: "video_dom",
viewPosition: Cesium.Cartesian3.fromDegrees(85.788705, 45.161394, 900),
viewPositionEnd: Cesium.Cartesian3.fromDegrees(85.788705, 45.167394, 500),
};
v = new video(viewer, options);
v.drawVideo();
// 播放
video_dom.play();
// 暂停
// video_dom.pause();
// 清除
// new video(viewer, {}).clearAll();
// 视角宽高比例
// v.change({
// aspectRatio: 1.7
// })
// // 视角水平张角
// v.change({
// fov: 1.2
// })
// // 视角距离
// v.change({
// far: 200
// })
// 切换视频源
function switchSP() {
var videoSrc = '';
var hls = new Hls();
hls.loadSource(videoSrc);
hls.attachMedia(video_dom);
}
</script>
</body>
</html>