Threepipe Tweakpane Editor Plugin
    Preparing search index...

    Class LayersPanelPlugin

    Layers Panel Plugin

    A list of the objects in the scene (scene.modelRoot) as a tree, like the layers panel of Figma or the outliner of Blender. It replaces the HierarchyUiPlugin.

    • A click on a row selects its object in the PickingPlugin; Ctrl, Cmd or Shift + click adds it to the selection or takes it out. A selection in the viewport marks its rows, opens the groups that hold it and scrolls to it (revealSelection).
    • The arrow on a row opens or closes it; Alt + click on the arrow opens or closes all the levels below it too.
    • A hovered row outlines its object in the viewport with the SelectionOutlinePlugin, when that plugin is added and follows the picking (viewportHover), when the pointer rests on the row (HoverDelay). It renders one more frame and does not restart the progressive render. The object hovered in the viewport is marked in the list.
    • The eye button hides or shows the object, the lock button locks or unlocks it. A locked object has userData.userSelectable set to false: the PickingPlugin does not pick it, or the objects inside it, in the viewport; the list can still select it. A row in the selection changes all the selected objects. Both are undo steps with the UndoManagerPlugin.
    • A double-click on a name (or F2) renames the object: Enter or a click outside keeps the name, Escape goes back.
    • With the focus in the list: Up and Down select the next row (Shift adds it), Right opens a row or goes to its first child, Left closes a row or goes to its parent.
    • The search field shows only the objects whose name has the text, with the groups that hold them; Escape or its × button clears it.
    • Tabs for the materials, the textures and the geometries that the objects use (tabs, each turned on or off by materialsTab and the others; one tab shows no tab bar). An asset row has a swatch, a picture or an icon, the name, a short text (the size of a texture, the vertices of a geometry, the users), and an arrow that lists its users. A click selects the asset in the PickingPlugin, a double-click selects its users, a double-click on the name (or F2) renames a material or a texture (renameAsset); a hover outlines its users.
    • The scene and the default camera are the first two rows, above the model (sceneRows), dimmer; a click selects them. Meshes, lines, points, cameras and lights show no children (leafTypes, showLeafChildren).
    • A double-click on a row selects it and moves the camera to it (doubleClickFocus; the scene row frames the model); a double-click on the name renames it. With clickToUnselect, a click on a selected row unselects it.
    • An open row shows its first maxChildren children (5), then a "… N more" row; a click on it shows all of them (showAllChildren). The objects at the top level, a search and children that hold the selection always show.
    • A virtual list: only the rows in view are in the DOM, so a scene with many objects stays fast.

    Lights and cameras have the icon and the colour of their kind (widgetKinds of threepipe), as in the viewport.

    Where the panel goes: in the container given to the constructor, else the app puts element in the page. The plugin does not depend on the editor: in the page frame of the TweakpaneEditorPlugin, the app adds it as a panel, editor.addPanel('layers', layers.element, {...LayersPanelPlugin.AreaEntry, area: 'left'}) (the person can move it to another place with the menu of its entry), and on the enabledChange event it takes the panel out (editor.removePanel('layers')) or adds it back. The element fills its parent: give the parent a height. The plugin takes the panel out of the page when it is removed.

    const layers = viewer.addPluginSync(LayersPanelPlugin)
    const editor = viewer.getPlugin(TweakpaneEditorPlugin)!
    const place = () => layers.isDisabled() ? editor.removePanel('layers') : editor.addPanel('layers', layers.element, {...LayersPanelPlugin.AreaEntry, area: 'left'})
    place()
    layers.addEventListener('enabledChange', place)

    The plugin UI folder (Layers Panel) has the settings. The settings and the open rows are not saved with the viewer.

    Hierarchy

    • AViewerPluginSync<LayersPanelPluginEventMap>
      • LayersPanelPlugin
    Index
    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    clickToUnselect: boolean = false

    A click on a selected row (without a key) unselects it

    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    container?: HTMLElement

    The element that holds the panel while the plugin is added, given to the constructor

    dependencies: typeof PickingPlugin[] = ...
    doubleClickFocus: boolean = true

    A double-click on a row selects it and moves the camera to it (the scene row: to the whole model). A double-click on the name renames it.

    element: HTMLDivElement

    The panel: the header, the search field and the list. It fills its parent.

    enabled: boolean = true

    Off: the panel is hidden, and the enabledChange event tells the app (which can take its area out of the editor frame)

    geometryTab: boolean = true

    The Geometry tab: the geometries of the objects in the scene, with the vertex count and the objects that use each

    isViewerPluginSync: true = ...
    leafTypes: LayerLeafType[] = ...

    The kinds of objects that show no children in the list: their helpers, targets or parts. Set a new list to change it. showLeafChildren shows the children of all kinds.

    materialsTab: boolean = true

    The Materials tab: the materials of the objects in the scene, with a swatch and the objects that use each

    maxChildren: number = 5

    An open row shows this many of its children, then a "… N more" row; a click on it shows all of them (until the row is closed). The objects at the top level, a search, and children that hold the selection always show. 0: all.

    objectsTab: boolean = true

    The Objects tab: the tree of the objects. The tabs that are on show in a tab bar (tabs); with one tab on, there is no tab bar.

    revealSelection: boolean = true

    A change of the selection opens the groups that hold the selected objects and scrolls the list to the first one

    sceneRows: boolean = true

    The scene and the default camera as the first two rows of the Objects tab, above the model, dimmer. A click selects them (the UI of the editor shows their settings). They are not in the model: they have no eye, lock or arrow. A search shows them when their name has the text (camera finds the default camera).

    serializeWithViewer: boolean = false
    showLeafChildren: boolean = false

    Shows the children of the objects of leafTypes too

    texturesTab: boolean = true

    The Textures tab: the textures that the scene and its objects use, with a picture, the size and the users

    uiConfig?: UiObjectConfig<any, string, any> = undefined
    viewportHover: boolean = true

    A hovered row outlines its object in the viewport. It needs the SelectionOutlinePlugin with followPicking on. A change renders one more frame, it does not restart the progressive render.

    AreaEntry: EditorFrameAreaOptions = ...

    A name, an icon and a colour for the entry of the panel in the mode bar of the editor frame, for the app to pass to TweakpaneEditorPlugin.addPanel. The plugin does not use it.

    HoverDelay: number = 80

    The time in ms that the pointer rests on a row before the viewport outlines its object (viewportHover). Each outline renders one frame, so a move across many rows renders none until the pointer stops. The pointer that leaves the list clears the outline at once. 0: at once on each row.

    InjectStyles: boolean = true

    Adds the stylesheet of the panel to the page when the first plugin is made. Off: the page styles the lyp- classes.

    OldPluginType?: string
    PluginType: "LayersPanelPlugin" = 'LayersPanelPlugin'
    RowHeight: 28

    The height of a row in px. The stylesheet takes it from the CSS variable --lyp-row on element.

    • Parameters

      • e: IViewerEvent

      Returns IViewerEvent

    • Parameters

      • Optionalprefix: string

      Returns string

    • Parameters

      • key: any
      • setDirty: boolean = true

      Returns void

    • Parameters

      • key: any
      • setDirty: boolean = true

      Returns void

    • Returns ISerializedConfig | Record<string, never>

    • Parameters

      • state: any

      Returns Promise<void>

    • The object is locked: its userData.userSelectable is false, so the PickingPlugin does not pick it, or the objects inside it, in the viewport. The lock of a parent is not checked.

      Parameters

      • object: IObject3D

      Returns boolean

    • Draws the rows in view again, in the next animation frame. Changes in the scene, the selection and the panel call it; call it after a change that the plugin does not hear about, such as a name set without setDirty.

      Parameters

      • structure: boolean = false

        also build the list again: after a change of the tree, of the open rows or of the search

      Returns void

    • Opens or closes the row of an object.

      Parameters

      • object: IObject3D
      • open: boolean
      • deep: boolean = false

        also all the levels below it

      Returns void

    • Locks or unlocks objects, as one undo step. A lock sets userData.userSelectable to false; an unlock gives back the value from before the lock (none, or true for an object without a material that is picked, like a text).

      Parameters

      • objects: IObject3D<
            IObject3DEventMap,
            IGeometry<NormalBufferAttributes, BufferGeometryEventMap>
            | undefined,
            IMaterial<IMaterialEventMap> | IMaterial<IMaterialEventMap>[] | undefined,
        >[]
      • locked: boolean

      Returns void

    • Shows or hides objects, as one undo step. Cameras are left out: threepipe does not support a hidden camera.

      Parameters

      • objects: IObject3D<
            IObject3DEventMap,
            IGeometry<NormalBufferAttributes, BufferGeometryEventMap>
            | undefined,
            IMaterial<IMaterialEventMap> | IMaterial<IMaterialEventMap>[] | undefined,
        >[]
      • visible: boolean

      Returns void

    • Opens the name field on the row of an object, as a double-click on its name does. The row must be in the list (its parents open). Returns false when it is not.

      Parameters

      • object: IObject3D

      Returns boolean

    • Parameters

      • Optionalmeta: SerializationMetaType

      Returns ISerializedConfig