ExtensionManager
The ExtensionManager manages all the extensions available to the viewer. Register, retrieve, and unregister your extension using the singleton Autodesk.Viewing.theExtensionManager
.
You can load/unload your registered extension into a Viewer by invoking viewer.loadExtension(id, options) and viewer.unloadExtension(id), respectively.
new ExtensionManager()
Methods
registerExtension(extensionId, extensionClass)
Registers a new extension with the given id.
Parameters
extensionId* string | The string id of the extension. |
extensionClass* | The Extension-derived class representing the extension. |
Returns
type | description |
---|---|
boolean |
|
getExtension(extensionId)
Returns the class representing the extension with the given id.
Parameters
extensionId* string | The string id of the extension. |
Returns
type | description |
---|---|
Extension, null |
|
unregisterExtension(extensionId)
Unregisters an existing extension with the given id.
Parameters
extensionId* string | The string id of the extension. |
Returns
type | description |
---|---|
boolean |
|
registerExternalExtension(extensionId, urlPathOrCallback, dependencies)
Registers an extension that needs to be downloaded before using it. The Viewer ships with some extensions that are not bundled, but can be runtime-fetched.
Parameters
extensionId* string | The string id of the extension. |
urlPathOrCallback* string, function | The url from where it needs to be pulled from. Can be a relative or an absolute path. Optionally, this can be a callback function that defers the loading to the client application. Useful for webpack import style loading. Callback must return a promise that resolves when loading is finished. |
dependencies* Array.<string> | Optional list of extension IDs, whose bundles are needed before this extension can be built. |
Returns
type | description |
---|---|
boolean |
|
getExternalPath(extensionId)
Returns the url path from where to download the extension; null if not registered through registerExternalExtension().
Parameters
extensionId* string | The string id of the extension. |
Returns
type | description |
---|---|
url, null |
|
getRegisteredExtensions()
Gets a list of all the extensions that are available for usage. Some are already available in memory, while others may require an additional file to be downloaded prior to its usage.
Returns
type | description |
---|---|
Array.<string> |
downloadExtension(extensionId)
Download the extension and return its downloading promise
Parameters
extensionId* string |
Returns
type | description |
---|---|
Promise | resolves when the extension class is ready for usage. |
isDownloading(extensionId)
Is the extension being downloaded?
Parameters
extensionId* string |
isAvailable(extensionId)
Is the extension class available?
Parameters
extensionId* string |