Options
Menu

Class MaterialBase

MaterialBase forms an abstract base class for any material. A material consists of several passes, each of which constitutes at least one render call. Several passes could be used for special effects (render lighting for many lights in several passes, render an outline in a separate pass) or to provide additional render-to-texture passes (rendering diffuse light to texture for texture-space subsurface scattering, or rendering a depth map for specialized self-shadowing).

Away3D provides default materials trough SinglePassMaterialBase and TriangleMaterial, which use modular methods to build the shader code. MaterialBase can be extended to build specific and high-performant custom shaders, or entire new material frameworks.

Hierarchy

  • AssetBase

Implements

Index

Constructors

constructor

  • Creates a new MaterialBase object.

    Parameters

    • Optional image: ImageBase
    • Optional alpha: number

    Returns MaterialBase

  • Creates a new MaterialBase object.

    Parameters

    • Optional color: number
    • Optional alpha: number

    Returns MaterialBase

Properties

_adapter

_adapter: IAssetAdapter

_iBaseScreenPassIndex

_iBaseScreenPassIndex: number

Private _iClassification

_iClassification: string

A value that can be used by materials that only work with a given type of renderer. The renderer can test the classification to choose which render path to use. For example, a deferred material could set this value so that the deferred renderer knows not to take the forward rendering path.

_pAlphaThreshold

_pAlphaThreshold: number

_pAnimateUVs

_pAnimateUVs: boolean

_pBlendMode

_pBlendMode: string

adaptee

adaptee: AssetBase

adapter

adapter: IAssetAdapter

adapter is used to provide MovieClip to scripts taken from different platforms setter typically managed by factory. getter defaults to AwayJS class

assetFullPath

assetFullPath: Array<string>

assetNamespace

assetNamespace: string

assetType

assetType: string

extra

extra: Object

An object to contain any extra data.

id

id: number

A unique id for the asset, used to identify assets in an associative array

name

name: string

originalName

originalName: string

The original name used for this asset in the resource (e.g. file) in which it was found. This may not be the same as name, which may have changed due to of a name conflict.

Static DEFAULT_NAMESPACE

DEFAULT_NAMESPACE: string

Static ID_COUNT

ID_COUNT: number

Accessors

alpha

  • get (): number
  • set (value: number): void
  • The alpha of the surface.

    Returns number

  • The alpha of the surface.

    Parameters

    • value: number

    Returns void

alphaBlending

  • get (): boolean
  • set (value: boolean): void
  • Indicates whether or not the material has transparency. If binary transparency is sufficient, for example when using textures of foliage, consider using alphaThreshold instead.

    Returns boolean

  • Indicates whether or not the material has transparency. If binary transparency is sufficient, for example when using textures of foliage, consider using alphaThreshold instead.

    Parameters

    • value: boolean

    Returns void

alphaPremultiplied

  • get (): boolean
  • set (value: boolean): void
  • Indicates whether visible textures (or other pixels) used by this material have already been premultiplied. Toggle this if you are seeing black halos around your blended alpha edges.

    Returns boolean

  • Indicates whether visible textures (or other pixels) used by this material have already been premultiplied. Toggle this if you are seeing black halos around your blended alpha edges.

    Parameters

    • value: boolean

    Returns void

alphaThreshold

  • get (): number
  • set (value: number): void
  • The minimum alpha value for which pixels should be drawn. This is used for transparency that is either invisible or entirely opaque, often used with textures for foliage, etc. Recommended values are 0 to disable alpha, or 0.5 to create smooth edges. Default value is 0 (disabled).

    Returns number

  • The minimum alpha value for which pixels should be drawn. This is used for transparency that is either invisible or entirely opaque, often used with textures for foliage, etc. Recommended values are 0 to disable alpha, or 0.5 to create smooth edges. Default value is 0 (disabled).

    Parameters

    • value: number

    Returns void

animateUVs

  • get (): boolean
  • set (value: boolean): void
  • Specifies whether or not the UV coordinates should be animated using a transformation matrix.

    Returns boolean

  • Specifies whether or not the UV coordinates should be animated using a transformation matrix.

    Parameters

    • value: boolean

    Returns void

animationSet

blendMode

  • get (): string
  • set (value: string): void
  • The blend mode to use when drawing this renderable. The following blend modes are supported:

    • BlendMode.NORMAL: No blending, unless the material inherently needs it
    • BlendMode.LAYER: Force blending. This will draw the object the same as NORMAL, but without writing depth writes.
    • BlendMode.MULTIPLY
    • BlendMode.ADD
    • BlendMode.ALPHA

    Returns string

  • The blend mode to use when drawing this renderable. The following blend modes are supported:

    • BlendMode.NORMAL: No blending, unless the material inherently needs it
    • BlendMode.LAYER: Force blending. This will draw the object the same as NORMAL, but without writing depth writes.
    • BlendMode.MULTIPLY
    • BlendMode.ADD
    • BlendMode.ALPHA

    Parameters

    • value: string

    Returns void

bothSides

  • get (): boolean
  • set (value: boolean): void
  • Defines whether or not the material should cull triangles facing away from the camera.

    Returns boolean

  • Defines whether or not the material should cull triangles facing away from the camera.

    Parameters

    • value: boolean

    Returns void

colorTransform

  • get (): ColorTransform
  • set (value: ColorTransform): void
  • The ColorTransform object to transform the colour of the material with. Defaults to null.

    Returns ColorTransform

  • The ColorTransform object to transform the colour of the material with. Defaults to null.

    Parameters

    • value: ColorTransform

    Returns void

curves

  • get (): boolean
  • set (value: boolean): void
  • Indicates whether material should use curves. Defaults to false.

    Returns boolean

  • Indicates whether material should use curves. Defaults to false.

    Parameters

    • value: boolean

    Returns void

Private iOwners

  • A list of the IEntities that use this material

    Returns Array<IEntity>

imageRect

  • get (): boolean
  • set (value: boolean): void
  • Indicates whether or not any used textures should use an atlas. Defaults to false.

    Returns boolean

  • Indicates whether or not any used textures should use an atlas. Defaults to false.

    Parameters

    • value: boolean

    Returns void

style

  • The style used to render the current TriangleGraphic. If set to null, its parent Sprite's style will be used instead.

    Returns Style

  • The style used to render the current TriangleGraphic. If set to null, its parent Sprite's style will be used instead.

    Parameters

    Returns void

useColorTransform

  • get (): boolean
  • set (value: boolean): void
  • Specifies whether or not the UV coordinates should be animated using a transformation matrix.

    Returns boolean

  • Specifies whether or not the UV coordinates should be animated using a transformation matrix.

    Parameters

    • value: boolean

    Returns void

Methods

addEventListener

  • addEventListener(type: string, listener: function): void
  • Add an event listener

    method

    addEventListener

    Parameters

    • type: string
    • listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns void

addTexture

addTextureAt

  • addTextureAt(texture: TextureBase, index: number): void
  • Parameters

    Returns void

assetPathEquals

  • assetPathEquals(name: string, ns: string): boolean
  • Parameters

    • name: string
    • ns: string

    Returns boolean

clear

  • clear(): void
  • Returns void

dispatchEvent

  • dispatchEvent(event: EventBase): void
  • Dispatch an event

    method

    dispatchEvent

    Parameters

    • event: EventBase

    Returns void

dispose

  • dispose(): void
  • Returns void

getNumTextures

  • getNumTextures(): number

getTextureAt

hasEventListener

  • hasEventListener(type: string, listener?: function): boolean
  • check if an object has an event listener assigned to it

    method

    hasListener

    Parameters

    • type: string
    • Optional listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns boolean

iAddOwner

  • Mark an IEntity as owner of this material. Assures we're not using the same material across renderables with different animations, since the Programs depend on animation. This method needs to be called when a material is assigned.

    internal

    Parameters

    • owner: IEntity

      The IEntity that had this material assigned

    Returns void

iRemoveOwner

  • iRemoveOwner(owner: IEntity): void
  • Removes an IEntity as owner.

    internal

    Parameters

    Returns void

invalidate

  • invalidate(): void
  • Returns void

invalidateMaterials

  • invalidateMaterials(): void
  • Returns void

Private invalidatePasses

  • invalidatePasses(): void
  • Marks the shader programs for all passes as invalid, so they will be recompiled before the next use.

    Returns void

invalidateTexture

  • invalidateTexture(): void
  • Returns void

isAsset

  • isAsset(assetClass: IAssetClass): boolean
  • Parameters

    • assetClass: IAssetClass

    Returns boolean

removeEventListener

  • removeEventListener(type: string, listener: function): void
  • Remove an event listener

    method

    removeEventListener

    Parameters

    • type: string
    • listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns void

removeTexture

resetAssetPath

  • resetAssetPath(name: string, ns?: string, overrideOriginal?: boolean): void
  • Parameters

    • name: string
    • Optional ns: string
    • Optional overrideOriginal: boolean

    Returns void

updateFullPath

  • updateFullPath(): void
  • Returns void

Generated using TypeDoc