icosa-foundation / icosa-gallery

Icosa Gallery is a 3D model hosting solution, intended as a replacement for Google's Poly
https://icosa.gallery
Apache License 2.0
9 stars 0 forks source link

Replicate the way the existing version decided which loader to use #18

Closed andybak closed 5 months ago

andybak commented 5 months ago

Either

await viewer.loadGltf("foo.gltf", true);

or

await viewer.loadGltf1("foo.gltf");

We currently always seem to do the first one but we should be detecting GLTF1 files and using the second.

andybak commented 5 months ago

here's the existing logic:

  static getPreferredFormat = (asset) => {
    let types = {}

    for (const newformat of asset.formats) {
      types[newformat.format] = newformat
    }

    if(types.hasOwnProperty("GLTF2")) {
      return types["GLTF2"]
    }

    if(types.hasOwnProperty("GLTF")) {
      return types["GLTF"]
    }

    if(types.hasOwnProperty("TILT")) {
      return types["TILT"]
    }

    return null
  }
}

So I think it just checks "formats" for an entry of type GLTF2 first. If it's there it uses the new loader. If not it assumes it's the old format.

andybak commented 5 months ago

Here's a good example to test it's working: /view/kevo/y7m0Evyso48/

jamesrampton commented 5 months ago

https://icosa-api-django.ixxy.co.uk/view/kevo/y7m0Evyso48/ LGTM

andybak commented 5 months ago

me too