forked from immersive-web/model-element-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybackrate.html
More file actions
43 lines (40 loc) · 1.38 KB
/
playbackrate.html
File metadata and controls
43 lines (40 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Model: playbackRate test</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>Model: playbackRate test</h1>
<hr />
<p>
A model's <code>playbackRate</code> may be altered to change the speed of
the animation. While playing, the animation will advance according to the
rate specified.
</p>
<h2>JavaScript</h2>
<pre>model.playbackRate = 2; //double the default rate </pre>
<model autoplay loop>
<source src="./teapot.usdz" type="model/vnd.usdz+zip" />
<source src="./teapot.glb" type="model/gltf-binary" />
<img src="./teapot-fallback-animated.jpg" alt="An image of a model of a teapot with a creature inside" >
</model>
<br />
Playback rate:
<span id="ratelabel"></span>
<input type="range" min="0" max="2" value="1" step="0.1" id="rate" />
</body>
<script type="module">
const model = document.querySelector("model");
await model.ready;
model.playbackRate = 1;
rate.addEventListener("input", (e) => {
var rateSq = Math.pow(rate.value, 2);
ratelabel.innerHTML = (rateSq * 100).toFixed() + "%";
model.playbackRate = rateSq;
});
</script>
</html>