MaterialUtils

A module containing useful utility methods to work with Verge3D materials.

Methods

.replaceTexture(mat : Material, oldTex : Texture, newTex : Texture)

Replace one texture by another in the given material. Currently this method supports only MeshNodeMaterial and MeshStandardMaterial materials.

.disposeTextures(mat : Material)

Dispose all textures found in the given material. Currently this method supports only MeshNodeMaterial and MeshStandardMaterial materials.

.createDiffuseMaterial(name : String, color : Color, opacity : Float, profile : String) → DiGraph

Generate node-based diffuse (lambert) material with the given color and opacity params.

.createEnvironmentMaterial(name : String, envTex : Texture, bkgTexOrColor : Texture | Color) → MeshNodeMaterial

Create node-based material which can be used for environment lighting and scene background.

.createStandardPBRMaterial(profile : String, params : Object) → DiGraph

Generate node-based standard PBR material with the given set of parameters:

color
Material base color. Default is 'white'.
opacity
Material opacity value. Default is 1.0 (opaque).
metalness
Material metalness value. Default is 0 (non-metallic).
roughness
Material roughness value. Default is 1.
emissive
Material emissive color. Default is 'black'.
emissiveIntensity
Material emissive color intensity. Default is 1.

Source

For more info on how to obtain the source code of this module see this page.