Skip to content

Feat/tilemap canvas caching - #1

Merged
Scan0815 merged 2 commits into
mainfrom
feat/tilemap-canvas-caching
Jan 22, 2026
Merged

Feat/tilemap canvas caching#1
Scan0815 merged 2 commits into
mainfrom
feat/tilemap-canvas-caching

Conversation

@Scan0815

Copy link
Copy Markdown
Owner

This pull request introduces significant improvements to the tg-sprite-map component, adding a new canvas-based rendering mode with support for static and animated tiles, optional collider registration, and debug visualization. It also updates the collider API for better interoperability, and enhances test coverage and documentation.

Key changes:

Major Feature: Canvas Rendering & Animation Support

  • Refactored tg-sprite-map to support both 'canvas' and 'dom' render modes, defaulting to 'canvas'. The canvas mode efficiently draws static and animated tiles using two layered canvases, with animation handled via requestAnimationFrame. ([[1]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2271f1f3eaa55a19df211c1c08796561c4724c5b59484e69e1a8922d91afedd7L1-R12), [[2]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2271f1f3eaa55a19df211c1c08796561c4724c5b59484e69e1a8922d91afedd7R22-L77))
  • Added new props: renderMode, registerColliders, colliderMapId, and debugColliders. These allow switching render modes, registering tile colliders, and showing debug overlays for colliders. ([[1]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2271f1f3eaa55a19df211c1c08796561c4724c5b59484e69e1a8922d91afedd7R22-L77), [[2]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-83be7908fa72fc89dfb2951d995a66a2040c91d94a2d2fe7123ac1a725f8fdc3L11-R17))
  • Implemented collider registration logic, integrating with ColliderManager, and added a debug overlay for collidable tiles. ([[1]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2271f1f3eaa55a19df211c1c08796561c4724c5b59484e69e1a8922d91afedd7R22-L77), [[2]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-36bb34ff1e6de527f6b78b1f6c5ce31b4c9072e120a2bd2401b4f963ecc3d5b7R5-R30))

API and Type Improvements

  • Updated collider-related methods in tg-collider to return the DOM element (HTMLTgColliderElement | null) instead of the component instance, improving compatibility and clarity. ([[1]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2a90a1a424f067c71293ecf057ea7b105f39485670ad41d50ac179ac1fdd2661L34-R34), [[2]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2a90a1a424f067c71293ecf057ea7b105f39485670ad41d50ac179ac1fdd2661L49-R49), [[3]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-62cc88f212d81ead0de3ebccbb821ce463b1a2bdcb96f90d3ac1e3421fc9adc7L31-R34), [[4]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-62cc88f212d81ead0de3ebccbb821ce463b1a2bdcb96f90d3ac1e3421fc9adc7L49-R53))
  • Improved import statements for interfaces to use barrel files for consistency. ([[1]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-62cc88f212d81ead0de3ebccbb821ce463b1a2bdcb96f90d3ac1e3421fc9adc7L3-R3), [[2]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-c8d6c65e507efad049bda8894a08e6142b327c8439bcbb33f84393f2c8ecc052L2-R16))

Testing and Documentation

  • Expanded unit tests for tg-sprite-map to cover both canvas and DOM rendering modes, including animated and static tile rendering, and the new prop behaviors. ([[1]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R8), [[2]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R17-R18), [[3]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R34-R35), [[4]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R50-R68), [[5]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R94), [[6]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R130), [[7]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044L122-R148), [[8]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R176), [[9]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R205), [[10]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-6e5b2de754491b4c95762d56fd69659ed1641a22ed886bc061e125d989228044R219))
  • Updated readme.md files for tg-collider and tg-sprite-map to reflect new method signatures and props. ([[1]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2a90a1a424f067c71293ecf057ea7b105f39485670ad41d50ac179ac1fdd2661L34-R34), [[2]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-2a90a1a424f067c71293ecf057ea7b105f39485670ad41d50ac179ac1fdd2661L49-R49), [[3]](https://github.com/Scan0815/tg-engine/pull/1/files#diff-83be7908fa72fc89dfb2951d995a66a2040c91d94a2d2fe7123ac1a725f8fdc3L11-R17))

Styling

  • Added SCSS for canvas layers and debug overlays, ensuring proper stacking and pixelated rendering for the canvas mode. ([src/components/engine/tg-sprite-map/tg-sprite-map.scssR5-R30](https://github.com/Scan0815/tg-engine/pull/1/files#diff-36bb34ff1e6de527f6b78b1f6c5ce31b4c9072e120a2bd2401b4f963ecc3d5b7R5-R30))

Miscellaneous

  • Bumped package version from 0.1.7 to 0.1.9. ([package.jsonL3-R3](https://github.com/Scan0815/tg-engine/pull/1/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L3-R3))

These changes collectively modernize the rendering engine, improve performance and flexibility, and enhance developer experience when working with colliders and tile maps.

oliver added 2 commits January 22, 2026 22:23
… singleton pattern and enhance TgSpriteMap with collider registration and rendering modes
@Scan0815
Scan0815 merged commit 16c8e1a into main Jan 22, 2026
2 checks passed
@Scan0815
Scan0815 deleted the feat/tilemap-canvas-caching branch January 22, 2026 21:29
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