cesium编程入门12学习:摄像机设置

Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjOWM3MzYxZS0xNDg5LTRhYzgtOTE3ZS1hMTgyNmFmNzY5ZDIiLCJpZCI6MTYwNTYsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1Njk0NzMxMjl9.QT-UwdXK6VZyYMhtznEEIru0AEQEzMPxDlxQw96mTlA'; var viewer = new Cesium.Viewer('cesiumContainer',{ geocoder : false, homeButton : false, sceneModePicker : false, baseLayerPicker : false, navigationHelpButton : false, animation : false, timeline : false, fullscreenButton : false, vrButton : false, //Cesium本地服务 //imageryProvider : Cesium.createTileMapServiceImageryProvider({ // url : Cesium.buildModuleUrl('http://Build/Cesium/Assets/Textures/NaturalEarthII') // }) }); //显示帧速 viewer.scene.debugShowFramesPerSecond = true; //关闭大气层显示 viewer.scene.skyAtmosphere.show = false; //控制视角不转到地下 viewer.scene.globe.depthTestAgainstTerrain = true; var thePosition = Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0); //方向 var theHeading = Cesium.Math.toRadians(20.0); //倾斜角度 var thePitch = Cesium.Math.toRadians(-90.0); var theRoll = 0; var redBox = viewer.entities.add({ name : 'red box with black outline', position : thePosition, box : { dimensions : new Cesium.Cartesian3(400000.0, 300000.0, 500000.0), material : Cesium.Color.RED.withAlpha(0.5), outline : true, outlineColor : Cesium.Color.BLACK } }); //viewer.zoomTo(viewer.entities); var translation = Cesium.Cartesian3.fromArray([]); //加载3dtiles建筑物模型 var tileset =viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ //数据路径 url : 'http://localhost:8080/apps/sampleData/Cesium3DTiles/Tilesets/Tileset/tileset.json', //最大的屏幕空间误差 maximumScreenSpaceError : 2, //最大加载瓦片个数 maximumNumberOfLoadedTiles : 1000 })); var m = tileset.modelMatrix; /* //旋转x角度,转为弧度再参与运算 var RotateX = 90.0; var m1 = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(RotateX)); //矩阵计算 Cesium.Matrix4.multiplyByMatrix3(m,m1,m); //赋值 tileset.modelMatrix = m; */ var defaultStyle = new Cesium.Cesium3DTileStyle({ color : 'rgba(255,255,255,0.5)', show : true }); tileset.style = defaultStyle; //视点看向3dtile模型 //viewer.zoomTo(tileset); /* //Cartesian3方式计算视角 viewer.camera.setView({ destination : thePosition, orientation : { heading : theHeading, pitch: thePitch, roll : theRoll } }); */ /* //rectangle方式计算视角 viewer.camera.setView({ //西南东北 destination : Cesium.Rectangle.fromDegrees(0.0,20.0, 10.0, 30.0), orientation : { heading : theHeading, pitch: thePitch, roll : theRoll } }); */ /* //flyto改变视角 viewer.camera.flyTo({ destination : thePosition, orientation : { heading : theHeading, pitch: thePitch, roll : theRoll }, //设置飞行持续时间,默认会根据距离来计算 duration : 5, //到达位置后执行的回调函数 complete :function(){ }, //如果取消飞行则会调用此函数 cancle : function() { }, //如果摄像机飞越高于该值,则调整俯仰角度, pitchAdjustHeight : -90, //相机最大飞行高度 maximumHeight : 5000, //如果到达目的地有两种方式,设置具体值后会强制选择方向飞过这个经度 flyOverLongitude : 100 }); */ //lookAt方式控制 var theRange = 5000.0; viewer.camera.lookAt(thePosition, new Cesium.HeadingPitchRange(theHeading, thePitch, theRange));

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值