三维地球实现飞机轨迹源代码



   

       
   

    视角向下
    侧面视角
    第一视角

    //Make sure viewer is at the desired time.
    viewer.clock.startTime = start.clone();
    viewer.clock.stopTime = stop.clone();
    viewer.clock.currentTime = start.clone();
    viewer.clock.clockRange = bmgl.ClockRange.LOOP_STOP; //Loop at the end
    viewer.clock.multiplier = 10;
    //Set timeline to simulation bounds
    viewer.timeline.zoomTo(start, stop);
    //Generate a random circular pattern with varying heights.
    function computeCirclularFlight(lon, lat, radius) {
        var property = new bmgl.SampledPositionProperty();
        for (var i = 0; i <= 360; i += 45) {
            var radians = bmgl.Math.toRadians(i);
            var time = bmgl.JulianDate.addSeconds(start, i, new bmgl.JulianDate());
            var position = bmgl.Cartesian3.fromDegrees(lon + (radius * 1.5 * Math.cos(radians)), lat + (radius * Math.sin(radians)), bmgl.Math.nextRandomNumber() * 500 + 8750);
            property.addSample(time, position);
            //Also create a point for each sample we generate.
            viewer.entities.add({
                position: position,
                point: {
                    pixelSize: 8,
                    color: bmgl.Color.TRANSPARENT,
                    outlineColor: bmgl.Color.YELLOW,
                    outlineWidth: 3
                }
            });
        }
        return property;
    }

    //Compute the entity position property.
    var position = computeCirclularFlight(86.93047, 27.986914, 0.03);
    viewer.camera.flyTo({
        destination: bmgl.Cartesian3.fromDegrees(86.93047, 27.986914, 20000)
    });

    //Actually create the entity
    entity = viewer.entities.add({
        //Set the entity availability to the same interval as the simulation time.
        availability: new bmgl.TimeIntervalCollection([new bmgl.TimeInterval({
            start: start,
            stop: stop
        })]),

        //Use our computed positions
        position: position,
        //Automatically compute orientation based on position movement.
        orientation: new bmgl.VelocityOrientationProperty(position),
        //Load the Cesium plane model to represent the entity
        model: {
            uri: '/bmgl/obj/plane.glb',
            minimumPixelSize: 64,
            scale:50,
        },

        //Show the path as a pink line sampled in 1 second increments.
        path: {
            resolution: 1,
            material: new bmgl.PolylineGlowMaterialProperty({
                glowPower: 0.1,
                color: bmgl.Color.YELLOW
            }),
            width: 10
        }
    });

    var viewModel = {
        selection: ["折线", "光滑线", "Hermite光滑线"],
        selectValue: 0
    };

    bmgl.knockout.track(viewModel);

    /*给viewModel中的所有属性进行监测*/
    var toolbar = document.getElementById('toolbar');
    bmgl.knockout.applyBindings(viewModel, toolbar);

    bmgl.knockout.getObservable(viewModel, 'selectValue').subscribe(
        function (newValue) {
            var that = this;
            if (newValue == '折线') {
                entity.position.setInterpolationOptions({
                    interpolationDegree: 1,
                    interpolationAlgorithm: bmgl.LinearApproximation
                });
            } else if (newValue == '光滑线') {
                entity.position.setInterpolationOptions({
                    interpolationDegree: 5,
                    interpolationAlgorithm: bmgl.LagrangePolynomialApproximation
                });
            } else if (newValue == 'Hermite光滑线') {
                entity.position.setInterpolationOptions({
                    interpolationDegree: 2,
                    interpolationAlgorithm: bmgl.HermitePolynomialApproximation
                });
            }
        }
    );

    function ViewToDown() {
        viewer.trackedEntity = undefined;
        viewer.zoomTo(viewer.entities, new bmgl.HeadingPitchRange(0, bmgl.Math.toRadians(-90)));
    }

    function ViewToSide() {
        viewer.trackedEntity = undefined;
        viewer.zoomTo(viewer.entities, new bmgl.HeadingPitchRange(bmgl.Math.toRadians(-90), bmgl.Math.toRadians(-15), 7500));
    }

    function ViewToAircraft() {
        viewer.trackedEntity = entity;
    }
    viewer.clock.shouldAnimate=true;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值