Constructors

constructor

constructor(resource: string, resourceData?: string | ArrayBuffer)

Populates the loader with data.

Parameters

  • resource: This can either be a resource URL, either an resource ID
  • (optional) resourceData: Explicit data you want to load

Accessors

resource

get resource(): string

Gets the loader’s resource.

Returns: string

Methods

load

abstract load(): Promise<boolean>

This function needs to handle all the resource loading.

Returns: A promise which resolves to a boolean indicating if the loading process completed successfully (true) or was interrupted/failed (false)

cancel

abstract cancel()

This function needs to cancel any ongoing loading process and clean afterwards.

Returns: void

dispose

abstract dispose()

This function needs to dispose of the loader and it’s allocated resources.

Returns: void

Typedefs

LoaderEvent

enum LoaderEvent {
  LoadProgress = 'load-progress',
  LoadCancelled = 'load-cancelled',
  LoadWarning = 'load-warning'
}

The basic events any Loader implementation should use. Implemented and used by both SpeckleLoader and ObjLoader fully or partially.

LoaderEventPayload

interface LoaderEventPayload {
  [LoaderEvent.LoadProgress]: { progress: number; id: string }
  [LoaderEvent.LoadCancelled]: string
  [LoaderEvent.LoadWarning]: { message: string }
}

Mapping of loader events to event handler argument types