2014-12-18 40 views
1

我試圖在空氣中放置一個PolygonGeometry在銫。總之,我想用height創建一個從地面的偏移量,並extrudedHeight給物體一定的厚度。但是,當我設置extrudedHeight時,高度設置本身將被忽略,並且擠壓一直下降到地面。所以我可以將飛機層疊在一起,但沒有三維物體。什麼是實現這一目標的正確方法?在空氣中放置一個PolygonGeometry在銫

下面是我在做什麼至今:

 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] 

回答

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 
    }) 
})); 
+0

謝謝,這有很大的幫助。爲了澄清,我想定位一個高度爲x的物體,然後將其拉伸10米。我一直將高度設置爲x,並將高度拉伸至10(以及其他一些奇怪的組合),而從您的示例中,我瞭解到它的高度爲x,並將高度拉伸至x + 10(當您知道它時很明顯)。 – Nicolas78

+0

這很有道理;我會做一個說明,以澄清文件是更具體的行爲。 –