Animations and Interactivity in Patches

This tutorial shows how to add animation to a 3D object and how to toggle it on and off.


Object Mesh

First add a 3D object to your scene. In this example a default 3D model Flamingo will be used. Open the Program view by pressing Tab and go to Patches > Objects: Basic > 3D Model

Patches list

While in Program view, drag and drop the 3D model to the Root or inside a nested scene patch. Connect the model to the Scene patch to see it in the viewport.

3D model is now visible

Press Tab to hide the Program view, and click on the 3D model to select it. Now press Shift+Tab to enter the 3D model patch.

Shift+Tab enters the object

This is a shortcut for pressing the edit button on the patch (pencil icon) and is useful if you have several objects in the scene and want to edit objects quickly.

Inside the object you can see a few patches. Open the Mesh patch to look at it’s slots.

Mesh patch

This patch shows the 3D object in the scene. This tutorial goes through how to add animation to the object’s position, rotation and scale.

Add Animation

While still inside the 3D model patch, go to the Patches list and search for Toggle Sine Animation. Drag and drop this patch into the model.

Add the Toggle Sine Animation patch

The elements of the Toggle Sine Animation patch

The Sine Oscillator creates a looping animation between two values, which are the Min and Max values. This patch contains four editable slots.

  • Ray Up from Object: Choose an object which works as an interactive button for toggling the animation on and off.
  • Animation Speed in Seconds: How long the animation plays in seconds.
  • Min/Max: Minimum and maximum values for the animation.

The Float output will be connected to the position, rotation or scale slots in the Mesh patch. To be able to do this, it needs a converter patch between them to work. Connect Float to the X, Y and Z slots.

Press 7 on your keyboard to add a XYZ to Vector patch. This will convert the Oscillator values (Min/Max) into Vector format, which can be then attached to the Mesh. Connect it to one, two or all of the position, rotation and scale slots to see the animation.

Animated position

The Min and Max values are set to 0 and 1, which means the object is animated between those values. The model moves 1 meter and then goes back to it’s original position at 0. You can add negative values like -5 for example to make it animate with more range. You can also animate only one or two of the XYZ coordinates to create more unique animations.

To change the interaction object for toggling the animation, select the object you want to use from the drop down menu on the Ray Up from Object patch. This can be any object in the scene.

Selected the toggle object

In this example the toggle is the flamingo model, so when it is clicked the animation will stop. Clicking on the flamingo again continues the animation. To interact with objects, hide the Program view with Tab and press V to enter the VR Camera. Now press H to hide the grid and all other tools and enable interactions. Now the object can be clicked and it will toggle the animation on and off.

To change how fast or slow the object animates, change the value in Animation Speed in Seconds. The lower the value, the faster the animation will be. For example the value 5 means the animation plays in 5 seconds, and 1 means it plays in one second and will be much faster. You can enter any value expect 0, which will not play anything.

Animation plays within 3 seconds

Examples

You can also have multiple Oscillators to have a different animation for different slots. Just leave the Ray Up the same to enable the animation toggle on the same object.

Two different animations

In this example the position and rotation have their own animations. Position is animated with X coordinate and rotation is animated with Y and Z.

Animated position and rotation

When animating scale, it’s good to know that to keep the object in it’s own proportions, all the three XYZ coordinates should be animated. Otherwise it will make empty coordinate slots into 0 value, which will scale the object so small it’s invisible.

Animated scale in Patches

Animated scale

However, animating only two coordinates for scale can create fun 2D effects. It will leave one value to 0, making the object look flat like a paper.

Only X and Y have inputs

2D effect

Here’s an example where the animation is toggled from the pink cylinder. Clicking the cylinder starts or stops the animation.

Cylinder set as the Ray Up from Object toggle

Play around with the slots and values to find what works the best for your objects.