首页 > 其他 > 详细

Cesium走廊外框

时间:2021-05-14 15:36:18      阅读:25      评论:0      收藏:0      [点我收藏+]
// Create the viewer.
var viewer = new Cesium.Viewer("cesiumContainer",{
terrainProvider: new Cesium.createWorldTerrain({
					requestWaterMask: true,
					requestVertexNormals: true,

				})});
var scene = viewer.scene;

// Example 1: Draw the outline of a corridor on the globe surface.
//在地球表面绘制走廊的轮廓
// Create the corridor outline geometry.
//创建道路轮廓几何图形
var corridorOutlineGeometry = new Cesium.CorridorOutlineGeometry({
  positions: Cesium.Cartesian3.fromDegreesArray([
    -100.0, 40.0,
    -105.0, 40.0,
    -105.0, 35.0,
  ]),
  width: 200000.0,
  

});
// Create the geometry instance.
//创建几何体实例
var corridorOutline = new Cesium.GeometryInstance({
  geometry: corridorOutlineGeometry,
  attributes: {
    color: Cesium.ColorGeometryInstanceAttribute.fromColor(
      Cesium.Color.RED
    ),
  },
});

// Example 2: Draw the outline of an extruded corridor.
// Create the corridor geometry.  To extrude, specify the
// height of the geometry with the extrudedHeight option.
corridorOutlineGeometry = new Cesium.CorridorOutlineGeometry({
  positions: Cesium.Cartesian3.fromDegreesArray([
    -90.0, 40.0,
    -95.0, 40.0,
    -95.0,35.0,
  ]),
  width: 200000.0,
  //确定角点的样式。
  //NONE  与椭圆表面不符的直线
  //GEODESIC  遵循测地路径
  //RHUMB  遵循大黄蜂或恶魔般的道路
  //MITERED  直角
  cornerType: Cesium.CornerType.GEODESIC,
  extrudedHeight: 100000.0,
});
// Create the geometry instance.
var extrudedCorridorOutline = new Cesium.GeometryInstance({
  geometry: corridorOutlineGeometry,
  attributes: {
    color: Cesium.ColorGeometryInstanceAttribute.fromColor(
      Cesium.Color.WHITE
    ),
  },
});

// Add both corridor outline instances to primitives
scene.primitives.add(
  new Cesium.Primitive({
    //要渲染的几何实例-或单个几何实例。
    geometryInstances: [corridorOutline, extrudedCorridorOutline],
    //用于渲染图元的外观。
    appearance: new Cesium.PerInstanceColorAppearance({
      //当 true 时,片段着色器中将使用平面阴影,这意味着不考虑照明。
      flat: true,
      renderState: {
        lineWidth: Math.min(2.0, scene.maximumAliasedLineWidth),
      },
    }),
  })
);

  结果:

技术分享图片

 

Cesium走廊外框

原文:https://www.cnblogs.com/191080438qq/p/14767465.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!