-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimations.html
More file actions
105 lines (82 loc) · 2.99 KB
/
animations.html
File metadata and controls
105 lines (82 loc) · 2.99 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!-- http://motherfuckingwebsite.com/ -->
<html>
<head>
<meta charset="utf-8">
<title>Mu animations</title>
<style>
body {
font-family: "Verdana";
}
</style>
<script src="VanillaJS/muTS.js"></script>
</head>
<body>
<h3>Animation list tool</h3>
<p>Lists every animation used by given file. (Drag & drop works here)</p>
<br>
<a href="index.html">Go to main demo</a>
<hr>
<input multiple accept=".mu" type="file" id="fileInput">
<hr>
<span id="output">no models uploaded</span>
</body>
<script>
function Update () {
let files = document.getElementById ("fileInput").files;
if (files.length < 1) {
document.getElementById ("output").innerHTML = "no models uploaded";
return;
}
document.getElementById ("output").innerHTML = "";
for (let i = 0; i < files.length; ++i) {
let reader = new FileReader();
reader.onload = () => {
let mu = new Mu (new Uint8Array (reader.result));
let anims = [];
function recursiveAnimSearch (muObj) {
if (muObj.Animation && muObj.Animation.Clips.length > 0) {
muObj.Animation.Clips.forEach (clip => {
anims.push (clip.Name);
});
}
muObj.Children.forEach (c => {
recursiveAnimSearch (c);
});
}
recursiveAnimSearch (mu.Object);
if (anims.length) {
document.getElementById ("output").innerHTML += `Animation clips in [${files[i].name}]:<ul>`;
anims.forEach (clip => {
document.getElementById ("output").innerHTML += `<li>${ clip }</li>`;
});
document.getElementById ("output").innerHTML += `</ul><hr>`;
} else {
document.getElementById ("output").innerHTML += `No animations found in [${files[i].name}]<hr>`;
}
}
reader.readAsArrayBuffer (files[i]);
}
}
document.getElementById ("fileInput").addEventListener ("change", Update);
window.addEventListener ("drop", e => {
e.stopPropagation ();
e.preventDefault ();
if (!e.dataTransfer) {
return;
}
let files = e.dataTransfer.files;
if (files.length == 0) {
return;
}
document.getElementById ("fileInput").files = files;
Update ();
});
window.addEventListener ("dragover", e => {
e.stopPropagation ();
e.preventDefault ();
if (e.dataTransfer) {
e.dataTransfer.dropEffect = "copy";
}
});
</script>
</html>