Reduce 4k texture 3dmodels size

Hello everyone
I faced with contextlost error
How can I reduce the size of some 3dmodel’s texture Programmatically?
Some of them are 4k
Can you help me for solving these rproblems
Shader Error
ContextLost webgl
ShaderSource

Ideally, you downscale textures offline with a tool.

If you have to do it programmatically, you can use a canvas element for this task. Meaning you create a new canvas object, define the desired dimensions and the copy the original texture to the canvas. This approach is used inside the renderer for resizing textures. I suggest you have a closer look at the following code section: