order | category | name | sourcePath | type | componentSignature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1.4 |
@threlte/theatre |
<Sequence> |
packages/theatre/src/lib/sequence/Sequence.svelte |
component |
|
Sequences are the heart of the Theatre.js animation system. The sequence represents the animation timeline and provides an API for controlling its playback.
In Threlte 7, you can reactively control animations through the <Sequence>
component, which you place inside a <Sheet>
.
Currently, you can only have one sequence in each sheet. Future versions of Theatre.js are expected to support multisequence sheets.
Sequence | Sequence Manual | Sequence API Reference |
The following example shows how <Sequence>
can be used to build a simple playback controller.
Threlte provides lifecycle props to allow you to configure how the sequence playback is connected to the Svelte component lifecycle. See the autoplay
, autoreset
and autopause
props below.
Note that the underlying Theatre.js sheets are persisted even when unmounting a <Sheet>
component. That's why the sequence doesn't reset automatically when unmounting a <Sheet>
, and why the autoreset
options is required.
The audio options allow you to attach a soundtrack to your animation sequence. Theatre.js achieves this using the Web Audio API. For more details, see audio manual and attach audio API reference
When using the sequence in a child component, a slot prop can come in handy.
<script lang="ts">
import { T, InteractiveObject } from '@threlte/core'
import { Sheet, Sequence, SheetObject } from '@threlte/theatre'
</script>
<Sheet>
<Sequence let:play>
<SheetObject
key="Cube"
let:Transform
>
<Transform>
<T.Mesh>
<InteractiveObject interactive on:click={play}>
<T.BoxGeometry />
<T.MeshStandardMaterial />
</T.Mesh>
</Transform>
</SheetObject>
</Sequence>
</Sheet>