Skip to content

KBE3D / KBCore / Cesium / Material

类: Material

A Material defines surface appearance through a combination of diffuse, specular, normal, emission, and alpha components. These values are specified using a JSON schema called Fabric which gets parsed and assembled into glsl shader code behind-the-scenes. Check out the wiki page

for more details on Fabric. <br /><br />

示例

ts
// Create a color material with fromType:
polygon.material = Cesium.Material.fromType('Color');
polygon.material.uniforms.color = new Cesium.Color(1.0, 1.0, 0.0, 1.0);

// Create the default material:
polygon.material = new Cesium.Material();

// Create a color material with full Fabric notation:
polygon.material = new Cesium.Material({
  fabric: {
    type: 'Color',
    uniforms: {
      color: new Cesium.Color(1.0, 1.0, 0.0, 1.0)
    }
  }
});

参数

Object with the following properties:

参数

Throws errors for issues that would normally be ignored, including unused uniforms or materials.

参数

When <code>true</code> or a function that returns <code>true</code>, the geometry with this material is expected to appear translucent.

参数

The TextureMinificationFilter to apply to this material's textures.

参数

The TextureMagnificationFilter to apply to this material's textures.

参数

The fabric JSON used to generate the material.

继承于

属性

DefaultImageId

static DefaultImageId: string

Gets or sets the default texture uniform value.


DefaultCubeMapId

static DefaultCubeMapId: string

Gets or sets the default cube map texture uniform value.


ColorType

readonly static ColorType: string

Gets the name of the color material.


ImageType

readonly static ImageType: string

Gets the name of the image material.


DiffuseMapType

readonly static DiffuseMapType: string

Gets the name of the diffuce map material.


AlphaMapType

readonly static AlphaMapType: string

Gets the name of the alpha map material.


SpecularMapType

readonly static SpecularMapType: string

Gets the name of the specular map material.


EmissionMapType

readonly static EmissionMapType: string

Gets the name of the emmision map material.


BumpMapType

readonly static BumpMapType: string

Gets the name of the bump map material.


NormalMapType

readonly static NormalMapType: string

Gets the name of the normal map material.


GridType

readonly static GridType: string

Gets the name of the grid material.


StripeType

readonly static StripeType: string

Gets the name of the stripe material.


CheckerboardType

readonly static CheckerboardType: string

Gets the name of the checkerboard material.


DotType

readonly static DotType: string

Gets the name of the dot material.


WaterType

readonly static WaterType: string

Gets the name of the water material.


RimLightingType

readonly static RimLightingType: string

Gets the name of the rim lighting material.


FadeType

readonly static FadeType: string

Gets the name of the fade material.


PolylineArrowType

readonly static PolylineArrowType: string

Gets the name of the polyline arrow material.


PolylineDashType

readonly static PolylineDashType: string

Gets the name of the polyline glow material.


PolylineGlowType

readonly static PolylineGlowType: string

Gets the name of the polyline glow material.


PolylineOutlineType

readonly static PolylineOutlineType: string

Gets the name of the polyline outline material.


ElevationContourType

readonly static ElevationContourType: string

Gets the name of the elevation contour material.


ElevationRampType

readonly static ElevationRampType: string

Gets the name of the elevation contour material.


SlopeRampMaterialType

readonly static SlopeRampMaterialType: string

Gets the name of the slope ramp material.


AspectRampMaterialType

readonly static AspectRampMaterialType: string

Gets the name of the aspect ramp material.


ElevationBandType

readonly static ElevationBandType: string

Gets the name of the elevation band material.


WaterMaskType

readonly static WaterMaskType: string

Gets the name of the water mask material.


type

type: string

The material type. Can be an existing type or a new type. If no type is specified in fabric, type is a GUID.


shaderSource

shaderSource: string

The glsl shader source for this material.


materials

materials: any

Maps sub-material names to Material objects.


uniforms

uniforms: any

Maps uniform names to their values.


translucent

translucent: boolean | (...params: any[]) => any

When <code>true</code> or a function that returns <code>true</code>, the geometry is expected to appear translucent.

方法

fromType()

static fromType(type: string, uniforms?: any): Material

Creates a new material using an existing material type. <br /><br /> Shorthand for: new Material({fabric : {type : type}});

参数

type

string

The base material type.

uniforms?

any

Overrides for the default uniforms.

返回

Material

New material object.

示例

ts
const material = Cesium.Material.fromType('Color', {
  color: new Cesium.Color(1.0, 0.0, 0.0, 1.0)
});

fromTypeAsync()

static fromTypeAsync(type: string, uniforms?: any): Promise<Material>

Creates a new material using an existing material type and returns a promise that resolves when all of the material's resources have been loaded.

参数

type

string

The base material type.

uniforms?

any

Overrides for the default uniforms.

返回

Promise<Material>

A promise that resolves to a new material object when all resources are loaded.

示例

ts
const material = await Cesium.Material.fromTypeAsync('Image', {
   image: '../Images/Cesium_Logo_overlay.png'
});

isTranslucent()

isTranslucent(): boolean

Gets whether or not this material is translucent.

返回

boolean

true if this material is translucent, false otherwise.


isDestroyed()

isDestroyed(): boolean

Returns true if this object was destroyed; otherwise, false. <br /><br /> If this object was destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception.

返回

boolean

True if this object was destroyed; otherwise, false.


destroy()

destroy(): void

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object. <br /><br /> Once an object is destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception. Therefore, assign the return value (<code>undefined</code>) to the object as done in the example.

返回

void

示例

ts
material = material && material.destroy();

构造函数

构造函数

new Material(options?: { fabric: any; strict?: boolean; translucent?: boolean | (...params: any[]) => any; minificationFilter?: TextureMinificationFilter; magnificationFilter?: TextureMagnificationFilter; }): Material

参数

options?
fabric

any

strict?

boolean

translucent?

boolean | (...params: any[]) => any

minificationFilter?

TextureMinificationFilter

magnificationFilter?

TextureMagnificationFilter

返回

Material

KBE3D @3.0.0 Copyright © 2024-present KBE3D