Mesh
Renders a custom triangle mesh from raw vertex data — the escape hatch for geometry the built-in primitives (Cube, Sphere, Plane, Cylinder) don't cover (procedural terrain, generated meshes, imported non-glTF geometry).
Vertices are non-interleaved: positions (xyz triples), normals (xyz triples), and uvs (uv pairs) are parallel arrays addressed by indices (a flat list of triangle corner indices, 3 per triangle). The tangent frame Filament's LIT shaders need is derived automatically from the normals, UVs, and topology — supply correct normals and UVs.
Geometry arrays are compared by content: re-creating identical arrays on recomposition is safe (no GPU re-upload); changing any element re-uploads the buffers and rebuilds the renderable. Still prefer remember-ing large arrays to skip the comparison cost.
Mesh(
material = myMaterial,
positions = floatArrayOf(/* x,y,z, … */),
normals = floatArrayOf(/* x,y,z, … */),
uvs = floatArrayOf(/* u,v, … */),
indices = intArrayOf(0, 1, 2, /* … */),
)Parameters
Material applied to the whole mesh, or null while it is still loading.
Vertex positions as xyz triples. Length must be a multiple of 3.
Per-vertex normals as xyz triples. Must match positions in length.
Per-vertex UVs as uv pairs. Length must be 2 * vertexCount.
Triangle indices (32-bit). Length must be a multiple of 3.
World-space position of the pivot point.
World-space rotation. Build one with Rotation.axisAngle/Rotation.euler.
Per-axis scale.
Mesh-space point that rotation/scale revolve around and that ends up at position. Defaults to the mesh origin.
AABB used for frustum culling. Defaults to one computed from positions. Provide an explicit box if you skip culling or animate vertices beyond the static bounds.
Whether this renderable is in the scene. False removes it from the scene (cheaply, keeping the entity alive) — a show/hide toggle without losing state.
Whether the mesh casts shadows onto other renderables. On by default.
Whether the mesh receives shadows cast by others. On by default.
Runs once when the mesh enters the scene, with the renderable entity and engine in scope (EntityScope) — use it to register the mesh with view.pick callbacks or other entity-keyed maps.