Material

external class Material(options: Material.ConstructorOptions? = definedExternally)(source)

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.

Base material types and their uniforms:

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

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

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

See also

Constructors

Link copied to clipboard
constructor(options: Material.ConstructorOptions? = definedExternally)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
sealed interface ConstructorOptions

Properties

Link copied to clipboard

Maps sub-material names to Material objects.

Link copied to clipboard

The glsl shader source for this material.

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

Maps uniform names to their values.

Functions

Link copied to clipboard
fun destroy()

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.

Link copied to clipboard

Returns true if this object was destroyed; otherwise, false.

Link copied to clipboard

Gets whether or not this material is translucent.