Skip to content

@orillusion/core


Class: MaterialUtilities

Defined in: src/loader/parser/prefab/mats/MaterialUtilities.ts:15

Helper utilities used while parsing prefab materials. Resolves a shader by name into a Material, and applies decoded textures and uniform properties onto a material.

Constructors

Constructor

new MaterialUtilities(): MaterialUtilities

Returns

MaterialUtilities

Methods

GetMaterial()

static GetMaterial(shaderName, ctx?): Material

Defined in: src/loader/parser/prefab/mats/MaterialUtilities.ts:24

Resolve a shader by its (possibly path-qualified) name and build a Material using it.

Parameters

shaderName

string

the shader name, optionally with a path/dotted prefix.

ctx?

Context3D

optional rendering context passed to the shader constructor.

Returns

Material

the constructed material.


applyMaterialTexture()

static applyMaterialTexture(mat, textures): void

Defined in: src/loader/parser/prefab/mats/MaterialUtilities.ts:49

Apply decoded textures onto a material, binding each to the matching material/shader property or falling back to Material.setTexture.

Parameters

mat

Material

the target material.

textures

PrefabTextureData[]

the decoded texture entries to apply.

Returns

void


applyMaterialProperties()

static applyMaterialProperties(mat, properties): void

Defined in: src/loader/parser/prefab/mats/MaterialUtilities.ts:68

Apply decoded key/value uniform properties onto a material, dispatching by value type to the matching material/shader property or uniform setter.

Parameters

mat

Material

the target material.

properties

KV[]

the decoded property entries to apply.

Returns

void

Released under the MIT License