Threepipe Tweakpane Editor Plugin
    Preparing search index...

    Class EditorCameraPlugin

    Editor Camera Plugin

    Gives an editor its own camera, separate from the scene's camera.

    • Edit (editing true): the view is through the editor camera. It moves 1:1 with the pointer (no damping) and has no orbit limits.
    • View (editing false): the view is through the previewCamera, a copy of the scene's default camera (the start view, saved in the file). This is what a visitor sees, with the controls of the file (orbit limits, damping). With syncStartView (on by default), each move in View changes the start view as it happens (one undo step per move). With it off, a move in View is a preview: saveStartView keeps it, resetStartView goes back. So an export in View always has the saved start view.

    The editor camera and the preview camera are added to the scene outside the model root: they are not saved in a file or exported.

    The C key (hotkey) switches between Edit and View (the action editorCamera.toggleEditing of actions, registered in viewer.actions, where a UI lists and runs it), and the editingChange event tells a UI (like the start view card of the TweakpaneEditorPlugin) when the view changes. startViewChange tells it when the saved start view changes, and startViewMovedChange when the view in View moves away from it.

    When a file with a viewer config loads, the editor camera takes its start view. setStartViewFromEditor moves the start view to the editor view. Each change of the start view is one undo step when the UndoManagerPlugin is present.

    The plugin is not saved with the viewer config (serializeWithViewer is false).

    Hierarchy

    Index
    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    actions: ViewerAction[] = ...

    The actions of the plugin, registered in viewer.actions while the plugin is added: editorCamera.toggleEditing switches between Edit and View, while the plugin is not disabled. Its shortcut is hotkey, set when the plugin registers the actions (on add, and on a change of the key).

    camera: PerspectiveCamera2<ICameraEventMap> = ...

    The editor camera. It is never saved. Its orbit controls are made in onAdded, on the canvas of the viewer.

    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    editing: boolean = true

    Edit (true) looks through the editor camera, View (false) through the preview of the start view. It stays false while the plugin is disabled (isDisabled()).

    enabled: boolean = true

    Off: the view goes to the scene's default camera (as without the plugin), and editing cannot be turned on. disable(key) does the same until enable(key), as for the other plugins: the plugin is off while isDisabled().

    hotkey: string = 'KeyC'

    The key that switches between Edit and View, as a KeyboardEvent.code ('KeyC': the C key). An empty string turns it off. The key does nothing in a text field, with Ctrl, Cmd, Alt or Shift, held down, or when another handler used it. The hotkeyChange event tells a UI when it changes. It is the shortcut of the action in actions.

    isViewerPluginSync: true = ...
    serializeWithViewer: boolean = false
    smooth: boolean = false

    Light damping on the editor camera: the view follows in about 0.1 s and glides a little after release. Off: 1:1.

    syncStartView: boolean = true

    In View: each move of the view changes the saved start view at once (one undo step per move). On by default. Off: a move in View is a preview only, kept with saveStartView. Turned on in View after a move, it saves the view.

    With orbit controls, only a user gesture on the controls of the preview camera is a move: from their start event to their end event, and the glide after it (see SyncGestureDelay). A change that the user did not make, like a clamp of the orbit limits (a start view outside them) or an animation of the camera by another plugin, is not synced. The keyboard pan of OrbitControls sends no start and end events, so it is not a move either. Other controls (first person, pointer lock) send no gesture events: each change of the view is a move, and a move ends when the view is still for SyncGestureDelay. Without controls (controlsMode ''), no change is a move.

    uiConfig?: UiObjectConfig<any, string, any> = undefined
    ControlProps: Partial<OrbitControls3> = ...

    The controls of the editor camera, set each time it becomes the main camera. The start view keeps the controls of the file.

    OldPluginType?: string
    PluginType: "EditorCameraPlugin" = 'EditorCameraPlugin'
    SyncGestureDelay: number = 300

    A user gesture on the controls of the preview camera (in View) goes on after the pointer is up, for the glide of damping: it ends after this time in ms without a change, with the pointer up (and at least three frames, for a slow frame rate). With autoRotate on the controls, it ends this time after the pointer is up. With syncStartView, a gesture is one undo step, recorded when it starts and changed while it goes on. A drag that starts this time or later after the last one is a new step.

    • get previewCamera(): ICamera<ICameraEventMap> | undefined

      The camera that View looks through: a copy of the start camera with its controls (orbit limits, damping), made again from it each time View starts. It is not saved or exported, and has no camera widget. Made when the plugin is added.

      Returns ICamera<ICameraEventMap> | undefined

    • get showsStartView(): boolean

      The view shows the saved start view now: in View when the preview is at it (not after a move, an auto rotation or a clamp of the orbit limits), in Edit when the editor camera is at the start view (after a load, copyStartView or setStartViewFromEditor) and the start camera is perspective, as the editor camera. A UI can take a picture of the start view from the canvas then.

      Returns boolean

    • Parameters

      • e: IViewerEvent

      Returns IViewerEvent

    • Parameters

      • Optionalprefix: string

      Returns string

    • The editor camera takes the start view. It looks in the same direction, also when the start view looks away from its target. The editor camera stays upright: a roll of the start view is not copied. The FoV and the zoom are copied from a perspective start camera only (the editor camera is perspective).

      Returns void

    • 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>

    • In View: the start view takes the view (one undo step), as the view that visitors see. It does nothing in Edit, or when the view was not moved (startViewMoved: a change that the user did not make, like a clamp of the orbit limits, is not saved).

      Returns void

    • The start view takes the view that is seen: one undo step when the UndoManagerPlugin is present. In Edit, the editor view (an orthographic start camera keeps its zoom: the editor camera is perspective). In View, the view of the preview camera, also a change that the user did not make (as a clamp of the orbit limits).

      Returns void

    • Parameters

      • Optionalmeta: SerializationMetaType

      Returns ISerializedConfig