Skip to content

Vibe coding a plugin? Teach your agent Modlumi first. Works with Claude Code, Codex, Cursor and more.

Material

A named color, optionally with an image, that faces and containers can use. Create one with Model.addMaterial; change its properties inside Model.operation.

readonly entityId: number

Identifier that stays the same for the entity’s lifetime, including across undo and redo.

Entity.entityId


readonly isDeleted: boolean

Whether the entity was deleted, for example by an edit or by undo.

Entity.isDeleted


readonly isValid: boolean

Whether the entity still exists in the model.

Entity.isValid


metallic: number

How metallic the surface is in PBR shading, from 0 for paint, wood, stone and plastic to 1 for bare metal; 0 by default. A metallic map, when there is one, replaces it. Needs the "materialSurface" feature.


name: string

Material name; names needn’t be unique.


roughness: number

How rough the surface is in PBR shading, from 0 for a mirror polish to 1 for fully matte; 0.7 by default. A roughness map, when there is one, replaces it. Needs the "materialSurface" feature.


readonly type: "Material"

The concrete class name, for narrowing unions such as AnyElement.

Entity.type

get color(): Color

Red, green, blue and alpha, each from 0 to 1. Assigning accepts a color without a, which is then 1.

Color

set color(value): void

Color | { a?: number; b: number; g: number; r: number; }

void


get texture(): Required<Texture> & object | null

The material’s image and the size of one repeat, or null. Assign null to remove it.

Required<Texture> & object | null

set texture(value): void

Texture | null

void

getMap(kind): Uint8Array<ArrayBufferLike> | null

Returns the bytes of the material’s map of this kind, or null. Needs the "materialSurface" feature.

MaterialMapKind

Uint8Array<ArrayBufferLike> | null


setMap(kind, image): void

Sets or, with null, removes a map inside Model.operation: the bytes of a PNG or JPEG file of at most 32 MiB. Maps follow the image’s placement and repeat, or repeat every meter without one. Metallic, roughness and opacity maps use their red channel; normal maps use the OpenGL convention, with green toward the top of the image. Opacity multiplies the material’s alpha. Needs the "materialSurface" feature.

MaterialMapKind

ArrayBuffer | Uint8Array<ArrayBufferLike> | null

void


toJSON(): object

JSON.stringify writes the entity as its type and entityId, plus its name when it has one, such as { "type": "Group", "entityId": 12, "name": "Wheel" }.

object

entityId: number

optional name?: string

type: "Material" | "Vertex" | "Edge" | "Face" | "Loop" | "EdgeUse" | "Curve" | "ArcCurve" | "ComponentDefinition" | "ComponentInstance" | "Group" | "Layer" | "Guide" | "Text" | "LinearDimension" | "SectionPlane"

Entity.toJSON