Skip to main content

js-sdk

NiraAPI.Viewer

The Viewer class provides an interface to a Nira iframe embed.

Key Features

  • Set active tool modes: Switch between modes like Orbit, Pan, Zoom, etc. Useful for implementing navigation tool buttons with custom styling.
  • Manage callouts: Activate callouts or change the view bookmark of a callout.
  • Events: React to events like asset loading/unloading, tool mode changes, and callout interactions.
  • View state: Set view state attributes for the session, such as object visibilities or rendering parameters. Useful for implementing more complex "configurators" that are not achievable via the View Variants dropdown.
  • Control view options: Show or hide certain UI elements and control various behaviors of the viewer. Useful when implementing your own callout or navigation UI. See IViewOptions.

Enterprise plan required

The NiraAPI.Viewer feature requires a customized Enterprise plan. Please contact us with any questions.

Samples

  • Navigation tool buttons with custom styling: Navigation buttons with custom styling. The button styling in this example is visually basic and is only for illustrative purposes.
  • Object visibility toggle with custom button styling: Please note, for simple use cases, this is more easily accomplished with no code using View Variants. The button styling in this example is visually basic and is only for illustrative purposes. For a more advanced use case of visibility changes, see the Advanced Configurator example below.
  • Advanced Configurator: A customer example of a more advanced configurator. When user makes a selection in the UI, the appropriate object visibility changes are made via setSessionState() and the appropriate camera movements are made via activateCallout(). It also uses basic event handling ('asset_load_finish' and 'asset_unload') to show/hide panel UI when the asset is loaded or unloaded.
  • Callout Handling: This is an example of how to implement your own callout creation and callout information display UX using the Viewer API. Please see the source code of the example for more details. This example is visually basic and is only for illustrative purposes.

Getting Started

1. Include viewer.js

Add the viewer.js script to your page:

<script src="https://sdk.nira.app/js/viewer.js"></script>

2. Add an Iframe

Include an iframe element on your page:

<iframe id="niraviewer" frameBorder="0" loading="lazy" class="niraIframe" src="YOUR_ASSET_URL"></iframe>

The src attribute should be set to a Nira asset URL. Also see Embedding a Nira asset with iframe.

3. Create a Viewer Instance

document.addEventListener("DOMContentLoaded", () => {
const viewer = new NiraAPI.Viewer(document.getElementById("niraviewer"));
});

4. Call methods and handle events

// Engage the pan tool as soon as the asset loads
viewer.on("asset_load_finish", () => {
viewer.setToolMode(NiraAPI.Toolmode.Pan);
});

viewer.on("toolmode", (toolmode) => {
// Handle tool mode changes here. For example, activate a custom button in your UI.
});

Kind: static class of NiraAPI


Constructor

new NiraAPI.Viewer(elementOrId, [options])

Creates a new NiraAPI.Viewer instance and attaches it to an iframe element. The second parameter is an optional object that controls certain behaviors of the Nira view (see IViewOptions).

ParamTypeDescription
elementOrIdstring | HTMLIFrameElementThe iframe element or its ID.
[options]IViewOptionsOptional configuration options.

Example

// Create a Viewer instance attached to an iframe with ID "nira-iframe"
const viewer = new NiraAPI.Viewer("nira-iframe");

Methods


viewer.on(name, callback)

Registers an event listener.

Kind: instance method of Viewer Category: Methods

ParamTypeDescription
namestringThe name of the event to listen for.
callbackfunctionThe callback function to execute when the event is emitted.

Example

// Listen for tool mode changes
viewer.on("toolmode", (toolmode) => {
console.log("Tool mode changed to:", toolmode);
});

viewer.off(eventName, callback)

Unregisters an event listener.

Kind: instance method of Viewer Category: Methods

ParamTypeDescription
eventNamestringThe name of the event to stop listening for.
callbackfunctionThe callback function to remove.

viewer.destroy()

Destroys the Viewer instance, cleaning up event listeners and intervals.

Kind: instance method of Viewer Category: Methods


viewer.setSessionState(state)

Sets the current view state for the loaded asset. See IViewState for the available view state parameters.

You can also explore available view state parameters within Nira:

  1. Within Nira, click "Edit Mode"
  2. Make one or more visual changes to your asset within Nira using the right panel
  3. Click the "Save | Revert..." button
  4. In the dialog that appears, expand the "Show Details" area. Any parameter change shown in this area can be passed via setSessionState().

Also see View Variants documentation for a no-code alternative that works in many cases.

Kind: instance method of Viewer Category: Methods

ParamTypeDescription
stateanyView state parameters.

Example

// Disable the display of textures
viewer.setSessionState({ 'renderTextures': false });
// Hide the object named 'foliage'
viewer.setSessionState({ nodeVisibility: [{
objectName: 'foliage'
}]});

viewer.setToolMode(toolmode)

Sets the current tool mode. Also see:

Kind: instance method of Viewer Category: Methods

ParamTypeDescription
toolmodeToolmodeThe tool mode to set. Must be a value from the Toolmode enum

Example

// Set the tool mode to "Orbit"
viewer.setToolMode(NiraAPI.Toolmode.Orbit);

viewer.setCalloutViewBookmark(labelOrUuid)

Sets the view bookmark for the specified callout. Equivalent to clicking the Set bookmark menu item for the specified callout.

Kind: instance method of Viewer Category: Methods

ParamTypeDescription
labelOrUuidstringThe label or UUID of the callout to set as a view bookmark.

Example

// Sets the view bookmark for callout with the label 'A1'.
viewer.setCalloutViewBookmark("A1");

viewer.activateCallout(labelOrUuid)

Activates a callout with the specified label or uuid. Equivalent to clicking the Go to bookmark menu item for the specified callout.

Kind: instance method of Viewer Category: Methods

ParamTypeDescription
labelOrUuidstringThe label, UUID, title or defectTitle of the callout to activate.

Example

// Activate a callout by its UUID
viewer.activateCallout("A1");

viewer.selectObject(labelOrUuid)

Activates a callout with the specified label or uuid. Equivalent to clicking the Go to bookmark menu item for the specified callout.

Kind: instance method of Viewer Category: Methods

ParamTypeDescription
labelOrUuidstringThe label, UUID, title or defectTitle of the callout to activate.

Example

// Activate a callout by its UUID
viewer.activateCallout("A1");

Events


"asset_unload"

Emitted when an asset is unloaded (e.g. due to idle timeout).

Kind: event emitted by Viewer Category: Events


"object_picked"

Emitted when an object is picked in the 3D view.

A common use case for this event is to present some custom user interface related to something that the user clicked on. The value of the objectName, sceneName, and/or matName properties can be used as a lookup key to retrieve relevant information from your own datasources to populate your UI.

To receive the object_picked event, either the enableObjectPicking or the useMeshesForTagging view option must be set to true.

Kind: event emitted by Viewer Category: Events
Properties

NameTypeDescription
objectTypestringThe type of object. Currently, only "mesh" is supported.
objectNamestringThe name of the object that was picked.
sceneNamestringThe scene name of the object that was picked, if applicable. (e.g. "my-scene.obj")
matNamestringThe material name that was picked, if applicable.

Example

// Create a Viewer instance and enable object picking,
// which is required to receive object_picked events.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"enableObjectPicking": true,
});
// Register to receive object_picked events.
viewer.on("object_picked", (objectInfo) => {
console.log("object was picked:", objectInfo.objectName);
});

"callout_created"

Emitted when a callout is created by the user.

Kind: event emitted by Viewer Category: Events
Properties

NameTypeDescription
uuidstringThe UUID of the created callout.
titlestringThe title of the activated callout.
calloutUuidstringThe UUID of the created callout (legacy, do not use).

"callout_activated"

Emitted when a callout is activated (selected) by the user.

Kind: event emitted by Viewer Category: Events
Properties

NameTypeDescription
uuidstringThe UUID of the activated callout.
titlestringThe title of the activated callout.
calloutUuidstringThe UUID of the created callout (legacy, do not use).

"asset_load_start"

Emitted when an asset starts loading.

Kind: event emitted by Viewer Category: Events
Properties

NameTypeDescription
assetUuidstringThe UUID of the asset being loaded.

"toolmode"

Emitted when the tool mode is changed.

Kind: event emitted by Viewer Category: Events
Properties

NameTypeDescription
toolmodestringThe current tool mode.

"asset_load_finish"

Emitted when an asset finishes loading.

Kind: event emitted by Viewer Category: Events
Properties

NameTypeDescription
assetUuidstringThe UUID of the asset that finished loading.

NiraAPI.Toolmode : enum

A Nira tool mode. Pass one of these values when setting the toolmode using the setToolMode function.

Kind: static enum of NiraAPI Read only: true
Properties

NameDescription
NiraAPI.Toolmode.SelectToolmode for selecting.
NiraAPI.Toolmode.FpsToolmode for fps.
NiraAPI.Toolmode.OrbitToolmode for orbiting.
NiraAPI.Toolmode.PanToolmode for panning.
NiraAPI.Toolmode.ZoomToolmode for zooming.
NiraAPI.Toolmode.MeasureToolmode for measuring.
NiraAPI.Toolmode.CalloutToolmode for callout.

Example

viewer.setToolMode(NiraAPI.Toolmode.Fps);

NiraAPI.IViewOptions

Options that control the behavior of the Nira embed. These parameters should be included in the object passed as the second parameter to the Viewer constructor. Many of these options can also be specified on a per-asset basis using the View mode options dialog

Kind: static interface of NiraAPI Example

// Create a Viewer instance attached to an iframe with ID "nira-iframe" and set a few options.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"showNavigationTools": false,
"showMeasureTool": false,
"suppressCalloutDialog": true,
});

IViewOptions.showNavigationTools : boolean

Whether to show Nira's built-in orbit/pan/FPS mode switch buttons on the left side of the UI. This is useful if you're providing your own, or if you'd prefer not to have buttons for switching between these modes.

Kind: static property of IViewOptions Default: true
Example

// Create a Viewer instance and hide its navigation tool buttons
const viewer = new NiraAPI.Viewer("nira-iframe", {
"showNavigationTools": false,
});

IViewOptions.showMeasureTool : boolean

Whether to show Nira's measurement and callout tool buttons on the left side of the UI. Setting this to false is useful if you're providing your own buttons to switch into and out of measurement and callout creation mode.

Kind: static property of IViewOptions Default: true
Example

// Create a Viewer instance and hide its measure tool button.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"showMeasureTool": false,
});

IViewOptions.showCalloutsList : boolean

Whether to show the callout list button in the lower right corner. Setting this to false is useful if you're providing your own listing UI.

Kind: static property of IViewOptions Default: true
Example

// Create a Viewer instance and hide its callout list button.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"showCalloutsList": false,
});

IViewOptions.showRenderModes : boolean

Whether to show Nira's render mode toggling features in the View Settings menu (lower right corner). Currently, Nira's render mode toggling feature consists only of a "Matcap" checkbox, but other toggles may be added in the future.

Kind: static property of IViewOptions Default: true
Example

// Create a Viewer instance and hide its render mode toggles.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"showRenderModes": false,
});

IViewOptions.suppressCalloutDialog : boolean

Whether to suppress the display of Nira's built-in callout dialog when a callout is activated. Setting this to true is useful if you're providing your own UI for the display of callout related information.

Kind: static property of IViewOptions Default: false
Example

// Create a Viewer instance and supress the built-in callout dialog.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"suppressCalloutDialog": true,
});

IViewOptions.useMeshesForTagging : boolean

Causes meshes within the asset to be used for the special purpose of tagging point cloud regions.

This requires a both a mesh and a point cloud to be uploaded to the same asset. The mesh should contain separate objects with each object encapsulating a portion of the point cloud. These encapsulating objects are typically created using an engineering or CAD application then exported to mesh file (e.g. .OBJ).

When useMeshesForTagging is true, all meshes in the asset will be invisible by default. When a mesh is picked by the user, it will become visible on top of the point cloud with a vibrant color in a slightly transparent style, which will cause that region of the point cloud to appear highlighted.

If you have registered as a listener on the "object_picked" event, you will receive a mesh object's information every time one is picked by the user. The object's name can then be used as a lookup key to display relevant information from your own data sources or perform other custom actions. See the object_picked event for more information.

Please note, the enableObjectPicking view option will automatically be set to true when useMeshesForTagging is true.

Kind: static property of IViewOptions Default: false
Example

// Create a Viewer instance and use meshes within the asset for the special purpose
// of tagging point cloud regions.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"useMeshesForTagging": true,
});

IViewOptions.enableObjectPicking : boolean

By default, selecting an object is not possible while in any of Nira's navigation tools. Setting enableObjectPicking to true allows a single click or tap (i.e. a pick) of an object in the 3D view to select it while in a navigation tool.

Additionally, if you are listening for object_picked events, you will receive an object's name any time one is picked. This object's name can then be used as a lookup key to display relevant information from your own data sources or perform other custom actions.

Kind: static property of IViewOptions Default: false
Example

// Create a Viewer instance and enable object picking.
const viewer = new NiraAPI.Viewer("nira-iframe", {
"enableObjectPicking": true,
});

NiraAPI.IViewState

View State parameters. Any combination of these parameters can be included in the object passed to the setSessionState function.

Kind: static interface of NiraAPI


IViewState.camType : "Perspective" | "Top" | "Bottom" | "Left" | "Right" | "Front" | "Back"

The type of camera in use (e.g., perspective or orthographic side view).

Kind: static property of IViewState Default: "Perspective"
Example

// Switch the camera to a top-down view:
viewer.setSessionState({ camType: 'Top' });

IViewState.camPos : object

The camera's position in 3D space.

Kind: static property of IViewState Properties

NameTypeDefaultDescription
xnumber0.0X coordinate of the camera.
ynumber0.0Y coordinate of the camera.
znumber0.0Z coordinate of the camera.

Example

// Move the camera to (10, 5, 0):
viewer.setSessionState({
camPos: { x: 10, y: 5, z: 0 }
});

IViewState.camTar : object

The camera's target (look-at) point in 3D space.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

// Make the camera look at (5, 0, 5):
viewer.setSessionState({
camTar: { x: 5, y: 0, z: 5 }
});

IViewState.camPivot : object

The camera's target position. The camera will orbit around this point.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

// Pivot around (0,1,0) for a horizontal rotation:
viewer.setSessionState({
camPivot: { x: 0, y: 1, z: 0 }
});

IViewState.camFov : number

The camera's field of view (in degrees).

Kind: static property of IViewState Default: 45.0
Example

// Use a wide angle lens (60 degrees):
viewer.setSessionState({ camFov: 60 });

IViewState.camFlashlight : number

Intensity of a flashlight-like effect attached to the camera.

Kind: static property of IViewState Default: 0.0
Example

// Enable a half-strength flashlight:
viewer.setSessionState({ camFlashlight: 0.5 });

IViewState.explode : number

A factor that "explodes" or offsets individual parts of the model for inspection.

Kind: static property of IViewState Default: 0.0
Example

// Slightly explode the model:
viewer.setSessionState({ explode: 0.2 });

IViewState.gridSize : number

The size of the 3D grid spacing.

Kind: static property of IViewState Default: 1.0
Example

// Double the grid spacing:
viewer.setSessionState({ gridSize: 2.0 });

IViewState.gridNumLines : number

The number of lines (in each direction) drawn in the 3D grid.

Kind: static property of IViewState Default: 8
Example

// Increase grid lines to 16:
viewer.setSessionState({ gridNumLines: 16 });

IViewState.gridDraw : boolean

Whether to display a 3D grid in the scene.

Kind: static property of IViewState Default: false
Example

// Show the 3D grid:
viewer.setSessionState({ gridDraw: true });

IViewState.envName : string

The name of an environment map or background texture.

Kind: static property of IViewState Example

// Use the 'Circus Maximus 1' environment map:
viewer.setSessionState({ envName: 'Circus Maximus 1' });

IViewState.envExposure : number

Exposure compensation for the environment lighting.

Kind: static property of IViewState Default: 0.0
Example

// Increase environment brightness:
viewer.setSessionState({ envExposure: 1.5 });

IViewState.envRotY : number

Rotation of the environment map around the Y-axis (in degrees).

Kind: static property of IViewState Default: 0.0
Example

// Rotate environment by 45 degrees:
viewer.setSessionState({ envRotY: 45.0 });

IViewState.bgType : "Color" | "Environment"

Indicates whether the background is a solid color or an environment map.

Kind: static property of IViewState Default: "Color"
Example

// Use an environment map instead of a solid color:
viewer.setSessionState({ bgType: 'Environment' });

IViewState.bgColor : object

The solid background color if bgType is "Color".

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

// Set the background color to light gray:
viewer.setSessionState({
bgType: 'Color',
bgColor: { x: 0.8, y: 0.8, z: 0.8 }
});

IViewState.wfColor : object

The color used for wireframe overlays.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

// Give wireframes a bright red color:
viewer.setSessionState({
wfColor: { x: 1.0, y: 0.0, z: 0.0 }
});

IViewState.wfThickness : number

The thickness of wireframe lines.

Kind: static property of IViewState Default: 1.0
Example

// Make wireframe lines thicker:
viewer.setSessionState({ wfThickness: 2.0 });

IViewState.renderTextures : boolean

Whether textures are rendered on objects.

Kind: static property of IViewState Default: true
Example

// Disable texture rendering:
viewer.setSessionState({ renderTextures: false });

IViewState.renderFacetedNormals : boolean

Whether to render geometry with faceted normals (hard edges).

Kind: static property of IViewState Default: true
Example

// Switch to smooth shading:
viewer.setSessionState({ renderFacetedNormals: false });

IViewState.renderAo : boolean

Whether ambient occlusion (AO) is rendered.

Kind: static property of IViewState Default: true
Example

// Turn off ambient occlusion:
viewer.setSessionState({ renderAo: false });

IViewState.renderTriangulatedWf : boolean

Whether wireframes show the triangulation of meshes.

Kind: static property of IViewState Default: true
Example

// Show only quadrilateral (and ngon > 4) edges:
viewer.setSessionState({ renderTriangulatedWf: false });

IViewState.coordSystem : "Yup" | "Zup"

Defines the coordinate system convention (Y-up or Z-up).

Kind: static property of IViewState Default: "Yup"
Example

// Switch to Z-up:
viewer.setSessionState({ coordSystem: 'Zup' });

IViewState.measurementPrecision : number

How many decimal places to show for measurement labels.

Kind: static property of IViewState Default: 2
Example

// Show 4 decimals for measurements:
viewer.setSessionState({ measurementPrecision: 4 });

IViewState.measurementDrawAxisLines : boolean

If true, renders additional axis lines for measurement references.

Kind: static property of IViewState Default: false
Example

// Enable measurement axis lines:
viewer.setSessionState({ measurementDrawAxisLines: true });

IViewState.animFrame : number

Current animation frame index or time.

Kind: static property of IViewState Default: 0.0
Example

// Jump to animation frame 10:
viewer.setSessionState({ animFrame: 10 });

IViewState.envBlur : number

Controls how blurred the environment texture is when rendered.

Kind: static property of IViewState Default: 0.0
Example

// Slightly blur environment reflections:
viewer.setSessionState({ envBlur: 0.25 });

IViewState.renderTaa : boolean

Whether temporal anti-aliasing (TAA) is enabled.

Kind: static property of IViewState Default: true
Example

// Disable TAA:
viewer.setSessionState({ renderTaa: false });

IViewState.renderBloom : boolean

Whether bloom is applied for bright highlights.

Kind: static property of IViewState Default: true
Example

// Turn off bloom:
viewer.setSessionState({ renderBloom: false });

IViewState.vignette : number

Vignette effect strength around the viewport edges.

Kind: static property of IViewState Default: 0.0
Example

// Mild vignette:
viewer.setSessionState({ vignette: 0.2 });

IViewState.dithering : number

Dithering amount used to reduce banding in gradients.

Kind: static property of IViewState Default: 0.0
Example

// Slight dithering:
viewer.setSessionState({ dithering: 0.1 });

IViewState.camUp : object

A vector representing the camera's up direction.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

// Switch the camera up direction to (0,0,1):
viewer.setSessionState({
camUp: { x: 0, y: 0, z: 1 }
});

IViewState.renderUseMipmaps : boolean

Whether textures use mipmaps for improved rendering performance.

Kind: static property of IViewState Default: true
Example

// Disable mipmaps:
viewer.setSessionState({ renderUseMipmaps: false });

IViewState.envGroundProj : boolean

If true, attempts to project the environment onto a ground plane.

Kind: static property of IViewState Default: false
Example

viewer.setSessionState({ envGroundProj: true });

IViewState.version : number

A version number for forward/backward compatibility checks.

Kind: static property of IViewState Default: 6
Example

viewer.setSessionState({ version: 7 });

IViewState.useSingleMat : boolean

If true, uses a single material for all geometry (for special rendering modes).

Kind: static property of IViewState Default: false
Example

// Force a single material:
viewer.setSessionState({ useSingleMat: true });

IViewState.noMipmapGen : boolean

Prevents automatic generation of mipmaps if true.

Kind: static property of IViewState Default: false
Example

viewer.setSessionState({ noMipmapGen: true });

IViewState.animFps : number

The frames per second for any animation or time-based updates.

Kind: static property of IViewState Default: 30
Example

// Lower the FPS for a slower animation rate:
viewer.setSessionState({ animFps: 15 });

IViewState.lighting : boolean

Whether scene lighting is enabled.

Kind: static property of IViewState Default: true
Example

// Switch to an unlit mode:
viewer.setSessionState({ lighting: false });

IViewState.matCapName : string

The name of a matcap (material capture) texture used for specialized shading.

Kind: static property of IViewState Example

viewer.setSessionState({ matCapName: 'chromeStyle' });

IViewState.renderVertexColors : boolean

Whether per-vertex colors are rendered.

Kind: static property of IViewState Default: true
Example

// Disable vertex colors:
viewer.setSessionState({ renderVertexColors: false });

IViewState.showCallouts : boolean

If true, callouts (labels, notes) are displayed in the scene.

Kind: static property of IViewState Default: true
Example

// Hide callouts:
viewer.setSessionState({ showCallouts: false });

IViewState.showMeasurements : boolean

Whether to display measurement lines and labels in the scene.

Kind: static property of IViewState Default: true
Example

// Disable measurement overlays:
viewer.setSessionState({ showMeasurements: false });

IViewState.globalRotX : number

Global rotation around the X-axis applied to all scene objects.

Kind: static property of IViewState Default: 0.0
Example

viewer.setSessionState({ globalRotX: 45.0 });

IViewState.globalRotY : number

Global rotation around the Y-axis applied to all scene objects.

Kind: static property of IViewState Default: 0.0
Example

viewer.setSessionState({ globalRotY: 180.0 });

IViewState.globalRotZ : number

Global rotation around the Z-axis applied to all scene objects.

Kind: static property of IViewState Default: 0.0
Example

viewer.setSessionState({ globalRotZ: 90.0 });

IViewState.sharpen : number

A factor controlling any post-process sharpening.

Kind: static property of IViewState Default: 0.5
Example

// Increase sharpening:
viewer.setSessionState({ sharpen: 1.0 });

IViewState.renderMode : string

A human-readable string for the render mode (e.g., "Shaded", "Wireframe").

Kind: static property of IViewState Example

viewer.setSessionState({ renderMode: 'Wireframe' });

IViewState.renderModeColor : object

The color used when renderMode is set to a single color shading mode.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

// Shade everything in green:
viewer.setSessionState({
renderMode: 'SingleColor',
renderModeColor: { x: 0.0, y: 1.0, z: 0.0 }
});

IViewState.nodeVisibility : Array.<NodeVisibility>

A list that controls visibility of specific scene nodes.

Kind: static property of IViewState Example

viewer.setSessionState({
nodeVisibility: [
{ objectName: 'foliage', sceneName: 'scene1' },
{ objectName: 'carBody' }
]
});

IViewState.renderDof : boolean

Whether depth of field (DoF) is simulated.

Kind: static property of IViewState Default: true
Example

// Turn off depth of field:
viewer.setSessionState({ renderDof: false });

IViewState.showAreas : boolean

If true, areas or region-specific outlines are displayed.

Kind: static property of IViewState Default: true
Example

// Hide area outlines:
viewer.setSessionState({ showAreas: false });

IViewState.cameraLimitsPanning : boolean

Enables or disables camera panning limits.

Kind: static property of IViewState Default: false
Example

viewer.setSessionState({ cameraLimitsPanning: true });

IViewState.cameraLimitsDraw : boolean

If true, draws a visual boundary for the camera limits.

Kind: static property of IViewState Default: false
Example

viewer.setSessionState({ cameraLimitsDraw: true });

IViewState.cameraLimitsXMin : number

Minimum X coordinate for camera movement.

Kind: static property of IViewState Example

viewer.setSessionState({ cameraLimitsXMin: -100 });

IViewState.cameraLimitsXMax : number

Maximum X coordinate for camera movement.

Kind: static property of IViewState Example

viewer.setSessionState({ cameraLimitsXMax: 100 });

IViewState.cameraLimitsYMin : number

Minimum Y coordinate for camera movement.

Kind: static property of IViewState Example

viewer.setSessionState({ cameraLimitsYMin: 0 });

IViewState.cameraLimitsYMax : number

Maximum Y coordinate for camera movement.

Kind: static property of IViewState Example

viewer.setSessionState({ cameraLimitsYMax: 50 });

IViewState.cameraLimitsZMin : number

Minimum Z coordinate for camera movement.

Kind: static property of IViewState Example

viewer.setSessionState({ cameraLimitsZMin: -20 });

IViewState.cameraLimitsZMax : number

Maximum Z coordinate for camera movement.

Kind: static property of IViewState Example

viewer.setSessionState({ cameraLimitsZMax: 20 });

IViewState.aoRadius : number

The radius used in ambient occlusion calculations.

Kind: static property of IViewState Default: 0.38
Example

// Increase AO radius for deeper shadows:
viewer.setSessionState({ aoRadius: 0.5 });

IViewState.cameraLimitsZoomMin : number

The minimum camera zoom (or distance) limit.

Kind: static property of IViewState Default: 0.0
Example

viewer.setSessionState({ cameraLimitsZoomMin: 5.0 });

IViewState.cameraLimitsZoomMax : number

The maximum camera zoom (or distance) limit.

Kind: static property of IViewState Default: 0.0
Example

viewer.setSessionState({ cameraLimitsZoomMax: 50.0 });

IViewState.aoIntensity : number

The strength of the ambient occlusion effect.

Kind: static property of IViewState Default: 0.38
Example

viewer.setSessionState({ aoIntensity: 0.8 });

IViewState.cameraLimitsBottom : boolean

If true, restricts the camera from going below a certain "floor."

Kind: static property of IViewState Default: false
Example

viewer.setSessionState({ cameraLimitsBottom: true });

IViewState.cameraLimitsPanningPos : object

A position used as a reference when applying panning limits.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

viewer.setSessionState({
cameraLimitsPanningPos: { x: 10, y: 0, z: 10 }
});

IViewState.clippingEnabled : boolean

Toggles whether a clipping box/plane is applied to the scene.

Kind: static property of IViewState Default: false
Example

viewer.setSessionState({ clippingEnabled: true });

IViewState.clippingDraw : boolean

Whether to visually draw the clipping gizmo.

Kind: static property of IViewState Default: true
Example

viewer.setSessionState({ clippingDraw: false });

IViewState.clippingScale : object

The scale of the clipping box or region.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

viewer.setSessionState({
clippingScale: { x: 2, y: 2, z: 2 }
});

IViewState.clippingRotate : object

The rotation of the clipping box or region.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

viewer.setSessionState({
clippingRotate: { x: 15, y: 0, z: 0 }
});

IViewState.clippingTranslate : object

The position/translation of the clipping box or region.

Kind: static property of IViewState Properties

NameTypeDefault
xnumber0.0
ynumber0.0
znumber0.0

Example

viewer.setSessionState({
clippingTranslate: { x: 0, y: -1, z: 0 }
});

IViewState.clippingGizmo : number

A numeric mode or variant of clipping gizmo to display.

Kind: static property of IViewState Default: 0
Example

// Switch clipping gizmo to mode 2:
viewer.setSessionState({ clippingGizmo: 2 });

IViewState.bloomRadius : number

The radius used for bloom effect blur.

Kind: static property of IViewState Default: 12.0
Example

// Use a larger bloom radius:
viewer.setSessionState({ bloomRadius: 20 });

IViewState.bloomIntensity : number

The intensity of the bloom effect.

Kind: static property of IViewState Default: 0.8
Example

// Increase bloom intensity:
viewer.setSessionState({ bloomIntensity: 1.5 });

IViewState.bloomLevel : number

The number of iterations/levels in the bloom filter.

Kind: static property of IViewState Default: 4
Example

// More bloom passes:
viewer.setSessionState({ bloomLevel: 6 });

IViewState.measurementUnits : "Meters" | "Feet"

The default measurement unit system for displaying distances.

Kind: static property of IViewState Default: "Meters"
Example

// Switch to feet:
viewer.setSessionState({ measurementUnits: 'Feet' });

IViewState.measurementMul : number

A multiplier to convert from the scene's internal units to measurementUnits.

Kind: static property of IViewState Default: 1.0
Example

// If the scene is in centimeters, multiply by 0.01 for meters:
viewer.setSessionState({ measurementMul: 0.01 });

IViewState.renderTransparency : boolean

Whether transparent surfaces are rendered by their alpha values.

Kind: static property of IViewState Default: true
Example

// Disable transparency:
viewer.setSessionState({ renderTransparency: false });

IViewState.calloutViewStyle : "CalloutId" | "Circle" | "Title"

How callouts (labels) are displayed: ID label, circle, or title text.

Kind: static property of IViewState Example

// Use circle callouts:
viewer.setSessionState({ calloutViewStyle: 'Circle' });

IViewState.cameraLimitsOrbiting : boolean

If true, restricts orbital camera movement to certain bounds.

Kind: static property of IViewState Default: false
Example

viewer.setSessionState({ cameraLimitsOrbiting: true });

IViewState.levelsEnabled : boolean

Toggles a "levels" post-processing effect.

Kind: static property of IViewState Default: false
Example

// Enable levels correction:
viewer.setSessionState({ levelsEnabled: true });

IViewState.levelsShadows : number

Shadows input level for the "levels" effect.

Kind: static property of IViewState Default: 0.0
Example

viewer.setSessionState({ levelsShadows: 10 });

IViewState.levelsMidtones : number

Midtones gamma for the "levels" effect.

Kind: static property of IViewState Default: 1.0
Example

// Darken midtones:
viewer.setSessionState({ levelsMidtones: 0.8 });

IViewState.levelsHighlights : number

Highlights input level for the "levels" effect.

Kind: static property of IViewState Default: 255.0
Example

viewer.setSessionState({ levelsHighlights: 220 });

IViewState.hiddenNodeViewStyle : "Invisible" | "Xray"

Determines how hidden nodes are visually treated: fully invisible or X-ray style.

Kind: static property of IViewState Example

// Show hidden nodes in X-ray:
viewer.setSessionState({ hiddenNodeViewStyle: 'Xray' });

IViewState.showScanStations : boolean

Whether to display scanning station markers for point cloud data.

Kind: static property of IViewState Default: true
Example

// Hide scan station markers:
viewer.setSessionState({ showScanStations: false });

IViewState.scanStationsSize : number

The size of each scan station marker if shown.

Kind: static property of IViewState Default: 45.0
Example

// Increase scan station markers size:
viewer.setSessionState({ scanStationsSize: 60.0 });

IViewState.showPoints : boolean

Whether points (in point clouds) are displayed at all.

Kind: static property of IViewState Default: true
Example

// Hide all point clouds:
viewer.setSessionState({ showPoints: false });

IViewState.showMeshes : boolean

Whether mesh geometry is displayed at all.

Kind: static property of IViewState Default: true
Example

// Hide all meshes:
viewer.setSessionState({ showMeshes: false });

IViewState.edl : "Off" | "Low" | "High"

Eye-Dome Lighting setting (off, low, or high quality).

Kind: static property of IViewState Default: "Low"
Example

// Turn off EDL:
viewer.setSessionState({ edl: 'Off' });

IViewState.pointsSize : number

The size of points rendered in point clouds.

Kind: static property of IViewState Default: 1.0
Example

// Increase point size:
viewer.setSessionState({ pointsSize: 2.5 });

IViewState.gapFill : "Off" | "Basic" | "HQ"

The gap-filling mode for rendering geometry or point clouds.

Kind: static property of IViewState Default: "HQ"
Example

// Disable gap-fill:
viewer.setSessionState({ gapFill: 'Off' });

NiraAPI.NodeVisibility

Controls the visibility of a specific node within a scene.

Kind: static interface of NiraAPI


NodeVisibility.objectName : string

The name of the node/object in the scene.

Kind: static property of NodeVisibility Example

// Hide object named 'foliage':
viewer.setSessionState({
nodeVisibility: [{ objectName: 'foliage' }]
});

NodeVisibility.sceneName : string

The name of the scene. If unspecified, it applies to the objectName across all scenes.

Kind: static property of NodeVisibility Example

// Hide 'buildingA' in the 'city.obj' scene:
viewer.setSessionState({
nodeVisibility: [{ objectName: 'buildingA', sceneName: 'cityScene.obj' }]
});