(texture: THREE.Texture)
| 2 | |
| 3 | // Function to convert THREE.Texture to data URL |
| 4 | const 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 |