Class: MaterialAppearance

MaterialAppearance

new MaterialAppearance()

The appearance of any geometric object (as opposed to EllipsoidSurfaceAppearance), supports material coloring.

Name Type Default Description
options.flat Boolean false optional

When true, flat shading is used in the fragment shader, which means lighting is not considered.

options.faceForward Boolean !options.closed optional

When true, the fragment shader will flip the surface normals as needed to ensure that the normals face the observer and avoid dark areas. This is very useful when coloring both sides of geometry, such as WallGeometry.

options.translucent Boolean true optional

When true, the geometry will appear semi transparent, so MaterialAppearance # renderState will enable alpha blending.

options.closed Boolean false optional

When true, the geometry will be enclosed, so MaterialAppearance # renderState has enabled back surface exclusion.

options.materialSupport MaterialAppearance.MaterialSupport MaterialAppearance.MaterialSupport.TEXTURED optional

Supported material types.

options.material Material Material.ColorType optional

The material used to determine the color of the fragments.

options.vertexShaderSource String optional

Optional GLSL vertex shading source, overriding default vertex shading.

options.fragmentShaderSource String optional

Optional GLSL fragment shader source, overriding default fragment shading.

options.renderState RenderState optional

Optional presentation state, overriding the default presentation state.

Example
var primitive = new SuperMap3D.Primitive({
  geometryInstances : new SuperMap3D.GeometryInstance({
    geometry : new SuperMap3D.WallGeometry({
        materialSupport :  SuperMap3D.MaterialAppearance.MaterialSupport.BASIC.vertexFormat,
      // ...
    })
  }),
  appearance : new SuperMap3D.MaterialAppearance({
    material : SuperMap3D.Material.fromType('Color'),
    faceForward : true
  })

});

Members

static MaterialSupport

Determine the Material types supported by the MaterialAppearance instance. This is a trade-off between flexibility (multiple materials) and memory/performance (required vertex formats and GLSL shader complexity).

readonly closedBoolean

When true, the geometry will be in a closed state, so MaterialAppearance # renderState has enabled the back surface removal feature. If the viewer enters geometry, it will not be visible.

Default Value:
false

readonly faceForwardBoolean

When true, the fragment shader will flip the surface normals as needed to ensure that the normals face the observer and avoid dark spots. This is very useful when coloring both sides of geometry, such as WallGeometry.

Default Value:
true

readonly flatBoolean

When true, flat shading is used in the fragment shader, which means lighting is not considered.

Default Value:
false

readonly fragmentShaderSourceString

GLSL source code for fragment shader. The complete fragment shader source code was created programmatically, taking into account MaterialAppearance # material, MaterialAppearance # flat, and MaterialAppearance # faceForward. Use MaterialAppearance # getFragmentShaderSource to obtain the complete source code.

materialMaterial

The material used to determine the color of the fragment. Unlike other MaterialAppearance properties, it is not a read-only property, so the appearance material can be changed at any time.

Default Value:
Material.ColorType

readonly materialSupportMaterialAppearance.MaterialSupport

The material types supported by this instance. This will affect the required VertexFormat and the complexity of vertex and fragment shaders.

Default Value:
MaterialAppearance.MaterialSupport.TEXTURED

readonly renderStateObject

The WebGL fixed function state used when rendering geometry.

The presentation state can be explicitly defined when building a MaterialAppearance instance, or implicitly set through MaterialAppearance # translated and MaterialAppearance # closed.

translucentBoolean

When set to true, the geometry will exhibit a semi transparent effect.

Default Value:
true

readonly vertexFormatVertexFormat

The VertexFormat vertex properties compatible with this appearance instance. A geometric object can have more vertex attributes and still be compatible, but it may come at a performance cost, but not less.

Default Value:
MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat

readonly vertexShaderSourceString

GLSL source code for vertex shader.

Methods

getFragmentShaderSource(){String}

Programmatically create a complete GLSL fragment shader source. For MaterialAppearance, this stems from MaterialAppearance#fragmentShaderSource、MaterialAppearance#material、MaterialAppearance#flat And MaterialAppearance # faceForward.

Returns:
Type Description
String Complete GLSL fragment shader source.

getRenderState(){Object}

Create a presentation state. This is not the final presentation state instance; On the contrary, it can contain a subset of presentation state attributes that are the same as those created in the context.

Returns:
Type Description
Object Rendering status.

isTranslucent(){Boolean}

Determine whether the geometry is semi transparent based on MaterialAppearance # translucent and Material # isTranslucent.

Returns:
Type Description
Boolean If the appearance is semi transparent, it is true.