cesium常用设置【转】
https://blog.csdn.net/D_Walker/article/details/82188514
1.加载线上cesium代码
<link href="http://cesiumjs.org/releases/1.20/Build/Cesium/Widgets/widgets.css" rel="stylesheet"/>
<script src="http://cesiumjs.org/releases/1.20/Build/Cesium/Cesium.js"></script>
2.默认情况下所加载的GLTF模型朝向东方。但是我们可以通过Entity.orientation属性指定一个四元组来控制模型的方向
var viewer = new Cesium.Viewer('cesiumContainer');
var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706);
var heading = Cesium.Math.toRadians(45.0);
var pitch = Cesium.Math.toRadians(15.0);
var roll = Cesium.Math.toRadians(0.0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);
var entity = viewer.entities.add({
position : position,
orientation : orientation,
model : {
uri : '../../SampleData/models/CesiumGround/Cesium_Ground.gltf'
}
});
viewer.trackedEntity = entity;
3.禁用默认的事件处理程序
var viewer = new Cesium.Viewer('cesiumContainer',{
baseLayerPicker : false,
imageryProvider : new Cesium.ArcGisMapServerImageryProvider({
url :'http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer'
})
});
var scene = viewer.scene;
var ellipsoid = viewer.scene.globe.ellipsoid; //获取地球球体对象
//禁用默认的事件处理程序
//如果为真,则允许用户旋转相机。如果为假,相机将锁定到当前标题。此标志仅适用于2D和3D
scene.screenSpaceCameraController.enableRotate = false;
//如果为真,则允许用户平移地图。如果为假,相机将保持锁定在当前位置。此标志仅适用于2D和Columbus视图模式
scene.screenSpaceCameraController.enableTranslate = false;
//如果为真,则允许用户放大和缩小。如果为假,相机将锁定到距离椭圆体的当前距离。
scene.screenSpaceCameraController.enableZoom = false;
//如果为真,则允许用户倾斜相机。如果为假,相机将锁定到当前标题。这个标志只适用于3D和哥伦布视图。
scene.screenSpaceCameraController.enableTilt = false;
//如果为真,则允许用户使用免费外观。如果为假,摄像机视图方向只能通过转换或旋转进行更改。此标志仅适用于3D和哥伦布视图模式。
scene.screenSpaceCameraController.enableLook = false;
4.隐藏对应的实体模型
tileset.style = new Cesium.Cesium3DTileStyle({
color: {
conditions: [
["${ID} === '528851'||${ID} === '554086'", "rgba(${red}, ${green}, ${blue}, 0)"],
["true","rgba(${red}, ${green}, ${blue}, 1)"]
]
}
});
5.对cesium的帮组按钮内容进行汉化
function navigationHelpButtonLang() {
var viewer = this.viewer;
if (viewer.navigationHelpButton) {
viewer.navigationHelpButton.viewModel.tooltip = "操作指南";
var clickHelper = viewer.navigationHelpButton.container.getElementsByClassName("cesium-click-navigation-help")[0];
var touchHelper = viewer.navigationHelpButton.container.getElementsByClassName("cesium-touch-navigation-help")[0];
var button = viewer.navigationHelpButton.container.getElementsByClassName("cesium-navigation-button-right")[0]
button.innerHTML = button.innerHTML.replace(">Touch", ">手势");
button = viewer.navigationHelpButton.container.getElementsByClassName("cesium-navigation-button-left")[0]
button.innerHTML = button.innerHTML.replace(">Mouse", ">鼠标");
var click_help_pan = clickHelper.getElementsByClassName("cesium-navigation-help-pan")[0];
click_help_pan.innerHTML = "平移";
var click_help_pan_details = click_help_pan.parentNode.getElementsByClassName("cesium-navigation-help-details")[0];
click_help_pan_details.innerHTML = "按下左键 + 拖动";
var click_help_zoom = clickHelper.getElementsByClassName("cesium-navigation-help-zoom")[0];
click_help_zoom.innerHTML = "旋转";
click_help_zoom.parentNode.getElementsByClassName("cesium-navigation-help-details")[0].innerHTML = "按下右键+拖动";
click_help_zoom.parentNode.getElementsByClassName("cesium-navigation-help-details")[1].innerHTML = "";
var click_help_rotate = clickHelper.getElementsByClassName("cesium-navigation-help-rotate")[0];
click_help_rotate.innerHTML = "缩放";
click_help_rotate.parentNode.getElementsByClassName("cesium-navigation-help-details")[0].innerHTML = "滚动鼠标滚轮";
click_help_rotate.parentNode.getElementsByClassName("cesium-navigation-help-details")[1].innerHTML = "";
//触屏操作
var touch_help_pan = touchHelper.getElementsByClassName("cesium-navigation-help-pan")[0];
touch_help_pan.innerHTML = "平移";
touch_help_pan.parentNode.getElementsByClassName("cesium-navigation-help-details")[0].innerHTML = "单指拖动";
var touch_help_zoom = touchHelper.getElementsByClassName("cesium-navigation-help-zoom")[0];
touch_help_zoom.innerHTML = "缩放";
touch_help_zoom.parentNode.getElementsByClassName("cesium-navigation-help-details")[0].innerHTML = "双指捏合";
var touch_help_tilt = touchHelper.getElementsByClassName("cesium-navigation-help-rotate")[0];
touch_help_tilt.innerHTML = "俯仰";
touch_help_tilt.parentNode.getElementsByClassName("cesium-navigation-help-details")[0].innerHTML = "双指同向拖动";
var touch_help_rotate = touchHelper.getElementsByClassName("cesium-navigation-help-tilt")[0];
touch_help_rotate.innerHTML = "旋转";
touch_help_rotate.parentNode.getElementsByClassName("cesium-navigation-help-details")[0].innerHTML = "双指反向拖动";
}
}
6.更改cesium默认的鼠标操作以及对调试工具的设置
viewer.scene.screenSpaceCameraController.zoomEventTypes = [Cesium.CameraEventType.WHEEL, Cesium.CameraEventType.PINCH];
viewer.scene.screenSpaceCameraController.tiltEventTypes = [Cesium.CameraEventType.PINCH, Cesium.CameraEventType.RIGHT_DRAG];
var imageryProviderViewModels = viewer.baseLayerPicker.viewModel.imageryProviderViewModels;
viewer.baseLayerPicker.viewModel.selectedImagery = imageryProviderViewModels[3];
viewer.extend(Cesium.viewerCesiumInspectorMixin);
viewer.cesiumInspector.container.style.display = "none";
viewer.scene.debugShowFramesPerSecond = true;
document.addEventListener('keydown', function (event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e) {
switch (e.keyCode) {
// case 82: //R键查看地形三角网
// if (viewer.cesiumInspector) {
// viewer.cesiumInspector.viewModel.wireframe = !viewer.cesiumInspector.viewModel.wireframe;
// }
// break;
case 70: //F键查看帧率
viewer.scene.debugShowFramesPerSecond = !viewer.scene.debugShowFramesPerSecond;
break;
default:
}
}
});
7.手机加载或者pad加载时提高画质。
if(Cesium.FeatureDetection.supportsImageRenderingPixelated()){
viewer.resolutionScale = window.devicePixelRatio;
}
原文链接:https://blog.csdn.net/D_Walker/article/details/82188514
cesium常用设置【转】的更多相关文章
- pycharm快捷键及一些常用设置
pycharm快捷键及一些常用设置,有需要的朋友可以参考下. Alt+Enter 自动添加包 Ctrl+t SVN更新 Ctrl+k SVN提交 Ctrl + / 注释(取消注释)选择的行 Ctrl+ ...
- PLSQLDeveloper 常用设置
PLSQL Developer常用设置及快捷键 1.登录后默认自动选中My Objects (已验证可用) 默认情况下,PLSQL Developer登录后,Brower里会选择All obj ...
- 百度编辑器UEditor常用设置函数大全
在线文档对UEditor说明不够全面,收集了一些常用的方法和基本设置,以供参考.1.创建编辑器UE.getEditor('editor', { initialFrameWidth:"100% ...
- IntelliJ IDEA 常用设置讲解
说明 IntelliJ IDEA 有很多人性化的设置我们必须单独拿出来讲解,也因为这些人性化的设置让我们这些 IntelliJ IDEA 死忠粉更加死心塌地使用它和分享它. 常用设置 IntelliJ ...
- pycharm快捷键、常用设置、包管理
pycharm快捷键.常用设置.包管理 在PyCharm安装目录 /opt/pycharm-3.4.1/help目录下可以找到ReferenceCard.pdf快捷键英文版说明 or 打开pychar ...
- 《Pro Express.js》学习笔记——Express框架常用设置项
Express 设置 系统设置 1. 无须再定义,大部分有默认值,可不设置 2. 常用设置 env view cache view engine views trust pro ...
- Source Insight 常用设置和快捷键大全
Source Insight 常用设置和快捷键大全 退出程序 : Alt+F4 重画屏幕 : Ctrl+Alt+Space 完成语法 : Ctrl+E 复制一行 : Ctrl+K 恰好复制该位置右边的 ...
- eclipse 常用设置,常用快捷键修改
eclipse 常用设置,常用快捷键,myeclipse和eclipse类似' 首先打开eclipse的首选项-->搜索 keys' 常用的一些快捷键: Ctrl+1 快速修复(最经典的快捷键, ...
- UIButton、UILabel、UITextField 初学者需要了解的基本定义和常用设置
以下是三个IOS开发中最常用的控件,作为IOS基础学习教程知识 ,初学者需要了解其基本定义和常用设置,以便在开发在熟练运用. UIButton按钮 第一.UIButton的定义 UIButton * ...
随机推荐
- VLC祥解
功能部份: VLC媒體播放器的核心是libvlc ,它提供了界面,應用處理功能,如播放列表管理,音頻和視頻解碼和輸出,線程系統.所有libvlc源文件設在的/src目錄及其子目錄: # con ...
- yum升级curl支持http2测试
首先,先为你的服务器获取最新匹配的源:http://mirror.city-fan.org/ftp/contrib/yum-repo/ 方法1,rpm方式安装city-fan.org的yum源 # 安 ...
- (安全之路)从头开始学python编程之文件操作
0x00 python学习路径 b站(哔哩哔哩)视频,w3cschool(详情百度),官方文档,各大群内获取资料等等方式 0x01 python的学习要点 open()函数:有两个参数,文件名跟模式, ...
- 一些带dga域名的恶意软件
04/02/2019 06:17下午 6,488,759 f4f242a50ba9efa1593beba6208a2508_PWS.win32.Simda_1250_DGADNS.pcap Simda ...
- Qualification Rounds(Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)+状态压缩)
题目链接 传送门 题意 现总共有\(n\)个题目\(k\)支参赛队伍,已知每个题目各队伍是否会写,现问你能否从题目中选出一个子序列使得每支队伍最多只会写一半的题目. 思路 对于每个题目我们用二进制压缩 ...
- 运维笔试Python编程题
一.用Python语言把列表[1,3,5,7,9]倒序并将元素变为字符类型,请写出多种方法: 第一种方法: list = [1, 3, 5, 7, 9] list.reverse() list2 = ...
- Python中实现count(distinct )
假设一个表有6个字段c1,c2,c3,c4,c5,c6,有如下的sql语句: select c1,count(distinct(c6)) from tbl where c3>1 group by ...
- 【模板】A*B Problem(FFT快速傅里叶)
题目:给出两个n位10进制整数x和y,你需要计算x*y.($n \leq 60000$) 分析: 两个正整数的相乘可以视为两个多项式的相乘, 例如 $15 \times 16 = 240$, 可写成 ...
- Direction of Arrival Based Spatial Covariance Model for Blind Sound Source Separation
基于信号协方差模型DOA的盲声源分离[1]. 在此基础上,作者团队于2018年又发布了一篇文章,采用分级和时间差的空间协方差模型及非负矩阵分解的多通道盲声源分离[2]. 摘要 本文通过对短时傅立叶变换 ...
- php 正则表达示中的原子
原子 原子是正则表达示里面的最小单位,原子说白了就是需要匹配的内容.一个成立的正则表达示当中必须最少要有一个原子.大理石平台精度等级 所有可见不可见的字符就是原子 说明:我们见到的空格.回车.换行.0 ...