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

@metav_xly/obj2glb

v1.0.7

Published

Convert OBJ files to optimized GLB format

Readme

obj2glb

一个基于 obj2gltf 和 gltf-pipeline 的命令行工具,用于将 OBJ 3D 模型文件转换为优化的 GLB 格式。

特性

  • 🚀 快速转换 OBJ 文件到 GLB 格式
  • 🗜️ 支持 Draco 压缩优化
  • 📦 批量处理多个文件
  • 🎛️ 多种质量预设(低/中/高)
  • 🎨 彩色命令行输出
  • 📊 详细的转换统计信息
  • 🔧 TypeScript 编写,类型安全

安装

全局安装

npm install -g @metav_xly/obj2glb

本地安装

npm install @metav_xly/obj2glb

使用方法

基本用法

# 转换单个文件
obj2glb model.obj

# 指定输出文件
obj2glb model.obj output.glb

# 指定质量级别
obj2glb model.obj --level 10

# 禁用 Draco 压缩
obj2glb model.obj --nodraco

# 批量转换目录中的所有 OBJ 文件
obj2glb ./models --batch

# 详细输出
obj2glb model.obj --verbose

命令行选项

Usage: obj2glb <input> [output] [options]

Arguments:
  input                    输入 OBJ 文件路径
  output                   输出 GLB 文件路径(可选)

Options:
  -l, --level             压缩等级(1-10,10为最高压缩,1为最低压缩),默认为7
  -b, --batch             批量转换目录中的所有 OBJ 文件
  -v, --verbose           详细输出
  --nodraco              禁用 Draco 压缩
  -h, --help              显示帮助信息
  -V, --version           显示版本号

编程接口

除了命令行工具,obj2glb 也可以作为 Node.js 模块使用:

import { convertObjToGlb } from '@metav_xly/obj2glb';

const result = await convertObjToGlb({
  input: 'model.obj',
  output: 'model.glb',
  level: 7,
  dracoCompression: true,
  verbose: true
});

if (result.success) {
  console.log(`转换成功!输出文件:${result.outputFile}`);
  console.log(`文件大小:${result.fileSize.input} -> ${result.fileSize.output} bytes`);
  console.log(`处理时间:${result.processingTime}ms`);
} else {
  console.error(`转换失败:${result.error}`);
}

技术栈

  • Node.js - 运行环境
  • TypeScript - 开发语言
  • obj2gltf - OBJ 到 GLTF 转换
  • gltf-pipeline - GLTF 优化和 GLB 生成
  • Commander.js - 命令行接口
  • Chalk - 彩色输出
  • Progress - 进度条显示

开发

环境要求

  • Node.js >= 18.0.0
  • npm 或 pnpm

本地开发

# 克隆项目
git clone <repository-url>
cd obj2glb

# 安装依赖
npm install

# 构建项目
npm run build

# 运行测试
npm test

# 开发模式(监听文件变化)
npm run dev

项目结构

obj2glb/
├── src/
│   ├── cli.ts          # 命令行入口
│   ├── converter.ts    # 核心转换逻辑
│   ├── types.ts        # 类型定义
│   └── index.ts        # 主入口文件
├── dist/               # 编译输出
├── package.json
├── tsconfig.json
└── README.md

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v1.0.0

  • 🎉 初始版本发布
  • ✨ 支持 OBJ 到 GLB 转换
  • ✨ 支持质量预设和 Draco 压缩