MaterialAppearance

new Cesium.MaterialAppearance(options)

用于任意几何体的外观(与例如 EllipsoidSurfaceAppearance 相对), 支持使用材质进行着色。
Name Type Description
options object optional 包含以下属性的对象:
Name Type Default Description
flat boolean false optional 当为 true 时,片段着色器中使用平面着色,这意味着不考虑光照。
faceForward boolean !options.closed optional 当为 true 时,片段着色器会按需翻转表面法线,以确保法线朝向观察者,从而避免暗斑。当几何体的两侧都应像 WallGeometry 那样被着色时,这很有用。
translucent boolean true optional 当为 true 时,几何体预计会呈现半透明效果,因此 MaterialAppearance#renderState 启用了 alpha 混合。
closed boolean false optional 当为 true 时,几何体预计是闭合的,因此 MaterialAppearance#renderState 启用了背面剔除。
materialSupport MaterialAppearance.MaterialSupportType MaterialAppearance.MaterialSupport.TEXTURED optional 将支持的材质类型。
material Material Material.ColorType optional 用于确定片段颜色的材质。
vertexShaderSource string optional 用于覆盖默认顶点着色器的可选 GLSL 顶点着色器源代码。
fragmentShaderSource string optional 用于覆盖默认片段着色器的可选 GLSL 片段着色器源代码。
renderState object optional 用于覆盖默认渲染状态的可选渲染状态。
Example:
const primitive = new Cesium.Primitive({
  geometryInstances : new Cesium.GeometryInstance({
    geometry : new Cesium.WallGeometry({
            materialSupport :  Cesium.MaterialAppearance.MaterialSupport.BASIC.vertexFormat,
      // ...
    })
  }),
  appearance : new Cesium.MaterialAppearance({
    material : Cesium.Material.fromType('Color'),
    faceForward : true
  })

});
Demo:
See:

Namespaces

MaterialSupport

Members

当为 true 时,几何体预计是闭合的,因此 MaterialAppearance#renderState 启用了背面剔除。 如果观察者进入几何体内部,它将不可见。
Default Value: false

readonly faceForward : boolean

当为 true 时,片段着色器会按需翻转表面法线, 以确保法线朝向观察者,从而避免 暗斑。当几何体的两侧都应 像 WallGeometry 那样被着色时,这很有用。
Default Value: true
当为 true 时,片段着色器中使用平面着色, 这意味着不考虑光照。
Default Value: false

readonly fragmentShaderSource : string

片段着色器的 GLSL 源代码。完整的片段着色器 源代码是根据 MaterialAppearance#materialMaterialAppearance#flatMaterialAppearance#faceForward 以编程方式构建的。使用 MaterialAppearance#getFragmentShaderSource 获取完整源代码。
用于确定片段颜色的材质。与 MaterialAppearance 的 其他属性不同,这不是只读的,因此外观的材质可以动态改变。
Default Value: Material.ColorType
See:
此实例支持的材质类型。这会影响所需的 VertexFormat 以及顶点和片段着色器的复杂度。
Default Value: MaterialAppearance.MaterialSupport.TEXTURED

readonly renderState : object

渲染几何体时要使用的 WebGL 固定功能状态。

渲染状态可以在构造 MaterialAppearance 实例时显式定义,也可以通过 MaterialAppearance#translucentMaterialAppearance#closed 隐式设置。

当为 true 时,几何体预计会呈现半透明效果。
Default Value: true
此外观实例所兼容的 VertexFormat。 几何体可以拥有更多的顶点属性而仍然兼容——代价是 潜在的性能损失——但不能更少。
Default Value: MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat

readonly vertexShaderSource : string

顶点着色器的 GLSL 源代码。

Methods

getFragmentShaderSource()string

以编程方式创建完整的 GLSL 片段着色器源代码。对于 MaterialAppearance, 这派生自 MaterialAppearance#fragmentShaderSourceMaterialAppearance#materialMaterialAppearance#flatMaterialAppearance#faceForward
Returns:
完整的 GLSL 片段着色器源代码。

getRenderState()object

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

isTranslucent()boolean

根据 MaterialAppearance#translucentMaterial#isTranslucent 确定几何体是否半透明。
Returns:
true 如果外观是半透明的。

Type Definitions

Cesium.MaterialAppearance.MaterialSupportType

Properties:
Name Type Description
vertexFormat VertexFormat
vertexShaderSource string
fragmentShaderSource string
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。