SessionStorageAPI

Interface SessionStorageAPI

The SessionStorageAPI provides tools to manage session storage and snapshots in webvis. A session represents the entire state of the 3D space, which can be shared, stored, and restored. Snapshots are subsets of a session that capture a momentary state, including elements like clip planes and measurements.

This API allows you to:

  • Create, change, restore, and delete snapshots.
  • Store and restore session states.

Example: Create a snapshot, modify its properties, and restore it.

// Get the WebVis context
const context = webvis.getContext();

// Create a snapshot
const snapshotId = await context.createSnapshot("My Snapshot");

// Change the snapshot's properties
context.changeSnapshot(snapshotId, { name: "Updated Snapshot Name" });

// Restore the snapshot
await context.restoreSnapshot(snapshotId);

The following events are associated with the SessionStorageAPI:

interface SessionStorageAPI {
    changeSnapshot(
        snapshotID: number,
        properties: SnapshotProperties,
    ): SnapshotProperties;
    changeSnapshot(
        snapshotID: number,
        name?: string,
        screenshotURL?: string,
        order?: number,
    ): SnapshotProperties;
    createSnapshot(
        name?: string,
        options?: SnapshotCreationOptions,
    ): Promise<number>;
    getSnapshotData(
        snapshotID: number,
    ): { attachmentID: number; name: string; order: number };
    getSnapshots(): number[];
    importSession(data: any, format?: "xscn"): Promise<any>;
    isOfflineStorageAvailable(): Promise<boolean>;
    removeSnapshot(snapshotID: number): void;
    requestSnapshotData(snapshotID: number): Promise<SnapshotProperties>;
    restoreSession(handle: string): Promise<void>;
    restoreSnapshot(
        snapshotID: number,
        options?: SnapshotRestoreOptions,
    ): Promise<void>;
    storeSession(): Promise<string>;
    transferSession(
        progressCallback: StoreSessionProgressCallback,
    ): Promise<string>;
    transferSession(): Promise<string>;
}

Hierarchy (View Summary)

Methods

  • Changes one or more properties of a snapshot with the specified ID.

    Triggers a SnapshotChangedEvent.

    Parameters

    • snapshotID: number

      The ID of the snapshot to change.

    • properties: SnapshotProperties

      The properties of the snapshot to change.

    Returns SnapshotProperties

    An object with the changed properties.

  • Changes the textual description of the snapshot with the specified ID to the value of text.

    Triggers a SnapshotChangedEvent.

    Parameters

    • snapshotID: number

      The ID of the snapshot to change.

    • Optionalname: string

      The new name of the snapshot.

    • OptionalscreenshotURL: string

      The new screenshot URL of the snapshot.

    • Optionalorder: number

      The order inside the list of snapshots.

    Returns SnapshotProperties

    Calling changeSnapshot with single parameters is deprecated, please use SnapshotProperties instead.

  • Parameters

    • snapshotID: number

      The ID of the snapshot to request data for.

    Returns { attachmentID: number; name: string; order: number }

    The data of the specified snapshot.

    getSnapshotData is deprecated. Please use requestSnapshotData instead.

  • Returns the IDs of all available snapshots.

    Returns number[]

    An array of snapshot IDs.

  • Imports a session from the given data string in the specified format.

    Supported formats: xscn.

    Parameters

    • data: any

      The content of the session file.

    • Optionalformat: "xscn"

      The format of the session file. Default: "xscn".

    Returns Promise<any>

    A Promise that resolves when the session is imported.

  • Returns Promise<boolean>

    A Promise that always resolves to false, as offline storage is not used anymore.

    isOfflineStorageAvailable is deprecated.

    Checks if offline storage is currently available. This functionality is no longer relevant as offline storage is not supported anymore.

  • Deletes the snapshot for the given snapshot ID.

    Triggers a SnapshotRemovedEvent.

    Parameters

    • snapshotID: number

      The ID of the snapshot to delete.

    Returns void

  • Requests the data of the specified snapshot.

    Parameters

    • snapshotID: number

      The ID of the snapshot to request data for.

    Returns Promise<SnapshotProperties>

    The data of the specified snapshot.

  • Restores a session for the given access handle from the infrastructure.

    Parameters

    • handle: string

      The access handle of the session to restore.

    Returns Promise<void>

    A Promise that resolves when the session is restored.

  • Restores the snapshot for the given snapshot ID.

    Triggers a SnapshotRestoreStartedEvent and, if successful, a SnapshotRestoredEvent.

    Parameters

    • snapshotID: number

      The ID of the snapshot to restore.

    • Optionaloptions: SnapshotRestoreOptions

      Options to control the subset of snapshot data to restore.

    Returns Promise<void>

    A Promise that resolves when the snapshot is restored.

  • Temporarily stores the session in the connected hub instance and returns an access handle.

    This function does not transfer caches of referenced resources to the hub instance. For transferring caches, see transferSession.

    Returns Promise<string>

    The access handle of the stored session.

  • Experimental

    Parameters

    Returns Promise<string>

    The access handle of the transferred session.

    transferSession with progress callback is deprecated. Please use transferSession without parameters and utilize the returned promise instead!

    Transfers the session to the connected hub instance and returns an access handle.

    Transfers caches of referenced resources to the hub instance if they are not already present.

  • Experimental

    Transfers the session to the connected hub instance and returns an access handle.

    Transfers caches of referenced resources to the hub instance if they are not already present.

    Returns Promise<string>

    The access handle of the transferred session.