playcanvas / playcanvas/engine

Engine - TextureAtlasHandler bugs

Open
#1,821 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: graphics
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

I tried to load an atlas exported from TexturePacker (I use: https://github.com/playcanvas/playcanvas-texturepacker exporter)

my code is:

this.app.assets.loadFromUrl("assets/atlas_0.json, "textureatlas", (err: string, asset: pc.Asset) => { );

  1. After the JSON file is loaded, the engine tries to load the texture (assets/atlas_0.png) but that doesn't work and the the engine hangs.

  2. I can load the texture myself before I start loading the atlas json. This works, but the JSON file exported from the TexturePacker has different structure of frames then pc.TextureAtlas and the pc.TextureAtlasHandler doesn't convert them correctly.

This is code from texture-atlas.js:

            // set frames
            var frames = {};
            for (var key in asset.data.frames) {
                var frame = asset.data.frames[key];
                frames[key] = {
                    rect: new pc.Vec4(frame.rect),
                    pivot: new pc.Vec2(frame.pivot),
                    border: new pc.Vec4(frame.border)
                };
            }
            asset.resource.frames = frames;

But in the JSON file there is no "rect" or "border". There is "frame" and "spriteSourceSize". Also the coordinates system is different: Y in TexturePacker starts at the top.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in texture-atlas.js and inspect TextureAtlasHandler's texture-loading path and frame conversion for TexturePacker JSON. Compare the exported frame, spriteSourceSize, and top-origin coordinates with the expected atlas fields; done means the texture loads without hanging and the frames are converted correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.