Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies & use @mml-io/model-loader #51

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions clis/glft-avatar-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
"lint-fix": "eslint \"./{src,test}/**/*.{js,jsx,ts,tsx}\" --fix"
},
"dependencies": {
"three": "0.161.0",
"@napi-rs/canvas": "0.1.51",
"jimp": "0.22.12",
"three": "0.163.0",
"@mml-io/model-loader": "0.14.0",
"gltf-avatar-export-lib": "file:../../packages/gltf-avatar-export-lib",
"yargs": "17.7.2"
},
"devDependencies": {
"@types/three": "0.160.0"
"@types/three": "0.163.0"
}
}
14 changes: 7 additions & 7 deletions clis/glft-avatar-exporter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import fs from "fs";
import process from "process";

import { correctionSteps, correctionStepNames, ModelLoader } from "gltf-avatar-export-lib";
import { ModelLoader } from "@mml-io/model-loader";
import { correctionSteps, correctionStepNames } from "gltf-avatar-export-lib";
import { LoadingManager } from "three";
import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter.js";
import { TGALoader } from "three/examples/jsm/loaders/TGALoader.js";
import { setupPolyfills } from "threejs-nodejs-polyfills";
import { Options } from "yargs";
import yargs from "yargs/yargs";

// A lot of classes used for texture loading and saving must be polyfilled as they are not present in Node
import "./setupPolyfills";
setupPolyfills(global);

function stepNameToSkipArgName(stepName: string): string {
return `skip-${stepName}`;
Expand Down Expand Up @@ -47,7 +49,6 @@ fs.readFile(argv.input, function (readFileErr, fileBuffer) {
try {
const asArrayBuffer = fileBuffer.buffer.slice(0);

const modelLoader = new ModelLoader();
const loadingManager = new LoadingManager();
loadingManager.addHandler(/\.tga$/i, new TGALoader(loadingManager));
let hasAssetsToLoad = false;
Expand All @@ -60,7 +61,8 @@ fs.readFile(argv.input, function (readFileErr, fileBuffer) {
};
});

const { group } = await modelLoader.loadFromBuffer(asArrayBuffer, "", loadingManager);
const modelLoader = new ModelLoader(loadingManager);
const { group } = await modelLoader.loadFromBuffer(asArrayBuffer, "");

// Only wait for loading if there are assets to load
if (hasAssetsToLoad) {
Expand All @@ -80,9 +82,7 @@ fs.readFile(argv.input, function (readFileErr, fileBuffer) {
async (gltf) => {
// process data
const buff = Buffer.from(gltf as ArrayBuffer);
const base64data = buff.toString("base64");

fs.writeFile(argv.output, base64data, "base64", (writeFileErr) => {
fs.writeFile(argv.output, buff, (writeFileErr) => {
if (writeFileErr) {
console.error("Error writing file", writeFileErr);
process.exit(1);
Expand Down
244 changes: 0 additions & 244 deletions clis/glft-avatar-exporter/src/setupPolyfills.ts

This file was deleted.

Loading
Loading