@pixi/3d
    Preparing search index...

    Variable loadGltfConst Advanced

    loadGltf: {
        extension: { name: string; type: LoadParser };
        id: string;
        name: string;
        load<T>(
            url: string,
            _resolvedAsset?: ResolvedAsset<any>,
            loader?: Loader,
        ): Promise<Scene3DSource>;
        test(url: string): boolean;
        unload(
            source: Scene3DSource,
            _resolvedAsset?: ResolvedAsset<any>,
            loader?: Loader,
        ): Promise<void>;
    } = ...

    Loads a .gltf file, with its external buffers and images, as a Scene3DSource

    @pixi/3d registers it with Assets on import, and Assets.unload(url) frees the source as Scene3DSource#destroy describes. loadGlb loads the binary .glb form.

    Meshopt-compressed buffers (EXT_meshopt_compression, KHR_meshopt_compression) and Draco-compressed meshes (KHR_draco_mesh_compression) decode as they load. Draco fetches its decoder from the URLs setDracoDecoderPath sets.

    Each texture loads the first of its images the app supports, in this order:

    • KTX2 (KHR_texture_basisu), once import 'pixi.js/ktx2' registers pixi's KTX2 loader. That loader fetches its transcoder from jsDelivr unless pixi's setKTXTranscoderPath sets other URLs.
    • AVIF (EXT_texture_avif), in a browser that decodes it.
    • WebP (EXT_texture_webp).
    • The PNG or JPEG in its source.

    A texture with no image the app supports fails the load, with an error that says why.

    Two glTF texture features work with limits:

    • Every texture samples the first UV set. One that asks for another, as some baked occlusion maps do, samples the first instead, and the loader warns.
    • A material applies the first KHR_texture_transform it finds on its textures to all of them.

    Type Declaration

    • extension: { name: string; type: LoadParser }
    • id: string
    • name: string
    • load: function
    • test: function
      • Parameters

        • url: string

        Returns boolean

    • unload: function
      • Destroys the materials first, as pixi warns when a bound texture source is destroyed, then unloads the images through the loader, as pixi also warns when a source Assets manages is destroyed directly

        Parameters

        Returns Promise<void>

    import 'pixi.js/ktx2'; // only needed for models with KTX2 textures
    import { Assets } from 'pixi.js';
    import { Model3D, type Scene3DSource } from '@pixi/3d';

    const source = await Assets.load<Scene3DSource>('robot.gltf');
    view3d.root.addChild(new Model3D(source));