Skip to content

Commit

Permalink
Add usage and separate cli usage
Browse files Browse the repository at this point in the history
  • Loading branch information
juunini committed Jan 7, 2023
1 parent ee5e7d4 commit 10ebf89
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ module.exports = {
'.js',
'/__snapshots__/',
'bin/index.ts',
'bin/flagOptions.ts',
'bin/gltfPipeline.ts',
'bin/utilsCoverageIgnore.ts'
'bin/flagOptions.ts'
],
moduleNameMapper: {}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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": {
Expand Down

0 comments on commit 10ebf89

Please sign in to comment.