Cesium(二):vue+cesium实现天际线分析

参考博客:Cesium天际线分析

闲聊:

最近入职新公司,业务面以地理信息为主,二维、三维地图都有所涉及。近期就研究了一下cesium的一点小案例。
这一篇是天际线分析:

效果图:

在这里插入图片描述

场景:

3维地图描绘出天际线效果,效果优于superMap的案例

实现原理:

利用cesium的边缘检测和后期处理效果叠加。即:在地图上检测此视角下的地形边缘,叠加标记效果层,叠加针对边缘实例和前一个标记效果层的标记进行颜色处理和纹理合成

实现代码:

vue:

<template>
  <div class="home">
    <div id="cesiumContainer"></div>
    <el-row type="flex" :gutter="20">
      <el-col :span="24">
        <div class="grid-content bg-purple">
          <el-button type="primary" @click="addSkyLine">绘制线</el-button>
          <el-button type="primary" @click="clearSkyLine">清除</el-button>
          <el-select v-model="curColor"  placeholder="请选择">
            <el-option
              v-for="(item,index) in colorList"
              :key="index"
              :label="item.label"
              :value="item.color">
            </el-option>
          </el-select>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
   createSkyLine,removeSkyLine} from './model/skyLine'
export default {
   
  name: "draw",
  data() {
   
    return {
   
      _viewer: undefined,
      tempEntities: [],
      pointArr:[],
      paramObj : {
   
            id: "Skyline",
            name: 'czm_skylinetemp',
            //fragmentShader 细绳   uniform着色器对象  
            fragmentShader: 'uniform sampler2D colorTexture;' +
                'uniform sampler2D depthTexture;' +
                'varying vec2 v_textureCoordinates;' +
                'void main(void)'</
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要在Vue实现Cesium的VR功能,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Vue.jsCesium。你可以使用npm或yarn来安装它们: ```shell # 安装Vue CLI npm install -g @vue/cli # 创建一个新的Vue项目 vue create cesium-vr-app # 进入项目目录 cd cesium-vr-app # 安装Cesium依赖 npm install cesium ``` 2. 现在,在你的Vue项目中,你可以创建一个CesiumVR组件。在src/components目录下创建一个新的文件CesiumVR.vue,然后在其中编写你的CesiumVR代码: ```vue <template> <div id="cesiumContainer" style="width: 100%; height: 100%;"></div> </template> <script> import * as Cesium from 'cesium/Cesium'; export default { mounted() { this.viewer = new Cesium.Viewer('cesiumContainer', { vrButton: true, // 启用VR按钮 vrButtonOptions: { // VR按钮配置选项 defaultVRButton: true, vrButtonElement: document.getElementById('vrButton') } }); }, beforeDestroy() { if (this.viewer && !this.viewer.isDestroyed()) { this.viewer.destroy(); } } }; </script> <style scoped> #cesiumContainer { position: absolute; top: 0; left: 0; } #vrButton { position: fixed; top: 10px; right: 10px; } </style> ``` 3. 接下来,在你的根组件(App.vue)中使用CesiumVR组件。在App.vue中,引入CesiumVR组件并将其添加到模板中: ```vue <template> <div id="app"> <cesium-vr></cesium-vr> </div> </template> <script> import CesiumVR from './components/CesiumVR.vue'; export default { components: { CesiumVR } }; </script> <style> #app { height: 100vh; } </style> ``` 4. 最后,在你的项目中运行以下命令以启动开发服务器: ```shell npm run serve ``` 现在,你应该能够在浏览器中看到一个具有VR功能的Cesium场景。用户可以通过单击VR按钮将应用程序切换到虚拟现实模式,然后使用适当的设备(如头戴式显示器)来浏览和与地球进行交互。请注意,为了在浏览器中使用VR功能,需要先确保你的设备和浏览器支持WebVR或WebXR技术。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_小郑有点困了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值