Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D packing depth issue? #37

Open
pward123 opened this issue Feb 1, 2023 · 0 comments
Open

3D packing depth issue? #37

pward123 opened this issue Feb 1, 2023 · 0 comments

Comments

@pward123
Copy link

pward123 commented Feb 1, 2023

If I run this:

'use strict'

const {BP3D: { Item, Bin, Packer}} = require('binpackingjs')

const item = [18.75, 7.25, 4, 1]
const binOfFour = ['bin_of_4', 18.75 * 2, 7.25 * 2, 4 * 1, 10000]
const binOfEight = ['bin_of_8', 18.75 * 2, 7.25 * 2, 4 * 2, 10000]

const packIt = (itemProps, itemCount, binProps) => {
    const packer = new Packer()

    const bin = new Bin(...binProps)
    packer.addBin(bin)

    for (let i = -1; ++i < itemCount; ) {
        packer.addItem(new Item(`item_${i + 1}`, ...itemProps))
    }

    packer.pack()
    return {
        ...bin,
        items: bin.items.length,
    }
}

console.log(JSON.stringify(packIt(item, 20, binOfFour), null, 4))
console.log(JSON.stringify(packIt(item, 20, binOfEight), null, 4))

the result is this:

{
    "name": "bin_of_4",
    "width": 3750000,
    "height": 1450000,
    "depth": 400000,
    "maxWeight": 1000000000,
    "items": 4
}
{
    "name": "bin_of_8",
    "width": 3750000,
    "height": 1450000,
    "depth": 800000,
    "maxWeight": 1000000000,
    "items": 6
}

correct me if I'm wrong, but for bin_of_8 if i have a bin that's 2 times the width, 2 times the height and 2 times the depth of the items it holds, then 8 items should fit in the bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant