Importing GLB from a GitHub repository

Hi,

In previous version of observable I was importing a GLB file from my github repository.
https://observablehq.com/@ferrari212/section-2-6-inserting-gltf-and-creating-a-more-realistic-mod

This is the peace of the code I used before, where the boatPath is the url pointing to the source:

{
  loaderGLTF.load(
    boatPath,
    (gltf) => {
      var shipGLTF = gltf.scene;
      shipGLTF.rotation.x = Math.PI / 2;
      shipGLTF.rotation.y = -Math.PI / 2;
      shipGLTF.position.set(-1, 0, 0);
      shipGLTF.name = "ModelGLTF";

      if (shipGLTF.material) {
        shipGLTF.material.side = THREE.DoubleSide;
      }

      scene.add(shipGLTF);
    },
    (xhr) => {
      mutable loaderPecentage = (xhr.loaded / 31780028) * 100;
    }
  );
}

In the newer version, however, I am not able to import it and by checking the console I noticed I receive a CORS issue problem and error 200. I want to know if there is a new procedure to import it from another source than observable. I saw some solutions using FileAttachment but I would rather prefer to keep with the one I am using.

Regards,
Felipe

CORS Proxy fetchp / Tom Larkworthy / Observable (remember to publish and wait a few seconds)

You don’t need a CORS proxy. Just use the following path:

https://raw.githubusercontent.com/ferrari212/vesseljs/master/examples/3D_models/GLTF/Gunnerus.glb

I would also recommend to pin the file to the current version by replacing /master/ with /3624e9c/ (the file’s most recent commit ID).


Note that your current boatPath points to Github’s web interface showing the file, not the file itself. I suspect this is not the actual path used in your original code?

oops, my bad, yeah CORS bypass not required for Github. I did not comprehend the context properly.

Hi @mootari and @tomlarkworthy ,

Thanks for the help. Yes, in fact the url I was pointing was wrong. I had to request from a github open site instead of my own repo:
https://ferrari212.github.io/vesseljs/examples/3D_models/GLTF/Gunnerus.glb

Thanks for the help!