Cesium-Examples/examples/cesiumEx/8.1.4、风场.html

70 lines
2.5 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="./cesium-wind.js"></script>
</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>
<script>
2025-06-07 11:30:00 +00:00
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMjBhMzcxMC0wNjBiLTRmYjItYjY1MC0wMzAwMzMyMGUyMmEiLCJpZCI6MzAzNzc3LCJpYXQiOjE3NDc2Mzk0NTV9.E_90aKtVdzRGlU2z48VwJ4mWvl-uuDkfQBCOO6zbzn4'
2025-03-11 08:25:45 +00:00
const viewer = new Cesium.Viewer('map', {});
viewer.scene.debugShowFramesPerSecond = true;
// !!!!!!!!!!!!!!教程!!!!!!!!!!!!!!!!!!!!!
/*
1、数据获取
数据源https://nomads.ncep.noaa.gov/ 记得要grid转json
简单方式方式https://github.com/jiawanlong/wind-js-server记得配java_home
2、利用WindLayer插件
链接https://github.com/jiawanlong/cesium-wind
*/
const windOptions = {
colorScale: [
'rgb(36,104, 180)',
'rgb(60,157, 194)',
'rgb(128,205,193 )',
'rgb(151,218,168 )',
'rgb(198,231,181)',
'rgb(238,247,217)',
'rgb(255,238,159)',
'rgb(252,217,125)',
'rgb(255,182,100)',
'rgb(252,150,75)',
'rgb(250,112,52)',
'rgb(245,64,32)',
'rgb(237,45,28)',
'rgb(220,24,32)',
'rgb(180,0,35)',
],
frameRate: 16,
maxAge: 60,
globalAlpha: 0.9,
velocityScale: 1 / 30,
paths: 2000
};
let windLayer;
fetch('./2024122600.json')
.then(res => res.json())
.then(res => {
windLayer = new CesiumWind.WindLayer(res, { windOptions });
windLayer.addTo(viewer);
// windLayer.remove();
});
</script>
</body>
</html>