具有颜色属性的
GeometryInstance
个实例的外观。
这允许多个几何体实例(每个实例具有不同的颜色)来
如下面第二个例子所示,用相同的Primitive
绘制。Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Example:
// A solid white line segment
var primitive = new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
geometry : new Cesium.SimplePolylineGeometry({
positions : Cesium.Cartesian3.fromDegreesArray([
0.0, 0.0,
5.0, 0.0
])
}),
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 1.0, 1.0, 1.0))
}
}),
appearance : new Cesium.PerInstanceColorAppearance({
flat : true,
translucent : false
})
});
// Two rectangles in a primitive, each with a different color
var instance = new Cesium.GeometryInstance({
geometry : new Cesium.RectangleGeometry({
rectangle : Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0)
}),
attributes : {
color : new Cesium.ColorGeometryInstanceAttribute(1.0, 0.0, 0.0, 0.5)
}
});
var anotherInstance = new Cesium.GeometryInstance({
geometry : new Cesium.RectangleGeometry({
rectangle : Cesium.Rectangle.fromDegrees(0.0, 40.0, 10.0, 50.0)
}),
attributes : {
color : new Cesium.ColorGeometryInstanceAttribute(0.0, 0.0, 1.0, 0.5)
}
});
var rectanglePrimitive = new Cesium.Primitive({
geometryInstances : [instance, anotherInstance],
appearance : new Cesium.PerInstanceColorAppearance()
});
Members
static constant Cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT : VertexFormat
VertexFormat
所有PerInstanceColorAppearance
实例
与PerInstanceColorAppearance#flat
为true
时兼容。
这只需要position
属性。static constant Cesium.PerInstanceColorAppearance.VERTEX_FORMAT : VertexFormat
当
true
时,几何体应该这样闭合
PerInstanceColorAppearance#renderState
已启用背面消隐。
如果查看器进入几何体,它将不可见。-
Default Value:
false
当
true
时,碎片着色器翻转曲面法线
如有必要,确保观察者避开法线
暗点。当几何体的两侧都应该
阴影像WallGeometry
。-
Default Value:
true
当
true
时,在片段着色器中使用平面着色,
这意味着照明不考虑在内。-
Default Value:
false
片段着色器的GLSL源代码。
material : Material
此属性是
Appearance
接口的一部分,但不是
6866完全使用了自定义着色器6166。-
Default Value:
undefined
WebGL修复了渲染几何体时要使用的函数状态。
The render state can be explicitly defined when constructing a PerInstanceColorAppearance
instance, or it is set implicitly via PerInstanceColorAppearance#translucent
and PerInstanceColorAppearance#closed
.
当
true
时,几何体看起来是半透明的
PerInstanceColorAppearance#renderState
启用了alpha混合。-
Default Value:
true
readonly vertexFormat : VertexFormat
此外观实例与
VertexFormat
兼容。
一个几何体可以有更多的顶点属性并且仍然是兼容的
潜在的性能成本-但它不能少。顶点着色器的GLSL源代码。
Methods
按程序创建完整的GLSL片段着色器源。对于
PerInstanceColorAppearance
,
它来自PerInstanceColorAppearance#fragmentShaderSource
,PerInstanceColorAppearance#flat
,
和PerInstanceColorAppearance#faceForward
。Returns:
完整的GLSL片段着色器源。
创建渲染状态。这不是最终渲染状态实例;而是,
它可以包含与渲染状态相同的渲染状态属性子集
在上下文中创建。
Returns:
渲染状态。
基于
PerInstanceColorAppearance#translucent
确定几何体是否半透明。Returns:
如果外观是半透明的,则为
true
。