MeshPhongMaterial

This material can apply illumination on model surface, which makes model looks shiny and specular. Performance will generally be greater when using this material over the PBRMaterial| PBRMaterial, at the cost of some graphical accuracy.

Core Class

This material can apply illumination on model surface, which makes model looks shiny and specular. Performance will generally be greater when using this material over the PBRMaterial| PBRMaterial, at the cost of some graphical accuracy.

Extends

  • LightableMaterial

Implements

  • DeferredMaterial

Constructors

Constructor

new MeshPhongMaterial(p?): MeshPhongMaterial

Parameters

p?

MeshPhongMaterialParameters

Returns

MeshPhongMaterial

Overrides

LightableMaterial.constructor

Properties

isDynamicShape

isDynamicShape: boolean

Mark this shape of this material is largely affect by shader. Hint the engine that pick, culling is disabled

Deprecated

Implementation of

DeferredMaterial.isDynamicShape

Inherited from

LightableMaterial.isDynamicShape


isVolumeRendering

isVolumeRendering: boolean

Mark this material uses volume like rendering technology. Hint the engine that some effect is disabled

Deprecated

Implementation of

DeferredMaterial.isVolumeRendering

Inherited from

LightableMaterial.isVolumeRendering


MAX_TEXTURES

readonly static MAX_TEXTURES: 6 = 6

max texture count, just in case some platform will take use of some channels by default, so set to 6 instead of 8

Inherited from

LightableMaterial.MAX_TEXTURES


name

name: string

Optional name of the object (doesn’t need to be unique). Default is an empty string.

Implementation of

DeferredMaterial.name

Inherited from

LightableMaterial.name


id

id: number

Unique number for this material instance.

Implementation of

DeferredMaterial.id

Inherited from

LightableMaterial.id


transparent

transparent: boolean

If use transparent effect, this value must be set to true to enable blending.

Default Value

false

Implementation of

DeferredMaterial.transparent

Inherited from

LightableMaterial.transparent


visible

visible: boolean

Defines whether this material is visible.

Default Value

true

Implementation of

DeferredMaterial.visible

Inherited from

LightableMaterial.visible


programId

programId: number

The id of shader program which this material shader belongs to.

Implementation of

DeferredMaterial.programId

Inherited from

LightableMaterial.programId


side

side: Side

Set which side of the object will be seen on screen.

Implementation of

DeferredMaterial.side

Inherited from

LightableMaterial.side


blending

blending: Blending

Which blending to use when displaying objects with this material. This must be set to CustomBlending to use custom blendSrc, blendDst or blendEquation. See the blending mode constants for all possible values. Default is NormalBlending.

Default Value

NormalBlending

Implementation of

DeferredMaterial.blending

Inherited from

LightableMaterial.blending


blendSrc

blendSrc: BlendingFactor

Blending source. Default is SrcAlphaFactor. See the source factors constants for all possible values.

Default Value

SrcAlphaFactor

Implementation of

DeferredMaterial.blendSrc

Inherited from

LightableMaterial.blendSrc


blendDst

blendDst: BlendingFactor

Blending destination. Default is OneMinusSrcAlphaFactor. See the destination factors constants for all possible values.

Default Value

OneMinusSrcAlpha

Implementation of

DeferredMaterial.blendDst

Inherited from

LightableMaterial.blendDst


blendEquation

blendEquation: BlendingEquation

Blending equation to use when applying blending. Default is AddEquation. See the blending equation constants for all possible values.

Default Value

Add

Implementation of

DeferredMaterial.blendEquation

Inherited from

LightableMaterial.blendEquation


blendSrcAlpha

blendSrcAlpha: Nullable<BlendingFactor>

The transparency of the blendSrc.

Implementation of

DeferredMaterial.blendSrcAlpha

Inherited from

LightableMaterial.blendSrcAlpha


blendDstAlpha

blendDstAlpha: Nullable<BlendingFactor>

The transparency of the blendDst.

Implementation of

DeferredMaterial.blendDstAlpha

Inherited from

LightableMaterial.blendDstAlpha


blendEquationAlpha

blendEquationAlpha: Nullable<BlendingEquation>

The transparency of the blendEquation.

Implementation of

DeferredMaterial.blendEquationAlpha

Inherited from

LightableMaterial.blendEquationAlpha


stencilWrite

stencilWrite: boolean

Whether rendering this material has any effect on the stencil buffer.

Default Value

false

Implementation of

DeferredMaterial.stencilWrite

Inherited from

LightableMaterial.stencilWrite


stencilWriteMask

stencilWriteMask: number

The bit mask to use when writing to the stencil buffer.

Default Value

0xFF

Implementation of

DeferredMaterial.stencilWriteMask

Inherited from

LightableMaterial.stencilWriteMask


stencilFuncMask

stencilFuncMask: number

The bit mask to use when comparing against the stencil buffer.

Default Value

0xFF

Implementation of

DeferredMaterial.stencilFuncMask

Inherited from

LightableMaterial.stencilFuncMask


stencilFunc

stencilFunc: StencilFunc

The stencil comparison function to use.

Default Value

AlwaysStencilFunc

Implementation of

DeferredMaterial.stencilFunc

Inherited from

LightableMaterial.stencilFunc


stencilRef

stencilRef: number

The value to use when performing stencil comparisons or stencil operations.

Default Value

0

Implementation of

DeferredMaterial.stencilRef

Inherited from

LightableMaterial.stencilRef


stencilFail

stencilFail: StencilOp

Which stencil operation to perform when the comparison function returns false.

Default Value

KeepStencilOp

Implementation of

DeferredMaterial.stencilFail

Inherited from

LightableMaterial.stencilFail


stencilZFail

stencilZFail: StencilOp

Which stencil operation to perform when the comparison function returns true but the depth test fails.

Default Value

KeepStencilOp

Implementation of

DeferredMaterial.stencilZFail

Inherited from

LightableMaterial.stencilZFail


stencilZPass

stencilZPass: StencilOp

Which stencil operation to perform when the comparison function returns true and the depth test passes.

Default Value

KeepStencilOp

Implementation of

DeferredMaterial.stencilZPass

Inherited from

LightableMaterial.stencilZPass


depthFunc

depthFunc: DepthModes

Which depth function to use.

Default Value

LessEqualDepth

Implementation of

DeferredMaterial.depthFunc

Inherited from

LightableMaterial.depthFunc


depthTest

depthTest: boolean

Whether to have depth test enabled when rendering this material. If this is set to false, this object’s occluding relationship will depend on Object3D.renderOrder| renderOrder.

Default Value

true

Implementation of

DeferredMaterial.depthTest

Inherited from

LightableMaterial.depthTest


depthWrite

depthWrite: boolean

Whether rendering this material has any effect on the depth buffer.

Default Value

true

Implementation of

DeferredMaterial.depthWrite

Inherited from

LightableMaterial.depthWrite


colorWrite

colorWrite: boolean

Whether to render the material’s color. This can be used in conjunction with a Object3D.renderOrder| renderOrder property to create invisible objects that occlude other objects.

Default Value

true

Implementation of

DeferredMaterial.colorWrite

Inherited from

LightableMaterial.colorWrite


colorWriteMasks

colorWriteMasks: [boolean, boolean, boolean, boolean]

Implementation of

DeferredMaterial.colorWriteMasks

Inherited from

LightableMaterial.colorWriteMasks


polygonOffset

polygonOffset: boolean

Whether to use polygon offset.

Default Value

false

Implementation of

DeferredMaterial.polygonOffset

Inherited from

LightableMaterial.polygonOffset


polygonOffsetFactor

polygonOffsetFactor: number

Sets the polygon offset factor.

Default Value

0

Implementation of

DeferredMaterial.polygonOffsetFactor

Inherited from

LightableMaterial.polygonOffsetFactor


polygonOffsetUnits

polygonOffsetUnits: number

Sets the polygon offset units.

Default Value

0

Implementation of

DeferredMaterial.polygonOffsetUnits

Inherited from

LightableMaterial.polygonOffsetUnits


premultipliedAlpha

premultipliedAlpha: boolean

Whether to premultiply the alpha (transparency) value.

Default Value

false

Implementation of

DeferredMaterial.premultipliedAlpha

Inherited from

LightableMaterial.premultipliedAlpha


onBeforeRender?

optional onBeforeRender?: (renderer) => void

An optionally overriding method for extents to get data from renderer before update uniforms.

Parameters

renderer

Renderer

instance of renderer for engine.

Returns

void

Implementation of

DeferredMaterial.onBeforeRender

Inherited from

LightableMaterial.onBeforeRender


colorWriteMask

colorWriteMask: [boolean, boolean, boolean, boolean]

Implementation of

DeferredMaterial.colorWriteMask

Inherited from

LightableMaterial.colorWriteMask


enableSceneClipping

enableSceneClipping: boolean

Inherited from

LightableMaterial.enableSceneClipping


pop

pop: Nullable<PopShaderComponent>

Inherited from

LightableMaterial.pop


isLightableMaterial

isLightableMaterial: boolean

Inherited from

LightableMaterial.isLightableMaterial


flatShadingNormal

flatShadingNormal: boolean

Inherited from

LightableMaterial.flatShadingNormal


isSupportDeferred

readonly isSupportDeferred: true

Implementation of

DeferredMaterial.isSupportDeferred


isMeshPhongMaterial

isMeshPhongMaterial: boolean

Check the type whether it belongs to MeshPhongMaterial. This value should not be changed by user.


texture

texture: Nullable<Texture2D>

Use texture cover object, if it is given.


opacityTex

opacityTex: Nullable<Texture2D>

Apply opacity texture to change the transparency on object’s some part. The opacity is decided by the value of texture’s red channel.


_uvTransform

_uvTransform: Readonly<Pick<ReadonlyMarked, "_readonly_mark" | "cloneReadonly" | "clone" | "equals" | "getSerializeData" | "getNumberCount" | "toArray" | "elements" | "applyToBufferAttribute" | "determinant" | "transposeIntoArray" | "applyToArray" | "applyInverse" | "decompose">>

Change the uv data by this matrix.


userData

readonly userData: Record<keyof any, any>

Implementation of

DeferredMaterial.userData

Inherited from

LightableMaterial.userData


_uuid

_uuid: any

Implementation of

DeferredMaterial._uuid

Inherited from

LightableMaterial._uuid


uuid

uuid: string

Implementation of

DeferredMaterial.uuid

Inherited from

LightableMaterial.uuid


_listeners

_listeners: Map<Symbol, Listener<never>[]>

Implementation of

DeferredMaterial._listeners

Inherited from

LightableMaterial._listeners

Accessors

color

Get Signature

get color(): ReadonlyColor

Returns

ReadonlyColor

Set Signature

set color(v): void

Parameters
v

ReadonlyColor

Returns

void


specular

Get Signature

get specular(): ReadonlyColor

Returns

ReadonlyColor

Set Signature

set specular(v): void

Parameters
v

ReadonlyColor

Returns

void


opacity

Get Signature

get opacity(): number

Returns

number

Set Signature

set opacity(v): void

Parameters
v

number

Returns

void


shininess

Get Signature

get shininess(): number

Returns

number

Set Signature

set shininess(v): void

Parameters
v

number

Returns

void


specularStrength

Get Signature

get specularStrength(): number

Returns

number

Set Signature

set specularStrength(v): void

Parameters
v

number

Returns

void


uvTransform

Get Signature

get uvTransform(): ReadonlyMatrix3

Returns

ReadonlyMatrix3

Set Signature

set uvTransform(v): void

Parameters
v

ReadonlyMatrix3

Returns

void


businessTag

Get Signature

get businessTag(): string

Returns

string

Set Signature

set businessTag(v): void

Parameters
v

string

Returns

void

Implementation of

DeferredMaterial.businessTag

Inherited from

LightableMaterial.businessTag

Methods

getComponents()

getComponents(): readonly ShaderComponent[]

Returns

readonly ShaderComponent[]

Implementation of

DeferredMaterial.getComponents

Inherited from

LightableMaterial.getComponents


deleteComponent()

deleteComponent(index): void

Parameters

index

number

Returns

void

Implementation of

DeferredMaterial.deleteComponent

Inherited from

LightableMaterial.deleteComponent


addComponent()

addComponent(c, index?): void

Parameters

c

ShaderComponent

index?

number

Returns

void

Implementation of

DeferredMaterial.addComponent

Inherited from

LightableMaterial.addComponent


refreshInstanceInBuilding()

refreshInstanceInBuilding(enable): void

Parameters

enable

boolean

Returns

void

Implementation of

DeferredMaterial.refreshInstanceInBuilding

Inherited from

LightableMaterial.refreshInstanceInBuilding


setColorWriteMasks()

setColorWriteMasks(r, g, b, a): void

Parameters

r

boolean

g

boolean

b

boolean

a

boolean

Returns

void

Implementation of

DeferredMaterial.setColorWriteMasks

Inherited from

LightableMaterial.setColorWriteMasks


notifyMaterialPropertyChanged()

notifyMaterialPropertyChanged(): void

When user change the material property manually, this method need to use to refresh data.

Returns

void

Implementation of

DeferredMaterial.notifyMaterialPropertyChanged

Inherited from

LightableMaterial.notifyMaterialPropertyChanged


getUUID()

getUUID(): string

UUID of this material instance. This gets automatically assigned, so this shouldn’t be edited.

Returns

string

Implementation of

DeferredMaterial.getUUID

Inherited from

LightableMaterial.getUUID


notifyRecompileShader()

notifyRecompileShader(): void

Reset the key of shader and force engine to compile shader again.

Returns

void

Implementation of

DeferredMaterial.notifyRecompileShader

Inherited from

LightableMaterial.notifyRecompileShader


destroyAllResourcesOwned()

destroyAllResourcesOwned(): void

Returns

void

Implementation of

DeferredMaterial.destroyAllResourcesOwned

Inherited from

LightableMaterial.destroyAllResourcesOwned


freeAllGpuResourceOwned()

freeAllGpuResourceOwned(): void

Returns

void

Implementation of

DeferredMaterial.freeAllGpuResourceOwned

Inherited from

LightableMaterial.freeAllGpuResourceOwned


updateShapeUniforms()

updateShapeUniforms(p, r): void

Parameters

p

WGLProgram

r

ShaderComponentRegistry

Returns

void

Implementation of

DeferredMaterial.updateShapeUniforms

Inherited from

LightableMaterial.updateShapeUniforms


computeShapeKey()

computeShapeKey(r): string

Parameters

r

ShaderComponentRegistry

Returns

string

Implementation of

DeferredMaterial.computeShapeKey

Inherited from

LightableMaterial.computeShapeKey


copyBase()

copyBase(other): this

Copy basic properties from other material.

Parameters

other

ScenePopLODMaterial

the source of copied data

Returns

this

Implementation of

DeferredMaterial.copyBase

Inherited from

LightableMaterial.copyBase


freeGPU()

freeGPU(): void

Returns

void

Implementation of

DeferredMaterial.freeGPU

Inherited from

LightableMaterial.freeGPU


extendShaderShape()

extendShaderShape(b, r): void

Parameters

b

ShaderBuilder

r

ShaderComponentRegistry

Returns

void

Implementation of

DeferredMaterial.extendShaderShape

Inherited from

LightableMaterial.extendShaderShape


getLightSystem()

getLightSystem(registry): LightShaderComponent

Parameters

registry

ShaderComponentRegistry

Returns

LightShaderComponent

Inherited from

LightableMaterial.getLightSystem


constructMaterialFromGBufferForLight()

static constructMaterialFromGBufferForLight(): string

Returns

string


extendDeferredLight()

static extendDeferredLight(builder): void

Parameters

builder

ShaderBuilder

Returns

void


extendEncodeDeferred()

extendEncodeDeferred(builder): void

Parameters

builder

ShaderBuilder

Returns

void

Implementation of

DeferredMaterial.extendEncodeDeferred


updateDeferredUniform()

updateDeferredUniform(p): void

Parameters

p

WGLProgram

Returns

void

Implementation of

DeferredMaterial.updateDeferredUniform


className()

className(): string

The name of instance’s class.

Returns

string

Implementation of

DeferredMaterial.className

Overrides

LightableMaterial.className


setValues()

setValues(values?): void

Change the corresponding attribute according to the values of given MeshPhongMaterialParameters| parameters.

Parameters

values?

MeshPhongMaterialParameters

a object of specified type contains parameters.

Returns

void

Implementation of

DeferredMaterial.setValues

Overrides

LightableMaterial.setValues


traverseUBO()

traverseUBO(visitor): void

Execute the given method for every ubo.

Parameters

visitor

(ubo) => void

Returns

void

Implementation of

DeferredMaterial.traverseUBO

Overrides

LightableMaterial.traverseUBO


copy()

copy(other): this

Copy the data to this instance from other instance.

Parameters

other

MeshPhongMaterial

the source of copied data

Returns

this

Implementation of

DeferredMaterial.copy

Overrides

LightableMaterial.copy


clone()

clone(): MeshPhongMaterial

Return a cloned instance of this class.

Returns

MeshPhongMaterial

Implementation of

DeferredMaterial.clone

Overrides

LightableMaterial.clone


serialize()

serialize(ctx): void

Store the attributes of this class into string as serializing format.

Parameters

ctx

Serializer

an instance used to store the data of scene objects.

Returns

void

Implementation of

DeferredMaterial.serialize

Overrides

LightableMaterial.serialize


deserialize()

deserialize(ctx): void

Parse the data for this class from string according to serializing format.

Parameters

ctx

Deserializer

an instance give the method to take the data for attribute.

Returns

void

Implementation of

DeferredMaterial.deserialize

Overrides

LightableMaterial.deserialize


markBusinessTag()

markBusinessTag(v): this

Parameters

v

string

Returns

this

Implementation of

DeferredMaterial.markBusinessTag

Inherited from

LightableMaterial.markBusinessTag


isDestroyed()

isDestroyed(): boolean

Returns

boolean

Implementation of

DeferredMaterial.isDestroyed

Inherited from

LightableMaterial.isDestroyed


destroy()

destroy(): void

Returns

void

Implementation of

DeferredMaterial.destroy

Inherited from

LightableMaterial.destroy


validate()

validate(): void

Returns

void

Implementation of

DeferredMaterial.validate

Inherited from

LightableMaterial.validate


on()

on<T>(_type, _listener): void

Adds a listener to an event type.

Type Parameters

T

T

Parameters

_type

EventType<T>

_listener

Listener<T>

Returns

void

Implementation of

DeferredMaterial.on

Inherited from

LightableMaterial.on


once()

once<T>(_type, _listener): void

Only active the listener one times and then off it| it.

Type Parameters

T

T

Parameters

_type

EventType<T>

_listener

Listener<T>

Returns

void

Implementation of

DeferredMaterial.once

Inherited from

LightableMaterial.once


has()

has<T>(_type, _listener): boolean

Checks if listener is added to an event type.

Type Parameters

T

T

Parameters

_type

EventType<T>

_listener

Listener<T>

Returns

boolean

Implementation of

DeferredMaterial.has

Inherited from

LightableMaterial.has


off()

off<T>(_type, _listener): void

Removes a listener from listening list.

Type Parameters

T

T

Parameters

_type

EventType<T>

_listener

Listener<T>

Returns

void

Implementation of

DeferredMaterial.off

Inherited from

LightableMaterial.off


emit()

Call Signature

emit(type): void

Active the event and call the registered listener.

Parameters
type

EventType<never>

Returns

void

Implementation of

DeferredMaterial.emit

Inherited from

LightableMaterial.emit

Call Signature

emit<T>(type, payload): void

Type Parameters
T

T

Parameters
type

EventType<T>

payload

T

Returns

void

Implementation of

DeferredMaterial.emit

Inherited from

LightableMaterial.emit


clearAllListeners()

clearAllListeners(): void

Removes all listeners from listening list.

Returns

void

Implementation of

DeferredMaterial.clearAllListeners

Inherited from

LightableMaterial.clearAllListeners