@pixi/3d
    Preparing search index...

    Class Scene3DSource

    The geometries, materials, textures and animations loaded from a glTF or GLB file

    A source is a template: add new Model3D(source) to a view, never the source itself. Every model spawned from one source shares its geometries, materials and textures, so a change to a source material shows on every model that draws it. Model3D#materials gives one model materials of its own.

    The plural lists (textures, materials, geometries) hold everything, by index in the file. The singular records (texture, material, geometry) hold only what the file named.

    loadGltf lists the texture formats a file can use and the imports they need.

    import { Assets } from 'pixi.js';
    import { Model3D, Scene3DSource } from '@pixi/3d';

    const source = await Assets.load<Scene3DSource>('robot.glb');

    // Two models sharing the same geometry, materials and textures
    const robotA = new Model3D(source);
    const robotB = new Model3D(source);

    view3d.root.addChild(robotA, robotB);

    // Repaints both robots
    source.material['Helmet'].baseColor = 0xff0000;
    Index
    animations: Record<string, Animation> = {}

    Animation clips keyed by name; an unnamed clip is keyed anim_<index>

    const walkSeconds = source.animations['Walk'].duration;
    
    destroyed: boolean = false

    Whether Scene3DSource#destroy has run

    if (!source.destroyed) view3d.root.addChild(new Model3D(source));
    
    geometries: Geometry3D[][] = []

    Every mesh's geometries, by its index in the file: one per primitive of the mesh

    const [body, glass] = source.geometries[0];
    
    geometry: Record<string, Geometry3D> = {}

    The geometry of each mesh the file names, keyed by mesh name

    A mesh with several primitives maps to its first; Scene3DSource#geometries has them all.

    const rock = new Mesh3D({ geometry: source.geometry['Rock'], material: new Material3D() });
    
    material: Record<string, BaseMaterial3D> = {}

    The materials the file names, keyed by name

    source.material['Paint'].baseColor = 0x3366ff;
    

    Every material, by its index in the file

    Unlit materials load as FlatMaterial, the rest as Material3D. When a mesh primitive names no material, the glTF default material, a white Material3D with metallic and roughness at 1, is added after the file's own.

    const pbrMaterials = source.materials.filter((material) => material instanceof Material3D);
    
    scene: Record<string, Scene3DEntry> = {}

    The scenes the file names, keyed by name

    Pass a name as Model3DOptions#scene to spawn that scene instead of the default one.

    const showroom = new Model3D({ source, scene: 'Showroom' });
    
    texture: Record<string, Texture> = {}

    The textures the file names, keyed by name

    const logo = new Sprite(source.texture['Logo']);
    
    textures: Texture<TextureSource<any>>[] = []

    Every texture, by its index in the file

    Textures in the file that use the same image share one Texture and its style, so an entry can repeat. The file's samplers set the style, and glTF's defaults (repeat wrapping, linear filtering, mipmaps) fill whatever a sampler leaves out.

    for (const texture of source.textures) texture.source.style.maxAnisotropy = 8;
    
    • Destroys every geometry, material and texture the source holds; a second call does nothing

      Every Model3D spawned from this source draws these resources, so destroy or stop rendering those models first. For a source from Assets.load, call Assets.unload(url) instead. It destroys the source and also unloads every image the file referenced from the loader's cache, even when another loaded asset still uses one.

      Returns void

      const source = await Assets.load<Scene3DSource>('robot.glb');
      const robot = new Model3D(source);

      // Later, once no model from it is rendered any more
      robot.destroy();
      await Assets.unload('robot.glb'); // calls source.destroy()