Atlaslog
Atlaslog / Examples / Cesium / Czml Polygon Interpolating
Cesium · Runnable Example

Czml Polygon Interpolating

Runnable Cesium example: Czml Polygon Interpolating. Open the live demo, read the complete source, and copy the file into your project. No build step or API key.

Open standalone → Chinese notes All Cesium examples
/demos/cesium-czml-polygon-interpolating.htmlLIVE
single HTML file · CDN dependencies onlyinterface may contain Chinese labels

Source

demos/cesium-czml-polygon-interpolating.html
<!--
  示例:CZML 多边形顶点引用其他对象的动态位置
  说明:positions.references 写成「id#position」,三个顶点各自运动,多边形随之变形
  核心逻辑:perPositionHeight + references → 顶点实时取值 → clock 推进
  依赖: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>CZML 多边形顶点引用</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%}
  .cesium-viewer-bottom .cesium-widget-credits,.cesium-viewer-animationContainer,
  .cesium-viewer-timelineContainer{display:none!important}
</style>
</head>
<body>
<div id="c"></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('#1c2733');
  scene.backgroundColor = Cesium.Color.fromCssColorString('#0e1116');
  scene.skyBox.show = false;
  scene.moon.show = false;
  if (scene.skyAtmosphere) scene.skyAtmosphere.show = false;

  var start = Cesium.JulianDate.fromIso8601('2026-10-28T00:00:00Z');
  var stop = Cesium.JulianDate.addSeconds(start, 120, new Cesium.JulianDate());

  viewer.clock.startTime = start.clone();
  viewer.clock.stopTime = stop.clone();
  viewer.clock.currentTime = start.clone();
  viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
  viewer.clock.multiplier = 3;
  viewer.clock.shouldAnimate = true;

  var data = [
    {
      id: 'document',
      name: '顶点引用',
      version: '1.0',
      clock: {
        interval: '2026-10-28T00:00:00Z/2026-10-28T00:02:00Z',
        currentTime: '2026-10-28T00:00:00Z',
        multiplier: 3,
        range: 'LOOP_STOP'
      }
    },
    {
      id: 'dynamicPolygon',
      availability: '2026-10-28T00:00:00Z/2026-10-28T00:02:00Z',
      polygon: {
        positions: { references: ['v1#position', 'v2#position', 'v3#position'] },
        perPositionHeight: true,
        material: {
          solidColor: {
            color: [
              { interval: '2026-10-28T00:00:00Z/2026-10-28T00:01:00Z', rgba: [77, 155, 255, 150] },
              { interval: '2026-10-28T00:01:00Z/2026-10-28T00:02:00Z', rgba: [228, 92, 122, 150] }
            ]
          }
        },
        outline: true,
        outlineColor: { rgba: [220, 236, 255, 230] }
      }
    },
    {
      id: 'v1',
      availability: '2026-10-28T00:00:00Z/2026-10-28T00:02:00Z',
      position: {
        epoch: '2026-10-28T00:00:00Z',
        interpolationAlgorithm: 'LINEAR',
        interpolationDegree: 1,
        cartographicDegrees: [
          0,   116.352, 39.890, 0,
          60,  116.360, 39.920, 1200,
          120, 116.352, 39.890, 0
        ]
      },
      point: {
        pixelSize: 9,
        color: { rgba: [255, 255, 255, 255] },
        disableDepthTestDistance: Number.POSITIVE_INFINITY
      }
    },
    {
      id: 'v2',
      availability: '2026-10-28T00:00:00Z/2026-10-28T00:02:00Z',
      position: {
        epoch: '2026-10-28T00:00:00Z',
        interpolationAlgorithm: 'LINEAR',
        interpolationDegree: 1,
        cartographicDegrees: [
          0,   116.432, 39.890, 0,
          60,  116.424, 39.926, 1600,
          120, 116.432, 39.890, 0
        ]
      },
      point: {
        pixelSize: 9,
        color: { rgba: [255, 255, 255, 255] },
        disableDepthTestDistance: Number.POSITIVE_INFINITY
      }
    },
    {
      id: 'v3',
      availability: '2026-10-28T00:00:00Z/2026-10-28T00:02:00Z',
      position: {
        epoch: '2026-10-28T00:00:00Z',
        interpolationAlgorithm: 'LINEAR',
        interpolationDegree: 1,
        cartographicDegrees: [
          0,   116.392, 39.876, 0,
          60,  116.392, 39.906, 2600,
          120, 116.392, 39.876, 0
        ]
      },
      point: {
        pixelSize: 9,
        color: { rgba: [255, 214, 102, 255] },
        disableDepthTestDistance: Number.POSITIVE_INFINITY
      }
    }
  ];

  Cesium.CzmlDataSource.load(data).then(function (ds) {
    viewer.dataSources.add(ds);
  });

  viewer.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(116.392, 39.888, 12000),
    orientation: {
      heading: 0,
      pitch: Cesium.Math.toRadians(-38),
      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.

More Cesium examples

Cesium · EXAMPLECzml Polygon Intervals Cesium · EXAMPLECzml Polyline Cesium · EXAMPLECzml Polyline Volume