首页 > 其他分享 >Cesium案例(五) Underground Color

Cesium案例(五) Underground Color

时间:2023-04-06 14:11:20浏览次数:36  
标签:farDistance const Color viewModel nearDistance Underground farAlpha Cesium

     Cesium.Ion.defaultAccessToken =        token       const viewer = new Cesium.Viewer("cesiumContainer");
      const scene = viewer.scene;       const globe = scene.globe;       //获取或设置深度测试椭球。
      scene.screenSpaceCameraController.enableCollisionDetection = false;       //获取用于相机输入处理的控制器。       //启用或禁用相机与地形的碰撞检测。       const longitude = -3.82518;       const latitude = 53.11728;       const height = -500.0;       const position = Cesium.Cartesian3.fromDegrees(         longitude,         latitude,         height       );       const url = " ../Source/SampleData/models/ParcLeadMine/ParcLeadMine.glb";
      const entity = viewer.entities.add({         name: url,         position: position,         model: {           uri: url,         },       });
      viewer.scene.camera.setView({         //设置相机位置、方向和变换。         destination: new Cesium.Cartesian3(           3827058.651471591,           -256575.7981065622,           5078738.238484612         ),         //摄像机在 WGS84(世界)坐标中的最终位置,         //或从自上而下视图可见的矩形。         orientation: new Cesium.HeadingPitchRoll(           1.9765540737339418,           -0.17352018581162754,           0.0030147639151465455         ),         //包含方向和向上属性或航向、俯仰和滚动属性的对象。         //默认情况下,方向将指向 3D 中框架的中心,在哥伦布视图中指向负 z 方向。         //向上方向将指向 3D 中的当地北方,在哥伦布视图中指向正 y 方向。         //在无限滚动模式下,2D 中不使用方向。         endTransform: Cesium.Matrix4.IDENTITY,         //表示相机的参考框架。       });
      const originalColor = Cesium.Color.BLACK;       const originalNearDistance = 1000.0;       const originalFarDistance = 1000000.0;       const originalNearAlpha = 0.0;       const originalFarAlpha = 1.0;
      let color = originalColor;
      const viewModel = {         enabled: true,         nearDistance: originalNearDistance,         farDistance: originalFarDistance,         nearAlpha: originalNearAlpha,         farAlpha: originalFarAlpha,       };
      Cesium.knockout.track(viewModel);       //Cesium.knock能够使Cesium球体监听html控件,       // 从而根据控件的值实时改变一些地图属性.       const toolbar = document.getElementById("toolbar");       Cesium.knockout.applyBindings(viewModel, toolbar);       for (const name in viewModel) {         if (viewModel.hasOwnProperty(name)) {           Cesium.knockout.getObservable(viewModel, name).subscribe(update);         }       }
      Sandcastle.addToolbarButton("Random color", function () {         color = Cesium.Color.fromRandom({           //使用提供的选项创建随机颜色。           //对于可重现的随机颜色,您应该在应用程序开始时调用 CesiumMath#setRandomNumberSeed 一次。           alpha: 1.0,           //如果指定,则使用 alpha 分量而不是随机值。         });         update();       });
      Sandcastle.addToolbarButton("Clear", function () {         color = originalColor;         viewModel.enabled = true;         viewModel.nearDistance = originalNearDistance;         viewModel.farDistance = originalFarDistance;         viewModel.nearAlpha = originalNearAlpha;         viewModel.farAlpha = originalFarAlpha;         update();       });
      function update() {         globe.undergroundColor = viewModel.enabled ? color : undefined;         //当相机在地下或球体半透明时渲染球体背面的颜色,根据相机的距离与球体颜色混合。         //要禁用地下着色,请将 undergroundColor 设置为 undefined 。         let nearDistance = Number(viewModel.nearDistance);         nearDistance = isNaN(nearDistance)           ? originalNearDistance           : nearDistance;
        let farDistance = Number(viewModel.farDistance);         farDistance = isNaN(farDistance) ? originalFarDistance : farDistance;
        if (nearDistance > farDistance) {           nearDistance = farDistance;         }
        let nearAlpha = Number(viewModel.nearAlpha);         nearAlpha = isNaN(nearAlpha) ? 0.0 : nearAlpha;
        let farAlpha = Number(viewModel.farAlpha);         farAlpha = isNaN(farAlpha) ? 1.0 : farAlpha;
        globe.undergroundColorAlphaByDistance.near = nearDistance;         globe.undergroundColorAlphaByDistance.far = farDistance;         globe.undergroundColorAlphaByDistance.nearValue = nearAlpha;         globe.undergroundColorAlphaByDistance.farValue = farAlpha;       }       update();

标签:farDistance,const,Color,viewModel,nearDistance,Underground,farAlpha,Cesium
From: https://www.cnblogs.com/BlackCaat/p/17292573.html

相关文章

  • Cesium 案例(三) Web Map Service(WMS) Washington DC 2017
    WMSCesium.Ion.defaultAccessToken="token";   constviewer=newCesium.Viewer("cesiumContainer");   //AddaWMSimagerylayer   constlayer=newCesium.ImageryLayer(    newCesium.WebMapServiceImageryProvider({ ......
  • Cesium 案例(二)Web MapTile Service with Time
    使用官方github包,部分解释来源于http://cesium.xin/cesium/cn/Documentation1.95/index.html  Cesium.Ion.defaultAccessToken=token;   constviewer=newCesium.Viewer("cesiumContainer",{    shouldAnimate:true,    //时钟应该默认尝试......
  • Cesium实例化绘制(Instanced Drawing)
    上篇《WebGL-实例化绘制》我们学习了实例化webgl底层实现原理,基于webgl1.0标准的扩展。这篇博客我们来了解下cesium引擎是如何支持实例化功能的。该篇公众号主要参考了博客:《Cesium原理篇:6Render模块(6:Instance实例化)》。假如有这样的需求:有四个不同颜色的点,它们的相对位置(......
  • 我们都错了,Color不是视频或图片分享应用,而是你的现场直播
    关注应用的人应该对之前的社交照片分享应用Color.com的故事不会陌生,未上线即被投4100万种子美金,不过最引人注目的也许不是这个应用本身,而是它所犯的错误及其如昙花一现的生命,当时人们都嘲笑,谴责,甚至称Color拉响投资警钟,投资人豪掷4100万美元只是举办了一场无人问津的派对。但是......
  • background-color 只填充容器的一半
     关键字的取值:toright  (表示从左往右渐变)toleft    (表示从右往左渐变)totop    (表示从下往上渐变)tobottom (表示从上往下渐变)角度的取值: 0deg  (从下到上totop)  180deg(从上到下tobottom)90deg  (从左到右toright)-90deg......
  • Android Button设置android:background=“@drawable/xxx“无效,<item android:drawable
    问题描述:AndroidButton设置android:background=“@drawable/xxx“无效,<itemandroid:drawable="@color/purple_200"/>无效  解决方法:找到res/values/themes.xm......
  • Cesium:entity闪烁(点、面以及billboard)
    entity的闪烁主要是通过回调函数CallbackProperty,控制样式改变或是否显示1.点的闪烁functionf2(){ varx=1; varflog=true; viewer.entities.add({ name:"圆点p......
  • Cesium 与 Babylon.js 可视化 glsl 特效篇(十八)
    我决定不从Babylonjs基础来讲了直接整合cesium与babylonjs可视化来讲我整合一个类库后续不断更新中npmi@haibalai/cesium-babylonjs初始化cesium-babylonjs类库,map......
  • 一统天下 flutter - 动画: 自定义 Tween - ColorTween, CurveTween, SizeTween, RectT
    一统天下flutterhttps://github.com/webabcd/flutter_demo作者webabcd一统天下flutter-动画:自定义Tween-ColorTween,CurveTween,SizeTween,RectTween,A......
  • cesium导航
    推荐:将 ​​NSDT场景编辑器​​ 加入你的3D开发工具链今天看到GoogleEarth上的导航栏,想起百度地图,高德地图,leaflet(插件)等等好像都有提供导航条,但是cesium官方包里面......