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#translucent 隐式设置 和 MaterialAppearance#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:
The full GLSL fragment shader source.

getRenderState()object

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

isTranslucent()boolean

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

Type Definitions

Cesium.MaterialAppearance.MaterialSupportType

Properties:
Name Type Description
vertexFormat VertexFormat
vertexShaderSource string
fragmentShaderSource string
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.