ThreePipe
    Preparing search index...

    Class DynamicImportPlugin

    A plugin that allows dynamic loading and unloading of other plugins at runtime, with support for hot module replacement (HMR) during development. This plugin provides a simple UI to load and unload plugins by specifying their module paths. It supports both direct path strings and module objects (imported or promises). The loaded plugins are tracked and can be managed through the provided UI.

    For HMR with vite, see sampleThreepipeViteHmrPlugin Note: This plugin is primarily intended for development and testing purposes.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    enabled: boolean = true
    plugins: Map<
        string,
        Class<AViewerPlugin<AViewerPluginEventMap, ThreeViewer, boolean>>,
    > = ...
    uiConfig: UiObjectConfig = ...
    OldPluginType?: string
    PluginType: "DynamicImportPlugin" = 'DynamicImportPlugin'

    Accessors

    Methods

    • Loads and adds a plugin to the viewer. The plugin can be specified as a path string or as a module object (imported or promise). If a path string is provided, it should point to a module that exports a default class extending AViewerPlugin. If a module object is provided, it should either have a default export or a named export that is a class extending AViewerPlugin. The module can also have a __tpPluginPath property to identify its path.

      Usage examples:

      // Load plugin from a path
      await DynamicImportPlugin.loadPlugin('./path/to/MyPlugin.js');

      // Load plugin from an imported module
      import MyPluginModule from './path/to/MyPlugin.js';
      await DynamicImportPlugin.loadPlugin(MyPluginModule);

      // Load plugin with dynamic import
      await DynamicImportPlugin.loadPlugin(import('./path/to/MyPlugin.js'));

      Parameters

      • pathOrModule: string | PluginModule | Promise<PluginModule>

      Returns Promise<any>

      The instance of the loaded plugin.

    • Unloads and removes a plugin from the viewer by its path. The path should match the one used when loading the plugin.

      Parameters

      • path: string

      Returns Promise<void>

      A promise that resolves when the plugin is removed.