Skip to content

Mesh.cloneWithMaterial

Summary

Mesh.cloneWithMaterial operates on a Mesh runtime object to update state, query data, or manage lifecycle.

Syntax

Mesh.cloneWithMaterial(material: Material): Mesh
const result = mesh.cloneWithMaterial(material);

Parameters

Name Type Required Description
material Material Yes Material instance that controls shading, blending, and uniforms.

Returns

Mesh - Mesh runtime object ready for scene attachment and rendering.

Type Details

// No additional descriptor expansion is required for this signature.

Example

const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);

const geometry = wgpu.geometry.box(1, 1, 1);
const material = wgpu.material.unlit({ color: [0.9, 0.6, 0.2], opacity: 1.0 });
const mesh = wgpu.createMesh(geometry, material);
const result = mesh.cloneWithMaterial(material);
console.log(result);

See Also