Material
A base class for all materials with some abstract functions. Materials describe the appearance of the objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer. The following properties and methods are inherited by all other material types (although they may have different defaults).
getComponents(): readonly ShaderComponent[];
deleteComponent(index: number): void;
addComponent(c: ShaderComponent, index?: number): void;
isDynamicShape: boolean;
isVolumeRendering: boolean;
name: string;
id: number;
transparent: boolean;
visible: boolean;
programId: number;
refreshInstanceInBuilding(enable: boolean): void;
side: Side;
blending: Blending;
blendSrc: BlendingFactor;
blendDst: BlendingFactor;
blendEquation: BlendingEquation;
blendSrcAlpha: Nullable<BlendingFactor>;
blendDstAlpha: Nullable<BlendingFactor>;
blendEquationAlpha: Nullable<BlendingEquation>;
stencilWrite: boolean;
stencilWriteMask: number;
stencilFuncMask: number;
stencilFunc: StencilFunc;
stencilRef: number;
stencilFail: StencilOp;
stencilZFail: StencilOp;
stencilZPass: StencilOp;
depthFunc: DepthModes;
depthTest: boolean;
depthWrite: boolean;
colorWrite: boolean;
colorWriteMasks: [boolean, boolean, boolean, boolean];
setColorWriteMasks(r: boolean, g: boolean, b: boolean, a: boolean): void;
polygonOffset: boolean;
polygonOffsetFactor: number;
polygonOffsetUnits: number;
premultipliedAlpha: boolean;
onBeforeRender?: (renderer: Renderer) => void;
notifyMaterialPropertyChanged(): void;
colorWriteMask: [boolean, boolean, boolean, boolean];
getUUID(): string;
className(): string;
clone(): Material;
copy(other: Material): void;
setValues(
values?: Partial<
SubTypeMap<
Pick<
Material,
| "transparent"
| "visible"
| "side"
| "blending"
| "blendSrc"
| "blendDst"
| "blendEquation"
| "blendSrcAlpha"
| "blendDstAlpha"
| "blendEquationAlpha"
| "depthFunc"
| "depthTest"
| "depthWrite"
| "colorWrite"
| "polygonOffset"
| "polygonOffsetFactor"
| "polygonOffsetUnits"
| "stencilWriteMask"
| "stencilFunc"
| "stencilRef"
| "stencilFuncMask"
| "stencilFail"
| "stencilZFail"
| "stencilZPass"
| "stencilWrite",
>,
Readonly<
Pick<
ReadonlyMarked<Color>,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "g"
| "r"
| "b"
| "isColor"
| "getHex",
>,
>,
| string
| number
| Readonly<
Pick<
ReadonlyMarked<Color>,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "g"
| "r"
| "b"
| "isColor"
| "getHex",
>,
>,
>,
>,
): void;
notifyRecompileShader(): void;
copyBase(other: Material): void;
freeGPU(): void;
serialize(ctx: Serializer): any;
deserialize(ctx: Deserializer): void;
destroyAllResourcesOwned(): void;
freeAllGpuResourceOwned(): void;
userData: Record<keyof any, any>;
markBusinessTag(v: string): this;
get businessTag(): string;
set businessTag(v: string): void;
isDestroyed(): boolean;
destroy(): void;
validate(): void;
_uuid: any;
uuid: string;
_listeners: Map<Symbol, Listener<never>[]>;
on<T>(_type: EventType<T>, _listener: Listener<T>): void;
once<T>(_type: EventType<T>, _listener: Listener<T>): void;
has<T>(_type: EventType<T>, _listener: Listener<T>): boolean;
off<T>(_type: EventType<T>, _listener: Listener<T>): void;
emit(type: EventType<never>): void;
emit<T>(type: EventType<T>, payload: T): void;
clearAllListeners(): void;
}
Hierarchy
- ElementEventDispatcher
- Material
Implements
- SerializerableDelegatedAsReference
- MaterialState
- ElementsWithGPUResource
Properties
is Dynamic Shape
Mark this shape of this material is largely affect by shader. Hint the engine that pick, culling is disabled
is Volume Rendering
Mark this material uses volume like rendering technology. Hint the engine that some effect is disabled
name
Optional name of the object (doesn't need to be unique). Default is an empty string.
id
Unique number for this material instance.
transparentfalse
If use transparent effect, this value must be set to true to enable blending.
Implementation of MaterialState.transparent
visibletrue
Defines whether this material is visible.
Implementation of MaterialState.visible
program Id
The id of shader program which this material shader belongs to.
side
Set which side of the object will be seen on screen.
Implementation of MaterialState.side
blendingNormalBlending
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.
Implementation of MaterialState.blending
blend SrcSrcAlphaFactor
Blending source. Default is SrcAlphaFactor. See the source factors constants for all possible values.
Implementation of MaterialState.blendSrc
blend DstOneMinusSrcAlpha
Blending destination. Default is OneMinusSrcAlphaFactor. See the destination factors constants for all possible values.
Implementation of MaterialState.blendDst
blend EquationAdd
Blending equation to use when applying blending. Default is AddEquation. See the blending equation constants for all possible values.
Implementation of MaterialState.blendEquation
blend Src Alpha
The transparency of the blendSrc .
Implementation of MaterialState.blendSrcAlpha
blend Dst Alpha
The transparency of the blendDst .
Implementation of MaterialState.blendDstAlpha
blend Equation Alpha
The transparency of the blendEquation .
Implementation of MaterialState.blendEquationAlpha
stencil Writefalse
Whether rendering this material has any effect on the stencil buffer.
Implementation of MaterialState.stencilWrite
stencil Write Mask0xFF
The bit mask to use when writing to the stencil buffer.
Implementation of MaterialState.stencilWriteMask
stencil Func Mask0xFF
The bit mask to use when comparing against the stencil buffer.
Implementation of MaterialState.stencilFuncMask
stencil FuncAlwaysStencilFunc
The stencil comparison function to use.
Implementation of MaterialState.stencilFunc
stencil Ref0
The value to use when performing stencil comparisons or stencil operations.
Implementation of MaterialState.stencilRef
stencil FailKeepStencilOp
Which stencil operation to perform when the comparison function returns false.
Implementation of MaterialState.stencilFail
stencil Z FailKeepStencilOp
Which stencil operation to perform when the comparison function returns true but the depth test fails.
Implementation of MaterialState.stencilZFail
stencil Z PassKeepStencilOp
Which stencil operation to perform when the comparison function returns true and the depth test passes.
Implementation of MaterialState.stencilZPass
depth FuncLessEqualDepth
Which depth function to use.
Implementation of MaterialState.depthFunc
depth Testtrue
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.
Implementation of MaterialState.depthTest
depth Writetrue
Whether rendering this material has any effect on the depth buffer.
Implementation of MaterialState.depthWrite
color Writetrue
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.
Implementation of MaterialState.colorWrite
color Write Masks
Implementation of MaterialState.colorWriteMasks
polygon Offsetfalse
Whether to use polygon offset.
Implementation of MaterialState.polygonOffset
polygon Offset Factor0
Sets the polygon offset factor.
Implementation of MaterialState.polygonOffsetFactor
polygon Offset Units0
Sets the polygon offset units.
Implementation of MaterialState.polygonOffsetUnits
premultiplied Alphafalse
Whether to premultiply the alpha (transparency) value.
Implementation of MaterialState.premultipliedAlpha
on Before Render
An optionally overriding method for extents to get data from renderer before update uniforms.
- (renderer: Renderer): void
Parameters
- renderer: Renderer
instance of renderer for engine.
Returns void
- renderer: Renderer
color Write Mask
Readonlyuser Data
Inherited from MeshPhongMaterial.userData
_ uuid
Inherited from ElementEventDispatcher._uuid
uuid
Inherited from ElementEventDispatcher.uuid
_ listeners
Inherited from ElementEventDispatcher._listeners
Accessors
business Tag
- get businessTag(): string
Returns string
Inherited from ElementEventDispatcher.businessTag
- set businessTag(v: string): void
Parameters
- v: string
Returns void
Inherited from ElementEventDispatcher.businessTag
Methods
get Components
Returns readonly ShaderComponent[]
delete Component
Parameters
- index: number
Returns void
add Component
Parameters
- c: ShaderComponent
- index: number
Returns void
refresh Instance In Building
Parameters
- enable: boolean
Returns void
set Color Write Masks
Parameters
- r: boolean
- g: boolean
- b: boolean
- a: boolean
Returns void
notify Material Property Changed
When user change the material property manually, this method need to use to refresh data.
Returns void
get UUID
UUID of this material instance. This gets automatically assigned, so this shouldn't be edited.
Returns string
Implementation of SerializerableDelegatedAsReference.getUUID
Abstractclass Name
The name of instance's class.
Returns string
Implementation of SerializerableDelegatedAsReference.className
Abstractclone
abstract function to clone each instance of the class
Returns Material
Abstractcopy
set Values
- setValues(
values?: Partial<
SubTypeMap<
Pick<
Material,
| "transparent"
| "visible"
| "side"
| "blending"
| "blendSrc"
| "blendDst"
| "blendEquation"
| "blendSrcAlpha"
| "blendDstAlpha"
| "blendEquationAlpha"
| "depthFunc"
| "depthTest"
| "depthWrite"
| "colorWrite"
| "polygonOffset"
| "polygonOffsetFactor"
| "polygonOffsetUnits"
| "stencilWriteMask"
| "stencilFunc"
| "stencilRef"
| "stencilFuncMask"
| "stencilFail"
| "stencilZFail"
| "stencilZPass"
| "stencilWrite",
>,
Readonly<
Pick<
ReadonlyMarked<Color>,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "g"
| "r"
| "b"
| "isColor"
| "getHex",
>,
>,
| string
| number
| Readonly<
Pick<
ReadonlyMarked<Color>,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "g"
| "r"
| "b"
| "isColor"
| "getHex",
>,
>,
>,
>,
): voidSets the properties with the given values. In extents class, this method need to override in extended material for corresponding parameters.
Parameters
- values: Partial<
SubTypeMap<
Pick<
Material,
| "transparent"
| "visible"
| "side"
| "blending"
| "blendSrc"
| "blendDst"
| "blendEquation"
| "blendSrcAlpha"
| "blendDstAlpha"
| "blendEquationAlpha"
| "depthFunc"
| "depthTest"
| "depthWrite"
| "colorWrite"
| "polygonOffset"
| "polygonOffsetFactor"
| "polygonOffsetUnits"
| "stencilWriteMask"
| "stencilFunc"
| "stencilRef"
| "stencilFuncMask"
| "stencilFail"
| "stencilZFail"
| "stencilZPass"
| "stencilWrite",
>,
Readonly<
Pick<
ReadonlyMarked<Color>,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "g"
| "r"
| "b"
| "isColor"
| "getHex",
>,
>,
| string
| number
| Readonly<
Pick<
ReadonlyMarked<Color>,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "g"
| "r"
| "b"
| "isColor"
| "getHex",
>,
>,
>,
>
Returns void
- values: Partial<
notify Recompile Shader
Reset the key of shader and force engine to compile shader again.
Returns void
copy Base
Copy basic properties from other material.
Parameters
- other: Material
the source of copied data
Returns void
- other: Material
free GPU
Make engine clear the current material's data in Ubo.
Returns void
Implementation of ElementsWithGPUResource.freeGPU
serialize
Store the attributes of this class into string as serializing format.
Parameters
- ctx: Serializer
this parameter has not supported external Serializer yet. It may cause that this method can not be used directly.
Returns any
Implementation of SerializerableDelegatedAsReference.serialize
- ctx: Serializer
deserialize
Parse the data for this class from string according to serializing format.
Parameters
- ctx: Deserializer
this parameter has not supported external Deserializer yet. It may cause that this method can not be used directly.
Returns void
Implementation of SerializerableDelegatedAsReference.deserialize
- ctx: Deserializer
destroy All Resources Owned
Returns void
Overrides ElementEventDispatcher.destroyAllResourcesOwned
free All Gpu Resource Owned
Returns void
Overrides ElementEventDispatcher.freeAllGpuResourceOwned
mark Business Tag
Parameters
- v: string
Returns this
Inherited from ElementEventDispatcher.markBusinessTag
is Destroyed
Returns boolean
Inherited from ElementEventDispatcher.isDestroyed
destroy
Returns void
Inherited from ElementEventDispatcher.destroy
validate
Returns void
Inherited from ElementEventDispatcher.validate
on
once
has
off
emit
Active the event and call the registered listener.
Parameters
- type: EventType<never>
Returns void
Inherited from ElementEventDispatcher.emit
clear All Listeners
Removes all listeners from listening list.
Returns void
Inherited from ElementEventDispatcher.clearAllListeners
A base class for all materials with some abstract functions. Materials describe the appearance of the objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer. The following properties and methods are inherited by all other material types (although they may have different defaults).