# Loader
Abstract class.
# Constructors
constructor |
---|
# Accessors
resource |
---|
# Methods
load | cancel | dispose |
---|
# Typedefs
LoaderEvent | LoaderEventPayload |
---|
# Constructors
# constructor
constructor(resource: string, resourceData?: string | ArrayBuffer)
1
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
1
Gets the loader's resource.
Returns: string
# Methods
# load
abstract load(): Promise<boolean>
1
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()
1
This function needs to cancel any ongoing loading process and clean afterwards.
Returns: void
# dispose
abstract dispose()
1
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'
}
1
2
3
4
5
2
3
4
5
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 }
}
1
2
3
4
5
2
3
4
5
Mapping of loader events to event handler argument types
← Intersections Queries →