cesiumjs - 铯表面上方的折线弧

标签 cesiumjs

默认情况下,铯折线遵循两点之间的地球曲率。如何制作高于地面的弧线,如本例所示?

http://armsglobe.chromeexperiments.com/

最佳答案

这是一个在实体位置上使用插值算法来计算平滑弧的示例。试试loading this in Sandcastle .

var viewer = new Cesium.Viewer('cesiumContainer');

var numberOfArcs = 50;
var startLon = -74;
var startLat = 39;

viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;

var startTime = viewer.clock.startTime;
var midTime = Cesium.JulianDate.addSeconds(startTime, 43200, new Cesium.JulianDate());
var stopTime = Cesium.JulianDate.addSeconds(startTime, 86400, new Cesium.JulianDate());

for (var i = 0; i < numberOfArcs; ++i) {
    var color = Cesium.Color.fromRandom({
        alpha : 1.0
    });
    var stopLon = Cesium.Math.nextRandomNumber() * 358 - 179;
    var stopLat = Cesium.Math.nextRandomNumber() * 178 - 89;

    // Create a straight-line path.
    var property = new Cesium.SampledPositionProperty();
    var startPosition = Cesium.Cartesian3.fromDegrees(startLon, startLat, 0);
    property.addSample(startTime, startPosition);
    var stopPosition = Cesium.Cartesian3.fromDegrees(stopLon, stopLat, 0);
    property.addSample(stopTime, stopPosition);

    // Find the midpoint of the straight path, and raise its altitude.
    var midPoint = Cesium.Cartographic.fromCartesian(property.getValue(midTime));
    midPoint.height = Cesium.Math.nextRandomNumber() * 500000 + 2500000;
    var midPosition = viewer.scene.globe.ellipsoid.cartographicToCartesian(
        midPoint, new Cesium.Cartesian3());

    // Redo the path to be the new arc.
    property = new Cesium.SampledPositionProperty();
    property.addSample(startTime, startPosition);
    property.addSample(midTime, midPosition);
    property.addSample(stopTime, stopPosition);

    // Create an Entity to show the arc.
    var arcEntity = viewer.entities.add({
        position : property,
        // The point is optional, I just wanted to see it.
        point : {
            pixelSize : 8,
            color : Cesium.Color.TRANSPARENT,
            outlineColor : color,
            outlineWidth : 3
        },
        // This path shows the arc as a polyline.
        path : {
            resolution : 1200,
            material : new Cesium.PolylineGlowMaterialProperty({
                glowPower : 0.16,
                color : color
            }),
            width : 10,
            leadTime: 1e10,
            trailTime: 1e10
        }
    });

    // This is where it becomes a smooth path.
    arcEntity.position.setInterpolationOptions({
        interpolationDegree : 5,
        interpolationAlgorithm : Cesium.LagrangePolynomialApproximation
    });
}

关于cesiumjs - 铯表面上方的折线弧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37381658/

相关文章:

cesiumjs - 将铯地球仪的默认 View 设置为特定国家

javascript - 添加地形网格后保持点可见 - Cesium

javascript - 如何更改 Cesium map 中 EllipseOutlineGeometry 的宽度?

glsl - 如何在Cesium中创建虚线箭头

javascript - CesiumJS - 如何控制查看器时间和滴答声?

javascript - Cartesian3.distance - 返回 NaN?

javascript - 铯销毁查看器的正确方法

javascript - 正确尝试Cesium创建、错误捕获、跨浏览器兼容性和开发人员错误

javascript - 如何将自定义 UI 元素(如复选框、组合等)添加到 CesiumJS 场景?

cesiumjs - 是否有一个通用的 ScreenSpaceEvent 可以捕获所有事件?