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.
Extends
Section titled “Extends”Properties
Section titled “Properties”entityId
Section titled “entityId”
readonlyentityId:number
Identifier that stays the same for the entity’s lifetime, including across undo and redo.
Inherited from
Section titled “Inherited from”isDeleted
Section titled “isDeleted”
readonlyisDeleted:boolean
Whether the entity was deleted, for example by an edit or by undo.
Inherited from
Section titled “Inherited from”isValid
Section titled “isValid”
readonlyisValid:boolean
Whether the entity still exists in the model.
Inherited from
Section titled “Inherited from”metallic
Section titled “metallic”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
Section titled “roughness”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.
readonlytype:"Material"
The concrete class name, for narrowing unions such as AnyElement.
Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get color():
Color
Red, green, blue and alpha, each from 0 to 1. Assigning accepts a color without a,
which is then 1.
Returns
Section titled “Returns”Set Signature
Section titled “Set Signature”set color(
value):void
Parameters
Section titled “Parameters”Color | { a?: number; b: number; g: number; r: number; }
Returns
Section titled “Returns”void
texture
Section titled “texture”Get Signature
Section titled “Get Signature”get texture():
Required<Texture> &object|null
The material’s image and the size of one repeat, or null. Assign null to remove it.
Returns
Section titled “Returns”Required<Texture> & object | null
Set Signature
Section titled “Set Signature”set texture(
value):void
Parameters
Section titled “Parameters”Texture | null
Returns
Section titled “Returns”void
Methods
Section titled “Methods”getMap()
Section titled “getMap()”getMap(
kind):Uint8Array<ArrayBufferLike> |null
Returns the bytes of the material’s map of this kind, or null. Needs the
"materialSurface" feature.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Uint8Array<ArrayBufferLike> | null
setMap()
Section titled “setMap()”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.
Parameters
Section titled “Parameters”ArrayBuffer | Uint8Array<ArrayBufferLike> | null
Returns
Section titled “Returns”void
toJSON()
Section titled “toJSON()”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" }.
Returns
Section titled “Returns”object
entityId
Section titled “entityId”entityId:
number
optionalname?:string
type:
"Material"|"Vertex"|"Edge"|"Face"|"Loop"|"EdgeUse"|"Curve"|"ArcCurve"|"ComponentDefinition"|"ComponentInstance"|"Group"|"Layer"|"Guide"|"Text"|"LinearDimension"|"SectionPlane"