Miscellaneous Functions
takeScreenshot
Captures a screenshot of the current camera view, optionally including virtual (augmented) content.
Name
Type
Description
Required/Optional
Default
params
Object
Object containing screenshot configuration.
Required
params.withAugmentation
Boolean
Enables or disables inclusion of virtual or augmented content in the screenshot.
Required
params.dataURL
Boolean
Enables or disables adding a data URI prefix (for example, “data:image/png;base64,”) to the result string.
Optional
true
params.imgFormat
String
Image format. The following file types are supported:
.png
.jpeg
Optional
"PNG"
params.imgWidth
Number
Target width (in pixels) of the captured image.
Optional
params.imgHeight
Number
Target height (in pixels) of the captured image.
Optional
successCallback
Function
Called when the operation completes successfully.
Optional
errorCallback
Function
Called when the operation fails.
Optional
* 
If imgWidth or imgHeight are not provided:
The image is captured at the camera’s native resolution.
If the resolution is smaller than half the screen width and height, the image is upscaled to at least half of the screen width times half of the screen height to avoid grey borders in the in-experience preview.
If the native resolution already meets this threshold, the image remains unchanged.
If only one dimension is provided (imgWidth or imgHeight), then the missing dimension is automatically calculated to maintain the original aspect ratio.
If both dimensions are provided (imgWidth and imgHeight):
One dimension is recalculated to preserve the original aspect ratio.
The final image fits within the given bounds.
If dataURL is true, the base64-encoded string is prefixed with a MIME type (for example, "data:image/png;base64," or "data:image/jpeg;base64,"
The image is returned via successCallback.
scanForNextBarCode
Starts the barcode scanner and waits for the next readable barcode. Once a barcode is detected, the scanner stops and returns the result.
Name
Type
Description
Required/Optional
successCallback
Function
Called when the operation completes successfully.
Optional
errorCallback
Function
Called when the operation fails.
Optional
* 
Once a valid barcode is detected, scanning automatically stops.
The returned value in successCallback is the decoded string representation of the barcode.
scanBarCodeScanning
Stops the currently running barcode scanner if it’s active, and has no effect if the scanner is not running.
Name
Type
Description
Required/Optional
successCallback
Function
Called when the operation completes successfully.
Optional
errorCallback
Function
Called when the operation fails.
Optional
* 
This function can be used to manually cancel an ongoing barcode scan started via scanForNextBarcode.
If no scan is currently active, the function returns successfully without effect.
The scanner also stops automatically after a successful barcode detection, so this is typically only needed for manual cancellation.
setupTrackingEventsCommand
Registers a callback to receive tracking event updates, such as changes in position or orientation of a tracked target.
Name
Type
Description
Required/Optional
successCallback
Function
Called when the operation completes successfully.
Optional
errorCallback
Function
Called when the operation fails.
Optional
* 
The successCallback is invoked once per frame while tracking is active.
Each callback receives a string array with the following values:
trackerId—ID of the current tracker (the Tracker ID).
cameraPosition—Position of the camera in tracker space, as a string in [x,y,z] format.
cameraForward—Forward direction vector of the camera, in tracker space.
cameraUp—Up direction vector of the camera, in tracker space.
timestamp—UNIX timestamp (in seconds) at the time of tracking.
The errorCallback is currently not used by this function.
setDimensions
Sets the width and height of a 3D image.
Name
Type
Description
Required/Optional
id
String
Studio ID of the 3D image to update.
Required
params
Object
Object containing dimension values.
Required
params.width
Number
Target width of the image.
Optional
NaN
params.height
Number
Target height of the image.
Optional
NaN
successCallback
Function
Called when the operation completes successfully.
Optional
errorCallback
Function
Called when the operation fails.
Optional
* 
This function is only supported for 3D widgets that accept images (3D Image, 3D Gauge, and 3D Label).
If either width or height is omitted or set to NaN, the missing value will be calculated based on the other provided dimension while preserving the original aspect ratio.
If both width and height are omitted or set to NaN, the dimensions will be automatically determined from the texture’s native size.
Was this helpful?