C1——cesium模拟建筑

阅读: 评论:0

C1——cesium模拟建筑

C1——cesium模拟建筑

需求:奔来有个建筑,换成其他建筑。特点是整个过程是动态的。

思路:

第一步:视角移动过去

第二部:隐藏原来建筑

第三步:显示新的建筑

特点:特点是整个过程是动态的; 每步之间有先后顺序。已经封装为类了

封装的代码:

class ConstructSimul {constructor(viewer) {this.viewer = del = null}
}// ConstructSimul.prototype.start这么些最好,只是在原型上加了方法,不会造成原型链断裂
ConstructSimul.prototype.start = ()=>{let _this = this;let viewer = this.viewer;let step0 = function(){setTimeout( ()=>{step1();},500)};let step1 = function(){viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees( 10*.***7267, 29.***2640, 4*5.1***9071292 ),orientation: {heading: Radians(  1**.**274808139827 ),pitch: Radians( -11.**085162 ),roll: 0},complete: function () {setTimeout( ()=>{step2(step3);},500)}});};let step2 = function(fun){let layer = _this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = false;}fun();};let step3 = function(){_ities.add({id:"gltf",position: Cesium.Cartesian3.fromDegrees(10*.**77714216316,29.**15177926754, 209),orientation: Cesium.Transforms.headingPitchRollQuaternion( Cesium.Cartesian3.fromDegrees(106.***714216316,29.**5177926754,209),new Cesium.HeadingPitchRoll(0, 0, 0)),model: {uri: "static/gltf/scene1.gltf",}});};let step4 = function(){let layer = _this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = true;}};step0();}
d = ()=>{let entity = ById("gltf");if (entity) {ve(entity);}let layer = this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = true;}
}
/*
// 这么写也不好因为ConstructSimul.prototype.__prot__指向Object,这么重新定义后原型链就断了,也就灭有toString等方法了。
ConstructSimul.prototype = {constructor: ConstructSimul,start: function(){let _this = this;let viewer = this.viewer;let step0 = function(){setTimeout( ()=>{step1();},500)};let step1 = function(){viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees( 10*.***7267, 29.***2640, 4*5.1***9071292 ),orientation: {heading: Radians(  1**.**274808139827 ),pitch: Radians( -11.**085162 ),roll: 0},complete: function () {setTimeout( ()=>{step2(step3);},500)}});};let step2 = function(fun){let layer = _this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = false;}fun();};let step3 = function(){_ities.add({id:"gltf",position: Cesium.Cartesian3.fromDegrees(10*.**77714216316,29.**15177926754, 209),orientation: Cesium.Transforms.headingPitchRollQuaternion( Cesium.Cartesian3.fromDegrees(106.***714216316,29.**5177926754,209),new Cesium.HeadingPitchRoll(0, 0, 0)),model: {uri: "static/gltf/scene1.gltf",}});};let step4 = function(){let layer = _this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = true;}};step0();},end:function(){let entity = ById("gltf");if (entity) {ve(entity);}let layer = this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = true;}}
}
*/
/* 
// 这么写有问题ConstructSimul.prototype会让类的原型改变,需要用constrstor指回去
ConstructSimul.prototype = {start(){let _this = this;let viewer = this.viewer;let step0 = function(){setTimeout( ()=>{step1();},500)};let step1 = function(){viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees( 10*.***7267, 29.***2640, 4*5.1***9071292 ),orientation: {heading: Radians(  1**.**274808139827 ),pitch: Radians( -11.**085162 ),roll: 0},complete: function () {setTimeout( ()=>{step2(step3);},500)}});};let step2 = function(fun){let layer = _this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = false;}fun();};let step3 = function(){_ities.add({id:"gltf",position: Cesium.Cartesian3.fromDegrees(10*.**77714216316,29.**15177926754, 209),orientation: Cesium.Transforms.headingPitchRollQuaternion( Cesium.Cartesian3.fromDegrees(106.***714216316,29.**5177926754,209),new Cesium.HeadingPitchRoll(0, 0, 0)),model: {uri: "static/gltf/scene1.gltf",}});};let step4 = function(){let layer = _this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = true;}};step0();},end(){let entity = ById("gltf");if (entity) {ve(entity);}let layer = this.viewer.scene.layers.find("原来的图层");if( layer){layer.visible = true;}}} 
*/
export default ConstructSimul

调用:

structSimul = new ConstructSimulCLASS( viewer );
//开始模拟建筑
structSimul.start();
//删除模拟建筑d();

本文发布于:2024-01-30 18:52:35,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170661195622108.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:建筑   cesium
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23