36 lines
926 B
JavaScript

import fs from "fs";
const file = fs.readFileSync("TFDi_MD11_PAX_CABIN_LOD0.gltf", {
encoding: "utf-8",
});
const model = JSON.parse(file);
model.animations.forEach((anim) => {
if (anim.name.includes("MD11_CAB_FIRST_TRAY")) {
let done = false;
anim.channels.forEach((channel) => {
const id = Number.parseInt(channel.target.node);
const node = model.nodes[id];
const child = model.nodes.find(
(_child, index) =>
node &&
node.children &&
node.children.includes(index) &&
_child.name.includes("WheelArm")
);
if (!done && child && child.name.includes("WheelArm")) {
done = true;
console.log(
`<UseTemplate Name="MD11_TrayTable">
<NODE_ID>${child.name}</NODE_ID>
<ANIM_NAME>${anim.name}</ANIM_NAME>
<ANIM_LENGTH>50</ANIM_LENGTH>
<ANIM_LAG>50</ANIM_LAG>
</UseTemplate>`
);
}
});
}
});