用于带有颜色属性的
GeometryInstance 实例的外观。
这允许将多个具有不同颜色的几何体实例与同一个 Primitive 一起绘制,如下方第二个示例所示。
| Name | Type | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
包含以下属性的对象:
|
Example:
// A solid white line segment
const 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
const 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)
}
});
const 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)
}
});
const rectanglePrimitive = new Cesium.Primitive({
geometryInstances : [instance, anotherInstance],
appearance : new Cesium.PerInstanceColorAppearance()
});
Members
static constant Cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT : VertexFormat
当
PerInstanceColorAppearance#flat 为 true 时,所有 PerInstanceColorAppearance 实例兼容的 VertexFormat。仅需要 position 属性。
static constant Cesium.PerInstanceColorAppearance.VERTEX_FORMAT : VertexFormat
当
true 时,几何体预期为闭合的,因此 PerInstanceColorAppearance#renderState 会启用背面剔除。
如果观察者进入几何体内部,它将不可见。
-
Default Value:
false
当
true 时,片段着色器会按需翻转表面法线,确保法线朝向观察者以避免暗斑。当几何体需要双面着色(如 WallGeometry)时,此属性非常有用。
-
Default Value:
true
当
true 时,片段着色器使用平面着色,即不考虑光照影响。
-
Default Value:
false
片段着色器的GLSL源代码。
该属性是
Appearance 接口的一部分,但由于 PerInstanceColorAppearance 使用了完全自定义的片段着色器,因此未被使用。
-
Default Value:
undefined
渲染几何体时使用的WebGL固定功能状态。
渲染状态可以在构造 PerInstanceColorAppearance 实例时显式定义,也可以通过 PerInstanceColorAppearance#translucent 和 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。
