zoukankan      html  css  js  c++  java
  • 单个czml加载小车

     // 单个czml加载小车
            var scene = viewer.scene;
            var entity;
            var positionProperty;
            var clock = new Cesium.Clock({
                startTime: Cesium.JulianDate.fromIso8601("2012-08-04T16:00:00Z"),
                currentTime: Cesium.JulianDate.fromIso8601("2012-08-04T16:00:00Z"),
                stopTime: Cesium.JulianDate.fromIso8601("2012-08-04T16:03:00Z"),
                clockRange: Cesium.ClockRange.LOOP_STOP,
                clockStep: Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER
            });
            var tileset = scene.primitives.add(
                new Cesium.Cesium3DTileset({
                    url: 'http://192.168.1.1/3dmodel/3dtile/tileset.json'
                })
            );
            const czmlPath = "http://192.168.1.1/carModel/path/czmlPath.czml"
            var dataSourcePromise = Cesium.CzmlDataSource.load(czmlPath);
            var that = this;
            viewer.dataSources.add(dataSourcePromise, that).then(function (dataSource) {
                entity = dataSource.entities.getById('Vehicle');
                viewer.trackedEntity = entity;
                positionProperty = entity.position;
                if (positionProperty != undefined) {
                    entity.orientation = new Cesium.VelocityOrientationProperty(positionProperty);
                }
    
            });
    
            if (scene.clampToHeightSupported) {
                tileset.initialTilesLoaded.addEventListener(start2);
            } else {
                console.log('This browser does not support clampToHeight.');
            }
    
            function start2() {
                var objectsToExclude = [entity];
                scene.postRender.addEventListener(function () {
                    var position = positionProperty.getValue(viewer.clock.currentTime);
                    if (position != undefined) {
                        entity.position = scene.clampToHeight(position, objectsToExclude);
                    }
                });
            }
            // viewer.trackedEntity = entity;
    

    设置视角

    carEntity.viewFrom = new Cesium.Cartesian3(15, 15, 6);
    
  • 相关阅读:
    ASP.NET 2.0的页面缓存功能介绍
    我对针对接口编程的浅解
    接口和抽象类的区别
    面向接口编程到底有什么好处
    泛型编程是什么
    方法的重写、重载及隐藏
    基于事件的编程有什么好处
    Socket Remoting WebService对比
    技术讲座:.NET委托、事件及应用兼谈软件项目开发
    ny589 糖果
  • 原文地址:https://www.cnblogs.com/marvelousone/p/11408230.html
Copyright © 2011-2022 走看看