为具有颜色属性的
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 实例兼容的 VertexFormat,
当 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 源代码。
该属性是
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 如果外观是半透明的。
