Skip to main content
Version: v5.3

Commands

Imperative helpers on the inner IafViewer instance for View3D (Communicator) state: selection, settings, isolation / hide / zoom sets, cutting planes, camera, and draw mode.

Scope: This page documents IafViewer.commands only. ArcGIS and Unreal Engine use separate surfaces (arcgis.command / ue.command, onIafMapReady / onUeReady → sendCommand, IafEvmUtils). See IafViewer ArcGIS and IafViewer Unreal Engine.

Access​

With IafViewerDBM, the commands object is on the nested viewer ref:

import React, { useRef } from "react";
import _ from "lodash";

const viewerRef = useRef();
// … <IafViewerDBM ref={viewerRef} … />

const commands = _.get(viewerRef, "current.iafviewerRef.current.commands");

Package: @dtplatform/iaf-viewer. Methods below match this.commands in IafViewer.jsx.

Known package typos​

Call these names exactly as implemented (aliases are not provided):

Intended meaningActual method / property
Get hidden element idsgetHiddenElemets (missing n)
Cutting planes on getView / setViewcuttingPlnaes (missing e)

getSelectedEntities()​

Returns package / element ids for the current View3D selection (walks parents via graphics resources when needed).

Returns: Promise<string[]>

if (commands?.getSelectedEntities) {
const pkgIds = await commands.getSelectedEntities();
}

getSettings()​

Returns the viewer’s current settings object.

Returns: Promise<object>

if (commands?.getSettings) {
const settings = await commands.getSettings();
}

getIsolatedElements()​

Returns the current isolated-element set.

Returns: the isolation set held by the viewer (IsolateElementSet)

if (commands?.getIsolatedElements) {
const isolated = commands.getIsolatedElements();
}

getHiddenElemets()​

Returns the current hidden-element set. Spelling is getHiddenElemets in the package.

Returns: the hide set held by the viewer (HiddenElementSet)

if (commands?.getHiddenElemets) {
const hidden = commands.getHiddenElemets();
}

zoomToElements()​

Returns the current zoom-to-element set (ZoomElementSet). Despite the name, this is a getter, not a zoom action.

Returns: the zoom set held by the viewer

if (commands?.zoomToElements) {
const zoomSet = commands.zoomToElements();
}

setDrawMode(glassMode, glassModeFromToolbar, newDrawMode)​

Sets Communicator draw mode / glass (XRay) handling used by the toolbar and view3d.renderingMode sync.

Parameters

ParameterTypeDescription
glassModeBooleanWhen true, treats the transition as glass / XRay style handling
glassModeFromToolbarBooleanTracks whether glass was requested from the toolbar
newDrawModeNumber / enumCommunicator draw mode (or XRay when applying glass)

Returns: none

if (commands?.setDrawMode) {
commands.setDrawMode(false, false, /* Communicator.DrawMode.Shaded */ 1);
}

Prefer declarative view3d.renderingMode when configuring from app props; use setDrawMode for imperative toolbar-style updates.

getCuttingPlanes()​

Returns current cutting-plane max / min coordinates (falls back to model bounds when a slider is unset).

Returns: { max: { x, y, z }, min: { x, y, z } }

if (commands?.getCuttingPlanes) {
const cuttingPlanes = commands.getCuttingPlanes();
}

Example shape:

{
max: { x: 60665.3359375, y: 48933.6171875, z: 14610 },
min: { x: -72522.125, y: -72522.125, z: -72522.125 }
}

setCuttingPlanes(cuttingPlane)​

Stores cutting-plane values and activates cutting-plane UI state.

Parameters

ParameterTypeDescription
cuttingPlaneObject{ max: { x, y, z }, min: { x, y, z } }
cuttingPlane.maxObjectMax plane coordinates
cuttingPlane.minObjectMin plane coordinates

Returns: none

const plane = {
max: { x: 60665.3359375, y: 48933.6171875, z: 14610 },
min: { x: -72522.125, y: -72522.125, z: -72522.125 },
};

if (commands?.setCuttingPlanes) {
commands.setCuttingPlanes(plane);
}

getCamera()​

Serializes the current Communicator camera to JSON and caches it on component state.

Returns: camera JSON (position, target, up, width, height, projection, nearLimit, className)

if (commands?.getCamera) {
const camera = commands.getCamera();
}

Example:

{
position: { x: -71503.14, y: -77040.73, z: 75165.63 },
target: { x: 770.49, y: -4767.09, z: 2891.99 },
up: { x: 0.408, y: 0.408, z: 0.816 },
width: 181899.53,
height: 181899.53,
projection: 1,
nearLimit: 0.001,
className: "Communicator.Camera"
}

setCamera(jsoncamera)​

Applies a camera from JSON (Communicator.Camera.fromJson). No-op if jsoncamera is null.

Parameters

ParameterTypeDescription
jsoncameraObjectSame shape as getCamera()
jsoncamera.position / target / upObject{ x, y, z }
jsoncamera.width / heightNumberCamera frustum size
jsoncamera.projectionNumberOrthographic 1, perspective 2 (Communicator convention)
jsoncamera.nearLimitNumberNear limit
jsoncamera.classNameString"Communicator.Camera"

Returns: none

if (commands?.setCamera) {
commands.setCamera(jsoncamera);
}

getView()​

Snapshot of camera, cutting planes, draw mode, and selection.

Returns: object with:

PropertyNotes
cameraFrom getCamera()
cuttingPlnaesFrom getCuttingPlanes() — spelling is cuttingPlnaes
drawModeCurrent Communicator draw mode
selectionCurrent filtered selection ids
if (commands?.getView) {
const view = commands.getView();
// view.cuttingPlnaes — not cuttingPlanes
}

setView(obj)​

Applies camera, cutting planes, draw mode, and selection from a view object. No-op if obj is null.

Parameters

ParameterTypeDescription
obj.cameraObjectPassed to setCamera
obj.cuttingPlnaesObjectPassed to setCuttingPlanes — must use cuttingPlnaes
obj.drawModeNumberCommunicator draw mode (0 Wireframe, 1 Shaded, 2 WireframeOnShaded, 3 HiddenLine, 4 XRay)
obj.selectionArrayElement ids to select (uses id mapping when available)

Returns: Promise<void> (async when applying selection)

const view = {
camera: { /* getCamera() shape */ },
cuttingPlnaes: {
max: { x: 60665.3359375, y: 48933.6171875, z: 14610 },
min: { x: -72522.125, y: -72522.125, z: -72522.125 },
},
drawMode: 1,
selection: [9192],
};

if (commands?.setView) {
await commands.setView(view);
}