Testing and Debugging

There are two ways to test and debug your projects in Spark AR Studio:

  • Console logging.
  • The Spark AR Player App.

Console Logging

You can use the Console in Spark AR Studio to log messages and the values of variables from scripts you've added to your project.

Showing and hiding the Console

To show or hide the Console:

  1. Click View in the menu bar.
  2. Select Show/Hide Console from the menu.

The Console will appear below the Viewport.

Logging values and messages

Messages and variable values can be logged from within a script with the log() method of the Diagnostics Module.

// Load in the Diagnostics module
const Diagnostics = require('Diagnostics');

// Log a string message  
Diagnostics.log('A console message logged from the script');

let myVariable = 5;

// Log a variable's value  

Log statements left in your scripts may have a negative effect on performance so remove all Diagnostics.log() calls before shipping your final effect.

Watching signal values

Signal values can be shown in the Console from within a script with the watch() method of the Diagnostics Module.

// Load in the required modules
const Diagnostics = require('Diagnostics');
const FaceTracking = require('FaceTracking');

// Add the mouth openness signal to the watch view
Diagnostics.watch("Mouth Openness - ", FaceTracking.face(0).mouth.openness);

The watch view appears in the top right of the console.

Spark AR Player

Once you're ready to test your effect on a device, you can use the Spark AR Player app.

If you connect your device via USB cable and select Send To Connected Device from the Send To Device menu, you will be able to select your device from the device dropdown within the Console to see messages logged from the device.