@relu-interactives/spatial-ecs
@relu-interactives/spatial-ecs / components / MaterialComponent
Class: MaterialComponent
Defined in: components/Material.ts:190
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
new MaterialComponent(materialOrMaterials?): MaterialComponent;Defined in: components/Material.ts:198
Parameters
| Parameter | Type | Default value |
|---|---|---|
materialOrMaterials | Material | Material[] | [] |
Returns
MaterialComponent
Overrides
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
materials | Material[] | Live three.js materials currently bound to the entity's mesh (one per submesh). | components/Material.ts:192 |
material | Material | null | Convenience reference to materials[0]. null when no material is assigned. | components/Material.ts:194 |
values | MaterialValueState[] | Serialized authoring state (one entry per material in materials). Saved with the project. | components/Material.ts:196 |
Methods
setMaterials()
setMaterials(materialOrMaterials?): void;Defined in: components/Material.ts:207
Parameters
| Parameter | Type | Default value |
|---|---|---|
materialOrMaterials | Material | Material[] | [] |
Returns
void
updateValue()
updateValue(index, patch): void;Defined in: components/Material.ts:223
Parameters
| Parameter | Type |
|---|---|
index | number |
patch | Partial<MaterialValueState> |
Returns
void
resetValue()
resetValue(index): void;Defined in: components/Material.ts:238
Parameters
| Parameter | Type |
|---|---|
index | number |
Returns
void
setMaterialType()
setMaterialType(index, type): void;Defined in: components/Material.ts:254
Parameters
| Parameter | Type |
|---|---|
index | number |
type | MaterialTypeValue |
Returns
void
setTextureFiltering()
setTextureFiltering(index, filtering): void;Defined in: components/Material.ts:258
Parameters
| Parameter | Type |
|---|---|
index | number |
filtering | TextureFilteringValue |
Returns
void
setUseMipmaps()
setUseMipmaps(index, enabled): void;Defined in: components/Material.ts:262
Parameters
| Parameter | Type |
|---|---|
index | number |
enabled | boolean |
Returns
void

