Continuing this comment:
Why isn’t Babylon loading the file properly? The URL loads correctly from my local development server but not the production/public server. Here is a simple directory layout:
Both game files (index.html) have the model in the ./model/<name>.gltf location. In the game code:
class Level extends Scene{
constructor(){
...
let model = 'model/corvette.gltf'; //this is set dynamically and maybe not be a relative path (e.g. with mods);
SceneLoader.LoadAssetContainerAsync('', model, this).then(...);
...
}
}
The third variable should be the root URL. You can also add a filename to the call as the last variable (setting whatever you don’t need to be undefined). The signature is this:
/**
* Load into an asset container.
* @param scene The scene to load into
* @param data The data to import
* @param rootUrl The root url for scene and resources
* @param onProgress The callback when the load progresses
* @param fileName Defines the name of the file to load
* @returns The loaded asset container
*/
loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
The plugin itself seems to load fine… maybe the loaders is out of date? The loaders on the CDN repo appear to be from 4.2.1.
Edit:
After further continuing my research, I’ve found the error to origin with GLTFFileLoader.prototype.loadAssetContainerAsync, which uses the parameters you mentioned.
I managed to trigger the error using this code:
let loader = new GLTFFIleLoader();
let model = /*GLTF string*/;
//game.scene() returns a valid scene
loader.loadAssetContainerAsync(game.scene(),model,'model/corvette.gltf').then(e=>console.log('Loading successful')).catch(err=>console.log('Loading failed: ' + err.stack))
It throws: TypeError: Cannot read properties of undefined (reading 'asset') at e._getLoader. and from GLTFFileLoader.ts, e == loader.
Edit #2:
Continuing down the rabbit trail (or rather the stack trace):
The error comes from this function:
Sorry, you are totally right. the docs i provided was for the plugins themselves. Still, the 2nd variable (in this case) should be the filename. the first should be the root url:
the CDN repo is no longer in use. the CDN has the latest 5.4.0