Switch Node Plugin (Basic UI) This plugin allows you to configure object variations in a file and apply them in the scene. Each SwitchNode is a parent object with multiple direct children. Only one child is visible at a time. This works by toggling the visible property of the children of a parent object. The plugin interfaces with the picking plugin and also provides uiConfig to show and edit the variations. It also provides a function to create snapshot previews of individual variations. This creates a limited render of the object with the selected child visible. To get a proper render, its better to render it offline and set the image as a preview. This functionality is inherited from SwitchNodeBasePlugin.

Additionally this plugin adds a Grid UI using GridItemListPlugin in the DOM over the viewer canvas to show various object variations and allow the user to select them. The UI can also be used in the editor to edit the variations and apply them.

Hierarchy

  • SwitchNodeBasePlugin
    • SwitchNodePlugin

Constructors

Properties

_dirty: boolean = false
_viewer?: ThreeViewer
_viewerListeners: PartialRecord<"dispose" | "*" | "update" | "preRender" | "postRender" | "preFrame" | "postFrame" | "addPlugin" | "removePlugin" | "renderEnabled" | "renderDisabled", ((e) => void)> = {}

Type declaration

    • (e): void
    • Parameters

      • e: IViewerEvent

      Returns void

applyOnLoad: boolean = true

Apply all variations(by selected index or first item) when a config is loaded

constructor: typeof AViewerPluginSync & typeof AViewerPlugin
dependencies: typeof GridItemListPlugin[] = ...
enableEditContextMenus: boolean = false
enabled: boolean = true
uiConfig: UiObjectConfig<any, string, any> = ...
variations: ObjectSwitchNode[] = []
OldPluginType?: string
PluginType: "SwitchNodePlugin" = 'SwitchNodePlugin'

Accessors

Methods

  • Parameters

    • e: IViewerEvent

    Returns IViewerEvent

  • Parameters

    • Optional prefix: string

    Returns string

  • Returns ISerializedConfig | Record<string, never>

  • Get the preview for a switch node variation Should be called from preFrame ideally. (or preRender but set viewerSetDirty = false)

    Parameters

    • variation: ObjectSwitchNode

      Switch node variation that contains the child.

    • child: Object3D<Event, string>

      Child Object to get the preview for

    • viewerSetDirty: boolean = true

      call viewer.setDirty() after setting the preview. So that the preview is cleared from the canvas.

    Returns string

  • Parameters

    • state: any

    Returns Promise<void>

  • Reapply all selected variations again. Useful when the scene is loaded or changed and the variations are not applied.

    Returns void

  • Select a switch node variation with name or uuid.

    Parameters

    • node: ObjectSwitchNode
    • nameOrUuid: string | number
    • setDirty: boolean = true

      set dirty in the viewer after update.

    Returns undefined | boolean

  • Parameters

    • Optional meta: SerializationMetaType

    Returns ISerializedConfig

Generated using TypeDoc