Skip to content

Instantly share code, notes, and snippets.

@VegarRingdalAibel
Last active March 28, 2023 20:20
Show Gist options
  • Select an option

  • Save VegarRingdalAibel/48c6a5721122bd202c400ccffaec7495 to your computer and use it in GitHub Desktop.

Select an option

Save VegarRingdalAibel/48c6a5721122bd202c400ccffaec7495 to your computer and use it in GitHub Desktop.
rvm helper
deno compile --target x86_64-unknown-linux-gnu --unstable --allow-all .\main.ts
deno compile --unstable --allow-all .\main.ts
./src.exe ./rvmparser.exe --tolerance=0.01 --output-gltf-split-level=3 ./8089.rvm --output-gltf=temp
//linux
./src ./rvmparser-linux-bin --tolerance=0.01 --output-gltf-split-level=3 ./8089.rvm --output-gltf=temp
import { DenoIO } from "https://esm.sh/@gltf-transform/core";
import * as path from "https://deno.land/std/path/mod.ts";
let folder = "";
const cmd:string[] = [];
Deno.args.forEach((e) => {
if (e.includes("output-gltf") && !e.includes("split-level")) {
folder = e.split("=")[1];
cmd.push(`--output-gltf=./${folder}/xyz.glb`)
}else {
cmd.push(e)
}
});
console.log(cmd)
// ./rvmparser.exe --tolerance=0.01 --output-gltf-split-level=3 ./AHA_ASB_8089.rvm --output-gltf=temp
//const cmd = ["./rvmparser.exe", "--tolerance=0.01", "--output-gltf-split-level=3", "./rvm/osa.rvm", `--output-gltf=./${folder}/xyz.glb`];
const p = Deno.run({ cmd, stderr: "inherit", stdout: "inherit" });
await p.status().catch((e) => {
console.log(e);
});
for await (const dirEntry of Deno.readDir(`${folder}`)) {
if (dirEntry.isFile && dirEntry.name?.toLowerCase().includes(".glb")) {
const io = new DenoIO(path);
const document = await io.readAsJSON(`./${folder}/` + dirEntry.name);
const binBuffer = document?.resources["@glb.bin"] || new Uint8Array();
const encoder = new TextEncoder();
await Deno.writeFile(
`./${folder}/` + dirEntry.name.replace(".glb", ".bin"),
new Uint8Array(binBuffer)
);
await Deno.writeFile(
`./${folder}/` +dirEntry.name.replace(".glb", ".gltf"),
new Uint8Array(encoder.encode(JSON.stringify(document.json)))
);
await Deno.remove(`./${folder}/` + dirEntry.name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment