Skip to content

Conversation

@Zyie
Copy link
Member

@Zyie Zyie commented Aug 21, 2025

This PR introduces a deserialize method to GL2D, adding initial support for parsing and deserializing spritesheets within the GL2D format.

Details

  • Implements the core concept of deserializing GL2D files.
  • The approach mirrors the Assets system, where each node and resource can register its own parser.
    • Currently implemented container and sprite
  • Updates the GL2D spec to include a spritesheet source.
    • A texture.source can now reference either:
      • an texture source (such as an image), or
      • a spritesheet.
    • Spritesheets, in turn, point to the image source they require.

Example:

stackblitz demo

serialize / deserialize scene

const serializedScene = await GL2D.serialize(app.stage);
const deserializedScene = await GL2D.deserialize(app.stage);

app.stage.addChild(deserializedScene);

serialized output

[
  {
    "type": "texture",
    "source": 2,
    "frame": [0, 0, 64, 64]
  },
  {
    "type": "image_source",
    "uri": "/textures/spritesheet.png"
  },
  {
    "type": "spritesheet",
    "uri": "/textures/spritesheet.json",
    "source": 1
  }
]

In this example:
texture → spritesheet → image source (following the source chain).

Notes

  • Not all engines require a dedicated spritesheet resource; some may directly load the image source instead.
  • In this PR currently only Container and Sprite have deserialize parsers

Zyie added 5 commits August 21, 2025 11:26
Adds support for spritesheets within the GL2D format. This includes:

- Defines structures for representing spritesheet resources.
- Implements logic to identify and serialize spritesheets and their textures within GL2D files.
- Creates utility to determine if a texture is sourced from a spritesheet.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 21, 2025

pixi.js-basepixi.js-bunny-mark

npm i https://pkg.pr.new/pixijs/pixijs/pixi.js@11629

commit: 16b4245

@Zyie Zyie force-pushed the feat/gl2d-deserialize branch from 308601f to 14cec37 Compare August 21, 2025 19:32
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.

2 participants