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.commandsonly. 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 meaning | Actual method / property |
|---|---|
| Get hidden element ids | getHiddenElemets (missing n) |
| Cutting planes on getView / setView | cuttingPlnaes (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
| Parameter | Type | Description |
|---|---|---|
glassMode | Boolean | When true, treats the transition as glass / XRay style handling |
glassModeFromToolbar | Boolean | Tracks whether glass was requested from the toolbar |
newDrawMode | Number / enum | Communicator 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
| Parameter | Type | Description |
|---|---|---|
cuttingPlane | Object | { max: { x, y, z }, min: { x, y, z } } |
cuttingPlane.max | Object | Max plane coordinates |
cuttingPlane.min | Object | Min 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
| Parameter | Type | Description |
|---|---|---|
jsoncamera | Object | Same shape as getCamera() |
jsoncamera.position / target / up | Object | { x, y, z } |
jsoncamera.width / height | Number | Camera frustum size |
jsoncamera.projection | Number | Orthographic 1, perspective 2 (Communicator convention) |
jsoncamera.nearLimit | Number | Near limit |
jsoncamera.className | String | "Communicator.Camera" |
Returns: none
if (commands?.setCamera) {
commands.setCamera(jsoncamera);
}
getView()
Snapshot of camera, cutting planes, draw mode, and selection.
Returns: object with:
| Property | Notes |
|---|---|
camera | From getCamera() |
cuttingPlnaes | From getCuttingPlanes() — spelling is cuttingPlnaes |
drawMode | Current Communicator draw mode |
selection | Current 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
| Parameter | Type | Description |
|---|---|---|
obj.camera | Object | Passed to setCamera |
obj.cuttingPlnaes | Object | Passed to setCuttingPlanes — must use cuttingPlnaes |
obj.drawMode | Number | Communicator draw mode (0 Wireframe, 1 Shaded, 2 WireframeOnShaded, 3 HiddenLine, 4 XRay) |
obj.selection | Array | Element 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);
}
Related
- Model Viewers Overview
- IafViewer — props including
view3d.renderingMode - IafViewerDBM
- IafViewer UI — toolbar / selection overview