From 10ebf890c7c5c4d24c546f83a05c16a07304fc85 Mon Sep 17 00:00:00 2001 From: juunini Date: Sat, 7 Jan 2023 19:10:54 +0900 Subject: [PATCH] Add usage and separate cli usage --- README.md | 18 ++++++++++++++++++ jest.config.cjs | 4 +--- package.json | 8 ++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a16de48..edafa40 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,24 @@ npm install --global gltf-optimizer ## Usage +```ts +import { optimizer } from 'gltf-optimizer' + +// ... + +// node (backend side) +const glb = fs.readFileSync('./target.glb') +const optimized = await optimizer.node(glb, { /* options */ }) +fs.writeFileSync('./compressed.glb', optimized) + +// browser (frontend side) +const optimized = await optimizer.web(glb, { /* options */ }) +// if using get-file-using-a-tag (https://github.com/juunini/get-file-using-a-tag) +download({ fileName: 'compressed.glb', arrayBuffer: optimized }) +``` + +## Usage(CLI) + ```bash gltf-optimizer -i model.glb gltf-optimizer -i model.glb -o ./output diff --git a/jest.config.cjs b/jest.config.cjs index dfb7e2c..0ed17da 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -27,9 +27,7 @@ module.exports = { '.js', '/__snapshots__/', 'bin/index.ts', - 'bin/flagOptions.ts', - 'bin/gltfPipeline.ts', - 'bin/utilsCoverageIgnore.ts' + 'bin/flagOptions.ts' ], moduleNameMapper: {} } diff --git a/package.json b/package.json index a827336..6b61b46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gltf-optimizer", - "version": "0.3.1", + "version": "0.3.2", "description": "Optimize glTF model", "homepage": "https://github.com/juunini/gltf-optimizer", "repository": "juunini/gltf-optimizer", @@ -14,9 +14,9 @@ }, "scripts": { "build": "tsc -p ./tsconfig.build.json", - "test": "pnpm test:prevent && jest", - "test:cov": "pnpm test:prevent && jest --coverage", - "test:prevent": "rimraf bin/*.js && rimraf bin/*.d.ts", + "test": "pnpm clear && jest", + "test:cov": "pnpm clear && jest --coverage", + "clear": "rimraf bin/*.js && rimraf bin/*.d.ts && rimraf src/**/*.js && rimraf src/**/*.d.ts", "lint": "eslint --ext .ts ." }, "devDependencies": {