Cesium Entity的point和billboard不会互相切换?

cesium 版本:1.119

示例代码

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/cesium/1.119.0/Cesium.js"></script>
  <link href="https://cdn.bootcdn.net/ajax/libs/cesium/1.119.0/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
  <div id="map"></div>
</body>

<script>
  
  let viewer = new Cesium.Viewer(document.getElementById('map'), {
    // 是否创建动画小器件,左下角仪表
    animation: false,
    // 是否显示图层选择器
    baseLayerPicker: false,
    // 是否显示全屏按钮
    fullscreenButton: false,
    // 是否显示geocoder小器件,右上角查询按钮
    geocoder: false,
    // 是否显示Home按钮
    homeButton: false,
    // 是否显示信息框
    infoBox: false,
    // 是否显示3D/2D选择器
    sceneModePicker: false,
    // 如果设置为true,则所有几何图形以3D模式绘制以节约GPU资源
    scene3DOnly: true,
    // 是否显示选取指示器组件
    selectionIndicator: false,
    // 是否显示时间轴
    timeline: false,
    // 是否显示右上角的帮助按钮
    navigationHelpButton: false,
    // 将图层选择的控件关掉,才能添加其他影像数据
    baselLayerPicker: false,
    // 是否显示背影
    shadows: false,
    shouldAnimate: false,
    vrButton: false,
    baseLayer: new Cesium.ImageryLayer(new Cesium.UrlTemplateImageryProvider({ // 设置底图
      url: 'https://abd.com',
    }))
  })

  viewer.camera.setView({ destination: Cesium.Cartesian3.fromDegrees(102.72355497615297, 25.035745367219242, 220000) });

  let point= {
    "heightReference": 3,
    "color": Cesium.Color.RED,
    "pixelSize": 100
  }
  let billboard = {
    "heightReference": 3,
    "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAFQpJREFUeF7tnU1sFdcVgO887BKwMUpCcCoRxbCoVCLSTdUEVa1BGDW7VqKJ1C5qI3WTRdWmm5hFBSgL6KZV1QWbSthZtFISFq1UNRVG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ZuPzp635NVuydMZx/z6fMJx/ns4Vhw2cMe2b3wpcbBSAPG/2awedGXz5n3t4zG34BImwr2esN8r1h+n0cMHkLiGmjlzKjhO13aS0pZLq7TNck9g0DJm8AASA63eXJ4o7v9OoiaTKwE3uIScLS+t7VDiAyl73qjWZefX3uuExL3ft6A8jJyQNXDDy22oq8p2fnnJJrvgYxe6eVzmk/iFurxjulyCbZy75KTbsOOSdw8WUy+bKqy8VqkTalI3Zul3I4TwCZgLuf02FVsWCCcyFCaZI9IeoxMTO1t5dLNxkCBLWDh5NNKIFCk7UyqH8l0GqBIy/tdseLClW5eIS1G5JLr1nwApBi6U8IEVrawjP6lgSz7jA2YHKpyOEFIKA1vBJDRq8LEtHjisHEG29y7zXS3gACSsoVsFK4frE1oUSVS/uZlcB6mNJFl8aOSml4BYhZFdLZSAKMESBkBSQBXtmepEMSIAk0S4A8CFkHSYA8CNkASUBNAuRB1ORGrSKRAAESiaKpm2oSIEDU5EatIpEAARKJoqmbahIgQNTkRq0ikQABEomiqZtqEiBA1ORGrSKRwP8BdG3MjFYh2MwAAAAASUVORK5CYII=",
    "width": 20,
    "height": 20,
    "scale": 1
  }

  // 添加点
  let entity = viewer.entities.add({
    position: Cesium.Cartesian3.fromDegrees(102.62355497615297, 25.035745367219242),
    point
  });


  setTimeout(() => {
    entity.point = undefined;
    entity.billboard = billboard;

    setTimeout(()=>{
      entity.billboard = undefined;
      entity.point = point;
    }, 3000)
  }, 3000);



</script>

<style>
  html,body,#map{
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
</style>

</html>
  1. 创建一个点(point)
  2. 3秒后修改点为billboard
  3. 3秒再修改为点
  4. 此时的点大小变小了,再继续添加的点也是小的

请问是什么导致了point变小?

阅读 809
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏