inhabitor/body.html
Jeremy Penner d1fb2daa41 Implement avatar limb animations
Refactor helpers to take "impl" objects rather than functions
2023-12-28 16:10:00 -05:00

74 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Inhabitor - The Habitat Inspector</title>
<style type="text/css">
body {
margin:40px auto;
line-height:1.6;
font-size:18px;
color:#444;
padding:0 10px
}
h1,h2,h3 {
line-height:1.2
}
</style>
<script src="index.js?v=1"></script>
</head>
<body>
<h1 id="filename"></h1>
<div id="limbs">
<h2>Limbs</h2>
</div>
<div id="cels">
<h2>Cels</h1>
</div>
<div id="data">
<h2>Data</h1>
</div>
<div id="errors"></div>
<a href="index.html">Back</a>
<script>
const propFilter = (key, value) => {
if (key != "bitmap" && key != "data" && key != "canvas") {
return value
}
}
const dumpProp = (prop, container) => {
container.appendChild(textNode(JSON.stringify(prop, propFilter, 2), "pre"))
}
const limbNames = ["legs", "legs2", "left arm", "torso", "face", "right arm"]
const labelLimb = (container, ilimb) => {
container.appendChild(textNode(ilimb < limbNames.length ? limbNames[ilimb] : `Limb #${ilimb}??`, "div"))
}
const onload = async () => {
const q = new URLSearchParams(window.location.search)
const filename = q.get("f")
document.getElementById("filename").innerText = filename
try {
const body = await decodeBinary(filename, BodyImpl)
dumpProp(body, document.getElementById("data"))
if (body.error) {
showError(body.error, filename)
} else {
const celContainer = document.getElementById("cels")
const limbContainer = document.getElementById("limbs")
for (const [ilimb, limb] of body.limbs.entries()) {
labelLimb(celContainer, ilimb)
showCels(limb, celContainer)
labelLimb(limbContainer, ilimb)
showAnimations(limb, limbContainer, LimbImpl)
}
}
} catch (e) {
showError(e, filename)
}
}
onload()
</script>
</body>
</html>