PerInstanceColorAppearance

new Cesium.PerInstanceColorAppearance(options)

具有颜色属性的GeometryInstance个实例的外观。 这允许多个几何体实例(每个实例具有不同的颜色)来 如下面第二个例子所示,用相同的Primitive绘制。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Default Description
flat Boolean false optional 在6666中,不考虑阴影,这意味着不考虑碎片。
faceForward Boolean !options.closed optionaltrue时,碎片着色器根据需要翻转曲面法线,以确保法线面向查看器以避免出现黑点。当几何体的两侧都应着色时,这很有用,如WallGeometry
translucent Boolean true optionaltrue时,几何体看起来是半透明的,因此PerInstanceColorAppearance#renderState启用了alpha混合。
closed Boolean false optionaltrue时,几何体应关闭,因此PerInstanceColorAppearance#renderState启用背面消隐。
vertexShaderSource String optional 可选的GLSL顶点着色器源来覆盖默认顶点着色器。
fragmentShaderSource String optional 可选的GLSL fragment shader source来覆盖默认片段着色器。
renderState 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#flattrue时兼容。 这只需要position属性。

static constant Cesium.PerInstanceColorAppearance.VERTEX_FORMAT : VertexFormat

VertexFormat所有PerInstanceColorAppearance实例 与兼容。这只需要positionnormal 属性。

readonly closed : Boolean

true时,几何体应该这样闭合 PerInstanceColorAppearance#renderState已启用背面消隐。 如果查看器进入几何体,它将不可见。
Default Value: false

readonly faceForward : Boolean

true时,碎片着色器翻转曲面法线 如有必要,确保观察者避开法线 暗点。当几何体的两侧都应该 阴影像WallGeometry
Default Value: true

readonly flat : Boolean

true时,在片段着色器中使用平面着色, 这意味着照明不考虑在内。
Default Value: false

readonly fragmentShaderSource : String

片段着色器的GLSL源代码。
此属性是Appearance接口的一部分,但不是 6866完全使用了自定义着色器6166。
Default Value: undefined

readonly renderState : Object

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
此外观实例与VertexFormat兼容。 一个几何体可以有更多的顶点属性并且仍然是兼容的 潜在的性能成本-但它不能少。

readonly vertexShaderSource : String

顶点着色器的GLSL源代码。

Methods

getFragmentShaderSource()String

Returns:
完整的GLSL片段着色器源。

getRenderState()Object

创建渲染状态。这不是最终渲染状态实例;而是, 它可以包含与渲染状态相同的渲染状态属性子集 在上下文中创建。
Returns:
渲染状态。

isTranslucent()Boolean

基于PerInstanceColorAppearance#translucent确定几何体是否半透明。
Returns:
如果外观是半透明的,则为true