1

I'm trying to position a PolygonGeometry in the air in Cesium. In short, I'd like to use height to create an offset from the ground, and extrudedHeight to give the object a certain thickness. However when I set extrudedHeight, the height setting itself is ignored and the extrusion goes down all the way to the ground. So I can layer planes on top of each other, but no three-dimensional objects. What's the correct way to achieve this?

Here's what I'm doing so far:

        polygonGeometry = Cesium.PolygonGeometry.fromPositions(
            positions: pos, 
            vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT                
            extrudedHeight: @options.extrudedHeight,
            height:@options.height
        )

        geometryInstance = new Cesium.GeometryInstance
            geometry: polygonGeometry

        primitive = new Cesium.Primitive
            geometryInstances: [geoInstance]
4

1 回答 1

2

很难确切地说出问题出在哪里,因为您的示例不完整,而且似乎使用了一种我不熟悉的数据绑定形式。但这是一个完整的示例,可以复制/粘贴到Sandcastle中,以便您进行比较。

var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;

var positions = Cesium.Cartesian3.fromDegreesArray([
    -88.0, 35.0,
    -80.0, 35.0,
    -80.0, 40.0,
    -88.0, 40.0
]);

var geometryInstance = new Cesium.GeometryInstance({
    geometry : Cesium.PolygonGeometry.fromPositions({
        positions : positions,
        height: 1000000,
        extrudedHeight: 1500000,
        vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT
    }),
    attributes: {
        color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.ORANGE)
    }
});

scene.primitives.add(new Cesium.Primitive({
    geometryInstances : geometryInstance,
    appearance : new Cesium.PerInstanceColorAppearance({
        closed : true,
        translucent : false
    })
}));
于 2014-12-19T19:54:08.700 回答