Cloud Parameters
Runnable Cesium example: Cloud Parameters. Open the live demo, read the complete source, and copy the file into your project. No build step or API key.
single HTML file · CDN dependencies onlyinterface may contain Chinese labels
Source
<!--
示例:用 CloudCollection 生成程序化云团并调参数
说明:每朵云由位置、平面缩放、最大尺寸、亮度与切片共同决定,全部由代码生成
核心逻辑:scene.primitives.add(new CloudCollection) → add 若干 CumulusCloud → 调 brightness / slice
依赖:CesiumJS 1.121 · jsDelivr CDN
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta name="robots" content="noindex,follow">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>体积云参数</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cesium@1.121.0/Build/Cesium/Widgets/widgets.css">
<style>
html,body{height:100%;margin:0}
body{background:#0e1116;color:#e6e8ec;overflow:hidden;
font:13px/1.6 -apple-system,"Segoe UI","PingFang SC",sans-serif}
#c{height:100%}
.hud{position:absolute;left:12px;top:12px;z-index:5;background:rgba(23,28,35,.9);
border:1px solid #2a313b;border-radius:6px;padding:9px 12px;font-size:12px;
color:#a2a9b6;max-width:250px}
.hud b{color:#e6e8ec;font-weight:600}
.hud .row{margin-top:7px}
input[type=range]{width:100%}
.cesium-viewer-bottom .cesium-widget-credits,.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer{display:none!important}
</style>
</head>
<body>
<div id="c"></div>
<div class="hud">
<div><b>体积云</b></div>
<div class="row">亮度 <span id="bVal">0.85</span></div>
<div class="row"><input id="b" type="range" min="0.1" max="1" step="0.05" value="0.85"></div>
<div class="row">底部切片 <span id="sVal">0.30</span></div>
<div class="row"><input id="s" type="range" min="-1" max="1" step="0.05" value="0.3"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/cesium@1.121.0/Build/Cesium/Cesium.js"></script>
<script>
(function () {
'use strict';
var viewer = new Cesium.Viewer('c', {
baseLayer: false,
baseLayerPicker: false, geocoder: false, homeButton: false,
sceneModePicker: false, navigationHelpButton: false,
animation: false, timeline: false, fullscreenButton: false,
infoBox: false, selectionIndicator: false
});
var scene = viewer.scene;
scene.globe.baseColor = Cesium.Color.fromCssColorString('#1b2a3a');
scene.backgroundColor = Cesium.Color.fromCssColorString('#0e1116');
scene.skyBox.show = false;
scene.moon.show = false;
if (scene.skyAtmosphere) scene.skyAtmosphere.show = false;
scene.globe.enableLighting = true;
var clouds = scene.primitives.add(new Cesium.CloudCollection());
var list = [];
var LON = 116.3913;
var LAT = 39.9074;
for (var i = 0; i < 14; i++) {
var dx = ((i % 5) - 2) * 0.012 + (i % 3) * 0.004;
var dy = (Math.floor(i / 5) - 1) * 0.010 + (i % 2) * 0.003;
var cloud = clouds.add({
position: Cesium.Cartesian3.fromDegrees(LON + dx, LAT + dy, 2600 + (i % 4) * 260),
scale: new Cesium.Cartesian2(28, 14),
maximumSize: new Cesium.Cartesian3(26, 18, 16),
slice: 0.3,
brightness: 0.85,
color: Cesium.Color.WHITE
});
list.push(cloud);
}
document.getElementById('b').addEventListener('input', function () {
var v = parseFloat(this.value);
document.getElementById('bVal').textContent = v.toFixed(2);
list.forEach(function (c) { c.brightness = v; });
});
document.getElementById('s').addEventListener('input', function () {
var v = parseFloat(this.value);
document.getElementById('sVal').textContent = v.toFixed(2);
list.forEach(function (c) { c.slice = v; });
});
/* 站在云层下方侧视,才能看出体积感 */
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(LON - 0.04, LAT - 0.05, 900),
orientation: {
heading: Cesium.Math.toRadians(38),
pitch: Cesium.Math.toRadians(8),
roll: 0
},
duration: 0
});
})();
</script>
</body>
</html>
Language: the code and this page are in English; the full tutorial and API notes for this example are in Chinese. The demo itself is the authoritative version — it runs exactly as shown.