Draco decoder & KTX local offline path being ignored in gltf-progressive.js in Needle Unity 4.2.2

I think your conclusion isn’t right and the draco loading errors are misleading.

The draco loader is loading from your local path.

For example if I change the URL to something arbitrary it totally fails to load even the base scene.

I think I need more details when this happens: in some projects it prevents models from loading properly when offline

What I see as an suspicios log in your project is the following - I assume the background gradient / horizon falloff is a texture?

I can share a separate project that is also small that this happens with, when running offline the errors show and the main model in the scene doesn’t load. The texture it can’t load is a material on the plane in the scene with a texture on it

Other bug report sent, it is the other project that I noticed the issue with, it is like any model with textures fails to load usually when offline despite KTX2 and Draco paths being set to Include folder.

In that build, offline it can’t load any textures basically:

When online, it loads fine:

This project was built to run offline and it used to run fine offline in an older Needle Engine version at Needle 3.49.0-pre for Unity, now upgraded to 4.2.2 it doesn’t load KTX2 or Draco offline using the properties set in index.html.

I can fix this issue by changing these lines in assets/gltf-progressive#######.js from:

let ee = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/",
  oe = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
const je = ee,
  et = oe,
  tt = new URL(ee + "draco_decoder.js");
fetch(tt, { method: "GET", headers: { Range: "bytes=0-1" } })
  .catch((o) => {
    ee === je && (ee = "./include/draco/"),
      oe === et && (oe = "./include/ktx2/");
  })
  .finally(() => {
    Re();
  });

to:

let ee = "../include/draco/",
  oe = "../include/ktx2/";
const je = ee,
  et = oe;

// Get the current script's URL to serve as a base
const scriptUrl = new URL(import.meta.url); // or window.location.href if not in a module
// Correct way to create the URL with a base url.
const tt = new URL(ee + "draco_decoder.js", scriptUrl);

fetch(tt, { method: "GET", headers: { Range: "bytes=0-1" } })
  .catch((o) => {
    ee === je && (ee = "./include/draco/"),
      oe === et && (oe = "./include/ktx2/");
  })
  .finally(() => {
    Re();
  });

Is there something I am doing wrong here? The fix for assets/gltf-progressive#######.js shows that the build can run offline:

Screenshot of the same build with the hotfix above while running offline and cache cleared:

I hope this is reproducible in the bug report projects?

Looking into it now

1 Like

Fixed in 4.2.3