SpriteMaterial

A dedicated material of Sprite| Sprite.

Core Class

A dedicated material of Sprite| Sprite.

Extends

Constructors

Constructor

new SpriteMaterial(p?): SpriteMaterial

Parameters

p?

SpriteMaterialParameters

Returns

SpriteMaterial

Overrides

Material.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

Inherited from

Material.isDynamicShape


isVolumeRendering

isVolumeRendering: boolean

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

Deprecated

Inherited from

Material.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

Material.MAX_TEXTURES


name

name: string

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

Inherited from

Material.name


id

id: number

Unique number for this material instance.

Inherited from

Material.id


transparent

transparent: boolean

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

Default Value

false

Inherited from

Material.transparent


visible

visible: boolean

Defines whether this material is visible.

Default Value

true

Inherited from

Material.visible


programId

programId: number

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

Inherited from

Material.programId


side

side: Side

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

Inherited from

Material.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

Inherited from

Material.blending


blendSrc

blendSrc: BlendingFactor

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

Default Value

SrcAlphaFactor

Inherited from

Material.blendSrc


blendDst

blendDst: BlendingFactor

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

Default Value

OneMinusSrcAlpha

Inherited from

Material.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

Inherited from

Material.blendEquation


blendSrcAlpha

blendSrcAlpha: Nullable<BlendingFactor>

The transparency of the blendSrc.

Inherited from

Material.blendSrcAlpha


blendDstAlpha

blendDstAlpha: Nullable<BlendingFactor>

The transparency of the blendDst.

Inherited from

Material.blendDstAlpha


blendEquationAlpha

blendEquationAlpha: Nullable<BlendingEquation>

The transparency of the blendEquation.

Inherited from

Material.blendEquationAlpha


stencilWrite

stencilWrite: boolean

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

Default Value

false

Inherited from

Material.stencilWrite


stencilWriteMask

stencilWriteMask: number

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

Default Value

0xFF

Inherited from

Material.stencilWriteMask


stencilFuncMask

stencilFuncMask: number

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

Default Value

0xFF

Inherited from

Material.stencilFuncMask


stencilFunc

stencilFunc: StencilFunc

The stencil comparison function to use.

Default Value

AlwaysStencilFunc

Inherited from

Material.stencilFunc


stencilRef

stencilRef: number

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

Default Value

0

Inherited from

Material.stencilRef


stencilFail

stencilFail: StencilOp

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

Default Value

KeepStencilOp

Inherited from

Material.stencilFail


stencilZFail

stencilZFail: StencilOp

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

Default Value

KeepStencilOp

Inherited from

Material.stencilZFail


stencilZPass

stencilZPass: StencilOp

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

Default Value

KeepStencilOp

Inherited from

Material.stencilZPass


depthFunc

depthFunc: DepthModes

Which depth function to use.

Default Value

LessEqualDepth

Inherited from

Material.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

Inherited from

Material.depthTest


depthWrite

depthWrite: boolean

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

Default Value

true

Inherited from

Material.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

Inherited from

Material.colorWrite


colorWriteMasks

colorWriteMasks: [boolean, boolean, boolean, boolean]

Inherited from

Material.colorWriteMasks


polygonOffset

polygonOffset: boolean

Whether to use polygon offset.

Default Value

false

Inherited from

Material.polygonOffset


polygonOffsetFactor

polygonOffsetFactor: number

Sets the polygon offset factor.

Default Value

0

Inherited from

Material.polygonOffsetFactor


polygonOffsetUnits

polygonOffsetUnits: number

Sets the polygon offset units.

Default Value

0

Inherited from

Material.polygonOffsetUnits


premultipliedAlpha

premultipliedAlpha: boolean

Whether to premultiply the alpha (transparency) value.

Default Value

false

Inherited from

Material.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

Inherited from

Material.onBeforeRender


colorWriteMask

colorWriteMask: [boolean, boolean, boolean, boolean]

Inherited from

Material.colorWriteMask


sizeAttenuation

sizeAttenuation: boolean

Whether the size of the sprite is attenuated by the camera depth. (Perspective camera only.)

Default Value

false


rotation

rotation: number

The rotation of the sprite in radians.

Default Value

0


color

color: Readonly<Pick<ReadonlyMarked, "_readonly_mark" | "cloneReadonly" | "clone" | "g" | "r" | "b" | "isColor" | "equals" | "getHex" | "getSerializeData">>

Color of the material, by default set to white (0xffffff). The value of color multiply with the color of texture.


texture

texture: Nullable<Texture2D>

A picture for sprite.

Default Value

null


opacity

opacity: number

The Transparency of object.

Default Value

null


userData

readonly userData: Record<keyof any, any>

Inherited from

Material.userData


_uuid

_uuid: any

Inherited from

Material._uuid


uuid

uuid: string

Inherited from

Material.uuid


_listeners

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

Inherited from

Material._listeners

Accessors

businessTag

Get Signature

get businessTag(): string

Returns

string

Set Signature

set businessTag(v): void

Parameters
v

string

Returns

void

Inherited from

Material.businessTag

Methods

getComponents()

getComponents(): readonly ShaderComponent[]

Returns

readonly ShaderComponent[]

Inherited from

Material.getComponents


deleteComponent()

deleteComponent(index): void

Parameters

index

number

Returns

void

Inherited from

Material.deleteComponent


addComponent()

addComponent(c, index?): void

Parameters

c

ShaderComponent

index?

number

Returns

void

Inherited from

Material.addComponent


refreshInstanceInBuilding()

refreshInstanceInBuilding(enable): void

Parameters

enable

boolean

Returns

void

Inherited from

Material.refreshInstanceInBuilding


setColorWriteMasks()

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

Parameters

r

boolean

g

boolean

b

boolean

a

boolean

Returns

void

Inherited from

Material.setColorWriteMasks


notifyMaterialPropertyChanged()

notifyMaterialPropertyChanged(): void

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

Returns

void

Inherited from

Material.notifyMaterialPropertyChanged


getUUID()

getUUID(): string

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

Returns

string

Inherited from

Material.getUUID


notifyRecompileShader()

notifyRecompileShader(): void

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

Returns

void

Inherited from

Material.notifyRecompileShader


copyBase()

copyBase(other): void

Copy basic properties from other material.

Parameters

other

Material

the source of copied data

Returns

void

Inherited from

Material.copyBase


freeGPU()

freeGPU(): void

Make engine clear the current material’s data in Ubo.

Returns

void

Inherited from

Material.freeGPU


destroyAllResourcesOwned()

destroyAllResourcesOwned(): void

Returns

void

Inherited from

Material.destroyAllResourcesOwned


freeAllGpuResourceOwned()

freeAllGpuResourceOwned(): void

Returns

void

Inherited from

Material.freeAllGpuResourceOwned


className()

className(): string

The name of instance’s class.

Returns

string

Overrides

Material.className


setValues()

setValues(p): void

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

Parameters

p

SpriteMaterialParameters

a object of specified type contains parameters.

Returns

void

Overrides

Material.setValues


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

Overrides

Material.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

Overrides

Material.deserialize


copy()

copy(other): this

Copy the data to this instance from other instance.

Parameters

other

SpriteMaterial

the source of copied data

Returns

this

Overrides

Material.copy


clone()

clone(): SpriteMaterial

Return a cloned instance of this class.

Returns

SpriteMaterial

Overrides

Material.clone


markBusinessTag()

markBusinessTag(v): this

Parameters

v

string

Returns

this

Inherited from

Material.markBusinessTag


isDestroyed()

isDestroyed(): boolean

Returns

boolean

Inherited from

Material.isDestroyed


destroy()

destroy(): void

Returns

void

Inherited from

Material.destroy


validate()

validate(): void

Returns

void

Inherited from

Material.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

Inherited from

Material.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

Inherited from

Material.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

Inherited from

Material.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

Inherited from

Material.off


emit()

Call Signature

emit(type): void

Active the event and call the registered listener.

Parameters
type

EventType<never>

Returns

void

Inherited from

Material.emit

Call Signature

emit<T>(type, payload): void

Type Parameters
T

T

Parameters
type

EventType<T>

payload

T

Returns

void

Inherited from

Material.emit


clearAllListeners()

clearAllListeners(): void

Removes all listeners from listening list.

Returns

void

Inherited from

Material.clearAllListeners