Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function createTextureData(options: Required<PackTexturesOptions>)
const packer = new MaxRectsPacker<PixiRectData>(options.width, options.height, options.padding, {
smart: true,
pot: options.powerOfTwo,
border: options.padding,
border: options.border,
allowRotation: options.allowRotation,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { PackTexturesOptions, PixiPacker } from './packTextures.js';

export function fitTextureToPacker(
bin: PixiPacker,
{ width, height, fixedSize, padding, powerOfTwo }: PackTexturesOptions,
{ width, height, fixedSize, border, powerOfTwo }: PackTexturesOptions,
) {
if (!fixedSize) {
width = 0;
Expand All @@ -20,8 +20,8 @@ export function fitTextureToPacker(
}
}

height += padding ?? 0;
width += padding ?? 0;
height += border ?? 0;
width += border ?? 0;

if (powerOfTwo) {
height = nearestPowerOf2(height);
Expand Down
2 changes: 2 additions & 0 deletions packages/assetpack/src/texture-packer/packer/packTextures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface PackTexturesOptions {
texturesToPack: { path: string; contents: Buffer }[];
textureName: string;
padding?: number;
border?: number;
fixedSize?: boolean;
powerOfTwo?: boolean;
width?: number;
Expand All @@ -57,6 +58,7 @@ export async function packTextures(_options: PackTexturesOptions): Promise<PackT
width: 1024,
height: 1024,
padding: 2,
border: 2,
fixedSize: false,
powerOfTwo: false,
allowTrim: true,
Expand Down
1 change: 1 addition & 0 deletions packages/docs/docs/guide/pipes/texture-packer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
| texturePacker | `object` | Options for generating texture atlases. |
| texturePacker.textureFormat | `png\|jpg` | The format of the texture atlas file.<br />Defaults to `png`. |
| texturePacker.padding | `number` | The padding between sprites in the texture atlas.<br />Defaults to `2`. |
| texturePacker.border | `number` | The padding around the edge of the packed texture atlas.<br />Defaults to `2`. |
| texturePacker.fixedSize | `boolean` | Whether the texture atlas should be a fixed size.<br />Defaults to `false`. |
| texturePacker.powerOfTwo | `boolean` | Whether the texture atlas should be a power of two.<br />Defaults to `false`. |
| texturePacker.width | `number` | The width of the texture atlas.<br />Defaults to `1024`. |
Expand Down
Loading