cesium 面贴地形

//面
var addPolygon = {
    id: "polygon",
    name: "面",
    show: true,
    polygon: {
            hierarchy: Cesium.Cartesian3.fromDegreesArray([
                    118, 30, 119, 32, 116, 32, 116, 30,
            ]),
            material: Cesium.Color.RED.withAlpha(0.4),
            
            classificationType: Cesium.ClassificationType.BOTH, //贴地 
    },
};

【cesium知识梳理】4.Entity绘制实体、贴地、材质

好的,你想了解关于 Cesium 中实现面贴地的 plane 的内容。在 Cesium 中,面贴地的 plane 可以通过创建一个 GeometryInstance 对象和一个 Primitive 对象来实现。GeometryInstance 对象描述了面贴地的 plane 的几何形状,而 Primitive 对象则定义了如何渲染这个 GeometryInstance 对象。 具体实现过程如下: 1. 创建一个 PlaneGeometry 对象,该对象表示一个无限平面。 ``` var planeGeometry = new Cesium.PlaneGeometry({ vertexFormat: Cesium.VertexFormat.POSITION_ONLY, }); ``` 2. 创建一个 PlaneGeometryInstance 对象,该对象描述了要面贴地的 plane 的位置、方向和大小等属性。在这里,我们使用 Cesium.Cartesian3.fromDegrees() 方法将经纬度坐标转换为笛卡尔坐标。 ``` var planeGeometryInstance = new Cesium.GeometryInstance({ geometry: planeGeometry, modelMatrix: Cesium.Matrix4.multiplyByTranslation( Cesium.Transforms.eastNorthUpToFixedFrame( Cesium.Cartesian3.fromDegrees(lon, lat, height) ), new Cesium.Cartesian3(0.0, 0.0, 0.0), new Cesium.Matrix4() ), }); ``` 3. 创建一个 Material 对象,该对象定义了面贴地的 plane 的外观样式,例如颜色、透明度等。 ``` var planeMaterial = Cesium.Material.fromType("Color"); planeMaterial.uniforms.color = new Cesium.Color(1.0, 1.0, 1.0, 0.5); ``` 4. 创建一个 Primitive 对象,该对象是最终的渲染对象,将 GeometryInstance 对象和 Material 对象结合起来,显示在场景中。 ``` var planePrimitive = new Cesium.Primitive({ geometryInstances: planeGeometryInstance, appearance: new Cesium.MaterialAppearance({ material: planeMaterial, faceForward: true, translucent: true, }), }); ``` 以上就是在 Cesium 中实现面贴地的 plane 的基本流程。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值