我的github

cesium可以建模吗?当然可以,但是。。。

建的模型比较单调乏味,比如建一个正方体,建一个圆球,如果是复杂一些的模型,例如一个tube(管道),一个圆环。。。。那该怎么办?cesium有没有提供这样的函数供我们使用呢?例如我们常见的。。。飞机模型   使用threejs建模呢?https://www.cnblogs.com/2008nmj/p/14886567.html

var viewer = new Cesium.Viewer("cesiumContainer", {
  infoBox: false,
  selectionIndicator: false,
  shadows: true,
  shouldAnimate: true,
});

function createModel(url, height) {
  viewer.entities.removeAll();

  var position = Cesium.Cartesian3.fromDegrees(
    -123.0744619,
    44.0503706,
    height
  );
  var heading = Cesium.Math.toRadians(135);
  var pitch = 0;
  var roll = 0;
  var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
  var orientation = Cesium.Transforms.headingPitchRollQuaternion(
    position,
    hpr
  );

  var entity = viewer.entities.add({
    name: url,
    position: position,
    orientation: orientation,
    model: {
      uri: url,
      minimumPixelSize: 128,
      maximumScale: 20000,
    },
  });
  viewer.trackedEntity = entity;
}

var options = [
  {
    text: "Aircraft",
    onselect: function () {
      createModel(
        "../SampleData/models/CesiumAir/Cesium_Air.glb",
        5000.0
      );
    },
  },
  {
    text: "Drone",
    onselect: function () {
      createModel(
        "../SampleData/models/CesiumDrone/CesiumDrone.glb",
        150.0
      );
    },
  },
  {
    text: "Ground Vehicle",
    onselect: function () {
      createModel(
        "../SampleData/models/GroundVehicle/GroundVehicle.glb",
        0
      );
    },
  },
  {
    text: "Hot Air Balloon",
    onselect: function () {
      createModel(
        "../SampleData/models/CesiumBalloon/CesiumBalloon.glb",
        1000.0
      );
    },
  },
  {
    text: "Milk Truck",
    onselect: function () {
      createModel(
        "../SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb",
        0
      );
    },
  },
  {
    text: "Skinned Character",
    onselect: function () {
      createModel(
        "../SampleData/models/CesiumMan/Cesium_Man.glb",
        0
      );
    },
  },
  {
    text: "Draco Compressed Model",
    onselect: function () {
      createModel(
        "../SampleData/models/DracoCompressed/CesiumMilkTruck.gltf",
        0
      );
    },
  },
];

Sandcastle.addToolbarMenu(options);

 

posted on 2021-06-24 16:58  XiaoNiuFeiTian  阅读(913)  评论(0编辑  收藏  举报