Skip to content

feat(atlas): 引入 SmartRectsBinPack 并支持多纹理打包输出#13

Open
cptbtptpbcptdtptp wants to merge 3 commits intogalacean:mainfrom
cptbtptpbcptdtptp:opt/smart
Open

feat(atlas): 引入 SmartRectsBinPack 并支持多纹理打包输出#13
cptbtptpbcptdtptp wants to merge 3 commits intogalacean:mainfrom
cptbtptpbcptdtptp:opt/smart

Conversation

@cptbtptpbcptdtptp
Copy link
Contributor

背景

为提升图集打包稳定性与空间利用率,本次将默认打包实现切换到 SmartRectsBinPack,并补齐浏览器端多纹理(multi-atlas)输出能力。

主要改动

  • 在 atlas-algorithm/atlas 两侧新增 SmartRectsBinPack,并抽象 IMaxRectsBinPack 接口,保持与旧实现一致的调用形态(init/insert/insert2)。
  • atlas 核心打包器默认实现切换为 SmartRectsBinPack(保留原有 maxrects method 参数能力)。
  • atlas-browser 打包流程升级为多 bin 循环打包:单次装不下时自动继续生成下一张纹理。
  • atlas-browser 绘制与输出流程改为多纹理产物:输出 imageFiles[],并在 info.atlasItems[] 中记录每张子图集及 sprite 信息。
  • 增强图片加载阶段的尺寸合法性校验,提前拦截超限图片。
  • 新增 atlas-algorithm 测试目录与场景数据(复用 maxrects-packer 场景),覆盖边界、无重叠、可装箱性等验证。

依赖与版本

  • 新增依赖:maxrects-packer@2.7.3
  • 版本提升:
    • @galacean/tools-atlas-algorithm -> 1.6.0-beta.0
    • @galacean/tools-atlas-browser -> 1.6.0-beta.0

验证

  • 已执行:pnpm -C packages/atlas-algorithm test
  • 结果:通过(包含 BestLongSideFit + no-rotateBestAreaFit + rotate 两组场景)

风险与兼容性说明

  • atlas-browserPackingOutput 结构与默认参数存在行为变化(输出字段从单图产物演进为多图产物;默认宽高/padding 也有调整),调用方若依赖旧字段需同步适配。
  • 算法切换后布局结果可能与旧实现不同(但约束正确性与测试已覆盖)。

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

Successfully merging this pull request may close these issues.

1 participant