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 🙏

© 2026 – Pkg Stats / Ryan Hefner

binpack3d

v0.1.1

Published

A fast 3D bin packing library for packing boxes into containers with multiple bins. TypeScript support and zero dependencies.

Readme

binpack3d

English | 中文

npm version CI License: MIT

实用型 3D 装箱算法库,把若干长方体物品装入一个或多个容器,支持旋转、重量上限、承重、易碎品、绑定分组、重力下沉、稳定性校验等约束。TypeScript 编写,纯 ESM 发布,零运行时依赖。

来源: 本项目是迁移自 Python 库 py3dbp(https://github.com/jerry800416/3D-bin-packing)的 TypeScript 版本。整数旋转编码与装箱启发式与上游保持一致,两端结果可复现对齐。

▶ 在线演示 —— 基于 Three.js 的可视化 demo,支持自定义输入和多个预设场景。

亮点

  • 多箱装箱 + 角点(corner-point)启发式
  • 每个物品 6 种轴向旋转(updown: false 时限制为 2 种竖直)
  • 重量上限 + 物品级承重
  • 易碎 / 不可堆叠物品
  • 绑定分组(原子装入)
  • 重力下沉 + 稳定性校验
  • 跨箱分发或每箱复制
  • 每箱体积利用率 + 4 象限重量分布
  • 箱内障碍物:py3dbp 兼容的 corner 立方体 + 通用 AABB 障碍(用于固定结构,或外部代码生成的斜切 ULD 如 LD3 等)
  • TypeScript 优先,ESM,零运行时依赖

完整逐符号 API 文档:docs/api/(英文)。

安装

npm install binpack3d

要求 Node.js >= 18(浏览器端通过任意现代打包工具即可)。

快速上手

import { pack } from 'binpack3d';

const result = pack({
  bins: [
    { partno: 'box-A', whd: [40, 30, 30], maxWeight: 30 },
  ],
  items: [
    { partno: 'item-1', whd: [10, 10, 10], weight: 2 },
    { partno: 'item-2', whd: [20, 10, 15], weight: 3, fragile: true },
    { partno: 'item-3', whd: [15, 15, 10], weight: 5, loadbear: 50 },
  ],
  options: { biggerFirst: true, numberOfDecimals: 2 },
});

console.log(result.bins[0].fittedItems);   // 已装入物品列表
console.log(result.bins[0].utilization);   // 体积填充率 0..1
console.log(result.bins[0].gravity);       // [FL%, FR%, BL%, BR%]
console.log(result.unfitItems);            // 未装入物品及原因

多箱 / 绑定分组 / 限制旋转等示例见 docs/api/pack.md

API 速览

import {
  pack,                       // 顶层装箱函数
  Bin, Item,                  // 底层类
  RotationType, Axis,         // 枚举
  type PackInput, type PackOptions, type PackResult,
  type BinInput, type BinResult,
  type ItemInput, type PlacedItem, type UnfitItem,
  type Vec3,
} from 'binpack3d';

| 符号 | 文档 | | -------------- | ---------------------------------------------------------- | | pack | docs/api/pack.md | | Bin | docs/api/Bin.md | | Item | docs/api/Item.md | | RotationTypeAxis | docs/api/enums.md | | 全部类型 | docs/api/types.md |

鸣谢

  • 核心算法移植自 Python 库 py3dbp —— 旋转编码、角点 pivot、易碎/承重/分组/稳定性规则。
  • Best-fit 旋转评分(fillW × fillH × fillD + 低高度优先)借鉴自 olragon/binpackingjs —— 替换上游的 first-fit 选择策略,在输入维度顺序变化时结果更稳定,装箱密度也略好。

协议

MIT © Albert