new Cesium.PerInstanceColorAppearance(options)

An appearance for GeometryInstance instances with color attributes. 这样可以让数个几何图形实例,每个实例都有不同的颜色 be drawn with the same Primitive as shown in the second example below.
Name Type Description
options object optional 下列属性的对象 :
Name Type Default Description
flat boolean false optional When true, flat shading is used in the fragment shader, which means lighting is not taking into account.
faceForward boolean !options.closed optional When true, the fragment shader flips the surface normal as needed to ensure that the normal faces the viewer to avoid dark spots. This is useful when both sides of a geometry should be shaded like WallGeometry.
translucent boolean true optional When true, the geometry is expected to appear translucent so PerInstanceColorAppearance#renderState has alpha blending enabled.
closed boolean false optional When true, the geometry is expected to be closed so PerInstanceColorAppearance#renderState has backface culling enabled.
vertexShaderSource string optional 可选 NT 0 顶点阴影源,以覆盖默认顶点阴影源.
fragmentShaderSource string optional 可选的 NT 0 碎片遮蔽源以覆盖默认的碎片遮蔽源 .
renderState 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

The VertexFormat that all PerInstanceColorAppearance instances are compatible with when PerInstanceColorAppearance#flat is true. 这只需要 NT 0 位置 NT 1 属性.

static constant Cesium.PerInstanceColorAppearance.VERTEX_FORMAT : VertexFormat

The VertexFormat that all PerInstanceColorAppearance instances 兼容。 这只需要 NT 0 位置 NT 1 和 NT 2 正常 NT 3 attributes.

readonly closed : boolean

当 NT 0 真 NT 1 时,几何会关闭如此 PerInstanceColorAppearance#renderState has backface culling enabled. 若观者入于几何不显.
Default Value: false

readonly faceForward : boolean

当 NT 0 true NT 1 时,碎片遮蔽器翻转表面正常 以确保正常人面对观众以避免 暗处 当一个几何学的两侧都应该是 shaded like WallGeometry.
Default Value: true

readonly flat : boolean

当 NT 0 真 NT 1 时,在碎片遮蔽器中使用平面阴影, 这意味着照明没有被考虑进去.
Default Value: false

readonly fragmentShaderSource : string

The GLSL source code for the fragment shader.

material : Material

This property is part of the Appearance interface, but is not 由于使用了完全自定义的片段遮蔽器,故由 PerInstanceColorAppearance 使用.
Default Value: undefined

readonly renderState : object

The WebGL fixed-function state to use when rendering the geometry.

The render state can be explicitly defined when constructing a PerInstanceColorAppearance instance, or it is set implicitly via PerInstanceColorAppearance#translucentPerInstanceColorAppearance#closed .

translucent : boolean

当 NT 0 real NT 1 时,几何会显得半透明,所以 PerInstanceColorAppearance#renderState 已启用α混合.
Default Value: true

readonly vertexFormat : VertexFormat

The VertexFormat that this appearance instance is compatible with. 几何可以有更多的顶点属性,并且仍然是兼容的 - 在 潜在性能成本 但它不能少.

readonly vertexShaderSource : string

顶点遮蔽器的 GLSL 源代码.

Methods

getFragmentShaderSource()string

Returns:
The full GLSL fragment shader source.

getRenderState()object

创建渲染状态。 这不是最终的州法院;相反, 它可以包含一个子集,与渲染状态相同的渲染状态属性 在上下文中创建.
Returns:
铸造状态.

isTranslucent()boolean

确定以 PerInstanceColorAppearance#translucent 为基础的几何是否半透明.
Returns:
如果外观为半透明,则使用# .
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.