#############
Configuration
#############


When starting with the HOOPS Web Viewer component, there are several configuration properties that you can provide to the :doc:`Communicator.WebViewer </api_ref/viewing/classes/Communicator.WebViewer>` object during initialization which control various behaviors of the library. In this chapter, we will discuss some of the more important properties.


Loading data at startup
=======================

There are two major loading modes supported by the HOOPS Web Viewer:

#. Streaming via the Stream Cache Server (in either client-side or server-side rendering)
#. Loading an SCS file via an HTTP Request


Streaming via the Stream Cache Server
=====================================

To connect to the Stream Cache Server you generally need to provide some kind of URI endpoint that essentially represents the "identifier" of a streaming session. You then specify the model name separately. See the example below:

.. literalinclude:: /../../applications/client/docs/GeneralConcepts.ts
   :start-after: //! [Server_Streaming]
   :end-before: //! [Server_Streaming]

In order to start the viewer in streaming mode but without loading a model simply specify ``_empty`` as the model name.


Loading an SCS file via an HTTP request
=======================================

In this case, the referenced file is loaded to the client (not streamed) via a standard HTTP request. You need to provide the URL of the SCS file either as an absolute or relative path (see examples below).

Example:

.. literalinclude:: /../../applications/client/docs/GeneralConcepts.ts
   :start-after: //! [Load_With_AJAX]
   :end-before: //! [Load_With_AJAX]

If you want to make the HTTP request and receive the SCS file yourself, you can also provide a Uint8Array memory buffer with the SCS data instead of the URL:

.. literalinclude:: /../../applications/client/docs/GeneralConcepts.ts
   :start-after: //! [Load_With_Typed_Array]
   :end-before: //! [Load_With_Typed_Array]

In order to start the HOOPS Web Viewer in non-streaming mode but without loading a model simply omit the ``endpointUri`` property, model, and buffer property completely.

For much more information on the various loading modes please see our Programming Guide about :doc:`Loading </prog_guide/viewing/data_model/stream_cache/loading>`.


Additional settings
===================

We will discuss a few of the other properties of the :doc:`Communicator.WebViewer </api_ref/viewing/classes/Communicator.WebViewer>` constructor below and throughout the rest of the Programming Guide. For a complete list of properties, please see the :ref:`reference manual <api_ref/viewing/classes/Communicator.WebViewer:constructor>`. Many of these properties can also be modified later via the API.


boundingPreviewMode
-------------------

In order to improve visual feedback to the user, the HOOPS Web Viewer component displays bounding box "previews" before the actual mesh data is streamed in. This property allows you to control this behavior. (See also: :ref:`API Reference  <api_ref/viewing/interfaces/Communicator.WebViewerConfig:boundingpreviewmode>`)


calculateDefaultViewAxes
------------------------

By default, HOOPS Web Viewer component uses the initial camera orientation as guidance to determine the "Up" axis of a model unless the up-axis is explicitly authored into the model (which is often not the case). This property allows you to disable this behavior and set the correct axis via the HOOPS Web Viewer API instead, provided you have that information. (See also: :ref:`API Reference  <api_ref/viewing/interfaces/Communicator.WebViewerConfig:calculatedefaultviewaxes>`)


defaultMeshLevel
----------------

The HOOPS Web Viewer component supports multiple detail levels of a mesh each of them with a lower triangle count to improve performance and reduce loading times. This value defines which of the mesh levels is initially used. See :doc:`this page </prog_guide/viewing/geometry/meshes>` for more information on this topic. (See also: :ref:`API Reference  <api_ref/viewing/interfaces/Communicator.WebViewerConfig:calculatedefaultviewaxes>`)


enginePath
----------

This property allows you to place the *.wasm* and *.js* files associated to *hoops_web_viewer.mjs* into a different directory from the main library. (See also: :ref:`API Reference <api_ref/viewing/interfaces/Communicator.WebViewerConfig:enginepath>`)


memoryLimit
-----------

In order to support large models on lower end devices and to get around memory restrictions in the browser, the HOOPS Web Viewer allows you to set an upper memory limit on the amount of mesh data that can reside on the client at a given time. If the limit is reached, HOOPS Web Viewer will start to unload meshes that are least relevant and replace them with new mesh data streamed from the server. (See also: :ref:`API Reference <api_ref/viewing/interfaces/Communicator.WebViewerConfig:memorylimit>`)

You can find more information on this and other performance-related topics :doc:`here </prog_guide/viewing/performance>`.


rendererType
------------

This property allows you to switch between client-side and server-side rendering. Server-Side rendering will only be available if you are in "streaming mode" and server hardware that supports fast GPU rendering is available (which usually means a high-end graphics card is installed). (See also: :ref:`API Reference  <api_ref/viewing/interfaces/Communicator.WebViewerConfig:renderertype>`)

You can find more information on the various loading modes of the HOOPS Web Viewer :doc:`here </prog_guide/viewing/data_model/stream_cache/loading>`.

For an in-depth discussion on Server-Side Rendering, see :ref:`this section <prog_guide/servers/overview:Rendering types>`.


sessionToken
------------

To enhance security your web application can provide a unique session token to the client. See the :ref:`API Reference <api_ref/viewing/interfaces/Communicator.WebViewerConfig:sessiontoken>` for more information.


streamingMode
-------------

An SC Model can be streamed in different ways. See :doc:`this page </prog_guide/viewing/data_model/stream_cache/overview>` for more information.

   
streamCutoffScale
-----------------

By default, the HOOPS Web Viewer only streams meshes up to a certain screen-space size to the client. You can control this behavior with this property. See the :doc:`meshes section </prog_guide/viewing/geometry/meshes>` for more information on this topic.

