Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

GLTF Loader: Setup

willneedit edited this page Jan 9, 2019 · 8 revisions

GLTF-Loader

A.K.A. I've got that nifty object I want to put on display, how can I put it up without too much hassle?

Setup

It's easy. Let's say you have an object residing at https://willneedit.github.io/misc/Drider_Baking.glb (yup, that's the monster I've put on display in my homespace), you'd need to create an MRE and use the following URL to configure it.

ws://willneedit-mre.herokuapp.com/app?name=gltf&gltf=https://willneedit.github.io/MRE/misc/Drider_Baking.glb

Protip: Use the 2D mode to put it down. Easier to deal with typos that way.

Cool, is there more to it?

If you have an animated model using bone/armature animation, it might be possible to put it on display as well. Add &animate (or &animate=animationName if your animation has a distinct name) to the end of the URL, and it should work.

I've found that cool thing on the 'net and...

Hold a second. Make sure of the following:

  1. Is it your artwork? Did you sculpt/build it? Then it's okay.
  2. Does the author allow to download and redistribute it in accordance to your intended purpose? If you want to promote something with it and the author only allows non-commercial usage, it'd be NOT okay.
  3. Does the author allow to put it on display in your webpage in accordance to your intended purpose? Same thing.

If you come here and cannot answer one of the above points with 'then it's okay', DON'T. Putting up artwork you don't hold copyrights over and you don't have the permission to use could get you in legal trouble, on top of being a breach in Altspace's TOS.

It goes without saying that it's about the same rules which apply to photos being uploaded and put on display within Altspace.

Troubleshooting

Doesn't show anything at all

Errors regarding the loading of the objects are completely disregarded by now. They're already working on it. But if you see nothing, it's most probably because there's an error in the object's URL you provided or the hosting server is down. Though, if you're sure the URL is correct and you can download the model using your browser, see below.

The object can be downloaded in the browser, but still doesn't show

The hosting service deploying your object needs to allow CORS (Cross origin requests). Github Pages do allow those, that's why this works for the example, but other sites may not. There are several things you can try:

  1. Look at your account settings of the site you host the model from and see if there is a setting to allow cross-origin requests and turn it on.
  2. Bug your provider's admin to have this setting turned on for you (Depends on the provider)
  3. Look for a different file provider which would allow CORS.
  4. (programming skills needed) Take the snippet from https://github.com/willneedit/AltSpaceMREs/blob/master/src/gltf/gltf_main.ts to host an MRE and the object in question yourself.

Animation doesn't play

Animations are still a bit iffy. As far as I've seen, only bone animations work. Trying to animate something using position/rotation/scale or using morphing targets for vertex animations simply fail to work. Same as with the animation names. If the model provides no name, the animation is addressed as 'animation:0' as far as I've seen.

Internals

This section is only of interest to whoever needs to distinguish between 'downloading' and 'putting on display' and things like this.

  1. The world builder who put up the object provided the URL to the object's data itself.
  2. The MRE gets started by the Altspace client of the visiting user and instructs the client to load the given object in the client's computer's memory and put it on display. This is comparable to an image link provided on an ordinary web page loaded by the browser.
  3. The MRE does not download the model itself.