Material

open 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
external object Companion
Link copied to clipboard
external interface ConstructorOptions

Properties

Link copied to clipboard

The TextureMagnificationFilter to apply to this material's textures.

Link copied to clipboard
external var materials: JsAny

Maps sub-material names to Material objects.

Link copied to clipboard

The TextureMinificationFilter to apply to this material's textures.

Link copied to clipboard
external var shaderSource: String

The glsl shader source for this material.

Link copied to clipboard
external var translucent: Boolean

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

Link copied to clipboard
external var 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.

Link copied to clipboard
external var uniforms: JsAny

Maps uniform names to their values.

Functions

Link copied to clipboard
external 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
external fun isDestroyed(): Boolean

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

Link copied to clipboard
external fun isTranslucent(): Boolean

Gets whether or not this material is translucent.