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');
});
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: [angle: 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 [angle, axisX, axisY, axisZ].
The options
parameter: duration
the duration of the rotation animation (a number, in seconds; 0 by default)
api.rotate(nodeId, [Math.PI, 1, 0, 0], { duration: 1.0 }, function () {
console.log('Node has been rotated');
});
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. position2D
is the coordinates in the 2D gl viewport with pixel ratio taken into account (an array [z, y], y origin at bottom)
api.pickFromScreen([100, 100], function (info) {
console.log(info.position3D, info.nodeId, info.material);
});
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');
});