Skip to content

snapshotToTexture(...)

Studio is being deprecated, please head over to the documentation page for Mattercraft, our most advanced 3D tool for the web, where you can find the most recent information and tutorials.

snapshotToTexture(reuse? : Z.DataTexture, callback?: ((tex : Z.DataTexture) => void)) : void;

Takes a snapshot(…) but instead of showing the save/share dialog, places the snapshot into a Z.DataTexture that can be used as a skin or material.

ParameterTypeDescription
reuseoptional, Z.DataTextureThe DataTexture the snapshot will be placed in. If one isn’t provided, a new one will be allocated.
callbackoptional, functionThe function will be called once the snapshot has been taken, and the argument will be the DataTexture that was filled.

It is recommended to reuse DataTextures to avoid allocating large amounts of memory with new DataTextures.

The example below shows an existing DataTexture being reused and used as the skin for a plane.

const myPlane = symbol.nodes.myPlane;
let myDataTexture = Z.DataTexture();
Z.device.snapshotToTexture(myDataTexture, () => {
myPlane.skin(myDataTexture);
});

The example below shows a DataTexture being allocated and used as the skin for a plane.

const myPlane = symbol.nodes.myPlane;
Z.device.snapshotToTexture(undefined,(texture) => {
myPlane.skin(texture);
});