The NEEDLE_progressive extension for the GLTFLoader is responsible for loading progressive LODs for meshes and textures.
This extension can be used to load different resolutions of a mesh or texture at runtime (e.g. for LODs or progressive textures).

Example

const loader = new GLTFLoader();
loader.register(new NEEDLE_progressive());
loader.load("model.glb", (gltf) => {
const mesh = gltf.scene.children[0] as Mesh;
NEEDLE_progressive.assignMeshLOD(context, sourceId, mesh, 1).then(mesh => {
console.log("Mesh with LOD level 1 loaded", mesh);
});
});

Implements

  • unknown

Constructors

Accessors

  • get name(): string
  • The name of the extension

    Returns string

Methods

  • Parameters

    • gltf: GLTF

    Returns null

  • Load a different resolution of a mesh (if available)

    Parameters

    • context: Context

      the context

    • source: string

      the sourceid of the file from which the mesh is loaded (this is usually the component's sourceId)

    • mesh: Mesh

      the mesh to load the LOD for

    • level: number

      the level of detail to load (0 is the highest resolution)

    Returns Promise<any>

    a promise that resolves to the mesh with the requested LOD level

    Example

    const mesh = this.gameObject as Mesh;
    NEEDLE_progressive.assignMeshLOD(context, sourceId, mesh, 1).then(mesh => {
    console.log("Mesh with LOD level 1 loaded", mesh);
    });
  • Load a different resolution of a texture (if available)

    Parameters

    • context: Context

      the context

    • source: string

      the sourceid of the file from which the texture is loaded (this is usually the component's sourceId)

    • materialOrTexture: any

      the material or texture to load the LOD for (if passing in a material all textures in the material will be loaded)

    • level: number = 0

      the level of detail to load (0 is the highest resolution) - currently only 0 is supported

    Returns Promise<any>

    a promise that resolves to the material or texture with the requested LOD level

  • subscribe to loading event ended event

    Parameters

    • context: Context
    • evt: ProgressiveLoadingEvent

    Returns void

  • subscribe to events whenever a loading event starts, invoked for every single loading process that starts

    Parameters

    • context: Context
    • evt: ProgressiveLoadingEvent

    Returns void

  • Parameters

    Returns NEEDLE_progressive_mesh_model

  • Check if a LOD level is available for a mesh or a texture

    Parameters

    • obj: any

      the mesh or texture to check

    • Optional level: number

      the level of detail to check for (0 is the highest resolution). If undefined, the function checks if any LOD level is available

    Returns boolean

    true if the LOD level is available (or if any LOD level is available if level is undefined)

  • Parameters

    • context: Context
    • evt: ProgressiveLoadingEvent

    Returns void

  • Parameters

    • context: Context
    • evt: ProgressiveLoadingEvent

    Returns void

Generated using TypeDoc