ThreePipe
    Preparing search index...

    Class SwitchNodeBasePlugin

    Switch Node Plugin (Base)

    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, it's better to render it offline and set the image as a preview.

    See SwitchNodePlugin in plugin-configurator for example on inheriting with a custom UI renderer.

    Hierarchy (View Summary)

    Index
    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    applyOnLoad: boolean = true

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

    autoSnapIcons: boolean = false

    If true, the plugin will automatically take snapshots of the icons in _refreshUi and put them in the object.userdata.__icon Otherwise, call snapIcons manually

    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    enabled: boolean = true
    isViewerPluginSync: true = ...
    previewSize: number = 256

    Size in pixels of the previews of the nodes. They render offscreen in the viewer's scene (with its environment map) and with the viewer's tone mapping, see snapObject.

    refreshScene: boolean = true

    Whether refreshScene should be called when a node is selected. Refreshing scene will notify the plugins about the update, like shadows can be baked. Disable this when nothing significant geometry/node changes happen when switch nodes are changed.

    uiConfig: UiObjectConfig = ...
    variations: ObjectSwitchNode[] = []
    OldPluginType?: string
    PluginType: "SwitchNodePlugin" = 'SwitchNodePlugin'
    • Get the preview for a switch node variation, as a png data url with a transparent background. It renders offscreen at previewSize and does not change the canvas. Call it from preFrame or postFrame (not during a render).

      Parameters

      • variation: ObjectSwitchNode

        Switch node variation that contains the child.

      • child: Object3D

        Child Object to get the preview for

      • viewerSetDirty: boolean = false

        call viewer.setDirty() after the preview. Not needed since the preview renders offscreen, kept for compatibility.

      Returns string