Preloader problem

Hello friends so I have built a simple preloader for my assets using a global var loaderGL = 0;
and then when a model is loaded and textures etc I do this:

if (child1.isMesh) {

if (child2.isMesh) {

Now the loaderGL count for me ends on 31 so everything is loaded when it hits 31
and then I do this to remove the preloader:

         function animate() {
                        if (loaderGL === 31) {
        				console.log('Assets Loader:',loaderGL);
                            $(".logo-load").fadeTo(200, 0.0);
                            $("#start").css("opacity", "1.00");
                            $("#start").css("opacity", "1.00");
                            $(".start .intro-open").removeClass("intro-close");
                            $(".start .page-full").css("pointer-events", "auto");
                            setTimeout(function () {
                                $(".start .page-wrapper-para").addClass("opacity-open");
                            }, 1000);

                            setTimeout(function () {
                                $(".start .page-wrapper-title").addClass("opacity-open");
                            }, 1250);

                            setTimeout(function () {
                                $(".start .page-wrapper-ts").addClass("opacity-open");
                            }, 1500);

                            setTimeout(function () {
                                $(".start .buttn").addClass("opacity-open");
                            }, 1750);

Now apparently when I have shown a few people this project online the preloader doesn’t get removed so I am wondering if the count of 31 is wrong?? or is it another issue?

Here is the full UNFINISHED project so you can have a look at the preloader:

thank you for reading

Perhaps a thing fails to load, maybe a texture too large for the GPU or something… You have no fall back.

How about this:

const loader = ( loadList ) => {
  if( loadList.length > 0 ) {
    //show preloader
    let loadable = loadList.pop();
    gltf.load( loadable , (object) => {
      scene.add( object.scene );
      loader( loadList );
  else {
loader( ['object1.glb','object2.glb'] );

An alternative approach is to use the threeJS THREE.LoadingManager and track the number of items which have started loading vs those which have completed - this is what I usually use myself, it uses an event based approach which I prefer for this kind of thing.

1 Like

Thanks for the reply is there a way to detect which texture might be the issue?
also it would be interesting to know if the project loaded for you?

  1. It seems to load and is pretty :smiley:
  2. Ask these few people to look into logs. It might be some device specific issues, or simply a slow network.
  3. As @becky_rose said:

First, there are some limitations in WebGL regarding texture sizes (although if that’d fail, it’d likely fail for most users at once.)
Second, if someone runs your app on mobile and you allocate too many resources at once - the device might still let you download all the resources, but some of them will not be allocated (applies to both ArrayBuffers and Images). In this case loader onError callback will be fired - you can add a listener there for debugging.

1 Like