-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcurrenttime.html
More file actions
43 lines (41 loc) · 1.42 KB
/
currenttime.html
File metadata and controls
43 lines (41 loc) · 1.42 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: currentTime test</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<h1>Model: currentTime test</h1>
<hr />
<p>
When a model has an animation, its <code>currentTime</code> attribute
can be read and written to update the animation's progress.
</p>
<h2>JavaScript</h2>
<pre>model.currentTime = 2.5;</pre>
<model alt="A model of a teapot with a hidden creature">
<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 />
Current time:
<span id="timelabel"></span>
<input type="range" min="0" max="1" value="0" step="0.02" id="time" />
</div>
<script type="module">
const model = document.querySelector('model');
await model.ready;
time.addEventListener('input', (e) => {
timelabel.innerHTML = (time.value * model.duration).toFixed(1) + 's';
model.currentTime = time.value * model.duration;
});
</script>
</body>
</html>