Log InDiscussions


This module is a high level scene graph manipulation and query library.


This module is only intended to be used within custom script actions inside asset configurator rules. For this purpose, the Scene API needs to be referenced with api.scene.

The Scene API is not intended to be used in either Item logic or front-end code, where the evaluation of the scene graph happens a little bit differently. Please keep Item logic only for product logic, while 3D logic should reside only on Assets. Spreading 3D logic across Items and the front-end makes it more difficult to understand and maintain an implementation.

If you would like to test these methods with the examples provided, please use the provided testing sandbox at the bottom of the page.

You can also test these methods in the browser console while you have a ThreeKit asset's page open, using playerApi.scene instead of api.scene. For example: playerApi.scene.getAll({name: 'coolerMesh'}).
For testing in the console of a page with an embedded player, you need to use the embedded player object instead, such as player.scene.

The Query Object

Each of the methods listed in this document allows for a query object to be passed as a parameter. You can use an object with the following key:value pairs.

  //Query Source
  from: 'QueryObject | String', // The ID of the node whose children we query
  //Query Controls
  id: 'String', //Matches the node with the exact id
  parent: 'Boolean', //Return the parent of the node
  child: 'String', //Return the first child of the node provided
  includeParent: 'Boolean', //If true, the query will also try to match on `from`
  shallow: 'Boolean', //If true, the query will not search the children's children
  skipModels: 'Boolean', //If true, the query will not descent into `Model` type nodes
  hierarchical: 'Boolean', //If true, the query will also descend proxies and models
  //Query Filter
  name: 'String | RegExp', // The name of the node you are querying for
  type: 'String | String[]', //The node type must be one of the `type` listed below
  tags: 'Array<String | RegExp>',
  hasPlug: 'String', //The node must have the listed plug from the list below.
  //Operator Filter
  properties: '{ [key: String]: any }', //Operator properties
  //Query Result
  evalNode: 'Boolean', //If true, the result will be the evaluated node
  evalPlug: 'String', //If true, the result will be the evaluated plug
  plug: 'String', // Plug you are querying for
  operatorIndex: 'Number', //Return the operator at the provided index
  property: 'String', // Several uses. See description

or you can use an array that defines the path to your query.

[from, plugs, plugName, index, property]

Option Details

Query Source

fromQueryObject | StringThe node whose children we query.
For simplicity's sake, the player API automatically sets from: api.instanceId.

When embedding a configurator, the ThreeKit player automatically creates new asset instances in the browser local memory. This is because an asset can be used multiple times, and the player needs to be able to distinguish between each instance of an asset where it gets referenced. The api.instanceId provides the reference to this new temporary asset created by the player for the current session.

Query Controls

idStringSearch for a node that matches the given id.
parentBooleanReturn the parent of the node id provided. This requires using the id option.
childStringReturn the first child of the node id provided. This requires using the id option.
includeParentBooleanIf true, the query will also try to match on from. The player API sets this to true by default.
shallowBooleanIf true, the query will not search the children's children.
skipModelsBooleanIf true, the query will not descend into Model type nodes.
hierarchicalBooleanIf true, the query will also descend proxies and model references. This requires the scene-graph to be evaluated.

Query Filter

nameString | RegExpThe name of the node you are searching for must match the given name. Can use wildcard "*".
typeString | String[]Specify that the node type must be one of the types listed below. Exact matches only.
tagsArray<String | RegExp>The node must have at least one tag matching one of the given tags. Can use wildcard "*".
hasPlugStringThe node must have the given plug type, from the list below.

Operator Filter

properties{ [key: String]: any }The operator must match the given template. Only works for number, string, and boolean properties.
Example: properties: { angle: 120, shift: true, mode:"parallel" }

Query Result

evalNodeBooleanIf true, the result will be the evaluated node. Can be combined with property to get the evaluated node's property.
evalPlugStringIf true, the result will be the evaluated plug. Can be combined with property to get the evaluated plug's property.
plugString- If set, the result will be the first matching operator of the plug.
- If set, it will also act as a filter like hasPlug.
- Can be combined with property to get the operator's property.
- If combined with property, but there is no operatorIndex, the operator must have the given property.
operatorIndexNumberIf set, return the operator at that index in the array of operators on a given plug.
propertyString- Can be used with evalNode to get an evaluated property.
- Can be used with evalPlug to get an evaluated plug property.
- Can be used on its own to get the node's "name" or "type".
- Can be used with plug to get the operator's property.

Node Types

{ 'Scene',     'Objects',     'MaterialLibrary',   'PolyMesh',    'Light',       'Camera',
  'Null',      'Model',       'Material',          'Image',       'Pass',        'Renderer',
  'Bone',      'Annotation',  'Measurement',       'Sprite',      'Shape',       'Helper',
  'Vrscene',   'Item',        'Upload',            'Group',       'Layer',       'ImageLayer',
  'Composite', 'ShadowPlane', 'Vector',            'Font',        'Video',       'Lut',
  'Vfb',       'Stage',       'VrayMesh',          'VrayLight',   'VraySky',     'LayoutContainer',
  'Connector' }

Plug Types

{ 'Annotation',       'Camera',        'Connector',          'Environment',       'Font',      
  'Group',            'Image',         'LayoutContainer',    'Light',             'Lut',
  'Material',         'Measurement',   'Null',               'Objects',           'Physics',
  'Player',           'PolyMesh',      'PostEffect',         'Properties',        'Proxy',
  'RenderSettings',   'Selection',     'ShadowPlane',        'Shape',             'Sprite',
  'Timeline',         'Transform',     'Vector',             'Vfb',               'Video',
  'VrayLight',        'VrayMesh',      'VraySky',            'Vrscene' }


  name: 'Cooler', 
  plug: 'Transform', 
  property: 'rotation', 

The Cooler -> Transform -> rotation object above will accomplish the same thing as the array below. You can find this path array using the find method.

['54f3a9f3-3ed1-4486-b5e7-9025fa0d9559', 'plugs', 'Transform', 0, 'rotation']

Using Regex

When querying a node by name, you may use a string or regular expression object. If you’re querying a node whose name has special characters, it’s recommended that you use a RegEx object for simplicity. Below are some examples of using a RegEx object to query nodes with various special characters in their names.

api.scene.get([player.scene.findNode({name: /Sphere\$/}), 'name']);
>> "Sphere$"
api.scene.get([player.scene.findNode({name: /Sphere\^/}), 'name']);
>> "Sphere^"
api.scene.get([player.scene.findNode({name: /Sphere\+/}), 'name']);
>> "Sphere+"
api.scene.get([player.scene.findNode({name: /Sphere\"/}), 'name']);
>> "Sphere\""

You can also use strings to query nodes by name, but these strings are not taken literally. Some of their special characters are replaced, and then the string is compiled into a RegEx in the form /^ReplacedString$/i. “ReplacedString" being the string that had some of its special characters replaced.

( and ) are escaped automatically, thus they are treated literally. You can’t do a ReGex “Group” via a string, you must use an actual RegEx object to achieve groups

* is converted to the regex (.*), thus behaving like a simple wildcard, the same as if you use * in a Google search

If the string starts or ends with a double-quote, ", it is removed. Thus, if you’re node name is something like "Ugly" Fabric, your string must be:
player.scene.get([player.scene.findNode({name: "\"\"Ugly\" Fabric"}), 'name'])

Here are the above examples implemented via strings:

// note, the name of the node ended with a space, not the "+" sign
api.scene.get([player.scene.findNode({name: "Sphere\\+ "}), 'name']);
>> "Sphere+ "

// first and last character are stripped if they are double-quotes, so I need to put 2
api.scene.get([player.scene.findNode({name: "Sphere\"\""}), 'name']);
>> "Sphere\""

api.scene.get([player.scene.findNode({name: "Sphere\\^"}), 'name']);
>> "Sphere^"

api.scene.get([player.scene.findNode({name: "Sphere\\$"}), 'name']);
>> "Sphere$"

Get All

getAll method will return object(s) of { nodeId: value } for all values that match the query.

Finds all nodes:

api.scene.getAll(null || QueryObject)


You query for and get all matching values for something as simple as the node's name:

api.scene.getAll({name: 'coolerMesh'})

You can provide additional parameters to your query:

  name: 'coolerMesh', 
  plug: 'Material', 
  property: 'defaultColor'


get method will return the value matching the query. An empty query will return the top level node.



api.scene.get({name: 'coolerMesh'})
  name: 'coolerMesh', 
  plug: 'Material', 
  property: 'reference'


find method will locate the first matching query & return its path. An empty query will return the top-level node's ID.



api.scene.find({name: 'Cooler'})
  name: 'Cooler', 
  plug: 'Transform', 
  property: 'rotation'
['54f3a9f3-3ed1-4486-b5e7-9025fa0d9559', 'plugs', 'Transform', 0, 'rotation']

Find Node

findNode method will locate the first matching node & returns its ID. An empty query will return the top-level node's ID.



api.scene.find({type: 'PolyMesh'})


api.scene.find({name: 'coolerMesh'})

Although the queries are different, they will resolve to the same node because the coolerMesh is the first node with the type of PolyMesh:



filter method will return an array of all matching paths to a query.



  type: 'PolyMesh', 
  plug: 'Transform', 
  property: 'rotation'

Filter Nodes

filterNodes method returns an array of all node IDs that match the query.



api.scene.filterNodes({type: 'PolyMesh'})
["5ed10727-5dbc-429f-b0f1-b566157fa71a", "2cf1a3f8-8529-4bec-8d24-7978eac41520", ...]


set method will set some value at the first query match. This method will accept two parameters: QueryObject and value. The value parameter must follow the format of the property being set (object, string, boolean, etc.).

api.scene.set(QueryObject, value)


   name: "meterArrow_GEO", 
   plug: 'Transform', 
   property: 'rotation'
  {x: 0,y: 50, z: 0}) // rotation property is an object with x, y, z values
    "path": [
    "value": {
        "x": 0,
        "y": 50,
        "z": 0

This particular example is subtle, zoom in on the meter to see it:

Set All

setAll method will set some value for each of the query matches.

api.scene.setAll(QueryObject, value)


  from: editingAssetId, 
  plug: 'Transform', 
  property: 'translation'
  }, {x: 3, y: 4, z: 5})
[{…}, {…}, {…}, {…}, …]


reparent method will set a new parent for all of the children in the array.

api.scene.reparent(parentId, childIds, index)
parentIdStringID of the new parent
childIdsArrayIDs of the children we're updating
indexIntegerOptional child index in the new parent


let parentId = '3352d9bb-9841-465a-a872-d3bf3c74b42a'; // ID of the new parent
let childIds = ['f4732ef7-4477-48d4-94fa-34e211e51c23']; // IDs of the children you are updating
let index; // Index of the optional child index in the new parent
api.scene.reparent(parentId, childIds, index) 
  parentId: "b35e489e-17b2-406e-b9eb-5d46bd21a737", 
  childIds: Array[1], 
  index: 0

Add Node

addNode method will add a node to the scene.



    name: "My Node",
    type: "PolyMesh"
  },"3352d9bb-9841-465a-a872-d3bf3c74b42a" // ID of the parent node for the new node

Delete Node

deleteNode method will delete a node from a scene.



    "value": [
    "type": "Node",
    "path": [

Add Operator

addOperator will add an operator to a node.

api.scene.addOperator(nodeId, plugType, operatorType, operatorObject)
nodeIdStringThe id of the node receiving the operator
plugTypeStringThe plug that is receiving the operator
operatorTypeStringThe type of operator being added
operatorObjectObjectThe details of the operator


let nodeId = "53f3ff02-8151-46ce-8831-d3e91285e024";
let plugType = "Material";
let operatorType = "Falloff";
let operatorObject = {color: {"r":0.5725490196078431,"g":0.09803921568627451,"b":0.09803921568627451}, strength: 1};

api.scene.addOperator(nodeId, plugType, operatorType, operatorObject)

Add Attribute

addAttribute method will add a configurator attribute.



    type: "String", 
    name: "Attribute Name", 
    values: ['Hey there', 'other'], 
    defaultValue: 'Hey there'


fetch method will fetch an asset and make it available for querying sceneGraph data.




Align Node

alignNode method will move a provided nodeId to align with another.

api.scene.alignNode(nodeId, alignNodeId, options)
nodeIdStringThe node that will be aligned.
alignNodeIdStringThe node nodeId will align with.
options.anchorNodeIdStringOptional - the child of nodeId that will be aligned with alignNodeId. If left undefined, nodeId itself will be aligned to alignNodeId.
options.withRotationBooleanDefault is false. When set to true, both position and rotation of alignNodeId and anchorNodeId will be same after alignment.


let nodeId = "d42068b1-8d2f-4c08-9935-68bb8de66bf6";
let alignNodeId = "143527fc-5f14-44de-ab35-48fa6099eb22";
let options = {anchorNodeId: "73988328-944f-4f8f-8fe9-5f65108a4950", withRotation: true};
api.scene.alignNode(nodeId, alignNodeId, options)

Merge Meshes

mergeMeshes method will merge the meshes specified by nodeIds, and creates a single mesh with the name specified by mergedName

api.scene.mergeMeshes(nodeIds, mergedName, options)
nodeIdsArray || QueryObjectIds of the nodes to merge, or query that selects those meshes
mergedNameStringName of the resulting merged mesh
options.throwOnWarningsBooleanIf the command has warnings, throw an error. Defaults to true.

Scene Graph Sandbox



Test your methods here using player.scene instead of api.scene.
IDs returned from these calls will be different than what is in the examples. SceneGraph IDs are generated at loadtime and do not persist.