接上一篇博客,这篇直接分析火星的源码,看它到底改了些什么。

注意:在cesium1.63.1版本改变了模块化方式,由AMD改为ES6模块化。注意引入文件加载模块时做出对应修改。

1.火星代码里修改了4处源码

1.1.GlobeSurfaceTileProvider.js

M代表引入的ExpandByMars.js文件

command.pass = Pass.GLOBE;

改为

command.pass = M.underEarth.enable?Pass.TRANSLUCENT:Pass.GLOBE;

1.2.RenderState.js

var enabled = cull.enabled;

改为

var enabled = defaultValue(M.undMerEarth.cullFace, cull.enabled);

1.3.Camera.js

                if (cartographic.height < height) {
cartographic.height = height;
if (mode === SceneMode.SCENE3D) {
ellipsoid.cartographicToCartesian(cartographic, this.position);
} else {
projection.project(cartographic, this.position);
}
heightUpdated = true;
}

改为(主要是监测到进入地下不自己弹出来的问题)

                if (cartographic.height < height) {
if (M.underEarth.enable && cartographic.height > (height - M.underEarth.enableDepth)){
return;
}
cartographic.height = height;
if (mode === SceneMode.SCENE3D) {
ellipsoid.cartographicToCartesian(cartographic, this.position);
} else {
projection.project(cartographic, this.position);
}
heightUpdated = true;
}

1.4.QuantizedMeshTerrainData.js(不知道有什么用,此处我没有改)

        return when(upsamplePromise).then(function(result) {
var quantizedVertices = new Uint16Array(result.vertices);
var indicesTypedArray = IndexDatatype.createTypedArray(quantizedVertices.length / , result.indices);
var encodedNormals;
if (defined(result.encodedNormals)) {
encodedNormals = new Uint8Array(result.encodedNormals);
}

改为

        return M.underEarth.enableSkirt &&(westSkirtHeight = ,
southSkirtHeight = ,
eastSkirtHeight = ,
northSkirtHeight = ),when(upsamplePromise).then(function(result) {
var quantizedVertices = new Uint16Array(result.vertices);
var indicesTypedArray = IndexDatatype.createTypedArray(quantizedVertices.length / , result.indices);
var encodedNormals;
if (defined(result.encodedNormals)) {
encodedNormals = new Uint8Array(result.encodedNormals);
}

2.火星新增了两个js文件

2.1.ExpandByMars.js

define(["../Core/clone"], function (e) {
"use strict";
return {
trustGenerator: ["fanfan"],
_defaultFloodAnalysis: {
floodVar: [, , , ],
ym_pos_x: [, , , , , , , , , , , , , , , ],
ym_pos_y: [, , , , , , , , , , , , , , , ],
ym_pos_z: [, , , , , , , , , , , , , , , ],
rect_flood: [, , , , , , , , ],
floodSpeed: ,
ym_max_index: ,
globe: !,
showElseArea: !
},
floodAnalysis: {
floodVar: [, , , ],
ym_pos_x: [, , , , , , , , , , , , , , , ],
ym_pos_y: [, , , , , , , , , , , , , , , ],
ym_pos_z: [, , , , , , , , , , , , , , , ],
rect_flood: [, , , , , , , , ],
floodSpeed: ,
ym_max_index: ,
globe: !,
showElseArea: !
},
resetFloodAnalysis: function () {
this.floodAnalysis = e(this._defaultFloodAnalysis)
},
_defaultExcavateAnalysis: {
splitNum: ,
showSelfOnly: !,
dig_pos_x: [, , , , , , , , , , , , , , , ],
dig_pos_y: [, , , , , , , , , , , , , , , ],
dig_pos_z: [, , , , , , , , , , , , , , , ],
rect_dig: [, , , , , , , , ],
dig_max_index: ,
excavateHeight: ,
excavateMinHeight: ,
excavatePerPoint: !
},
excavateAnalysis: {
splitNum: ,
showSelfOnly: !,
dig_pos_x: [, , , , , , , , , , , , , , , ],
dig_pos_y: [, , , , , , , , , , , , , , , ],
dig_pos_z: [, , , , , , , , , , , , , , , ],
rect_dig: [, , , , , , , , ],
dig_max_index: ,
excavateHeight: ,
excavateMinHeight: ,
excavatePerPoint: !
},
resetExcavateAnalysis: function () {
this.excavateAnalysis = e(this._defaultExcavateAnalysis)
},
_defaultTilesEditor: {
floodVar: [, , , ],
flatRect: [, , , , , , , , ],
yp_mat_x: [, , , , , , , , , , , , , , , ],
yp_mat_y: [, , , , , , , , , , , , , , , ],
yp_mat_z: [, , , , , , , , , , , , , , , ],
yp_max_index: ,
model_min_height: ,
IsYaPing: [!, !, !, !],
yp_show_InOrOut: [!, !, !, !],
yp_black_texture: null,
hm_dh_attr: [, , ],
modelLight: 2.2,
times: (new Date).getTime(),
floodColor: [, , , .]
},
tilesEditor: {
floodVar: [, , , ],
flatRect: [, , , , , , , , ],
yp_mat_x: [, , , , , , , , , , , , , , , ],
yp_mat_y: [, , , , , , , , , , , , , , , ],
yp_mat_z: [, , , , , , , , , , , , , , , ],
yp_max_index: ,
model_min_height: ,
IsYaPing: [!, !, !, !],
yp_show_InOrOut: [!, !, !, !],
yp_black_texture: null,
hm_dh_attr: [, , ],
modelLight: 2.2,
times: (new Date).getTime(),
floodColor: [, , , .]
},
resetTilesEditor: function () {
this.tilesEditor = e(this._defaultTilesEditor)
},
underEarth: {
cullFace: void ,
enable: void ,
enableDepth: ,
enableSkirt: !
},
occlusionOpen: !
}
})

2.2.underground.js

文件做了修改了,大概的意思如下面代码

function underground(t, i) {
this._viewer = t;
var n = Cesium.defaultValue(i, {});
this._depth = Cesium.defaultValue(n.depth, ),
this._alpha = Cesium.defaultValue(n.alpha, .),
this.enable = Cesium.defaultValue(n.enable, !)
}
underground.prototype._updateImageryLayersAlpha=function(e) {
for (var t = this._viewer.imageryLayers._layers, i = , a = t.length; i < a; i++)
t[i].alpha = e
}
underground.prototype._historyOpts =function() {
var e = {};
e.alpha = Cesium.clone(this._viewer.imageryLayers._layers[] && this._viewer.imageryLayers._layers[].alpha),
e.highDynamicRange = Cesium.clone(this._viewer.scene.highDynamicRange),
e.skyShow = Cesium.clone(this._viewer.scene.skyAtmosphere.show),
e.skyBoxShow = Cesium.clone(this._viewer.scene.skyBox.show),
e.depthTest = Cesium.clone(this._viewer.scene.globe.depthTestAgainstTerrain),
this._viewer.scene.globe._surface && this._viewer.scene.globe._surface._tileProvider && this._viewer.scene.globe._surface._tileProvider._renderState && (e.blending = Cesium.clone(this._viewer.scene.globe._surface._tileProvider._renderState.blending)),
this._oldViewOpts = e
}
underground.prototype.activate =function() {
if (!this._enable) {
this._enable = !,
this._historyOpts(),
this._updateImageryLayersAlpha(this._alpha);
var e = this._viewer;
Cesium.ExpandByMars.underEarth.cullFace = !,
Cesium.ExpandByMars.underEarth.enable = !,
Cesium.ExpandByMars.underEarth.enableDepth = this._depth,
Cesium.ExpandByMars.underEarth.enableSkirt = !,
e.scene.globe.depthTestAgainstTerrain = !,
e.scene.highDynamicRange = !,
e.scene.skyAtmosphere.show = !,
e.scene.skyBox.show = !,
e.scene.globe._surface._tileProvider && e.scene.globe._surface._tileProvider._renderState && e.scene.globe._surface._tileProvider._renderState.blending /*&& (e.scene.globe._surface._tileProvider._renderState.blending.enabled = !0,
e.scene.globe._surface._tileProvider._renderState.blending.equationRgb = Cesium.BlendEquation.ADD,
e.scene.globe._surface._tileProvider._renderState.blending.equationAlpha = Cesium.BlendEquation.ADD,
e.scene.globe._surface._tileProvider._renderState.blending.functionSourceAlpha = Cesium.BlendFunction.ONE,
e.scene.globe._surface._tileProvider._renderState.blending.functionSourceRgb = Cesium.BlendFunction.ONE,
e.scene.globe._surface._tileProvider._renderState.blending.functionDestinationAlpha = Cesium.BlendFunction.ZERO,
e.scene.globe._surface._tileProvider._renderState.blending.functionDestinationRgb = Cesium.BlendFunction.ZERO)*/
}
}
underground.prototype.disable=function() {
if (this._enable) {
this._enable = !,
this._updateImageryLayersAlpha(this._oldViewOpts.alpha);
var e = this._viewer;
Cesium.ExpandByMars.underEarth.cullFace = void ,
Cesium.ExpandByMars.underEarth.enable = !,
Cesium.ExpandByMars.underEarth.enableDepth = ,
Cesium.ExpandByMars.underEarth.enableSkirt = !,
e.scene.globe.depthTestAgainstTerrain = this._oldViewOpts.depthTest,
e.scene.skyBox.show = this._oldViewOpts.skyBoxShow,
e.scene.highDynamicRange = this._oldViewOpts.highDynamicRange,
e.scene.skyAtmosphere.show = this._oldViewOpts.skyShow/*,
void 0 != this._oldViewOpts.blending && (e.scene.globe._surface._tileProvider._renderState.blending = this._oldViewOpts.blending)*/
}
}
underground.prototype.destroy=function(){
delete this._viewer,
delete this._alpha,
delete this._depth,
delete this._enable,
delete this._oldViewOpts
}

3.测试

3.1.修改3处源码

3.2.增加1个文件,ExpandByMars.js

3.3.重新打包

npm run minifyRelease

3.4.沙盒里测试

function underground(t, i) {
this._viewer = t;
var n = Cesium.defaultValue(i, {});
this._depth = Cesium.defaultValue(n.depth, ),
this._alpha = Cesium.defaultValue(n.alpha, .),
this.enable = Cesium.defaultValue(n.enable, !)
}
underground.prototype._updateImageryLayersAlpha=function(e) {
for (var t = this._viewer.imageryLayers._layers, i = , a = t.length; i < a; i++)
t[i].alpha = e
}
underground.prototype._historyOpts =function() {
var e = {};
e.alpha = Cesium.clone(this._viewer.imageryLayers._layers[] && this._viewer.imageryLayers._layers[].alpha),
e.highDynamicRange = Cesium.clone(this._viewer.scene.highDynamicRange),
e.skyShow = Cesium.clone(this._viewer.scene.skyAtmosphere.show),
e.skyBoxShow = Cesium.clone(this._viewer.scene.skyBox.show),
e.depthTest = Cesium.clone(this._viewer.scene.globe.depthTestAgainstTerrain),
this._viewer.scene.globe._surface && this._viewer.scene.globe._surface._tileProvider && this._viewer.scene.globe._surface._tileProvider._renderState && (e.blending = Cesium.clone(this._viewer.scene.globe._surface._tileProvider._renderState.blending)),
this._oldViewOpts = e
}
underground.prototype.activate =function() {
if (!this._enable) {
this._enable = !,
this._historyOpts(),
this._updateImageryLayersAlpha(this._alpha);
var e = this._viewer;
Cesium.ExpandByMars.underEarth.cullFace = !,
Cesium.ExpandByMars.underEarth.enable = !,
Cesium.ExpandByMars.underEarth.enableDepth = this._depth,
Cesium.ExpandByMars.underEarth.enableSkirt = !,
e.scene.globe.depthTestAgainstTerrain = !,
e.scene.highDynamicRange = !,
e.scene.skyAtmosphere.show = !,
e.scene.skyBox.show = !,
e.scene.globe._surface._tileProvider && e.scene.globe._surface._tileProvider._renderState && e.scene.globe._surface._tileProvider._renderState.blending /*&& (e.scene.globe._surface._tileProvider._renderState.blending.enabled = !0,
e.scene.globe._surface._tileProvider._renderState.blending.equationRgb = Cesium.BlendEquation.ADD,
e.scene.globe._surface._tileProvider._renderState.blending.equationAlpha = Cesium.BlendEquation.ADD,
e.scene.globe._surface._tileProvider._renderState.blending.functionSourceAlpha = Cesium.BlendFunction.ONE,
e.scene.globe._surface._tileProvider._renderState.blending.functionSourceRgb = Cesium.BlendFunction.ONE,
e.scene.globe._surface._tileProvider._renderState.blending.functionDestinationAlpha = Cesium.BlendFunction.ZERO,
e.scene.globe._surface._tileProvider._renderState.blending.functionDestinationRgb = Cesium.BlendFunction.ZERO)*/
}
}
underground.prototype.disable=function() {
if (this._enable) {
this._enable = !,
this._updateImageryLayersAlpha(this._oldViewOpts.alpha);
var e = this._viewer;
Cesium.ExpandByMars.underEarth.cullFace = void ,
Cesium.ExpandByMars.underEarth.enable = !,
Cesium.ExpandByMars.underEarth.enableDepth = ,
Cesium.ExpandByMars.underEarth.enableSkirt = !,
e.scene.globe.depthTestAgainstTerrain = this._oldViewOpts.depthTest,
e.scene.skyBox.show = this._oldViewOpts.skyBoxShow,
e.scene.highDynamicRange = this._oldViewOpts.highDynamicRange,
e.scene.skyAtmosphere.show = this._oldViewOpts.skyShow/*,
void 0 != this._oldViewOpts.blending && (e.scene.globe._surface._tileProvider._renderState.blending = this._oldViewOpts.blending)*/
}
}
underground.prototype.destroy=function(){
delete this._viewer,
delete this._alpha,
delete this._depth,
delete this._enable,
delete this._oldViewOpts
} var viewer = new Cesium.Viewer('cesiumContainer');
viewer.scene.globe.baseColor = new Cesium.Color(, , , );
var blueBox = viewer.entities.add({
name: 'Blue box',
position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, ),
box: {
dimensions: new Cesium.Cartesian3(100.0, 100.0, 5000.0),
material: Cesium.Color.RED
}
});
viewer.zoomTo(blueBox);
var ug = new underground(viewer, {
depth: ,
alpha: 0.6
})
ug.activate(); Sandcastle.addToggleButton('地下模式', true, function(checked) {
checked?ug.activate():ug.disable();
});

cesium地下模式(地表透明)2的更多相关文章

  1. cesium地下模式(地表透明)4

    这篇博客主要罗列一下解决地下模式(地表透明)的相关资源 1.Cesium的Github仓库地下模式issue 有人提了这个问题,但是cesium官方没有解决这个问题,持续跟踪一下问题说不定哪天官方就解 ...

  2. cesium地下模式(地表透明)1

    cesium没有提供地下功能,实现地下模式需要以下三步. 1.修改cesium源码,在GlobeSurfaceTileProvider.js文件里修改一行代码 command.pass = Pass. ...

  3. cesium地下模式(地表透明)3

    这篇博客主要解决“瓦片的白色网格”问题 设置skirt=0可以解决这个问题,需要设置3个地方 1.HeightmapTerrainData.js createMesh方法 this._skirtHei ...

  4. 对端边缘云网络计算模式:透明计算、移动边缘计算、雾计算和Cloudlet

    对端边缘云网络计算模式:透明计算.移动边缘计算.雾计算和Cloudlet 概要 将数据发送到云端进行分析是过去几十年的一个突出趋势,推动了云计算成为主流计算范式.然而,物联网时代设备数量和数据流量的急 ...

  5. 七个结构模式之装饰者模式(Decorator Pattern)

    定义: 使用组合的方法,动态给一个类增加一些额外的功能,避免因为使用子类继承而导致类继承结构复杂.并且可以保持和被装饰者同一个抽象接口,从而使客户端透明. 结构图: Component:抽象构件类,定 ...

  6. <代码整洁之道>、<java与模式>、<head first设计模式>读书笔记集合

    一.前言                                                                                       几个月前的看书笔记 ...

  7. (十七)迭代器模式详解(foreach的精髓)

    作者:zuoxiaolong8810(左潇龙),转载请注明出处,特别说明:本博文来自博主原博客,为保证新博客中博文的完整性,特复制到此留存,如需转载请注明新博客地址即可. 各位好,很久没以LZ的身份和 ...

  8. JavaScript高级---装饰者模式设计

    一.设计模式 javascript里面给我们提供了很多种设计模式: 工厂.桥.组合.门面.适配器.装饰者.享元.代理.观察者.命令.责任链 在前面我们实现了工厂模式和桥模式 工厂模式 : 核心:为了生 ...

  9. 24种设计模式--组合模式【Composite Pattern】

    大家在上学的时候应该都学过“数据结构”这门课程吧,还记得其中有一节叫“二叉树”吧,我们上学那会儿这一章节是必考内容,左子树,右子树,什么先序遍历后序遍历什么,重点就是二叉树的的遍历,我还记得当时老师就 ...

随机推荐

  1. vs2019 netocore项目本地程序ip地址访问需修改的配置文件

    IISPress启动项目后,打开IISPress托盘可以看到当前项目 根据图中标识出来的applicationhost.config文件路径,一般为你的项目解决方案目录下的.vs\解决方案文件夹\co ...

  2. Django--模型层进阶

    目录 QuerySet对象 可切片 可迭代 惰性查询 缓存机制 何时查询集不会被缓存? exists()与iterator()方法 exists() iterator() 中介模型 查询优化 表数据 ...

  3. jQuery---jq基础了解(语法,特性),JQ和JS的区别对比,JQ和JS相互转换,Jquery的选择器(基础选择器,层级选择器,属性选择器),Jquery的筛选器(基本筛选器,表单筛选器),Jquery筛选方法

    jQuery---jq基础了解(语法,特性),JQ和JS的区别对比,JQ和JS相互转换,Jquery的选择器(基础选择器,层级选择器,属性选择器),Jquery的筛选器(基本筛选器,表单筛选器),Jq ...

  4. [Linux] Ubuntu Server18 python3.7 虚拟环境

    Ubuntu Server18 python3.7 环境 Ubuntu Server18 默认是python3.6, 目前开发主要用python3.7. 所以想搭建python3.7环境. 试过几手动 ...

  5. iOS - 适配 iOS 13 之工兵连扫雷

    iOS 13 支持适配的机型 目前最新 iPhone 11.iPhone 11 Pro和iPhone 11 Pro Max iPhone X.iPhone XR.iPhone XS.iPhone XS ...

  6. JS 中类型和类型转换

    类型 首先明确一点,Js中的类型是针对值来说,而不是针对变量,值就是所谓的42, 'abc', false 等能用js 操作的数据.在js 中说某某某是什么数据类型,其实是说的这些值是什么类型.值呢? ...

  7. 记Html的初次接触

    第一次接触Html是在昨天的培训班体验课上,这一次课我明白了许多. 1.程序语言比我想象中还要多(原来除了C与Java还有这么多) 2.程序员毕业后掌握7种语言是很正常的事(难怪程序员会秃顶) 3.H ...

  8. 《linux就该这么学》课堂笔记07 while、case、计划任务、用户增删改查命令

    while条件循环语句 while 条件测试操作 do 命令序列 done  case条件测试语句 case 变量值 in 模式一) 命令序列1 ;; 模式二) 命令序列2 ;; *) 默认命令序列 ...

  9. ERROR 1129 (HY000): Host '192.168.7.210' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

    一.问题现象 mysql远程连接报错 ERROR (HY000): Host '192.168.7.210' is blocked because of many connection errors; ...

  10. DT企业新闻也叫公司新闻简介调取方案

    今天我们讲的是企业新闻简介的事,由于destoon官方比较懒,企业新闻没有开发这个截字功能,我们就变通思维直接调取内容前100字,但是由于企业新闻是2个不同的 表,所以我们必须做点小事,  就是写点p ...