具有颜色属性的
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
隐式设置
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:
The full GLSL fragment shader source.
创建渲染状态。 这不是最终的渲染状态实例;相反
它可以包含与渲染状态相同的渲染状态属性的子集
在上下文中创建。
Returns:
render 状态。
根据
PerInstanceColorAppearance#translucent
确定几何体是否为半透明。
Returns:
true
,如果外观是半透明的。