InstanceGraphAPI¶
Interface InstanceGraphAPI
add(options: AddNodeOptions): number;
add(
dataURI: string,
parentID?: number,
usage?: UsageString,
label?: string,
contentType?: string,
initialProperties?: InitialNodeProperties,
cacheStrategy?: CacheStrategy,
): number;
addCustomNode(
customNodeType: string,
data: any,
dataType?: AttachmentType,
): number;
collectRuntimeNodesOfType(nodeType: NodeType, subType?: string): number[];
getEnabledAuxNodes(nodeID: number): Promise<number[]>;
getMetadata(nodeID: number): Promise<{ [key: string]: string }>;
getProperties<T extends string>(
nodeID: number,
properties: T[],
): Promise<PropertyType<T>[]>;
getProperty<T extends string>(
nodeID: number,
property: T,
): Promise<PropertyType<T>>;
getRootNodeId(
target: number | TopologyHandle,
includeTarget?: boolean,
): number;
getStatistics(
nodeType?: NodeType,
nodeID?: number,
recursive?: boolean,
): Promise<any>;
invertEnabledStates(): void;
isNodeDeletable(nodeID: number): boolean;
isNodeType(nodeID: number, nodeType: NodeType): boolean;
registerCustomProperty(
name: string,
defaultValue: any,
recursive?: boolean,
): void;
remove(nodeID?: number | number[], safe?: boolean): Promise<RemoveState>;
requestActiveSceneVolume(): Promise<BoxVolume>;
requestAuxRootNodeIds(scopeNodeId?: number): Promise<number[]>;
requestFullSceneVolume(): Promise<BoxVolume>;
requestL3DInformation(targetNodeId: number): Promise<any>;
requestNodeIdsByBoxVolume(
boxVolume: BoxVolume,
includeOverlappingNodes?: boolean,
includeDisabledNodes?: boolean,
forceExpand?: boolean,
scopeNodeId?: number,
): Promise<number[]>;
requestRootNodeIds(
scopeNodeId?: number,
recursive?: boolean,
): Promise<number[]>;
resetProperties(
nodeID: number,
properties: string[],
recursive?: boolean,
): Promise<void>;
resetProperty(
nodeID: number,
property: string,
recursive?: boolean,
): Promise<void>;
setParent(nodeID: number, newParentID: number): void;
setProperty<T extends string>(
nodeID: number | number[],
property: T,
value: PropertyType<T>,
silent?: boolean,
): Promise<void>;
}
Hierarchy (View Summary)
- InstanceGraphAPI
Methods
add
- add(options: AddNodeOptions): number
- Adds a new node to the instance graph. - Parameters- options: AddNodeOptionsSpecifies the options for the new Node. 
 - Returns number- The ID of the added node 
- options: AddNodeOptions
- add(
 dataURI: string,
 parentID?: number,
 usage?: UsageString,
 label?: string,
 contentType?: string,
 initialProperties?: InitialNodeProperties,
 cacheStrategy?: CacheStrategy,
 ): number
- Parameters- dataURI: stringSpecifies the URI to the data resource. 
- OptionalparentID: number- Specifies the parent Node ID of the added Node. 
- Optionalusage: UsageString- The usage parameter allows to define how the resource should be inserted in the InstanceGraph. 
- Optionallabel: string- Specifies a custom label for the added Node. 
- OptionalcontentType: string- Specifies the MimeType of the data resource. 
- OptionalinitialProperties: InitialNodeProperties- Specifies initialProperties of the added Node. 
- OptionalcacheStrategy: CacheStrategy- Specifies the strategy which is used when a data cache is requested from the Hub. 
 - Returns number- The ID of added node - Deprecated- This function will no longer be available in future webvis releases. Please use the add function with AddNodeOptions instead. - Adds a new Node to the InstanceGraph. - Triggers a NodeAddedEvent. In case of an error, a NodeErrorEvent is triggered. 
- dataURI: string
add
- addCustomNode(
 customNodeType: string,
 data: any,
 dataType?: AttachmentType,
 ): number
- Creates a custom node along with custom data which is stored in an attachment. - The attached data can be accessed via the Property.ATTACHMENT property of the node. - Triggers a NodeAddedEvent. In case of an error, a NodeErrorEvent is triggered. - Parameters- customNodeType: stringSpecifies the custom node type. 
- data: anySpecifies the data of the custom node. 
- OptionaldataType: AttachmentType- Specifies the type of the data. Default: "json". 
 - Returns number- The ID of the newly created custom node. 
- customNodeType: string
collect
- collectRuntimeNodesOfType(nodeType: NodeType, subType?: string): number[]
- Returns a list of all existing runtime node IDs of a specified type. - Parameters- nodeType: NodeTypeThe node type to collect. 
- OptionalsubType: string- The sub type to collect. Only used for custom nodes. See Property.SUBTYPE. 
 - Returns number[]- A list of runtime node IDs of the specified type. 
- nodeType: NodeType
get
- getEnabledAuxNodes(nodeID: number): Promise<number[]>
- Parameters- nodeID: numberSpecifies the entry point of the subtree traversal. Default: 0 
 - Returns Promise<number[]>- An Array of all enabled aux node IDs - Deprecated- This function will no longer be available in future webvis releases. Use the QueryAPI instead. - Traverses the subtree of a given node ID and collects all enabled aux nodes. 
- nodeID: number
get
get
- getProperties<T extends string>(
 nodeID: number,
 properties: T[],
 ): Promise<PropertyType<T>[]>
- Returns the values of the specified properties of the given node. - Type Parameters- Parameters- nodeID: numberThe ID of the node whose properties should be read. 
- properties: T[]The names of the Properties whose values should be read. 
 - Returns Promise<PropertyType<T>[]>- The retrieved values of the node's properties. 
- nodeID: number
get
- getProperty<T extends string>(
 nodeID: number,
 property: T,
 ): Promise<PropertyType<T>>
- Returns the value of the specified property of the given node. - Type Parameters- Parameters- Returns Promise<PropertyType<T>>- The retrieved value of the node property. 
get
- getRootNodeId(target: number | TopologyHandle, includeTarget?: boolean): number
- Returns the root node ID of the given node or topology element. - Parameters- target: number | TopologyHandleSpecifies the target node or topology element. 
- OptionalincludeTarget: boolean- Controls if the target node itself can be returned as root node. If set to false and a root node ID is passed in, it returns the next higher root node ID. Default: true 
 - Returns number- The root node ID of the given node ID or topology handle. 
- target: number | TopologyHandle
get
- getStatistics(
 nodeType?: NodeType,
 nodeID?: number,
 recursive?: boolean,
 ): Promise<any>
- Traverses the subtree of a given node ID and collects all statistics (currently only available for AUX nodes). - Parameters- OptionalnodeType: NodeType- Specifies the target node type. Default: NodeType.ALL 
- OptionalnodeID: number- Specifies the node ID as the entry point of the subtree traversal. Default: 0 
- Optionalrecursive: boolean
 - Returns Promise<any>- An object of type/count pairs. 
invert
- invertEnabledStates(): void
- Inverts all enabled states. - Triggers a NodeChangedEvent. - Returns void
is
is
register
- registerCustomProperty(
 name: string,
 defaultValue: any,
 recursive?: boolean,
 ): void
- Registers a new custom node property. - Custom properties allow developers to hook into the node hierarchy with custom data. This enables the creation of custom behaviors and interactions that can benefit from the NODE_* events, like the NodeChangedEvent, emitted by the InstanceGraphAPI. - Triggers a CustomPropertyRegisteredEvent - Parameters- name: stringThe name of the new property. 
- defaultValue: anySpecifies the default value. 
- Optionalrecursive: boolean- Defines whether the property is recursive. Default: false 
 - Returns void
- name: string
remove
- remove(nodeID?: number | number[], safe?: boolean): Promise<RemoveState>
- Removes the node for the given node ID from the scene and all related snapshots. If no node ID is supplied, all nodes are deleted. - Triggers a NodeRemovedEvent. - Parameters- OptionalnodeID: number | number[]- The ID of the node that should be removed or undefined to remove all nodes. 
- Optionalsafe: boolean- Performs a safe remove which interrupt the removal process if the node is part of one or more snapshots. Default: false. 
 - Returns Promise<RemoveState>- A promise that resolves with the RemoveState once the operation is complete. 
request
request
- requestAuxRootNodeIds(scopeNodeId?: number): Promise<number[]>
- Returns a list of all existing AUX root node IDs below the specified subtree. - Parameters- OptionalscopeNodeId: number- Specifies the top one node ID of the subtree to be searched. Default: 0 
 - Returns Promise<number[]>- A list of AUX root node IDs. 
request
- requestFullSceneVolume(): Promise<BoxVolume>
- Returns the full volume of the current scene. It is the smallest volume that contains all nodes of the scene, regardless of their Property.ENABLED state. - Returns Promise<BoxVolume>
request
request
- requestNodeIdsByBoxVolume(
 boxVolume: BoxVolume,
 includeOverlappingNodes?: boolean,
 includeDisabledNodes?: boolean,
 forceExpand?: boolean,
 scopeNodeId?: number,
 ): Promise<number[]>
- Returns a list of all node IDs that are included in or overlapped by the specified bounding volume. - Parameters- boxVolume: BoxVolumeSpecifies the bounding volume. 
- OptionalincludeOverlappingNodes: boolean- Specifies whether the result should include nodes which overlap the specified bounding volume as well. Default: false 
- OptionalincludeDisabledNodes: boolean- Specifies whether the result should include nodes which are disabled as well. Default: false 
- OptionalforceExpand: boolean- If set to true, L3D instances may be expanded to find their leaf nodes. Default: false 
- OptionalscopeNodeId: number- Specifies the top one node ID of the subtree to be searched. Default: 0 
 - Returns Promise<number[]>- List of all node IDs which are included or overlapped by the specified bounding volume. 
- boxVolume: BoxVolume
request
- requestRootNodeIds(scopeNodeId?: number, recursive?: boolean): Promise<number[]>
- Returns a list of all existing root node IDs below the specified subtree. - Parameters- OptionalscopeNodeId: number- Specifies the top one node ID of the subtree to be searched. Default: 0 
- Optionalrecursive: boolean- Specifies if the subtree is traversed recursively. Default: false 
 - Returns Promise<number[]>- A list of root node IDs. 
reset
- resetProperties(
 nodeID: number,
 properties: string[],
 recursive?: boolean,
 ): Promise<void>
- Resets the value of the specified properties of the given node. - Triggers a NodePropertiesResetEvent. If the property has changed, this will additionally trigger a NodeChangedEvent. - Parameters- nodeID: numberThe ID of the node whose Property should be reset. 
- properties: string[]List of properties which should be reset. 
- Optionalrecursive: boolean- If set to true, the properties are reset recursively. Default: false 
 - Returns Promise<void>
- nodeID: number
reset
- resetProperty(
 nodeID: number,
 property: string,
 recursive?: boolean,
 ): Promise<void>
- Resets the value of the specified property of the given node. - Triggers a NodePropertiesResetEvent. If the property has changed, this will additionally trigger a NodeChangedEvent. - Parameters- nodeID: numberThe ID of the node whose Property should be reset. 
- property: stringThe Property that should be reset. 
- Optionalrecursive: boolean- If set to true, the properties are reset recursively. Default: false 
 - Returns Promise<void>
- nodeID: number
set
- setParent(nodeID: number, newParentID: number): void
- Sets a new parent for a given node ID. - Triggers a NodeChangedEvent. - Parameters- nodeID: numberThe ID of the node whose parent should be set. 
- newParentID: numberThe ID of the new parent node. 
 - Returns void
- nodeID: number
set
- setProperty<T extends string>(
 nodeID: number | number[],
 property: T,
 value: PropertyType<T>,
 silent?: boolean,
 ): Promise<void>
- Sets the specified property to the given value on the node(s) with the specified ID(s). - Triggers a NodeChangedEvent. Depending on the property it can trigger additional events, e.g. ActiveSceneVolumeChangedEvent. - Type Parameters- Parameters- nodeID: number | number[]The ID(s) of the node(s) whose property has to be set. 
- property: TThe name of the Property that has to be set. 
- value: PropertyType<T>The new value of the specified property. 
- Optionalsilent: boolean- The silent flag indicates that no NODE_CHANGED event is fired. Default: false 
 - Returns Promise<void>
- nodeID: number | number[]
InstanceGraphAPI
Overview
The InstanceGraphAPI allows for the control and manipulation of webvis content. The instance graph represents a scene graph-like tree structure of nodes, where each node can contain links to 3D geometry and/or group other nodes.
The getProperty and setProperty functions enable setting and retrieving properties of various types on the nodes. Properties are used to modify any node-dependent data, such as color, local transformation, etc. While there is a set of predefined node properties that webvis will respond to, the surrounding application can add any other custom properties to the nodes using registerCustomProperty.
All properties can be persisted by the different functionalities of the SessionStorageAPI.
Quick Start
Events
The InstanceGraphAPI emits the following events: