Setting up WebViewer BIM Client

To get the sample working, both WebViewer BIM client and server must be setup and running. The server URL will be referenced in the front-end to allow communication between client and server.

Prerequisites

It is recommended you install Node and npm.

Setup application

  1. Run the following:

Bash

1git clone https://github.com/XodoDocs/webviewer-BIM-sample.git
2cd webviewer-BIM-sample
3npm install
  1. Change serverURL variable in App.js to wherever your server is hosted. See Setting up WebViewer BIM Server section for details.

JavaScript

1WebViewer({ path: "/webviewer/lib" }, viewer.current).then(async (instance) => {
2 const license = `---- Insert commercial license key here after purchase ----`;
3 const serverURL = `---- Insert server URL after setup ----`;
4
5 const options = getViewerOptions(license);
6 const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
7 webviewerBIM.File.load3dAsset(
8 "Add URL to your 3D asset here"
9 );
10});

Run application

After setup is complete, run the application:

Bash

1npm start

Include credentials in cross-origin BIM requests

The following APIs accept a withCredentials boolean property in their respective options parameters:

If enabled, the underlying Fetch requests have { credentials: 'include' } added to the options parameter. See the Fetch MDN documentation and WHATWG 'credentials' definition for more information on automatically including credentials in cross-origin requests.

The BIM server must have allow_credentials enabled, and a non-wildcard value specifed in allow_origins, otherwise the browser will throw a CORS error. See configuring cross-origin credentials documentation for server-side configuration steps.

NOTE: The WebViewer BIM custom authorization is not affected by this functionality. If you enabled server-side authorization, ensure the authorization tokens are included in their respective APIs.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales