How to use the babylonjs-loaders.GLTFFileLoader function in babylonjs-loaders

To help you get started, we’ve selected a few babylonjs-loaders examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BabylonJS / Babylon.js / inspector / src / tabs / GLTFTab.ts View on Github external
private _getLoaderDefaultsAsync(): Promise {
        if (GLTFTab._LoaderDefaults) {
            return Promise.resolve(GLTFTab._LoaderDefaults);
        }

        const defaults: ILoaderDefaults = {
            extensions: {}
        };

        const engine = new NullEngine();
        const scene = new Scene(engine);

        const loader = new GLTFFileLoader();
        GLTFTab._EnumeratePublic(loader, (key, value) => {
            defaults[key] = value;
        });

        loader.onExtensionLoadedObservable.add(extension => {
            const extensionDefaults: any = {};
            GLTFTab._EnumeratePublic(extension, (key, value) => {
                extensionDefaults[key] = value;
            });
            defaults.extensions[extension.name] = extensionDefaults;
        });

        const data = '{ "asset": { "version": "2.0" } }';
        return loader.importMeshAsync([], scene, data, "").then(() => {
            scene.dispose();
            engine.dispose();