MCPcopy Create free account
hub / github.com/EaseCation/cube-3d-text / textureToDataURL

Function textureToDataURL

src/utils/debug.ts:4–11  ·  view source on GitHub ↗
(texture: THREE.Texture)

Source from the content-addressed store, hash-verified

2
3// Function to convert THREE.Texture to data URL
4const textureToDataURL = (texture: THREE.Texture): string => {
5 const image = texture.image as HTMLImageElement | HTMLCanvasElement;
6 const canvas = document.createElement("canvas");
7 canvas.width = image.width;
8 canvas.height = image.height;
9 const context = canvas.getContext("2d")!;
10 context.drawImage(image, 0, 0);
11 return canvas.toDataURL();
12};
13
14// Function to display the texture on the page

Callers 1

displayTextureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected