English中文

MaterialAppearance

new Cesium.MaterialAppearance(options)

任意几何体的外观(与 An appearance for arbitrary geometry (as opposed to EllipsoidSurfaceAppearance,例如)支持材质着色。 , for example) that supports shading with materials.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 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 MaterialAppearance#renderState 启用了 alpha 混合。 has alpha blending enabled.
closed boolean false 可选 optional When true,几何形状预计将是封闭的,因此 , the geometry is expected to be closed so MaterialAppearance#renderState 已启用背面剔除。 has backface culling enabled.
materialSupport MaterialAppearance.MaterialSupportType MaterialAppearance.MaterialSupport.TEXTURED 可选 optional 将支持的材料类型。 The type of materials that will be supported.
material Material Material.ColorType 可选 optional 用于确定片段颜色的材质。 The material used to determine the fragment color.
vertexShaderSource string 可选 optional 可选的 GLSL 顶点着色器源来覆盖默认顶点着色器。 Optional GLSL vertex shader source to override the default vertex shader.
fragmentShaderSource string 可选 optional 可选的 GLSL 片段着色器源来覆盖默认片段着色器。 Optional GLSL fragment shader source to override the default fragment shader.
renderState object 可选 optional 可选渲染状态覆盖默认渲染状态。 Optional render state to override the default render state.
示例: 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

When true,几何形状预计将是封闭的,因此 , the geometry is expected to be closed so MaterialAppearance#renderState 已启用背面剔除。如果观察者进入几何图形,它将不可见。 has backface culling enabled. If the viewer enters the geometry, it will not be visible.
默认值: Default Value: false

readonly faceForward : boolean

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.
默认值: Default Value: true
When true,片段着色器中使用平面着色,这意味着不考虑光照。 , flat shading is used in the fragment shader, which means lighting is not taking into account.
默认值: Default Value: false

readonly fragmentShaderSource : string

片段着色器的 GLSL 源代码。完整的片段着色器源是在程序上构建的,考虑到 The GLSL source code for the fragment shader. The full fragment shader source is built procedurally taking into account MaterialAppearance#material, MaterialAppearance#flat, 和 , and MaterialAppearance#faceForward。使用 . Use MaterialAppearance#getFragmentShaderSource 获得完整的源码。 to get the full source.
用于确定片段颜色的材质。与其他不同 The material used to determine the fragment color. Unlike other MaterialAppearance 属性,这不是只读的,因此外观的材质可以动态更改。 properties, this is not read-only, so an appearance's material can change on the fly.
默认值: Default Value: Material.ColorType
另见: See:
该实例支持的材料类型。这会影响所需的 The type of materials supported by this instance. This impacts the required VertexFormat 以及顶点和片段着色器的复杂性。 and the complexity of the vertex and fragment shaders.
默认值: Default Value: MaterialAppearance.MaterialSupport.TEXTURED

readonly renderState : object

渲染几何体时使用的 WebGL 固定功能状态。 The WebGL fixed-function state to use when rendering the geometry.

构建时可以显式定义渲染状态 The render state can be explicitly defined when constructing a MaterialAppearance 实例,或者通过隐式设置 instance, or it is set implicitly via MaterialAppearance#translucent and MaterialAppearance#closed.

When true,几何体预计会呈现半透明。 , the geometry is expected to appear translucent.
默认值: Default Value: true
The VertexFormat 该外观实例与之兼容。几何体可以具有更多的顶点属性并且仍然兼容(但会带来潜在的性能成本),但不能有更少的属性。 that this appearance instance is compatible with. A geometry can have more vertex attributes and still be compatible - at a potential performance cost - but it can't have less.
默认值: Default Value: MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat

readonly vertexShaderSource : string

顶点着色器的 GLSL 源代码。 The GLSL source code for the vertex shader.

方法 Methods

getFragmentShaderSource()string

按程序创建完整的 GLSL 片段着色器源。对于 Procedurally creates the full GLSL fragment shader source. For MaterialAppearance,这是从 , this is derived from MaterialAppearance#fragmentShaderSource, MaterialAppearance#material, MaterialAppearance#flat, 和 , and MaterialAppearance#faceForward.
返回: Returns:
完整的 GLSL 片段着色器源代码。 The full GLSL fragment shader source.

getRenderState()object

创建渲染状态。这不是最终的渲染状态实例;相反,它可以包含与上下文中创建的渲染状态相同的渲染状态属性的子集。 Creates a render state. This is not the final render state instance; instead, it can contain a subset of render state properties identical to the render state created in the context.
返回: Returns:
渲染状态。 The render state.

isTranslucent()boolean

确定几何体是否是半透明的 Determines if the geometry is translucent based on MaterialAppearance#translucent and Material#isTranslucent.
返回: Returns:
true 如果外观是半透明的。 if the appearance is translucent.

类型定义 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.