Svelte
Copy as MarkdownQuick start
Section titled “Quick start”-
Install the player.
Terminal window npm i @rupamotion/player -
Put
hero.rupaplay(export as Player file in Rupamotion) inpublic/. -
Import the element and use it in a component:
<script>import "@rupamotion/player/element";</script><rupa-player src="/hero.rupaplay"></rupa-player>
That’s it: the animation plays. In SvelteKit, see SvelteKit.
This demo loads a .rupaplay file: it plays once JavaScript runs.
Need control?
Section titled “Need control?”The element’s player is the player once the file is mounted (null before). Bind the element with bind:this
(Svelte 5 syntax; Svelte 4 writes on:click):
<script> import "@rupamotion/player/element";
let hero;</script>
<rupa-player bind:this={hero} src="/hero.rupaplay"></rupa-player><button onclick={() => hero.player?.pause()}>Pause</button>See Control playback and Events.