vue+Cesium示例中缺少要素以至于运行不起来

示例:

网址:

https://cesium.com/learn/cesiumjs-learn/cesiumjs-creating-entities/

缺少:

正确的代码:

复制代码
<template>
  <div id="cesiumContainer" ref="cesiumContainer"></div>
</template>

<script setup>

import * as Cesium from 'cesium'
import '../Widgets/widgets.css' //这是src下面的widgets.css文件
import { onMounted } from 'vue'

Cesium.Ion.defaultAccessToken = "*****";
window.CESIUM_BASE_URL = '/'  //这是根目录下的四个文件夹

/* eslint-disable no-unused-vars */

onMounted(() => {

const viewer = new Cesium.Viewer("cesiumContainer");

viewer.entities.add({
  name: "Blue box",
  position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, 300000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    material: Cesium.Color.BLUE,
  },
});

viewer.entities.add({
  name: "Red box with black outline",
  position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    material: Cesium.Color.RED.withAlpha(0.5),
    outline: true,
    outlineColor: Cesium.Color.BLACK,
  },
});

 viewer.entities.add({
  name: "Yellow box outline",
  position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 300000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    fill: false,
    outline: true,
    outlineColor: Cesium.Color.YELLOW,
  },
});

viewer.zoomTo(viewer.entities);

})


</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
* {
  margin: 0;
  padding: 0
}

#cesiumContainer {
  width: 100%;
  height: 100vh;
}
</style>

展示:

相关推荐
2501_901147831 小时前
学习笔记:单调递增数字求解的迭代优化与工程实践
linux·服务器·笔记·学习·算法
三水不滴3 小时前
计算机网络核心网络模型
经验分享·笔记·tcp/ip·计算机网络·http·https
凉、介3 小时前
静态路由探究
网络·笔记·操作系统·嵌入式
hssfscv4 小时前
Javaweb学习笔记——后端实战8 springboot原理
笔记·后端·学习
浩浩的科研笔记4 小时前
入门读物---一篇24年的负荷预测综述---逐句翻译整理版
笔记·能源
爱吃羊的老虎4 小时前
【大模型开发】学习笔记一:RAG & LangChain 实战核心笔记
人工智能·笔记·语言模型·langchain
蒸蒸yyyyzwd4 小时前
DDIA学习笔记
笔记·学习
2501_901147834 小时前
学习笔记:基于摩尔投票法的高性能实现与工程实践
笔记·学习·算法·性能优化
Titan20245 小时前
搜索二叉树笔记模拟实现
数据结构·c++·笔记·学习