Objects
getNodeList
getNodeList([callback: Function])
Returns a flattened list of nodes in the scene. This list includes all the nodes (also nested ones) in the scene.
api.getNodeList(function (nodes) {
console.log(nodes);
});
getGeometries
getGeometries([callback: Function])
Returns a list of geometries in the space. This list includes only objects added via the Space-Editor
api.getGeometries(function (geometryList) {
console.log("Geometry list: ", geometryList);
});
clone
clone(geometryId: string, [callback: Function])
Clones a geometry. The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.clone(geometryId, function (newNodeId) {
console.log("Cloned node with ID", newNodeId);
});
show
show(nodeId: string, [callback: Function])
Shows a node. The nodeId
is the ID of the node, which can be found via getNodeList.
api.show(nodeId, function () {
console.log("Showed node");
});
hide
hide(nodeId: string, [callback: Function])
Hides a node. The nodeId
is the ID of the node, which can be found via getNodeList.
api.hide(nodeId, function () {
console.log("Hide node");
});
setOpacity
setOpacity(nodeId: string, opacity: number, [callback: Function])
Sets the opacity of a node. The nodeId
is the ID of the node, which can be found via getNodeList. The opacity
is a number between 0 and 1.
Hint
Changing opacity does not work on instances.
api.setOpacity(nodeId, 0.25, function () {
console.log("Changed node opacity");
});
getOpacity
getOpacity(nodeId: string, [callback: Function])
Returns the opacity of a node. The nodeId
is the ID of the node, which can be found via getNodeList.
api.getOpacity(nodeId, function (visibility) {
console.log("Node has the opacity", visibility);
});
remove
remove(nodeId: string, [callback: Function])
Delete a node. The nodeId
is the ID of the node, which can be found via getNodeList.
api.remove(nodeId, function () {
console.log("Node removed");
});
translate
translate(nodeId: string, newPosition: [x: number, y: number, z: number], [options: Object], [callback: Function])
Translates a node. The nodeId
is the ID of the node, which can be found via getNodeList.
The options
parameter: duration
the duration of the translation animation (a number, in seconds; 0 by default)
api.translate(nodeId, [1, 1, 1], { duration: 1.0 }, function () {
console.log("Node has been translated");
});
rotate
rotate(nodeId: string, newRotation: [degrees: number, x: number, y: number, z: number], [options: Object], [callback: Function])
Rotates a node. The nodeId
is the ID of the node, which can be found via getNodeList.
newRotation
: an array containing [degrees, axisX, axisY, axisZ].
The options
parameter: duration
the duration of the rotation animation (a number, in seconds; 0 by default)
api.rotate(nodeId, [180, 1, 0, 0], { duration: 1.0 }, function () {
console.log("Node has been rotated");
});
getTransform
getTransform(nodeId: string, callback: Function)
Gets the transform of a node. The nodeId
is the ID of the node, which can be found via getNodeList.
api.getTransform(nodeId, function ({ position, rotation, scaling }) {
console.log(position); // { x: 0, y: 0, z: 0 }
console.log(rotation); // { x: 0, y: 0, z: 0 }
console.log(scaling); // { x: 1, y: 1, z: 1 }
});
pickFromScreen
pickFromScreen(position2D: [x: number, y: number], [callback: Function])
Returns information about the world position of the first hit (intersection) at a given screen coordinate.
api.pickFromScreen([100, 100], function (info) {
console.log(info.position3D, info.id, info.name);
});
exportGLB
exportGLB(options: { scaling?: number, usdzCompat?: boolean }, callback: Function)
Exports the object without the skybox and shadowplane as an blob-string in gltf-binary. options
: is the object with different export options for GLB object. options.scale
: defines node scaling for export (1 by default). options.usdzCompat
: prepares the glb file so that it can be converted to usdz. takes into account usdz limitations, such as no support for second uv map. (false by default)
api.exportGLB({ scaling: 1 }, function (blob) {
downloadBlob(blob, "mesh.glb"); // pseudo-code
});
getHighlight
getHighlight(nodeId: string, callback: Function)
Returns the highlight settings from object in the scene. The nodeId
is the ID of the node, which can be found via getNodeList.
Result: alpha
, color
and enabled
api.getHighlight(nodeId, function (highlight) {
console.log(highlight.alpha); // Result: 0.4
console.log(highlight.color); // Result: #ffd700
console.log(highlight.enabled); // Result: true
});
setHighlight
setHighlight(nodeId: string, options: Object, [callback: Function])
Set the highlight settings on an object in the scene. The nodeId
is the ID of the node, which can be found via getNodeList.
Options: alpha
, color
and enabled
api.setHighlight(
nodeId,
{ enabled: true, alpha: 0.4, color: "#ffd700" },
function () {
console.log("Highlight set");
}
);
setScale
setScale(nodeId: string, scale: [number, number, number], [callback: Function])
Set the scale of an object in the scene. The nodeId
is the ID of the node, which can be found via getNodeList.
api.setScale(nodeId, [1, 1, 1], function (scaling) {
console.log(`${nodeId} is scaled to ${scaling}`);
});
getScale
getScale(nodeId: string, callback: Function)
Get the scale of an object in the scene. The nodeId
is the ID of the node, which can be found via getNodeList.
api.getScale(nodeId, function (scaling) {
console.log(`${nodeId} scaling: ${scaling}`);
});
getLights
getLights(callback: Function)
Gets a list of all lights in the scene.
api.getLights(function (lights) {
console.log(lights);
});
updateLight
updateLight(options: object, [callback: Function])
Updates a light by setting some options. To get all options of a given light, use the getLights function.
api.getLights(function (lights) {
light = lights[0];
light.intensity = 0.5;
api.updateLight(light);
});
setParticleUpdateSpeed
setParticleUpdateSpeed(geometryId: string, updateSpeed: number, callback: Function)
Set the object-related particle system update speed. The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.setParticleUpdateSpeed(geometryId, updateSpeed, function () {
console.log(`Update speed is set.`);
});
setParticleEmitRate
setParticleEmitRate(geometryId: string, emitRate: number, callback: Function)
Set the object-related particle system emit rate. The geometryId
is the ID of the geometry, which can be found via getGeometries. Note that the high emit rate may not have an effect if it exceeds the particle system capacity, which gets calculated according to the emitter mesh dimensions
api.setParticleEmitRate(geometryId, emitRate, function () {
console.log(`Emit rate is set.`);
});
startParticleSystem
startParticleSystem(geometryId: string, callback: Function)
Start the object-related particle system. The geometryId
is the ID of the node, which can be found via getGeometries.
api.startParticleSystem(geometryId, updateSpeed, function () {
console.log(`Particle system is started.`);
});
stopParticleSystem
stopParticleSystem(geometryId: string, callback: Function)
Stop the object-related particle system. The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.stopParticleSystem(geometryId, updateSpeed, function () {
console.log(`Particle system is stopped.`);
});
updateFog
updateFog(options: object, [callback: Function])
Updates the fog with provided options.
Available options:
fogStart?: number
: the distance from which the fog becomes visible.fogEnd?: number
: the distance where the fog ends.color?: [r: number, g: number, b: number]
: color of the fog. Possible value for each color is 0 to 1.
api.updateFog(options, function () {
console.log("Fog is updated.");
});