snapshotToTexture(...)
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.
Parameters
Parameter | Type | Description |
---|---|---|
reuse | optional, Z.DataTexture | The DataTexture the snapshot will be placed in. If one isn't provided, a new one will be allocated. |
callback | optional, function | The 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.
Examples
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);
});