npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gltf-optimizer-breizhwebsolution

v1.0.4

Published

A powerful Node.js library and CLI tool to optimize 3D models in GLTF/GLB format using gltf-transform. Compresses meshes (Draco), resizes textures, and converts to WebP for optimal web performance.

Readme

GLTF Optimizer

A powerful Node.js library and CLI tool to optimize 3D models in GLTF/GLB format. Uses gltf-transform to compress meshes (Draco), resize textures, and convert them to WebP for optimal web performance.

npm version license
node version

🚀 Features

  • Multi-format support: GLTF (.gltf + .bin) and GLB (single file)
  • Advanced optimizations:
    • Draco mesh compression
    • Texture resizing (configurable max size)
    • WebP texture conversion
    • Automatic deduplication and optimization
  • Model validation: Checks file integrity before optimization
  • Backup system: Automatic original file backups
  • Detailed reporting: Size comparisons and optimization statistics
  • CLI & API: Both command-line interface and programmatic API
  • Configuration: JSON-based configuration support
  • Non-interactive mode: Perfect for CI/CD pipelines

📦 Installation

npm i gltf-optimizer-breizhwebsolution

🛠️ Usage

Programmatic API

Import and use functions directly in your Node.js code:

const { findGltfFiles, optimizeModel } = require('gltf-optimizer-breizhwebsolution');

// Find all GLTF files in a directory
const modelsDir = './path/to/your/models';
const gltfFiles = findGltfFiles(modelsDir);

// Optimize a specific model with custom options
gltfFiles.forEach(file => {
  optimizeModel(file, {
    compressDraco: true,      // Draco compression (default: true)
    resizeTextures: true,     // Resize textures (default: true)
    maxTextureSize: 1024,     // Max texture size (default: 1024)
    backupOriginal: true      // Backup original files (default: true)
  });
});

Command Line Interface (CLI)

Run the interactive script to optimize models via terminal:

npx gltf-optimizer
# or after global installation: gltf-optimizer

CLI Options

gltf-optimizer [options]

Options:
  --yes, -y                Non-interactive mode (automation)
  --models-dir=<path>      Directory containing the models
  --output-dir=<path>      Output directory (optional)
  --help, -h              Show this help

Examples:
  gltf-optimizer --yes
  gltf-optimizer --models-dir=./assets --yes
  gltf-optimizer --yes --output-dir=./optimized
  • Default behavior: Scans models/ folder
  • Interactive mode: Menu to select specific models or optimize all
  • Non-interactive mode: Optimizes all models automatically
  • Colored logs: Shows sizes before/after and optimization details

⚙️ Configuration

Create a gltf-optimizer.config.json file in your project root:

{
  "modelsDir": "./models",
  "outputDir": null,
  "options": {
    "compressDraco": true,
    "resizeTextures": true,
    "maxTextureSize": 1024,
    "backupOriginal": true
  },
  "excludePatterns": [
    "**/node_modules/**",
    "**/*.backup.*",
    "**/*-original.*"
  ],
  "includePatterns": [
    "**/*.gltf",
    "**/*.glb"
  ],
  "parallelProcessing": false,
  "maxConcurrency": 4,
  "logLevel": "info",
  "generateReport": false,
  "reportFormat": "json"
}

Or add a gltf-optimizer section to your package.json:

{
  "name": "my-project",
  "gltf-optimizer": {
    "modelsDir": "./assets/models",
    "options": {
      "maxTextureSize": 2048
    }
  }
}

📊 Optimization Results

The tool provides detailed optimization reports:

📦 Original size: 4.32 MB → 1.14 MB
💾 Reduction: 73.6% (3.18 MB saved)

📋 Detailed information:
   📄 Format: .GLTF
   🔧 Applied optimizations:
     ✓ Draco compression (geometry)
     ✓ Texture resizing (max 1024px)
     ✓ WebP texture compression
     ✓ gltf-transform optimizations

📊 GLOBAL OPTIMIZATION REPORT
📈 Statistics:
   ✅ Successfully optimized models: 5
   ❌ Optimization failures: 0
   📦 Total original size: 21.5 MB
   📦 Total optimized size: 6.8 MB
   💾 Total reduction: 68.4% (14.7 MB saved)

🔧 Advanced Usage

Custom Validation

const { validateGltfModel } = require('gltf-optimizer-breizhwebsolution');

const validation = validateGltfModel('model.gltf');
if (!validation.valid) {
  console.log(`Model invalid: ${validation.error}`);
}

Loading Configuration

const { loadConfig } = require('gltf-optimizer-breizhwebsolution');

const config = loadConfig('./custom-config.json');
console.log('Loaded configuration:', config);

Custom Optimization Pipeline

const { optimizeModel } = require('gltf-optimizer-breizhwebsolution');

await optimizeModel('input.gltf', {
  compressDraco: true,
  resizeTextures: false,  // Skip texture resizing
  maxTextureSize: 512,    // Smaller textures
  backupOriginal: false   // Don't backup
});

🏗️ Architecture

gltf-optimizer/
├── cli.js              # Command-line interface
├── lib/
│   └── optimize.js     # Core optimization logic
├── index.js            # Main API exports
├── gltf-optimizer.config.json  # Default configuration
└── README.md           # This file

🔧 Development

Setup

git clone https://github.com/Timothee-alt/gltfoptimizer.git
cd gltfoptimizer
npm install

Testing

npm start  # Run CLI
node test-validation.js  # Test validation

Publishing

npm login
npm publish

📋 Requirements

  • Node.js: >= 14.0.0
  • npm: >= 6.0.0
  • gltf-transform: ^2.2.0 (automatically installed)

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

--

Made with ❤️ for the 3D web community