polyline interpolation

var viewer = new Cesium.Viewer('cesiumContainer', {
			navigationInstructionsInitiallyVisible: false,
			// These next 5 lines are just to avoid the Bing Key error message.
			imageryProvider: Cesium.createTileMapServiceImageryProvider({
				url: Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
			}),
			baseLayerPicker: false,
			geocoder: false,
			// This next line fixes another Stack Snippet error, you may omit
			// this setting from production code as well.
			infoBox: false
		});

		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: 50,
				interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
				//interpolationAlgorithm: Cesium.LinearApproximation
				//interpolationAlgorithm: Cesium.HermitePolynomialApproximation
			});
		}

  

 

转载于:https://www.cnblogs.com/dontStopByTime/p/5608546.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值