{"_id":"3d-bin-packing-ts","_rev":"2-c35230a4bd7fd7a50b8c30c2a9b016ad","name":"3d-bin-packing-ts","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"3d-bin-packing-ts","version":"1.0.0","keywords":["3d","bin","packing","algorithm","container","packing","eb-afit","optimization"],"author":{"name":"taherjerbi"},"license":"MIT","_id":"3d-bin-packing-ts@1.0.0","maintainers":[{"name":"taher_jerbi","email":"jerbi.taherr@gmail.com"}],"homepage":"https://github.com/taherjerbi/3d-bin-packing-ts#readme","bugs":{"url":"https://github.com/taherjerbi/3d-bin-packing-ts/issues"},"dist":{"shasum":"0d082a4ed1ae6923f8a9b8225c959ba379a790aa","tarball":"https://registry.npmjs.org/3d-bin-packing-ts/-/3d-bin-packing-ts-1.0.0.tgz","fileCount":8,"integrity":"sha512-FAU4cwe3L7sD88Hk7yVud19OO67rW2CB7X5ibBCNbqay7oHQQCkXjP6N0QpYZITaFdgZKJvLoTsOw6N8TeuO9w==","signatures":[{"sig":"MEYCIQCaDgajPDBEO6Q7VZZLkHK+bEIKMwFrqPUVLpB6sQ2iXgIhAIHlfMz+yeDxIHFMvcspXfF2a1CvDrnle2F08O7WDFFM","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":89759},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"c4a3a3c0b1626050125ef602d3249f84d07ddcef","scripts":{"test":"echo \"No tests specified\"","build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"taher_jerbi","email":"jerbi.taherr@gmail.com"},"repository":{"url":"git+https://github.com/taherjerbi/3d-bin-packing-ts.git","type":"git"},"_npmVersion":"10.8.2","description":"A TypeScript implementation of the EB AFIT algorithm for 3D container packing","directories":{},"_nodeVersion":"20.19.3","dependencies":{"uuid":"^13.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jiti":"^2.5.1","tsup":"^8.3.0","eslint":"^9.35.0","globals":"^16.4.0","@eslint/js":"^9.35.0","typescript":"^5.6.3","typescript-eslint":"^8.44.0"},"_npmOperationalInternal":{"tmp":"tmp/3d-bin-packing-ts_1.0.0_1758123754064_0.6885620543833286","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"3d-bin-packing-ts","version":"1.0.1","description":"A TypeScript implementation of the EB AFIT algorithm for 3D container packing","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"build":"tsup","prepublishOnly":"npm run build","test":"echo \"No tests specified\""},"keywords":["3d","bin","packing","algorithm","container","packing","eb-afit","optimization"],"author":{"name":"taherjerbi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/taherjerbi/3d-bin-packing-ts.git"},"devDependencies":{"@eslint/js":"^9.35.0","eslint":"^9.35.0","globals":"^16.4.0","jiti":"^2.5.1","tsup":"^8.3.0","typescript":"^5.6.3","typescript-eslint":"^8.44.0"},"dependencies":{"uuid":"^13.0.0"},"_id":"3d-bin-packing-ts@1.0.1","gitHead":"b58aee0f43cd361548a9ea981cf225c513f5b221","bugs":{"url":"https://github.com/taherjerbi/3d-bin-packing-ts/issues"},"homepage":"https://github.com/taherjerbi/3d-bin-packing-ts#readme","_nodeVersion":"20.19.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-O9uCokPiOv6WHzqJtQwTHM1kscg+JDH/Hwp46vzvdfee3p3Ul2xAY+IOUf5JSBFpAGach0efnjCbdMUOUSOTYg==","shasum":"4e3d188d94626121b2e5f855cc53d2810b3ceac7","tarball":"https://registry.npmjs.org/3d-bin-packing-ts/-/3d-bin-packing-ts-1.0.1.tgz","fileCount":14,"unpackedSize":103219,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIANjQlTl9oZhvYb9Atu6Dnd//1+ZtHZbFQST8uafdJfwAiAaUIn6mcihbIUo6POnPuf1J9UcYn1dNH4WJNiL23BBbw=="}]},"_npmUser":{"name":"taher_jerbi","email":"jerbi.taherr@gmail.com"},"directories":{},"maintainers":[{"name":"taher_jerbi","email":"jerbi.taherr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/3d-bin-packing-ts_1.0.1_1758124411619_0.7439542944598072"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-17T15:42:33.985Z","modified":"2025-09-17T15:53:31.957Z","1.0.0":"2025-09-17T15:42:34.245Z","1.0.1":"2025-09-17T15:53:31.782Z"},"bugs":{"url":"https://github.com/taherjerbi/3d-bin-packing-ts/issues"},"author":{"name":"taherjerbi"},"license":"MIT","homepage":"https://github.com/taherjerbi/3d-bin-packing-ts#readme","keywords":["3d","bin","packing","algorithm","container","packing","eb-afit","optimization"],"repository":{"type":"git","url":"git+https://github.com/taherjerbi/3d-bin-packing-ts.git"},"description":"A TypeScript implementation of the EB AFIT algorithm for 3D container packing","maintainers":[{"name":"taher_jerbi","email":"jerbi.taherr@gmail.com"}],"readme":"# 3D Container Packing in TypeScript\n\n[![npm version](https://img.shields.io/npm/v/3d-bin-packing-ts.svg)](https://www.npmjs.com/package/3d-bin-packing-ts)\n\nThis is a TypeScript port of the [3DContainerPacking C# library by davidmchapman](https://github.com/davidmchapman/3DContainerPacking).\n\nIt contains an implementation of the EB-AFIT algorithm, a heuristic approach designed to solve the three-dimensional pallet-packing problem, also known as 3D bin packing. It was developed by Erhan Baltacıoğlu (EB) at the U.S. Air Force Institute of Technology (AFIT) as part of his master's thesis in 2001, and later described in a paper co-authored with James T. Moore and Raymond R. Hill Jr. in 2006. If you want to learn more about the algorithm and its' history, visit reference implementation repository: https://github.com/wknechtel/3d-bin-pack.\n\nThis TypeScript port includes all the original functionality plus a new packIncremental feature that automatically distributes items across multiple containers of the same dimensions.\n\n## Features\n\n- Pack items into containers with optimal space utilization.\n- Incremental packing to distribute items across multiple containers of the same size.\n- TypeScript support with full type definitions.\n\nCheck out the [examples](./examples) folder for runnable code samples.\n\n## Usage\n\n### Installation\n\n```bash\nnpm install 3d-bin-packing-ts\n```\n\n### Basic Usage\n\n```typescript\nimport { Container, Item, PackingService, PackingAlgorithmType } from '3d-bin-packing-ts';\n\n// Create a container\nconst container = new Container('container1', 100, 100, 100);\n\n// Create items to pack\nconst items = [\n  new Item('item1', 30, 40, 50, 1),\n  new Item('item2', 20, 30, 40, 2),\n  new Item('item3', 10, 20, 30, 3)\n];\n\n// Pack items into the container\nconst result = PackingService.packSingle(container, items);\n\n// Check if all items were packed\nconsole.log(`All items packed: ${result.algorithmPackingResults[0].isCompletePacked}`);\n\n// Get packed items with their positions\nconst packedItems = result.algorithmPackingResults[0].packedItems;\nconsole.log('Packed items:', packedItems);\n\n// Get unpacked items\nconst unpackedItems = result.algorithmPackingResults[0].unpackedItems;\nconsole.log('Unpacked items:', unpackedItems);\n```\n\n### Packing Multiple Containers\n\n```typescript\nimport { Container, Item, PackingService } from '3d-bin-packing-ts';\n\n// Create multiple containers\nconst containers = [\n  new Container('container1', 100, 100, 100),\n  new Container('container2', 150, 150, 150)\n];\n\n// Create items to pack\nconst items = [\n  new Item('item1', 30, 40, 50, 1),\n  new Item('item2', 20, 30, 40, 2),\n  new Item('item3', 10, 20, 30, 3)\n];\n\n// Pack items into containers\nconst results = PackingService.pack(containers, items);\n\n// Process results for each container\nresults.forEach(result => {\n  console.log(`Container ${result.containerId}:`);\n  console.log(`- Packed items: ${result.algorithmPackingResults[0].packedItems.length}`);\n  console.log(`- Unpacked items: ${result.algorithmPackingResults[0].unpackedItems.length}`);\n  console.log(`- Volume utilization: ${result.algorithmPackingResults[0].percentContainerVolumePacked}%`);\n});\n```\n\n### Incremental Packing\n\n```typescript\nimport { Item, PackingService } from '3d-bin-packing-ts';\n\n// Create items to pack\nconst items = [\n  new Item('item1', 30, 40, 50, 1),\n  new Item('item2', 20, 30, 40, 2),\n  new Item('item3', 10, 20, 30, 3)\n];\n\n// Define container dimensions\nconst containerDimensions = { length: 100, width: 100, height: 100 };\n\n// Pack items incrementally (creates as many containers as needed)\nconst result = PackingService.packIncremental(items, containerDimensions);\n\n// Get information about containers and item distribution\nconsole.log(`Number of containers needed: ${result.containers.length}`);\n\n// Get aggregated results (which items went into which container)\nresult.aggregatedResults.forEach(aggResult => {\n  console.log(`Container ${aggResult.containerId}:`);\n  aggResult.itemQuantities.forEach(itemQty => {\n    console.log(`- Item ${itemQty.itemId}: ${itemQty.quantity} units`);\n  });\n});\n```\n\n## API Reference\n\n### Classes\n\n#### `Container`\n\nRepresents a 3D container to pack items into.\n\n```typescript\nnew Container(id: string, length: number, width: number, height: number)\n```\n\n#### `Item`\n\nRepresents a 3D item to be packed.\n\n```typescript\nnew Item(id: string, dim1: number, dim2: number, dim3: number, quantity: number)\n```\n\n#### `PackingService`\n\nStatic service for packing operations.\n\nMethods:\n- `packSingle(container, items, algorithmTypeIDs?)`: Pack items into a single container\n- `pack(containers, items, algorithmTypeIDs?)`: Pack items into multiple containers\n- `packIncremental(items, containerDimensions, maxVolumePercentage?, idGenerator?)`: Pack items into as many containers as needed\n\n### Interfaces and Types\n\n#### `AlgorithmPackingResult`\n\nContains the results of a packing operation.\n\nProperties:\n- `packedItems`: Array of packed items with their positions\n- `unpackedItems`: Array of items that couldn't be packed\n- `isCompletePacked`: Boolean indicating if all items were packed\n- `packTimeMilliseconds`: Time taken for packing\n- `percentContainerVolumePacked`: Percentage of container volume utilized\n- `percentItemVolumePacked`: Percentage of total item volume packed\n","readmeFilename":"README.md"}