Some test text!

Discord Logo

Chat with us

PDFTron is now Apryse, learn more here.

Web / Guides / Client API

Platform


PDFTron is now Apryse, learn more here.

WebViewer BIM Client APIs

initializeBimViewer

Construct initialized 3D viewer.

Params

instance

WebViewer instance that is available after initializing.

serverURL

URL of WebViewer BIM server.

options

An object containing options for the initializeBimViewer call. The following are possible arguments:

license

WebViewer BIM license key.

dataSchema

Options to define schema of the properties panel.

Example

import  WebViewer  from  '@pdftron/webviewer';
import { initializeBimViewer } from '@pdftron/webviewer-bim-client'

WebViewer({
  path: '/webviewer/lib',
}, document.getElementById('viewer')).then(instance  => {

  const  license = `---- Insert commercial license key here after purchase ----`;
  const  serverURL = `---- Insert server URL after setup ----`;
  const  options = {
    license: license,
    dataSchema: {
      headerName: 'Name',
      defaultValues: {
        Description: 'Description',
        GlobalID: 'GlobalId',
        Handle: 'handle',
        EmptyRow1: 'EmptyRow1',
      },
      groups: {
        Dimensions: {
          Length: 'Length',
          Width: 'Width',
          Height: 'Height',
          EmptyRow2: 'EmptyRow2',
          GrossFootprintArea: 'GrossFootprintArea',
          GrossSideArea: 'GrossSideArea',
          GrossVolume: 'GrossVolume',
        }
        EmptyGroupTest: {
            ObjectType: 'Lions',
            EmptyRow3: 'Tigers',
            ObjectPlacement: 'Bears',
        },
      },
      groupOrder: ['EmptyGroupTest', 'Dimensions'],
      removeEmptyRows: true,
      removeEmptyGroups: true,
      createMiscGroup: true,
    }
  };

  const WebViewerBIM = await initializeBimViewer(instance, serverURL, options);
}

Returns

a promise that resolves to an object containing the functions needed to load models in WebViewer.

load3dAsset

Load an IFC model.

Params

pathToAsset

URL or path to IFC model.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.File.load3dAsset('Add URL to your 3D asset here');

Returns

N/A

preload3dAsset

Static method that preloads an IFC model for future loading. This can be used to convert model data prior to loading.

Params

serverURL

URL to your BIM server instance.

pathToAsset

URL or path to IFC model.

conversionOptions

Optional options object to modify load behavior.

Example

const assetObject = await preload3dAsset(<serverURL>, <pathToAsset>, <conversionOptions>);

Returns

An object containing IDs for model data and optionally properties data. If enable_auth is enabled on your BIM server you will also receive an auth token for both the model data and the properties data.

// Sample assetObject
assetObject = {
  modelData: {
    id: '7bdb6aeab27191a882b9d3ed1e48afd4b490d755',
    auth: 'be36e17d84d9eac35f41aef4cd9dc6e894f9f452b96175b2075308725338c3fe',
  },
  propertiesData: {
    id: 'b204f18fb2168dc547d5056721c50ceb5bb3c62b',
    auth: 'fa34e17d84g3awe35f41aef4cd9dc6e894f9f452b96175b2075308725338c3fe',
  },
};

loadCached3dAsset

Loads a cached 3d asset from the BIM server.

Params

assetObject

Object containing IDs for model data and optional properties data. auth tokens are only necessary if the BIM Server has enable_auth set to true.

Example

sampleAssetObject = {
  modelData: {
    id: '7bdb6aeab27191a882b9d3ed1e48afd4b490d755',
    auth: 'be36e17d84d9eac35f41aef4cd9dc6e894f9f452b96175b2075308725338c3fe',
  },
  propertiesData: {
    id: 'b204f18fb2168dc547d5056721c50ceb5bb3c62b',
    auth: 'fa34e17d84g3awe35f41aef4cd9dc6e894f9f452b96175b2075308725338c3fe',
  },
};

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
const assetObject = await webviewerBIM.File.loadCached3dAsset(
  sampleAssetObject
);

Returns

N/A

checkAssetConversionProgress

Checks the status on asset conversion, returning true when an asset is ready to load.

Params

assetObject

Object containing IDs for model data and optional properties data.

Example

sampleAssetObject = {
  modelData: {
    id: '7bdb6aeab27191a882b9d3ed1e48afd4b490d755',
    auth: 'be36e17d84d9eac35f41aef4cd9dc6e894f9f452b96175b2075308725338c3fe',
  },
  propertiesData: {
    id: 'b204f18fb2168dc547d5056721c50ceb5bb3c62b',
    auth: 'fa34e17d84g3awe35f41aef4cd9dc6e894f9f452b96175b2075308725338c3fe',
  },
};

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);

// rudimentary polling against the BIM server to know when the Asset is ready
while (true) {
  const status = await webviewerBim.File.checkAssetConversionProgress(
    assetObject
  );

  if (status === true) {
    break;
  }

  await new Promise((r) => setTimeout(r, 200));
}

const assetObject = await webviewerBIM.File.loadCached3dAsset(
  sampleAssetObject
);

Returns

Boolean - true if the asset is ready to be loaded, false otherwise.

unmountBimViewer

Unmount the Bim Viewer

Params

instance

WebViewer instance that is available after initializing.

Example

import  Webviewer  from  '@pdftron/webviewer';
import { initializeBimViewer, unmountBimViewer } from '@pdftron/webviewer-bim-client'

Webviewer({
  path: '/webviewer/lib',
}, document.getElementById('viewer')).then(instance  => {
  const  license = `---- Insert commercial license key here after purchase ----`;
  const  serverURL = `---- Insert server URL after setup ----`;
  const  options = {
    license: license,
  }

  const WebViewerBIM = await initializeBimViewer(instance, serverURL, options);
  webviewerBIM.File.load3dAsset("Add URL to your 3D asset here");

  // Call unmountBimViewer when you're ready to unmount.
  // unmountBimViewer(instance);
}

Returns

N/A

Viewer APIs

enableSSAO

Enable screen-space ambient occlusion for the viewer.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.enableSSAO();

Returns

N/A

disableSSAO

Disable screen-space ambient occlusion for the viewer.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.disableSSAO();

Returns

N/A

setSSAOOptions

Adjust screen-space ambient occlusion for the viewer.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.setSSAOOptions({
  // example parameters:
  isDynamicRadius: true,
  radius: 1,
  loops: 64,
  blurRadius: 2,
  power: 1.4,
});

Returns

N/A

enableAntiAliasing

Enable anti-aliasing for the viewer.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.enableAntiAliasing();

Returns

N/A

disableAntiAliasing

Disable anti-aliasing for the viewer.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.disableAntiAliasing();

Returns

N/A

enableShadows

Enable ground shadows for the viewer.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.enableShadows();

Returns

N/A

disableShadows

Disable ground shadows for the viewer.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.disableShadows();

Returns

N/A

getWalkMode

Gets the current Walk Mode for the First Person Mode.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.FirstPersonMode.getWalkMode();

Returns

String - Returns either WalkThrough or FlyThrough.

setWalkMode

Sets the current Walk Mode for the First Person Mode, either WalkThrough or FlyThrough. WalkThrough simulates walking where going forward for example is always in reference to the ground plane. When set to FlyThrough directional movement is relative to the camera orientation.

Params

walkMode

String containing the desired walk mode, either WalkThrough or FlyThrough.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.Viewer.FirstPersonMode.setWalkMode('WalkThrough');

Returns

N/A

Orbit & Pan Tools APIs

setCameraSensitivity

Sets the sensitivity for Orbit/Pan tool.

Example

const cameraTools = {
  orbit: 'Orbit3D',
  pan: 'Pan3D',
  walk: 'Walk',
};
const panTool = instance.Core.DocumentViewer.getTool(cameraTools.pan);
panTool.setCameraSensitivity(10);

Returns

N/A

getCameraSensitivity

Gets the Orbit/Pan tool's sensitivity.

Example

const cameraTools = {
  orbit: 'Orbit3D',
  pan: 'Pan3D',
  walk: 'Walk',
};
const orbitTool = instance.Core.DocumentViewer.getTool(cameraTools.orbit);
orbitTool.getCameraSensitivity();

Returns

Number

Properties Panel APIs

setPanelSchema

Sets a new Properties Panel configuration based on a passed in Schema.

Params

schema

Object containing the desired configuration.

Example

const sampleSchema =  {
      headerName: 'Name',
      defaultValues: {
        Description: 'Description',
        GlobalID: 'GlobalId',
        Handle: 'handle',
        EmptyRow1: 'EmptyRow1',
      },
      groups: {
        Dimensions: {
          Length: 'Length',
          Width: 'Width',
          Height: 'Height',
          EmptyRow2: 'EmptyRow2',
          GrossFootprintArea: 'GrossFootprintArea',
          GrossSideArea: 'GrossSideArea',
          GrossVolume: 'GrossVolume',
        }
        EmptyGroupTest: {
            ObjectType: 'Lions',
            EmptyRow3: 'Tigers',
            ObjectPlacement: 'Bears',
        },
      },
      groupOrder: ['EmptyGroupTest', 'Dimensions'],
      removeEmptyRows: true,
      removeEmptyGroups: true,
      createMiscGroup: true,
    }

    const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
    webviewerBIM.PropertiesPanel.setSchema(sampleSchema);
}

Returns

N/A

toggleShowDefaultGroup

Toggles showing the Default group. This group contains all of the key/value pairs on a selected element without any adjustments.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.PropertiesPanel.toggleShowDefaultGroup();

Returns

N/A

toggleShowEmptyGroups

Toggles showing empty Groups on the properties panel. Empty Groups are defined as groups where every Row has an empty String.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.PropertiesPanel.toggleShowEmptyGroups();

Returns

N/A

toggleShowEmptyRows

Toggles showing empty Rows on the properties panel. An empty Row is defined as a row where the value is an empty String.

Example

const webviewerBIM = await initializeBimViewer(instance, serverURL, options);
webviewerBIM.PropertiesPanel.toggleShowEmptyRows();

Returns

N/A

Get the answers you need: Support