Introduction to Blocks

With blocks, you can save and export sections of a project in Spark AR Studio, to be reused in other projects and shared with other creators.

You can create a block for most things you often need to repeat or reuse. Combinations of objects, assets, patches, materials and texture settings are all supported.

Follow this step-by-step tutorial to create a block that adds snow to an effect.

Creating a block

You can either create an empty block, or combine objects you’ve already added to the Scene panel into a block.

Creating an empty block

To create an empty block:

  1. Click Add Asset in the Assets panel.
  2. Select Block.

The block will be listed in the Assets panel. When it's selected you can rename it if you want to:

Creating a block from objects in the Scene panel

When you create a block using objects in the Scene panel, any related assets and patches will be added to the block.

Before creating a block this way, make sure any objects you want to add are:

To create a block from objects in the Scene panel:

  1. In the Scene panel, select all the objects you want to add to the block.
  2. Right-click, and select Create Block:

When the block has been created, it will be listed in the Assets panel. The scene objects added to the block will be replaced with a block in the Scene panel.

Editing blocks

To add scene objects and other elements to a block:

  1. Select the block in the Assets panel.
  2. Click Edit in the Inspector.

This will open the block in a new window, where you can make changes to it:

Here, the block will be listed in the Scene panel as Block Root. Simply add the objects and assets you want to include in the block as a child of Block Root.

When you save a block, it will automatically update in all projects that use the block. You'll see this message in Spark AR Studio to remind you:

Adding a block to your project

The quickest way to add a block to your scene is to simply click and drag it from the Assets panel to the Scene panel. Alternatively:

  1. Select the block in the Assets panel.
  2. Right-click, and select Instantiate.

The block will be listed in both the Scene panel and the Assets panel:

  • The version of the block in the Assets panel is the main block.
  • The block in the Scene panel is an instance of the main block.

Below, we've added a block to the Scene panel. We've used it to create an effect with a particle system that looks like snow:

In the Scene panel, Snow is the instance of the Block. You'd use the options under Inputs in the Inspector to customize how the block behaves in the effect. In the Assets panel, Snow is the main block.

You can instantiate the same block more than once.

Learn how we made this block.

Creating inputs and outputs

Inputs and outputs pass information to and from blocks, into your projects. You'll use them to set default values for the block's properties, allowing you to customize the block.

Supported data types for inputs and outputs

The following data types are supported:

  • Pulse
  • Boolean
  • Scalar
  • Vector2, Vector3 and Vector4
  • Color
  • String

To create an input or output, make sure the block is open, by right-clicking on the box in the Assets panel and selecting Edit. Then:

  1. Select the block in the Scene panel - it'll be listed as Block Root.
  2. In the Inspector, click Block Properties:

To add:

  • An input, click + next to Inputs.
  • An output, click + next to Outputs.

Alternatively, you can create input and output ports using patches in the Patch Editor. To do this:

  1. Click any input or output port in any patch you've added as part of your block.
  2. Click Create Input to Block or Create Output for Block:

Editing inputs and outputs

You'll see a list of options that you can edit to configure the input or output, depending on the data type you select:

  • Type - this is where you'll set the data type.
  • Input Limit - use this option to add minimum and maximum values for numerical and vector types. For vector types, it’ll be applied to each individual axis.
  • Input Style - use this option to control how an input can changed in the Inspector. Choose between text or a slider.
  • Default Value - set a default value.

Reordering inputs and outputs

To reorder inputs and outputs, just click and drag them in the properties window. For example, you could place blockInput0 below blockInput1.

Using inputs and outputs in blocks


Use inputs to customize your patch graph inside a block:

  1. Open the block.
  2. Select Block Root in the Scene panel.
  3. Go to Interactions in the Inspector.
  4. Click Create next to Producer Patch:

Alternatively, drag the block scene object from the Scene panel into the Patch Editor.


Use outputs to pass information from the block, into your project. For example to a patch outside the block.

In the opened block:

  1. Select Block Root in the Scene panel.
  2. Click the arrow next to Output in the Inspector.

A consumer patch will be created:

Using inputs and outputs in your project


All the inputs you've added to a Block will be listed under Inputs in the Inspector, when you select the block in the Scene panel:

You can change the values of the inputs in the Inspector, to change how the block behaves in your effect. Or, click the arrow next to the input to create a consumer patch that can be connected to the rest of your graph:

You can also drag the block from the Scene panel into the Patch Editor.


Once you've defined the outputs of the block, drag it from the Scene panel into the Patch Editor to create a patch:


You can set the values of inputs and get the values of outputs in a script by using the methods of the BlockSceneRoot class after accessing your block in the scene by name.

 // Load in the scene module
 const Scene = require('Scene');
 const Diagnostics = require('Diagnostics');
 // Locate a block in the scene
     // Set a scalar input (signals also accepted)
     myBlock.inputs.setScalar('blockInput', 5)
     .then(function() {
         // Success
     }, function(error) {
         // input named blockInput probably doesn't exist
         // or is not of scalar type, check error for details
     // Get a scalar output
         // Do something with blockOutputScalarSignal
     }, function(error) {
         // output named blockOutput probably doesn't exist
         // or is not of scalar type, check error for details
     // Alternatively get scalar output with implicit
     // error handling - i.e. in case of error `blockOutputScalarSignal` will have value 0.   
     const blockOutputScalarSignal = myBlock.outputs.getScalarOrFallback('blockOutput', 0);

Adding a description

It's a good idea to add descriptions to your blocks. This will help any creators you share the block with understand what it does, and help you keep track too.

To add a description:

  1. Select the Block Root in the Scene panel of the block.
  2. Click Block Properties in the Inspector.
  3. Enter your description of the Block in the General tab.

When you select the block in the Assets panel, you'll see the description in the Inspector:

Sharing blocks and using blocks in other projects

You can package blocks to share them with other creators, or add them to other projects.

To package a block:

  1. Open your block.
  2. Click File and select Package...
  3. Choose a name and destination.
  4. Click Save.

An .arblockpkg file will be created — you can share this with other creators or add the block to another project. They'll be able to import the .arblockpkg file to their projects.

Join the Spark AR Community to share tips, inspiration and assets like blocks and patch groups with other creators.

Creating a block within a block

It is also possible to create blocks within blocks.

Let’s reuse the block with the particle system that looks like snow:

To add another block inside SnowBlock:

  1. Double-click SnowBlock to open it in a new, first-level window.
  2. In the Assets panel, create another block.

The second-level block will be listed as block0 in the Assets panel.

Editing the second-level block

To edit the second-level block:

  1. Select block0 in the Assets panel, in the Inspector, click Edit.
  2. Make any edits in the new second-level window that opens.
  3. Go to File and click Save.
  4. In the example below we added a different particle system to block0. It’s listed in the Scene panel as emitter0.

Instantiate the second-level block

You need to instantiate the second-level block so the contents also appears in the first-level block. To do so:

  1. Go back to the first-level window, right-click block0 in the Assets panel and select Instantiate.
  2. Go to File and click Save.

The contents of both blocks will now be visible in the first-level window.

The contents of both blocks will also be visible in the main project. In our example, both particle systems are visible in the Viewport and Simulator:

Choosing between blocks and patch assets

Blocks allow you to structure your project, to use parts of it again and again. They can contain scene objects, assets and patches.

Patch Assets allow you to save and share groups of patches with other Spark AR Studio creators. Patch Assets can’t contain producer patches, consumer patches or any assets.

In general:

  • If the element of your effect that you want to save and export only uses patches, use Patch Groups.
  • If you're using scene objects and assets as well as patches, use blocks.


Blocks can only be used in projects with meters as the unit of measurement.

The following features are not supported:

  • Some global objects and assets, for example ambient lights and environment textures.
  • Scripts.
  • Other elements that require special capabilities.
Was this article helpful?