Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / MaterialComponent

Class: MaterialComponent ​

Defined in: components/Material.ts:237

Material catalog for an entity. Tracks the live three.js materials (materials, material) plus serialized authoring state (values[]) mirrored from the inspector. Supports standard, basic, phong, and physical PBR types with optional texture map slots.

Remarks ​

Use setMaterials, updateValue, setMaterialType, setTextureFiltering, and setUseMipmaps to mutate state — these keep values[] and the live three.js materials in sync. Texture URLs use the localasset:// protocol inside the editor.

Extends ​

Constructors ​

Constructor ​

ts
new MaterialComponent(materialOrMaterials?): MaterialComponent;

Defined in: components/Material.ts:254

Parameters ​

ParameterTypeDefault value
materialOrMaterialsMaterial<MaterialEventMap> | Material<MaterialEventMap>[][]

Returns ​

MaterialComponent

Overrides ​

Component.constructor

Properties ​

PropertyTypeDescriptionDefined in
materialsMaterial<MaterialEventMap>[]Live three.js materials currently bound to the entity's mesh (one per submesh).components/Material.ts:239
materialMaterial<MaterialEventMap> | nullConvenience reference to materials[0]. null when no material is assigned.components/Material.ts:241
valuesMaterialValueState[]Serialized authoring state (one entry per material in materials). Saved with the project.components/Material.ts:243
assetRefs(string | null)[]Editor-managed material-asset linkage, one entry per slot (parallel to values). A localasset:// URL of a .material asset file, or null/absent for a local (unlinked) material. The editor materializes the asset's values into values and keeps them in sync when the asset is edited — rendering and the runtime read only values and ignore this field. Saved with the project; survives material rebinds.components/Material.ts:252

Methods ​

setAssetRef() ​

ts
setAssetRef(index, url): void;

Defined in: components/Material.ts:265

Link/unlink a slot to a material asset URL (editor bookkeeping only).

Parameters ​

ParameterType
indexnumber
urlstring | null

Returns ​

void


getAssetRef() ​

ts
getAssetRef(index): string | null;

Defined in: components/Material.ts:276

The material-asset URL a slot is linked to, or null when local.

Parameters ​

ParameterType
indexnumber

Returns ​

string | null


setMaterials() ​

ts
setMaterials(materialOrMaterials?): void;

Defined in: components/Material.ts:280

Parameters ​

ParameterTypeDefault value
materialOrMaterialsMaterial<MaterialEventMap> | Material<MaterialEventMap>[][]

Returns ​

void


updateValue() ​

ts
updateValue(index, patch): void;

Defined in: components/Material.ts:296

Parameters ​

ParameterType
indexnumber
patchPartial<MaterialValueState>

Returns ​

void


resetValue() ​

ts
resetValue(index): void;

Defined in: components/Material.ts:311

Parameters ​

ParameterType
indexnumber

Returns ​

void


setMaterialType() ​

ts
setMaterialType(index, type): void;

Defined in: components/Material.ts:327

Parameters ​

ParameterType
indexnumber
typeMaterialTypeValue

Returns ​

void


setTextureFiltering() ​

ts
setTextureFiltering(index, filtering): void;

Defined in: components/Material.ts:331

Parameters ​

ParameterType
indexnumber
filteringTextureFilteringValue

Returns ​

void


setUseMipmaps() ​

ts
setUseMipmaps(index, enabled): void;

Defined in: components/Material.ts:335

Parameters ​

ParameterType
indexnumber
enabledboolean

Returns ​

void