
###########
StreamModel
###########

.. js:class:: cee.vs.StreamModel

   A remote Visualization Streamer (VizStreamer) model that can be displayed in the Viewer.
   
   The ``StreamModel`` class supports an efficient streaming and rendering of 3D data. The data to this model is sent from the VizStreamer Service, to which data is sent using GRPC or a C++ interface.
   
   To create a new instance of the ``StreamModel``\ , the :js:class:`ServerSession <cee.vs.ServerSession>` object needs to be created first. Afterwards, use the :js:meth:`ServerSession.createStreamModel <cee.vs.ServerSession.createStreamModel>` method to create a model linked to the stream. By default, the model starts streaming immediately.
   
   The streaming to this model is controlled with the ``startStreaming`` and :js:meth:`stopStreaming <cee.vs.StreamModel.stopStreaming>` methods. You can also check whether streaming is active with the :js:meth:`isStreamingActive <cee.vs.StreamModel.isStreamingActive>` method.
   
   The current frame of the StreamModel can be set with the :js:func:`currentFrameIndex <cee.vs.StreamModel.currentFrameIndex>` property.
   
   **Example:**
   
   Create a StreamModel and add it to the view.
   
   .. code-block:: typescript
   
      // create a cloud session first, viewer and a view
      const cloudSession = new cee.CloudSession();
      const viewer = cloudSession.addViewer(htmlCanvasElement, { useOperators: false });
      const view = viewer.addView()
      
      // Connect to the server session at the given url. 
      const serverSession = await cee.vs.ServerSession.createInstance_async("http://localhost:8091");
      // Get the available streams
      const streams = await serverSession.getAvailableStreams_async();
      
      // Grab the first stream
      if (streams[0]) {
          const streamId = streams[0].streamId;
          const streamModel = serverSession.createStreamModel(streamId);
      
          // Add the model to the cee.View
          view.addModel(streamModel);
          // Start the streaming if not already started.
          if (!streamModel.isStreamingActive()) {
              await streamModel.startStreaming_async();
          }
      }
   
   
   Index
   =====
   
   .. rubric:: Accessors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.vs.StreamModel.currentFrameIndex`
   * :js:func:`~cee.vs.StreamModel.frameCount`
   * :js:func:`~cee.vs.StreamModel.name`
   * :js:func:`~cee.vs.StreamModel.publishTag`
   * :js:func:`~cee.vs.StreamModel.streamId`
   * :js:func:`~cee.vs.StreamModel.streamRevision`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~cee.vs.StreamModel.addConfigReadyCallback`
   * :js:meth:`~cee.vs.StreamModel.addConfigReadyCallbackForRevision`
   * :js:meth:`~cee.vs.StreamModel.addStreamingCompleteCallback`
   * :js:meth:`~cee.vs.StreamModel.addStreamingCompleteCallbackForRevision`
   * :js:meth:`~cee.vs.StreamModel.detachFromSession`
   * :js:meth:`~cee.vs.StreamModel.getBoundingBox`
   * :js:meth:`~cee.vs.StreamModel.getDefaultCameraConfig`
   * :js:meth:`~cee.vs.StreamModel.isStreamingActive`
   * :js:meth:`~cee.vs.StreamModel.isStreamingComplete`
   * :js:meth:`~cee.vs.StreamModel.pollForStreamConfig_async`
   * :js:meth:`~cee.vs.StreamModel.rayIntersect`
   * :js:meth:`~cee.vs.StreamModel.removeAllConfigReadyCallbacks`
   * :js:meth:`~cee.vs.StreamModel.removeAllStreamingCompleteCallbacks`
   * :js:meth:`~cee.vs.StreamModel.setGuidingCamera`
   * :js:meth:`~cee.vs.StreamModel.startStreaming_async`
   * :js:meth:`~cee.vs.StreamModel.stopStreaming`
   
   



.. rst-class:: kind-group kind-accessors

.. rubric:: Accessors
   :class: kind-group-title


.. js:method:: cee.vs.StreamModel.currentFrameIndex

      .. rst-class:: sig-pretty-signature
      
         | *get* currentFrameIndex(): *number*
      
      Gets/sets the current frame index displayed in this model.
      
      **Returns**\ : *number*
      
      .. rst-class:: sig-pretty-signature
      
         | *set* currentFrameIndex(**frameIndex**\ : *number*\ ): *void*
      
      **Parameters**
      
      
         **frameIndex**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.frameCount

      .. rst-class:: sig-pretty-signature
      
         | *get* frameCount(): *number*
      
      Gets the number of frames in this model.
      
      **Returns**\ : *number*
      



.. js:method:: cee.vs.StreamModel.name

      Name of the model.
      
      Mainly used for debugging.
      
      .. rst-class:: sig-pretty-signature
      
         | *get* name(): *string*
      
      Name of the model, primarily used for debugging.
      
      **Returns**\ : *string*
      
      .. rst-class:: sig-pretty-signature
      
         | *set* name(**name**\ : *string*\ ): *void*
      
      Name of the model.
      
      Mainly used for debugging.
      
      **Parameters**
      
      
         **name**\ : *string*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.publishTag

      .. rst-class:: sig-pretty-signature
      
         | *get* publishTag(): *string*
      
      The publishTag associated with the current stream config or null if no publishTag was set.
      
      **Returns**\ : *string*
      



.. js:method:: cee.vs.StreamModel.streamId

      .. rst-class:: sig-pretty-signature
      
         | *get* streamId(): *string*
      
      The stream id of the stream being consumed by this model
      
      **Returns**\ : *string*
      



.. js:method:: cee.vs.StreamModel.streamRevision

      .. rst-class:: sig-pretty-signature
      
         | *get* streamRevision(): *number*
      
      The current streamRevision of the stream being consumed by this model, or undefined if no stream config has been received yet.
      
      **Returns**\ : *number*
      



.. rst-class:: kind-group kind-methods

.. rubric:: Methods
   :class: kind-group-title


.. js:method:: cee.vs.StreamModel.addConfigReadyCallback

      .. rst-class:: sig-pretty-signature
      
         | addConfigReadyCallback(**callback**\ : :js:data:`ConfigReadyCallback <cee.vs.ConfigReadyCallback>`\ ): *void*
      
      **Parameters**
      
      
         **callback**\ : :js:data:`ConfigReadyCallback <cee.vs.ConfigReadyCallback>`
      
      
      **Returns**\ : *void*
      
      .. rst-class:: sig-pretty-signature
      
         | addConfigReadyCallback(**options**\ : :js:data:`CallbackOptions <cee.vs.CallbackOptions>`\ , **callback**\ : :js:data:`ConfigReadyCallback <cee.vs.ConfigReadyCallback>`\ ): *void*
      
      **Parameters**
      
      
         **options**\ : :js:data:`CallbackOptions <cee.vs.CallbackOptions>`
      
         **callback**\ : :js:data:`ConfigReadyCallback <cee.vs.ConfigReadyCallback>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.addConfigReadyCallbackForRevision

      .. rst-class:: sig-pretty-signature
      
         | addConfigReadyCallbackForRevision(**streamRevision**\ : *number*\ , **callback**\ : :js:data:`RevisionBoundConfigReadyCallback <cee.vs.RevisionBoundConfigReadyCallback>`\ ): *void*
      
      **Parameters**
      
      
         **streamRevision**\ : *number*
      
         **callback**\ : :js:data:`RevisionBoundConfigReadyCallback <cee.vs.RevisionBoundConfigReadyCallback>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.addStreamingCompleteCallback

      .. rst-class:: sig-pretty-signature
      
         | addStreamingCompleteCallback(**callback**\ : :js:data:`StreamingCompleteCallback <cee.vs.StreamingCompleteCallback>`\ ): *void*
      
      **Parameters**
      
      
         **callback**\ : :js:data:`StreamingCompleteCallback <cee.vs.StreamingCompleteCallback>`
      
      
      **Returns**\ : *void*
      
      .. rst-class:: sig-pretty-signature
      
         | addStreamingCompleteCallback(**options**\ : :js:data:`CallbackOptions <cee.vs.CallbackOptions>`\ , **callback**\ : :js:data:`StreamingCompleteCallback <cee.vs.StreamingCompleteCallback>`\ ): *void*
      
      **Parameters**
      
      
         **options**\ : :js:data:`CallbackOptions <cee.vs.CallbackOptions>`
      
         **callback**\ : :js:data:`StreamingCompleteCallback <cee.vs.StreamingCompleteCallback>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.addStreamingCompleteCallbackForRevision

      .. rst-class:: sig-pretty-signature
      
         | addStreamingCompleteCallbackForRevision(**streamRevision**\ : *number*\ , **callback**\ : :js:data:`RevisionBoundStreamingCompleteCallback <cee.vs.RevisionBoundStreamingCompleteCallback>`\ ): *void*
      
      **Parameters**
      
      
         **streamRevision**\ : *number*
      
         **callback**\ : :js:data:`RevisionBoundStreamingCompleteCallback <cee.vs.RevisionBoundStreamingCompleteCallback>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.detachFromSession

      .. rst-class:: sig-pretty-signature
      
         | detachFromSession(): *void*
      
      Detaches the model from its owner server session. This will permanently stop streaming of the model.
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.getBoundingBox

      .. rst-class:: sig-pretty-signature
      
         | getBoundingBox(**_options**\ : :js:class:`ModelBoundingBoxOptions <cee.ModelBoundingBoxOptions>`\ ): :js:class:`BoundingBox <cee.BoundingBox>`
      
      Returns the :js:class:`BoundingBox <cee.BoundingBox>` (in world coordinates) of the current contents of the model
      
      Note that this method does not support any :js:class:`ModelBoundingBoxOptions <cee.ModelBoundingBoxOptions>`
      
      **Parameters**
      
      
         **_options**\ : :js:class:`ModelBoundingBoxOptions <cee.ModelBoundingBoxOptions>`
      
      
      **Returns**\ : :js:class:`BoundingBox <cee.BoundingBox>`
      



.. js:method:: cee.vs.StreamModel.getDefaultCameraConfig

      .. rst-class:: sig-pretty-signature
      
         | getDefaultCameraConfig(): *None*
      
      Returns default camera configuration, which is always null for this model.
      
      **Returns**\ : *None*
      



.. js:method:: cee.vs.StreamModel.isStreamingActive

      .. rst-class:: sig-pretty-signature
      
         | isStreamingActive(): *boolean*
      
      Checks whether the streaming to the model is enabled or not.
      
      **Returns**\ : *boolean*
      



.. js:method:: cee.vs.StreamModel.isStreamingComplete

      .. rst-class:: sig-pretty-signature
      
         | isStreamingComplete(): *boolean*
      
      **Returns**\ : *boolean*
      



.. js:method:: cee.vs.StreamModel.pollForStreamConfig_async

      .. rst-class:: sig-pretty-signature
      
         | pollForStreamConfig_async(): *Promise*
      
      Polls for new data for this model.
      
      **Returns**\ : *Promise*
      



.. js:method:: cee.vs.StreamModel.rayIntersect

      .. rst-class:: sig-pretty-signature
      
         | rayIntersect(**ray**\ : :js:class:`Ray <cee.Ray>`\ ): :js:class:`HitItem <cee.vs.HitItem>`
      
      Performs picking on the model using the current frame. Returns null when nothing is hit.
      
      **Parameters**
      
      
         **ray**\ : :js:class:`Ray <cee.Ray>`
      
      
      **Returns**\ : :js:class:`HitItem <cee.vs.HitItem>`
      



.. js:method:: cee.vs.StreamModel.removeAllConfigReadyCallbacks

      .. rst-class:: sig-pretty-signature
      
         | removeAllConfigReadyCallbacks(): *void*
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.removeAllStreamingCompleteCallbacks

      .. rst-class:: sig-pretty-signature
      
         | removeAllStreamingCompleteCallbacks(): *void*
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.setGuidingCamera

      .. rst-class:: sig-pretty-signature
      
         | setGuidingCamera(**camera**\ : :js:class:`Camera <cee.Camera>`\ ): *void*
      
      Sets the guiding camera by watching its changes and using it to guide the streaming.
      
      **Parameters**
      
      
         **camera**\ : :js:class:`Camera <cee.Camera>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.StreamModel.startStreaming_async

      .. rst-class:: sig-pretty-signature
      
         | startStreaming_async(): *Promise*
      
      Starts the streaming from the VizStreamer Service.
      
      **Returns**\ : *Promise*
      



.. js:method:: cee.vs.StreamModel.stopStreaming

      .. rst-class:: sig-pretty-signature
      
         | stopStreaming(): *void*
      
      Stops the streaming from the VizStreamer Service.
      
      **Returns**\ : *void*
      




