Objects
getNodeList
getNodeList([callback: Function])
Returns a flattened list of nodes in the scene.
api.getNodeList(function (nodes) {
console.log(nodes);
});
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(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");
}
);
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);
});