Stream tracks

Stream Tracks are animations or other kinds of tracks on a timeline which exist on an asset before it is used inside Mattercraft.

Examples of stream tracks include embedded animations in a 3D model, video tracks or audio tracks.

A Stream Track in a Timeline Clip

Adding a Stream Track to a Timeline

You may play a stream track using Behavior Actions, though you will have more control over that track by adding it to a Timeline. This allows you to create interactive moments, such as automatically pausing a track or animation at a specific time, or creating a volume slider.

To learn more about creating a timeline, check out our dedicated Timeline article.

Adding a new Stream Tracks to a Timeline

To add a stream track to a timeline, you can use the following steps:

  1. Click on the Animations panel to open it up
  2. Click on Layers if your Timeline is inside a layer or Clips if it is independent
  3. Find and click on the Timeline you wish to add the Stream Track to
  4. Go to the Timeline Clip editor and find the + (plus) icon
  5. Find Streams and then click on the Stream Track you wish to add to the Timeline
  6. Mattercraft will automatically add the Stream Track to the Timeline

Giving the timelines your stream tracks are assigned to brief but descriptive names will make them easier to manage; particularly when activating them with Behavior Actions or script.

Customizing Stream Tracks

Mattercraft will automatically add a stream track to a timeline according to how that track has been exported, however, you are able to modify the playback options for stream tracks to customize how they are played in your Mattercraft project.

Customizing the playback for a Stream Track

To customize the playback for a stream track, you can use the following instructions:

  1. Find and click on the Timeline you wish to add the Stream Track to
  2. When the Timeline Clip editor is open, right click on the stream instance and left click on Modify stream playback…
  3. Adjust the values of the Stream Track’s properties and click on Done when you have finished

Playing a Stream Track with Behavior Actions

You may play a stream track from within the Mattercraft visual editor, or with custom scripts.

For more information about adding interactivity to your Mattercraft projects, consider reading our Adding interactivity article.

Playing a Stream Track in a Timeline Layer Clip

You can play a stream track by using the following instructions:

  1. Find the Node you wish to play the Stream Track with inside the Hierarchy Panel and select it
  2. Head to the Behavior Actions Panel and click on the + (plus) icon
  3. Find the Animation Actions category or the Stream Actions category and use any of the following Behavior Actions to activate the stream tracks:

Animation Actions

Animation Action Description
Set Layer Off Resets the chosen layer to whatever values are specified for the Off state.
Play Layer Clip Plays the stream track's timeline.
Pause Layer Clips Pauses the stream track's timeline. Unless reset or played from the start, the stream track will play from this point.

Stream Actions

Stream Action Description
Stop Stream Stops the stream track from playing and sets the timeline Time to 0 (the start of the stream track).
Seek Stream Sets the Time along the timeline where the stream track should play from. Useful if you want to replay a particular section of a stream track.
Play Stream Plays the stream track along its timeline. Will play from whatever Time is currently set to, unless From Start is checked.
Pause Stream Pauses the stream track. Unless reset or played from the start, the stream track will play from this point.

Playing a Stream Track with Script

To activate stream tracks with a script, you can use similar functions as you might with States or Timelines.

Function Description
.play() Plays the stream track along its timeline. Will play from whatever Time is currently set to.
.pause() Pauses the stream track. Unless reset or played from the start, the stream track will play from this point.
.seek() Sets the Time along the timeline where stream track should play from. Useful if you want to replay a particular section of a stream track.
.stop() Stops the stream track from playing and sets the timeline Time to 0 (the start of the stream track).

An example custom behavior for playing and restarting a video component along a stream track might look like this:

// Register that this node should be listening to an event,
// in this case onPointerDown (on click or tap)
this.register(this.instance.onPointerDown, evt => {

    // Play the stream track by finding the layer containing the
    // stream track's timeline; and then the stream track's timeline itself
        this.zcomponent.animation.layers.StreamTrackLayer.clips.StreamTrackTimeline.play();

});

// Register that the video component should be listening to the onEnded event,
// which fires when the video has finished playing
this.register(this.zcomponent.nodes.myVideo.onEnded, evt => {

    // Stop the stream track (and set the Time to 0) by finding the
    // layer containing the stream track timeline; and then the
    // stream track timeline itself
        this.zcomponent.animation.layers.StreamTrackLayer.clips.StreamTrackTimeline.stop();

    // Play the stream track by finding the layer containing the
    // stream track timeline; and then the stream track timeline itself
        this.zcomponent.animation.layers.StreamTrackLayer.clips.StreamTrackTimeline.play();

});

See Mattercraft's full API documentation here.

zapcode branded_zapcode i