Skip to content

Buttons and Interactivity

Studio is being deprecated, please head over to the documentation page for Mattercraft, our most advanced 3D tool for the web, where you can find the most recent information and tutorials.

Interactivity is an integral part of any immersive AR experience. Luckily, ZapWorks Studio allows you to listen out for user interactions (e.g. a button the user can tap) or events that were triggered (e.g. the target image entering the camera view) and activate actions in response. There are two ways these can be set up:

  1. Code-free, with Actions
  2. Or with code using an Event Handler in a script.

Actions are an easy, but powerful, method of adding interactivity to your experience without having to write any code. With Actions you can:

  • Launch a website when a button is tapped.
  • Set up a menu that switches between different UIs.
  • Play a timeline animation.
  • Move content to the screen when the tracking image exits the camera view.

Actions can be added to certain node types (listed under the Events section of this article) from the Actions tab under the Properties panel, by selecting the + Add button.

The default Plane object in the Media Library, as well as imported images, support pointer events and can therefore be used as buttons in an experience.

When adding an action, the first option lists the events that the selected node emits, with the second list of options allowing you to choose an action to perform when the selected event is emitted.

The events available to a node are contextual and will vary depending on the node type.

Once selected, the action is displayed in the Properties panel, along with a set of options. In the example below, an On Tap > Launch Web Link action is added to a Plane node.

Nodes with actions can be identified in the Hierarchy by the icon after their name.


The following table lists the events available to each node type, along with a description of the event itself.

Node TypeEventDescription
AccelerometerLandscapeThe device is in the default landscape orientation.
-Landscape InvertedThe device is in an inverted landscape orientation.
-PortraitThe device is in portrait orientation.
-Portrait InvertedThe device is in an inverted portrait orientation.
AudioFinishThe audio has finished playing.
Face Group / Face PaintOn SeenA face is detected in the camera feed.
-On First SeenA face is first detected in the camera feed.
-On Not SeenA face is not detected in the camera feed.
-On Mouth OpenThe current face instance’s mouth is open.
-On Mouth CloseThe current face instance’s mouth is closed.
-On Left Eye OpenThe current face instance’s left eye is open.
-On Left Eye CloseThe current face instance’s left eye is closed.
-On Right Eye OpenThe current face instance’s right eye is open.
-On Right Eye CloseThe current face instance’s right eye is closed.
Headset ManagerHeadset Mode EnterThe device has entered headset mode.
-Headset Mode LeaveThe device has exited headset mode.
-Headset Button PressThe button has been pressed, while in headset mode.
ObjectTapThe object has been tapped.
-Trigger Region EnterThe origin point of the object first enters a TriggerRegion.
-Trigger Region LeaveThe origin point of the object leaves a TriggerRegion.
RaycasterIntersectionEnterThe raycaster has intersected with an object.
-Intersection LeaveThe raycaster is no longer intersecting with the object it had been previously.
RootShowThe root node is currently visible.
-HideThe root node is currently hidden.
Target / ZapBox Map / ZapBox ControllerSeenThe target image is detected in the camera feed.
-First SeenThe target image is first detected in the camera feed.
-Not SeenThe target image is not detected in the camera feed.
Trigger RegionTrigger EnterThe origin point of an object first enters the TriggerRegion.
-Trigger Region LeaveThe origin point of an object leaves the TriggerRegion.
VideoPlayingThe video has begun playback.
-PauseThe video has been paused.
-FinishThe video has finished playing.
-BufferingThe video is buffering and needs to download more data before continuing.
-ErrorThere is an issue with video playback.
Video TextureFinishThe video has finished playing.

The following table lists the actions available for all events, along with a description of what the action does and the options provided.

FunctionDescription
Launch Web LinkLaunches a URL, with the option to launch it in an external browser.
VibrateVibrates the user’s device (if the device’s vibration functionality is enabled).
Activate StateActivates a state from a controller.
Play TimelinePlays a timeline.
Stop TimelineStops a timeline.
Play Fullscreen VideoPlays a video in full screen, using the device’s default video player.
Take SnapshotTakes a snapshot of the current camera feed, with the option to save or share the resulting image.
Use Front Facing CameraSets the front facing camera as active in the camera feed.
Use Back Facing CameraSets the back facing camera as active in the camera feed.
Enter Headset ModeRequests the device to enter headset mode for use in ZapBox and other cardboard headsets.

Although actions are a quick and easy way of adding interactivity, setting up event handlers within a script allows for full control and customization of content behavior using Studio’s TypeScript environment.

Although familiarity with TypeScript (or a similar language) is useful, ZapWorks Studio simplifies the process of adding event handlers to make this method more accessible.

If you have little to no experience with the language, our TypeScript Primer is a great resource to get started with.


To add an event handler, right-click a node in the Hierarchy and select New > Script >. A menu will be displayed, listing the events that are emitted by that node.

Just as with actions, the events listed will be contextual to the node’s type.

Selecting an event creates a new script node with the event handler automatically set up, or an empty script if the Blank option was selected.

States and timelines can be dragged directly into the event handler to activate/play them when the event is fired. Custom logic can also be coded within the event handler.

For a closer look at using a pointerdown event to set up a button, check out our Creating Buttons scripting example.


In addition to user input, interaction can also be set up with Triggers and Raycasters. For more information on setting up event handlers for these check out the articles linked below:


Next article: Previewing and Publishing