Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit44fd9e59bd

README.md

Model

Loads and displays a 3D mesh on an entity. Disabling the component hides the mesh. Supports procedural meshes (cube, sphere, ...), model files, and remote URLs. Tint and outline are shader effects applied to the mesh.

Material lives on this component. There is no standalone Material component — a material only renders where there is a mesh to render it on, so the material field is part of Model (and SkinnedModel). Set it at add time or assign the field later; properties are registry-wide.

Public fields: model, material (AssetRef<material>), tintR/G/B, tintBlend, outlineR/G/B, outlineIntensity.

Methods: :setTint(color, blend?) (color: {r, g, b} array or {r=, g=, b=} map), :clearTint(), :setOutline(color, intensity?), :clearOutline(), :setMaterialProperty(prop, value), :getMaterialProperty(prop), :getMaterialPropertyNames().

entity(id).component.add("Model", { model = "cube", material = "gold" })
entity(id).component.get("Model").material = "checkerboard"   -- swap material
entity(id).component.get("Model"):setTint({1, 0, 0}, 0.5)
entity(id).component.get("Model"):setMaterialProperty("roughness", 0.2)

Tint is synced. Every tint* field replicates, so :setTint is the colour every participant sees. A colour that changes every frame on many entities (a stress map, a heat map, a damage flash, per instance colour) belongs in an instance-data lane instead: wear @builtin::materials.instance_color (or instance_color_unlit) and write renderer.instanceData.set(id, 2, r, g, b, coverage), which replicates nothing and costs about a twentieth of a tint write. guides { path = "topics/rendering-instance-data" } has the lane layout.