Model loader is a global object accessible via OccViewer.modelLoader, providing an interface for loading files/models into the Viewer scene.

See also OccViewer.InteractiveMesh for object-oriented interface to this functionality.

interface ModelLoader {
    openFromFile(
        theName: string,
        theFilePath: string,
        theToExpand: boolean,
    ): boolean;
    openFromMemory(
        theName: string,
        theBuffer: ArrayBuffer,
        theToExpand: boolean,
    ): boolean;
    openFromUrl(
        theName: string,
        theFileUrl: string,
        theToExpand: boolean,
    ): Promise<boolean>;
    preloadFile(
        theBuffer: Uint8Array,
        theFilePath: string,
        theToPreload: boolean,
    ): Promise<boolean>;
    unlinkFile(theFilePath: string): boolean;
    uploadUrl(
        theFileUrl: string,
        theFilePath: string,
        theToPreload: boolean,
    ): Promise<boolean>;
}

Methods

  • Open object from file and register presentation(s) in erased state.

    Parameters

    • theName: string

      object name

    • theFilePath: string

      path to the file in emulated filesystem

    • theToExpand: boolean

      expand model or display as a single part

    Returns boolean

    FALSE on reading error

  • Open object from memory and register presentation(s) in erased state.

    Parameters

    • theName: string

      object name

    • theBuffer: ArrayBuffer

      pointer to data

    • theToExpand: boolean

      expand model or display as a single part

    Returns boolean

    FALSE on reading error

  • Open object from the given URL and register presentation(s) in erased state. File will be loaded asynchronously. To remove file from file system you should call OccViewer.ModelLoader.unlinkFile if it is no longer needed

    Parameters

    • theName: string

      object name

    • theFileUrl: string

      the file URL address

    • theToExpand: boolean

      expand model or display as a single part

    Returns Promise<boolean>

  • Take buffer and upload it to emulated file system.

    Parameters

    • theBuffer: Uint8Array

      buffer to load

    • theFilePath: string

      file path on emulated file system (or empty string to take name from URL)

    • theToPreload: boolean

      decode image file using Emscripten plugins

    Returns Promise<boolean>

    evaluation result as promise returning TRUE or Error

  • Unlinks the node at path. This removes a name from the file system. If that name was the last link to a file (and no processes have the file open) the file is deleted. Usually you should call this function after

    Parameters

    • theFilePath: string

      file path on emulated file system (or empty string to take name from URL)

    Returns boolean

    openFromUrl() /

    uploadUrl() to remove file which is no longer needed

  • Fetch remote file from specified URL and upload it to emulated file system. To remove file from file system you should call

    Parameters

    • theFileUrl: string

      URL to load

    • theFilePath: string

      file path on emulated file system (or empty string to take name from URL)

    • theToPreload: boolean

      decode image file using Emscripten plugins

    Returns Promise<boolean>

    evaluation result as promise returning TRUE or Error

    unlinkFile if it is no longer needed