How does JS load pictures blocked by Synchronize?

problem description

if we load a picture, we often write:

class Car {
    constructor() {
        // load shader
        // load texture
    }
    draw() {
        // use shader and texture to render
    }
}

is loaded in the constructor, while draw depends on the completion of loading in the constructor. Consider using Promise , but it"s a shame that I"m not familiar with Promise . And I"m not sure if it can be used with webgl .
if anyone understands and answers, thank you very much!

Mar.29,2021

download pictures blocked by XHR, and then generate data uri or blob url, settings from blob

.

it doesn't really do any good..


there seems to be no way to use Synchronize's ajax to get image data and assign values to img, but why Synchronize?


you can new Image after onload


later, when the subject reconstructs the code, choose to load all the material concurrently with Promise at the beginning, and then start rendering, and then all the logic will be done in series.


Recursive.

Menu