Vue
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/. -
Tell Vue that
rupa-playeris a custom element (compilerOptions.isCustomElementin the Vue plugin options ofvite.config, see the Vue guide on web components):vite.config.ts import vue from "@vitejs/plugin-vue";import { defineConfig } from "vite";export default defineConfig({plugins: [vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === "rupa-player" } } })],}); -
Import the element and use it in a component:
<script setup>import "@rupamotion/player/element";</script><template><rupa-player src="/hero.rupaplay"></rupa-player></template>
That’s it: the animation plays.
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). A template ref is the element:
<script setup>import "@rupamotion/player/element";import { ref } from "vue";
const hero = ref(null);</script>
<template> <rupa-player ref="hero" src="/hero.rupaplay"></rupa-player> <button @click="hero.player?.pause()">Pause</button></template>See Control playback and Events.