@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 ​
new MaterialComponent(materialOrMaterials?): MaterialComponent;Defined in: components/Material.ts:254
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
materialOrMaterials | Material<MaterialEventMap> | Material<MaterialEventMap>[] | [] |
Returns ​
MaterialComponent
Overrides ​
Properties ​
| Property | Type | Description | Defined in |
|---|---|---|---|
materials | Material<MaterialEventMap>[] | Live three.js materials currently bound to the entity's mesh (one per submesh). | components/Material.ts:239 |
material | Material<MaterialEventMap> | null | Convenience reference to materials[0]. null when no material is assigned. | components/Material.ts:241 |
values | MaterialValueState[] | 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() ​
setAssetRef(index, url): void;Defined in: components/Material.ts:265
Link/unlink a slot to a material asset URL (editor bookkeeping only).
Parameters ​
| Parameter | Type |
|---|---|
index | number |
url | string | null |
Returns ​
void
getAssetRef() ​
getAssetRef(index): string | null;Defined in: components/Material.ts:276
The material-asset URL a slot is linked to, or null when local.
Parameters ​
| Parameter | Type |
|---|---|
index | number |
Returns ​
string | null
setMaterials() ​
setMaterials(materialOrMaterials?): void;Defined in: components/Material.ts:280
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
materialOrMaterials | Material<MaterialEventMap> | Material<MaterialEventMap>[] | [] |
Returns ​
void
updateValue() ​
updateValue(index, patch): void;Defined in: components/Material.ts:296
Parameters ​
| Parameter | Type |
|---|---|
index | number |
patch | Partial<MaterialValueState> |
Returns ​
void
resetValue() ​
resetValue(index): void;Defined in: components/Material.ts:311
Parameters ​
| Parameter | Type |
|---|---|
index | number |
Returns ​
void
setMaterialType() ​
setMaterialType(index, type): void;Defined in: components/Material.ts:327
Parameters ​
| Parameter | Type |
|---|---|
index | number |
type | MaterialTypeValue |
Returns ​
void
setTextureFiltering() ​
setTextureFiltering(index, filtering): void;Defined in: components/Material.ts:331
Parameters ​
| Parameter | Type |
|---|---|
index | number |
filtering | TextureFilteringValue |
Returns ​
void
setUseMipmaps() ​
setUseMipmaps(index, enabled): void;Defined in: components/Material.ts:335
Parameters ​
| Parameter | Type |
|---|---|
index | number |
enabled | boolean |
Returns ​
void

