Repository navigation
API Class MeshRenderer
Defined in: src/engine/render/components.ts:373
Draws a mesh with a material (ADR 0043, 0044). mesh is a model asset (asset:models/robot.fbx
draws all its meshes, asset:models/robot.fbx#Body one of them) or a built-in mesh
(builtin:cube, sphere, capsule, cylinder, plane, quad). Meshes are lit by the
World's Lights; a World with no Light gets a default sun and ambient light.
new MeshRenderer(): MeshRenderer;MeshRenderer
castShadows: boolean = true;Defined in: src/engine/render/components.ts:388
Cast shadows from Lights with castShadows on.
material: string = "";Defined in: src/engine/render/components.ts:379
A material asset (asset:materials/wood.material.json). Empty: the model's own materials,
or the default material (white, lit) for meshes without one.
materials: string[] = [];Defined in: src/engine/render/components.ts:386
A material asset per material slot (ADR 0089), drawn in place of material for that slot.
The slots are the model's own materials, in the order its meshes first use them (a built-in
mesh has one); an empty entry, or none, leaves the slot to material, then to the model's
import settings, then to the model's own material.
mesh: string = "builtin:cube";Defined in: src/engine/render/components.ts:374
receiveShadows: boolean = true;Defined in: src/engine/render/components.ts:390
Show shadows cast onto it.
variant: string = "";Defined in: src/engine/render/components.ts:396
The model's material variant to draw (glTF KHR_materials_variants, ADR 0118), by name; empty
draws the file's default materials. It changes only slots drawing the model's own material: a
slot with a material asset keeps it. The choices are variants.
get enabled(): boolean;Defined in: src/engine/core/Component.ts:57
boolean
set enabled(value): void;Defined in: src/engine/core/Component.ts:61
boolean
void
get gameObject(): GameObject;Defined in: src/engine/core/Component.ts:37
Unity-style alias for node.
get isActiveAndEnabled(): boolean;Defined in: src/engine/core/Component.ts:68
True when enabled, the node is active in the hierarchy, and the node is in a loaded world.
boolean
get materialInstance(): Material;Defined in: src/engine/render/components.ts:472
Slot 0's own Material (Unity's renderer.material; getMaterialInstance(0)).
get node(): GameObject;Defined in: src/engine/core/Component.ts:32
The node this component is on.
get owner(): GameObject;Defined in: src/engine/core/Component.ts:45
The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).
get sharedMaterial(): Material | null;Defined in: src/engine/render/components.ts:463
The Material slot 0 draws (getSharedMaterial(0)); assigning sets slot 0 (setSharedMaterial(0, m)). A renderer without material slots has only slot 0, drawn by every mesh.
Material | null
set sharedMaterial(m): void;Defined in: src/engine/render/components.ts:467
Material | null
void
get sharedMaterials(): (Material | null)[];Defined in: src/engine/render/components.ts:481
Every slot's Material (Unity's sharedMaterials): slot 0, then the slots materials lists or
Materials were assigned to. The model decides how many slots it has (ADR 0089); a slot past the
list draws material.
(Material | null)[]
set sharedMaterials(ms): void;Defined in: src/engine/render/components.ts:486
readonly (Material | null)[]
void
get time(): Readonly<TimeState>;Defined in: src/engine/core/Component.ts:93
This component's World's clock (ADR 0032): the same values as Time, but safe to read
outside the World's frame too (after an await, say).
Readonly<TimeState>
get transform(): Transform;Defined in: src/engine/core/Component.ts:51
The Transform of the node this component is on, if it has one.
get variants(): readonly string[];Defined in: src/engine/render/components.ts:399
The names of the material variants the model offers (ADR 0118): empty until it has loaded, or for a model without variants.
readonly string[]
get world(): WorldHandle;Defined in: src/engine/core/Component.ts:82
A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load
a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json").
Throws for a World no Engine owns.
clearMaterialProperties(slot?): void;Defined in: src/engine/render/components.ts:552
Go back to the material's own values for every property (of the slot slot, or, without it, the whole renderer's).
number
void
clearMaterialProperty(name, slot?): void;Defined in: src/engine/render/components.ts:540
Go back to the material's own value for one property.
string
number
void
getMaterialInstance(slot?): Material;Defined in: src/engine/render/components.ts:453
Slot slot's own Material (Unity's renderer.materials[i], ADR 0107): made on first access as a
copy of the slot's shared Material (its values at that moment), then kept. It draws apart from the
instanced batch of its mesh. A slot without a material asset gets an instance of the default lit material.
number = 0
getMaterialProperty(name, slot?):
| MaterialPropertyValue
| undefined;Defined in: src/engine/render/components.ts:535
The value set with setMaterialProperty, or undefined when the material's own value is used.
string
number
| MaterialPropertyValue
| undefined
getSharedMaterial(slot?): Material | null;Defined in: src/engine/render/components.ts:434
The Material slot slot draws (ADR 0107): its material asset's shared Material (changing it
changes every renderer drawing that asset), or a Material assigned to the slot. Null when the slot
has no material asset (the model's own material).
number = 0
Material | null
instantiate(prefabPath, options?): GameObject;Defined in: src/engine/core/Component.ts:103
Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate.
Use it in code that may run after an await: by then the frame is over and the current World
is the Engine's default one, which may not be this component's. A parent from another
World throws.
string
InstantiateOptions = {}
setMaterialProperty(
name,
value,
slot?
): void;Defined in: src/engine/render/components.ts:521
Override one of the material's properties for this renderer only (ADR 0049), like Unity's
MaterialPropertyBlock: the material asset and other renderers are unchanged. Names are a
shader graph's property names, or color, emission, metalness, roughness and
texture for the built-in lit and unlit materials. A texture is an asset path.
With slot (ADR 0371: an animation's materials[slot].<name> track), the override is for that material slot
only, whatever draws it (the model's own material included), and the built-in names also take the glTF
ones: alphaCutoff, normalScale, occlusionStrength, clearcoatNormalScale, dispersion,
attenuationColor, attenuationDistance, iridescenceThicknessMinimum, iridescenceThicknessMaximum and
textureTransform.offset, .scale and .rotation. A slot's colours are linear (as a model surface holds
them), not sRGB.
string
number
void
setSharedMaterial(slot, m): void;Defined in: src/engine/render/components.ts:442
Draw m in slot slot: a shared Material sets the slot's asset path; an instance is drawn as it is (renderers may share one). Null clears the slot.
number
Material | null
void
This wiki is generated from docs/wiki/ and the myco module's source on every push to master. Change pages there in a pull request: edits made here are not kept.
Basics
Gameplay
Rendering
Audio
- Playing sound
- Why is there no sound?
- Playlists
- Interactive music
- Sound generators
- Spatial audio
- Audio mixer
- Live mixing
- Loudness
- Audio profiler
- Audio takes
Reference