Class Material

Constructors

Properties

additiveBlend: boolean = false
alphaCutoff: number

Transparency threshold, pixels with alpha below this value will be discarded

Default

0.0
ambient: RGB

Ambient colour will be multiplied with the ambient light level & colour

diffuse: RGB

Diffuse colour will be multiplied with the diffuse texture

Default

[1, 1, 1]
diffuseTex?: WebGLTexture

Diffuse texture map

Default

"1 pixel white texture"
emissive: RGB

Emissive colour will be added to the final colour, use for glowing materials

normalTex?: WebGLTexture

Normal texture map

Default

"1 pixel white texture"
opacity: number

Opacity, 0.0 to 1.0

Default

1.0
reflectivity: number

Reflectivity, 0.0 to 1.0

Default

0.0
shininess: number

Shininess, for size of specular highlights

Default

20
specular: RGB

Specular colour will be multiplied with the specular texture

Default

[0, 0, 0]
specularTex?: WebGLTexture

Specular texture map

Default

"1 pixel white texture"

Accessors

Methods

  • Add a normal texture map to existing material, probably created with createBasicTexture

    Parameters

    • url: string
    • filter: boolean = true
    • flipY: boolean = false

    Returns void

  • Add a specular texture map to existing material, probably created with createBasicTexture

    Parameters

    • url: string
    • filter: boolean = true
    • flipY: boolean = false

    Returns void

  • Adds this material to a program, as a set of uniforms

    Parameters

    • programInfo: ProgramInfo

      ProgramInfo object to update with uniforms

    • uniformSuffix: string = ''

      Optional suffix to add to uniform names

    Returns void

  • Create a new Material with a texture map loaded from a URL/filepath or Buffer

    Parameters

    • src: string | ArrayBufferView

      URL or filename path of texture image, or ArrayBufferView holding texture

    • filter: boolean = true

      Enable texture filtering and mipmaps (default true)

    • flipY: boolean = false

      Flip the texture vertically (default false)

    • extraOptions: TextureOptions = {}

      Extra options to pass to twgl.createTexture, see https://twgljs.org/docs/module-twgl.html#.TextureOptions

    Returns Material

  • Create a basic Material with a solid/flat diffuse colour

    Parameters

    • r: number

      Red component, 0.0 to 1.0

    • g: number

      Green component, 0.0 to 1.0

    • b: number

      Blue component, 0.0 to 1.0

    Returns Material

  • Create a new material from a raw MTL material. Users are not expected to call this directly as it is used internally by the OBJ parser

    Parameters

    • rawMtl: MtlMaterial

      Raw MTL material

    • basePath: string

      Base path for locating & loading textures in MTL file

    • filter: boolean = true

      Apply texture filtering to textures, default: true

    • flipY: boolean = false

      Flip the Y axis of textures, default: false

    Returns Material

Generated using TypeDoc