soimy / maxrects-packer

A max rectangle 2d bin packer npm-module for packing glyphs or images into multiple sprite-sheet/atlas
https://soimy.github.io/maxrects-packer/
MIT License
186 stars 35 forks source link

packer.addArray(array) fails if the array is empty and exclusiveTag: false is set #23

Closed CosmoMyzrailGorynych closed 3 years ago

CosmoMyzrailGorynych commented 4 years ago

It is not a critical issue but is a case of inconsistent behavior under different settings.

To reproduce:

const Packer = require('maxrects-packer').MaxRectsPacker;
const packer = new Packer(atlasWidth, atlasHeight, 0, {
    pot: true,
    square: true,
    tag: true,
    exclusiveTag: false
});
packer.addArray([]); // Bazinga! Cannot read property 'data' of undefined
                     // Does work if you remove `exclusiveTag: false`