Class: Gfx3Material
The `Gfx3Material` class represents the material of a surface and provides method for controlling
texture, light reflection, uv animation, texture scrolling, texture displacement, environment reflection
and opacity of a surface. It used the phong illumination model for a full-artistic freedom.
Constructors
- new Gfx3Material(options: MATOptions): Gfx3Material
The constructor.
- options: The `options` parameter is an object that contains various properties
for configuring the material.
Methods
- delete(): void
The "delete" function free all resources.
Warning: you need to call this method to free allocation for this object.
- enableDecal(enabled: boolean): void
The "enableDecal" function enable decals on the material surface.
- enabled: A boolean value indicating whether the decal should be enabled or
disabled.
- enableShadow(enabled: boolean): void
The "enableShadow" function enable shadow on the material surface.
- enabled: A boolean value indicating whether the shadow should be enabled or
disabled.
- getDisplacementMap(): Gfx3Texture
The "getDisplacementMap" function returns the displacement map texture.
- getEnvMap(): Gfx3Texture
The "getEnvMap" function returns the environment map texture.
- getGroup02(): Gfx3StaticGroup
The "getGroup02" function returns the static group index 2.
- getGroup03(): Gfx3StaticGroup
The "getGroup03" function returns the static group index 3.
- getNormalMap(): Gfx3Texture
The "getNormalMap" function returns the normal map texture.
- getSpecularityMap(): Gfx3Texture
The "getSpecularityMap" function returns the specularity map texture.
- getTexture(): Gfx3Texture
The "getTexture" function returns the albedo texture.
- playAnimation(animationName: string, looped: boolean, preventSameAnimation: boolean): void
The "playAnimation" function is used to start playing a specific uv animation, with options for looping and
preventing the same animation from being played again.
- animationName: The name of the animation to be played.
- looped: The `looped` parameter is a boolean that determines whether
the animation should loop or not.
- preventSameAnimation: The `preventSameAnimation` parameter is a boolean
flag that determines whether the same animation should be prevented from playing again.
- resetAnimation(): void
The "resetAnimation" function stop animation and set current animation to null.
- setAmbient(r: number, g: number, b: number): void
The "setAmbient" function sets the ambient color of the material surface.
It is the color of the object on it's shadow parts.
- r: The parameter "r" represents the red component.
- g: The parameter "g" represents the green component.
- b: The parameter "b" represents the blue component.
- setDiffuse(r: number, g: number, b: number): void
The "setDiffuse" function sets the diffuse color of the material surface.
It is the color of the object on it's lightning parts.
- r: The parameter "r" represents the red component.
- g: The parameter "g" represents the green component.
- b: The parameter "b" represents the blue component.
- setDisplacementMap(displacementMap: Gfx3Texture, angle: number, rate: number, factor: number): void
The "setDisplacementMap" function sets the displacement texture map, scroll angle, scroll rate, and factor
for the graphics effect. It is used to displace pixels of the texture base. It is ideal for water shallow effect, magma etc...
1. White pixel of this texture force pixel of the albedo texture to move in the top-left direction.
2. Grey don't move pixels.
3. Black pixel of this texture force pixel of the albedo texture to move in the bottom-right direction.
- displacementMap: The displacementMap texture.
- angle: The `angle` parameter represents the angle at which the texture will be
scrolled. It is measured in radians.
- rate: The `rate` is used to specify the scrolling rate of the texture.
It determines how fast the texture will scroll when applied to a surface.
- factor: The `factor` parameter in the setDisplacementMap function is used to
control the strength or intensity of the displacement effect. It determines how much the pixels of
the displacement map will affect the corresponding pixels of the target image. A higher factor value
will result in a more pronounced displacement effect.
- setEmissive(r: number, g: number, b: number): void
The "setEmissive" function sets the emissive color of the material surface.
It is the color that the object emit.
- r: The parameter "r" represents the red component.
- g: The parameter "g" represents the green component.
- b: The parameter "b" represents the blue component.
- setEnvMap(envMap: Gfx3Texture): void
The "setEnvMap" function sets the environment map texture of the material surface.
- envMap: The envMap texture is used to set the environment reflection on the material surface.
- setLightning(lightning: boolean): void
The "setLightning" function sets the lightning boolean flag of the material surface.
- lightning: The "lightning" parameter is a boolean value that indicates if light is applied
or not to the material.
- setNormalIntensity(normalIntensity: number): void
The "setNormalIntensity" function sets the normal bumping intensity of the material surface.
- normalIntensity: The `normalIntensity` increase or decrease the bumping effect.
- setNormalMap(normalMap: Gfx3Texture): void
The "setNormalMap" function sets a normal map texture of the material surface.
- normalMap: The normalMap is a texture used for controlling
the texture granularity and orientations by adding normals informations on it.
- setOpacity(opacity: number): void
The "setOpacity" function sets the opacity of the material surface.
- opacity: The "opacity" determines how transparent or opaque the material should be.
The value ranges from 0 (completely transparent) to 1 (completely opaque).
- setSpecular(r: number, g: number, b: number): void
The "setSpecular" function sets the specular color of the material surface.
It is the color of the object on it's lightning and eye-oriented parts.
- r: The parameter "r" represents the red component.
- g: The parameter "g" represents the green component.
- b: The parameter "b" represents the blue component.
- setSpecularity(specularity: number): void
The "setSpecularity" function sets the specular intensity of the material surface.
It determines how much light is reflected off the surface and can range
from 0 (no specularity) to 1 (maximum specularity).
- specularity: The specularity parameter is a number that represents the level of
specularity or shininess of the surface.
- setSpecularityMap(specularityMap: Gfx3Texture): void
The "setSpecularityMap" function sets the specularity map texture of the material surface.
- specularityMap: The specularityMap is a texture used for
controlling the specularity (shininess) of a material surface.
- setTexture(texture: Gfx3Texture, angle: number, rate: number): void
The "setTexture" function sets the texture, texture scroll angle, and texture scroll rate of the material surface.
- texture: The texture that will be applied to the material surface.
- angle: The `angle` parameter represents the angle at which the texture will be
scrolled. It is measured in radians.
- rate: The `rate` is used to specify the scrolling rate of the texture.
It determines how fast the texture will scroll when applied to a surface.
- update(ts: number): void
The "update" function.
- createFromFile(path: string): Promise
The "createFromFile" is a static function asynchronously loads and create material from a json file (mat).
- path: The `path` parameter is the file path.