Appearance
Material
Chainable builder for an inline material. Seven kinds: unlit, pbr, occlusion, customShader, materialX, video, transmission. Use the matching factory (Material.unlit({...}), etc.) or new Material(kind).
Properties map to the underlying material data model with web-standard names: - Colors: color, emissive, sheenColor, specularColor – flat tint. - Maps: map, emissiveMap, roughnessMap, metalnessMap, normalMap, aoMap, specularMap, sheenMap, clearcoatMap, alphaMap – textures accept either a URL/asset-id string or { texture, scale }. - Scalars: roughness, metalness, clearcoat, opacity, emissiveIntensity. - Rendering: opaque, transparent, opacityThreshold, blendMode, faceCulling, wireframe, writesDepth, readsDepth.
Static Methods
unlit()
javascript
Material.unlit(opts?: Object): MaterialFlat-shaded material. Renders the surface color regardless of scene lighting – useful for UI, billboards, vertex-colored point clouds, etc.
Parameters:
opts(Object) (optional) - Any chainable setter name as a key:color,map,opacity,alphaMap,disableToneMapping,faceCulling,blendMode,wireframe,target,name.
Returns: Material
pbr()
javascript
Material.pbr(opts?: Object): MaterialPhysically-Based material – the realistic-rendering default for surfaces that should respond to scene lighting.
Parameters:
opts(Object) (optional) -color,map,emissive,emissiveMap,emissiveIntensity,metalness,metalnessMap,roughness,roughnessMap,normalMap,aoMap,sheenColor,sheenMap,specularColor,specularMap,clearcoat,clearcoatMap,opacity,alphaMap,opacityThreshold, plus rendering state.
Returns: Material
occlusion()
javascript
Material.occlusion(opts?: Object): MaterialOcclusion material – invisible itself but hides geometry behind it. Use for matte holdouts, real-world geometry masks, portals.
Parameters:
opts(Object) (optional) -receivesDynamicLighting,faceCulling.
Returns: Material
customShader()
javascript
Material.customShader(opts?: Object): MaterialCustom shader material – author-supplied surface shader and/or geometry modifier from a compiled shader library.
Parameters:
opts(Object) (optional) -shaderLibrary,lightingModel,surfaceShader,geometryModifier, plus general rendering state.
Returns: Material
materialX()
javascript
Material.materialX(opts?: Object): MaterialMaterialX material from a bundled .usdz. Reference by file path plus the /Root/<MaterialName> path inside.
Parameters:
opts(Object) (optional) - Typically use.materialXAsset(urlOrId, name)followed by.setParameter(name, value, typeHint?)calls.
Returns: Material
video()
javascript
Material.video(): MaterialVideo texture material. Use .videoSource(urlOrId) for the playback source and .videoOptions({ loops, streamContent, volume }) for playback config.
Returns: Material
transmission()
javascript
Material.transmission(opts?: Object): MaterialTransmission material – glass, water or ice that refracts the scene behind it. Refracts on iPhone, iPad and Mac; on Apple Vision Pro it draws tinted and frosted, without refraction.
Example:
javascript
const glass = Material.transmission({
transmissionOptions: { ior: 1.5, thickness: 0.4, roughness: 0.1 },
faceCulling: 'none'
});Parameters:
opts(Object) (optional) -transmissionOptions, plus rendering state such asfaceCulling.
Returns: Material
Instance Methods
opacity()
javascript
opacity(): voidMaterial opacity. Values < 1 also flip isOpaque to false so the blending state matches.
Returns: void
transmissionOptions()
javascript
transmissionOptions(): voidTransmission settings. Every key is optional and keeps its default when left out: ior (1 to 2.333, default 1.5), thickness (fraction of the object's largest side, 0.4), roughness (0 clear to 1 frosted, 0.25), dispersion (0), distortion (0), distortionScale (0.5), temporalDistortion (0), attenuationColor and tint (colors, white), attenuationDistance (fraction of the largest side, 0 = no absorption), specular (0), clearcoat (0), lit (default true).
Returns: void
shaderTexture()
javascript
shaderTexture(name: string, texture: string | Texture | any): MaterialBind a texture to one of a shader's named texture slots: a slot in an authored shader's header, or a texture input of a MaterialX material. Takes the same inputs as .map(), and a dynamic texture keeps updating in the slot, so a video or camera feed drives the shader frame by frame.
Example:
javascript
const clip = await Texture.video('clip.mp4');
await entity.representation.setMaterial(
scene.getMaterial('glitchShaderMaterialId').clone().shaderTexture('image', clip)
);Parameters:
name(string) - The slot's name.texture(string | Texture | any) - URL, asset id or texture handle.
Returns: Material
materialXAsset()
javascript
materialXAsset(): voidMaterialX: URL or asset id of the .usdz, plus the path to the material inside it (e.g. "/Root/MyMaterial").
Returns: void
setParameter()
javascript
setParameter(name: string, value: any, typeHint?: Object): MaterialSet a constant value on a shader parameter. Works on customShader and materialX kinds – routes to the right options blob automatically. Warns and no-ops on kinds without shader parameters.
For runtime variable bindings, use entity.representation.bindMaterialParameter(name, variableId, opts?).
Example:
javascript
Material.materialX().materialXAsset('myAsset', '/Root/MyMat')
.setParameter('intensity', 0.6)
.setParameter('tintColor', '#FF00FF', { type: 'color' });Parameters:
name(string) - Material parameter name (case-sensitive, must match the name the material exposes).value(any) - Number, boolean, string, array (vec2/3/4), color-like object ('#RRGGBB',{r,g,b,a?},{colorSpace,hex}), or aTransformfor a Matrix parameter, which receives its 4×4 matrix. The matrix holds position, rotation and scale only, so it carries no shear.typeHint(Object) (optional) - Override inferred type:{ type: "float" | "int" | "vector2" | "vector3" | "vector4" | "matrix4x4" | "color" | "boolean" | "string" }.
Returns: Material
clone()
javascript
clone(): voidDeep-copy the material with a fresh id. Use for the get → clone → tweak → apply pattern when overriding a library material for a single entity without mutating the library entry.
Returns: void
toString()
javascript
toString(): voidUseful per-kind summary for console.log(mat) – includes kind, id, name, and the meaningful state set on the material (channel colors, scalar values, shader params, etc.) so authors can see "what's on this material" at a glance. For the full serialized shape, use JSON.stringify(mat, null, 2).
Returns: void