MaterialRegistry

Registry storing material definitions and providing fallback handling.

Constructor

new MaterialRegistry()

Classes

MaterialRegistry

Members

(static) diagnostics

Static access to the default registry's diagnostic log.

_customFallback :object|null

Type:
  • object | null

_fallbackId :string

Type:
  • string

_materials :Map.<string, object>

Type:
  • Map.<string, object>

diagnostics :Array.<object>

Type:
  • Array.<object>

onDiagnostic :function|null

Type:
  • function | null

Methods

(static) get()

Static helper to get a material definition from the default registry.

(static) getDefault() → {MaterialRegistry}

Get the default singleton instance of MaterialRegistry.

Returns:
Type: 
MaterialRegistry

(static) has()

Static helper to check if a material definition exists in the default registry.

(static) register()

Static helper to register a material definition on the default registry.

(static) reset()

Static helper to reset the default registry to built-ins.

get(id, optionsopt) → {object}

Query a material definition by ID with fallback handling and diagnostic warning.

Parameters:
NameTypeAttributesDescription
idstring

Material identifier.

optionsobject<optional>
Properties
NameTypeAttributesDefaultDescription
suppressWarningboolean<optional>
false

Whether to suppress console warning.

Returns:

The material definition or fallback.

Type: 
object

getAll() → {Array.<object>}

Get all registered material definitions as an array.

Returns:
Type: 
Array.<object>

getIds() → {Array.<string>}

Get all registered material IDs.

Returns:
Type: 
Array.<string>

has(id) → {boolean}

Check if a material is registered.

Parameters:
NameTypeDescription
idstring

Material identifier.

Returns:
Type: 
boolean

register(id, def) → {object}

Register or update a material definition.

Parameters:
NameTypeDescription
idstring

Unique material identifier.

defobject

Material properties.

Returns:

The registered material definition.

Type: 
object

reset()

Reset registry to default built-in materials and clear diagnostics.

setFallback(fallback)

Configure the fallback material.

Parameters:
NameTypeDescription
fallbackstring | object

Material ID or definition.

unregister(id) → {boolean}

Unregister a material definition.

Parameters:
NameTypeDescription
idstring
Returns:
Type: 
boolean