This module is a high level scene graph manipulation and query library.
Scene
- Either id, name, or regex's can be used for node names.
- All get functions return the value, or undefined if no match is found
- All find functions return an id or a Path
- All filter functions return an array of id or Path
PHASES
There are three events that are triggered in turn as the scene loads: PRELOADED
, LOADED
, and RENDERED
.
Kind: event emitted by Scene
Read only: true
name | description |
---|---|
PHASES.PRELOADED | Emitted when the scene and all assets necessary to render the scene have been loaded. Occurs before the 'loaded' event, and is an opportunity to modify the scene before it becomes visible. A change here might trigger more loading. |
PHASES.LOADED | Emitted when the scene and all assets necessary to render the scene have been loaded. |
PHASES.RENDERED | Emitted when the scene is ready for display. |
// Avoid typos by referencing the phase constants
const { PRELOADED, LOADED, RENDERED } = player.scene.PHASES;
player.on(PRELOADED, () => {
console.log(PRELOADED);
});
player.on(LOADED, () => {
console.log(LOADED);
});
player.on(RENDERED, () => {
console.log(RENDERED);
});
find(query)
Finds first matching node.
Kind: inner method of Scene
parameter | type | description |
---|---|---|
query |
| The query object to filter on. |
// Return the node uuid
scene.find({ name: 'Box' }); // -> ['uuid']
// Return the path to the transform operator
scene.find({ name: 'Box', plug: 'Transform', property: 'translation' });// -> ['uuid','plugs','Transform',0]
// Match the first node that starts with Box
scene.find({ name: 'Box*' });
fetch(id)
Fetch an asset, to make it available for querying sceneGraph data.
Kind: inner method of Scene
parameter | type | description |
---|---|---|
id |
| Asset ID to fetch |
alignNode(nodeId, alignNodeId)
Move nodeId to align with alignNodeId
, optionally using anchorNodeId
to do the alignment.
Kind: inner method of Scene
parameter | type | description |
---|---|---|
nodeId |
| The node that will be aligned. |
alignNodeId |
| The node |
options.anchorNodeId |
| Optionally, the child of |
options.withRotation |
| Default is |
// Move the sword to place the sword handle in the hand
scene.alignNode(swordId, handId, { anchorNodeId: swordHandleId, withRotation: true });