Feat/tilemap canvas caching - #1
Merged
Merged
Conversation
added 2 commits
January 22, 2026 22:23
… singleton pattern and enhance TgSpriteMap with collider registration and rendering modes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements to the
tg-sprite-mapcomponent, 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
tg-sprite-mapto 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 viarequestAnimationFrame. ([[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))renderMode,registerColliders,colliderMapId, anddebugColliders. 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))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
tg-colliderto 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))[[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
tg-sprite-mapto 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))readme.mdfiles fortg-colliderandtg-sprite-mapto 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
[src/components/engine/tg-sprite-map/tg-sprite-map.scssR5-R30](https://github.com/Scan0815/tg-engine/pull/1/files#diff-36bb34ff1e6de527f6b78b1f6c5ce31b4c9072e120a2bd2401b4f963ecc3d5b7R5-R30))Miscellaneous
0.1.7to0.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.