Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CloudSession

The CloudSession's responsibility is to manage the Viewers and the main event loop of C3 (handleAnimationFrameCallback).

All C3 applications need a CloudSession object. There is only need for one, even in apps with multiple viewers, views, models and remote servers.

Hierarchy

  • CloudSession

Index

Constructors

constructor

Accessors

Readonly version

version: string

Returns the version of Ceetron Cloud Components

Format: Major.Minor.Patch-Build. E.g. '1.2.0-34145'

Readonly viewerCount

viewerCount: number

Returns the number of viewers in the client application.

Methods

addModelToProcessingSet

  • Manually add a model to the set of models that need background processing

    Parameters

    Returns void

addViewer

  • Adds a new Viewer to the session.

    The Viewer is tied to a HTML Canvas element, and the provided canvas must be capable of rendering WebGL. A Viewer can have many Views, and all the Views within a Viewer can share WebGL resources. So, to show the same Model in two Views, using one Viewer with two Views is more efficient than using two Viewers with one View each.

    A client application can contain many Viewers, but each Viewer must be linked to single unique Canvas.

    Parameters

    • canvas: HTMLCanvasElement
    • Optional viewerOptions: ViewerOptions

    Returns Viewer

deleteAllViewers

  • deleteAllViewers(): void
  • Deletes all viewers from the app.

    Returns void

deleteViewerAt

  • deleteViewerAt(index: number): void
  • Deletes the viewer at the given index.

    The index must be zero based and between 0 and viewerCount - 1

    Parameters

    • index: number

    Returns void

destroySession

  • destroySession(): void
  • Destroys the session object. This will delete all the viewers.

    Returns void

getViewerArray

  • getViewerArray(): ReadonlyArray<Viewer>
  • Returns a read only array with all viewers in the session

    Returns ReadonlyArray<Viewer>

getViewerAt

  • getViewerAt(index: number): Viewer
  • Returns the viewer with the given index.

    The index must be zero based and between 0 and viewerCount - 1

    Parameters

    • index: number

    Returns Viewer

handleAnimationFrameCallback

  • handleAnimationFrameCallback(highResTimestamp: number): boolean
  • Mandatory update method for the Ceetron Cloud Components Client.

    This method must be called from a requestAnimationFrame() for animations to run and server communication to work as expected.

    The standard code for doing this is:

        // Setup timer to keep the session viewer up-to-date
        function myAnimationFrameCallback(highResTimestamp) {
            mySession.handleAnimationFrameCallback(highResTimestamp);
            requestAnimationFrame(myAnimationFrameCallback);
        }
    
        requestAnimationFrame(myAnimationFrameCallback);

    Parameters

    • highResTimestamp: number

    Returns boolean

removeModelFromProcessingSet

  • Remove a model that was previously added manually to the processing set

    Parameters

    Returns void

Generated using TypeDoc