Configuration

When starting with the HOOPS Web Viewer component, there are several configuration properties that you can provide to the 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:

  1. Streaming via the Stream Cache Server (in either client-side or server-side rendering)

  2. 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:

    const hwv = new Communicator.WebViewer({
        containerId: "viewerContainer",
        endpointUri: "ws://localhost:55555",
        model: "micro",
    });

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:

    const hwv = new Communicator.WebViewer({
        containerId: "viewerContainer",
        endpointUri: "http://www.example.com/micro.scs",
    });

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:

    const myBinaryData = new Uint8Array(0);

    const hwv = new Communicator.WebViewer({
        containerId: "viewerContainer",
        buffer: myBinaryData,
    });

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 Loading.

Additional settings

We will discuss a few of the other properties of the Communicator.WebViewer constructor below and throughout the rest of the Programming Guide. For a complete list of properties, please see the reference manual. 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: API Reference)

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: API Reference)

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 this page for more information on this topic. (See also: API Reference)

enginePath

This property allows you to place the .wasm and .js files associated to hoops_web_viewer.js into a different directory from the main library. (See also: API Reference)

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: API Reference)

You can find more information on this and other performance-related topics here.

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: API Reference)

You can find more information on the various loading modes of the HOOPS Web Viewer here.

For an in-depth discussion on Server-Side Rendering, see this section.

sessionToken

To enhance security your web application can provide a unique session token to the client. See the API Reference for more information.

streamingMode

An SC Model can be streamed in different ways. See this page 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 meshes section for more information on this topic.