JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>model-viewer: re-appending a finished animation</title>
<script type="module" src="https://unpkg.com/@google/model-viewer@4.4.0/dist/model-viewer.min.js"></script>
<style>
body { font-family: system-ui, sans-serif; margin: 16px; max-width: 900px; }
model-viewer { width: 100%; height: 360px; background: #eee; }
button { margin: 8px 8px 0 0; padding: 6px 12px; }
#log { background: #111; color: #ddd; padding: 8px; min-height: 120px;
white-space: pre-wrap; font: 13px/1.4 monospace; }
.pass { color: #6c6; } .fail { color: #f66; }
</style>
</head>
<body>
<h3>Re-appending a finished animation with <code>appendAnimation()</code></h3>
<model-viewer id="mv" camera-controls
src="https://modelviewer.dev/shared-assets/models/RobotExpressive.glb">
</model-viewer>
<div>
<button id="repetitions" disabled>1. Repetitions after a reverse run</button>
<button id="time" disabled>2. Reverse run from the end (time option)</button>
</div>
<pre id="log">Loading model…</pre>
<script type="module">
const mv = document.querySelector('#mv');
const logEl = document.querySelector('#log');
const buttons = [...document.querySelectorAll('button')];
const NAME = 'Wave';
const DURATION = 1.833; // Length of the Wave clip, in seconds
const SPEED = 2; // Play at double speed to keep the demo short
// model-viewer clamps the time option to the clip's exact length (1.8333…),
// so this starts at the very end. (A rounded value like 1.833 would be just
// before the end, which avoids the bug.)
const END = 10;
const log = (text, cls) => {
const line = document.createElement('div');
line.textContent = text;
...