Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(TileBuilder): migrate to TypeScript #2440

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

HoloTheDrunk
Copy link
Contributor

@HoloTheDrunk HoloTheDrunk commented Oct 16, 2024

Description

Create types for the tile builder section of iTowns.
Improve performance of tile creation.
Improve code readability of tile creation.

Depends on #2447. Merged.

Summary of changes

  • Lots of renaming, most notably the BuilderEllipsoidTile being changed to GlobalTileBuilder to match the naming of the PlanarTileBuilder (especially considering its position inside a Globe folder). Hesitated between "Globe" and "Global" so feel free to criticize the choice, it's already a breaking change so we might as well pick the best one.
  • Resolve circular type dependency between builders and their parameters by making the new builder interface generic over type parameters.
  • Significantly refactor computeBuffers.js into computeBuffers.ts, changing algorithm to take advantage of simple math to avoid using slow JS constructs in favor of ArrayBuffers and moving some checks out of loops.

Motivation and Context

This fits into the larger motion towards converting iTowns to TypeScript.
Code had to be changed and moved around to allow static type checking.
Some of the functions around buffer generation were cryptic and had low readability, which required additional changes.

Tested on Ubuntu 22.04.5 LTS x86_64 using Firefox 126.0.1 (64-bit)

@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch 3 times, most recently from c131f60 to 9d9b3c8 Compare October 22, 2024 15:23
@HoloTheDrunk HoloTheDrunk changed the title refacto: switch tile builder to typescript refactor: migrate TileBuilder to typescript Oct 23, 2024
@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch 4 times, most recently from 164fabe to d8855a9 Compare October 29, 2024 10:06
@HoloTheDrunk HoloTheDrunk requested a review from jailln October 29, 2024 10:12
@HoloTheDrunk
Copy link
Contributor Author

HoloTheDrunk commented Oct 29, 2024

It'd be great if I could please get a go-ahead on the general structure of this refactor so I can start working on the next one—which will inevitably be based off of this one, while the specific details of the PR get reviewed :)

@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch from d8855a9 to 5dad0cb Compare October 29, 2024 10:58
@jailln jailln self-assigned this Nov 6, 2024
@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch from 5dad0cb to 55a01e7 Compare November 12, 2024 16:13
Copy link
Contributor

@jailln jailln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all these changes, it's already better and easier to understand with typings. I think we should take this opportunity to improve the architecture and the doc of this part of the code a little bit more, that's what stands out from my comments. Let me know what you think :)

src/Core/Prefab/Globe/GlobeTileBuilder.ts Outdated Show resolved Hide resolved
src/Core/Prefab/Globe/GlobeTileBuilder.ts Show resolved Hide resolved
src/Core/Prefab/Globe/GlobeTileBuilder.ts Show resolved Hide resolved
src/Core/Prefab/Globe/GlobeTileBuilder.ts Show resolved Hide resolved
src/Core/Prefab/Globe/GlobeTileBuilder.ts Show resolved Hide resolved
src/Core/Prefab/TileBuilder.ts Show resolved Hide resolved
src/Core/Prefab/TileBuilder.ts Outdated Show resolved Hide resolved
src/Core/TileGeometry.ts Show resolved Hide resolved
src/Core/TileGeometry.ts Show resolved Hide resolved
src/Core/TileGeometry.ts Show resolved Hide resolved
@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch from 7e84c08 to 865316d Compare November 27, 2024 16:51
@jailln jailln mentioned this pull request Nov 27, 2024
@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch 2 times, most recently from c1c0dce to c4f597b Compare December 3, 2024 16:23
@HoloTheDrunk HoloTheDrunk requested a review from jailln December 3, 2024 16:23
Copy link
Contributor

@jailln jailln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the commenting and refactoring efforts 🙏

@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch 3 times, most recently from ca84bba to f5cafb7 Compare December 9, 2024 15:10
Improve performance by using statically-sized ArrayBuffers.
Reorganize code to get rid of some of the params/builder mess.
Cleanup computeBuffers function.

Squashed commit history (oldest to youngest):
- fix: UV_1 generation
- refacto(wip): cleanup and optimize computeBuffers
- refacto(wip): improve index generation
- wip: correct offset, off-by-one still at large
- fix: change calls to allow camera debug
- fix: found the error, off by a power of 2 actually
- fix(uv): correct indices passed to UV buffering
- fix(index): only generate buffer when needed
- wip: enable cache
- fix(computeBuffers): group tile and skirt together
- fix(wip): squash rogue private field access
- refacto: convert TileGeometry to TypeScript
- style(builders): make method visibility explicit
- refactor(exports): remove default exports
- feat(TileGeometry): add OBB type
- refactor: rename BuilderEllipsoidTile, fix imports
- fix(tileGeometry): update tests to use public api
- fix(TileBuilder): remove dead code comments
feat(tile): add doc comments, rm unused tileCenter
@HoloTheDrunk HoloTheDrunk force-pushed the tile_builder_typescript branch from f5cafb7 to 4fc027e Compare December 9, 2024 15:19
@HoloTheDrunk HoloTheDrunk merged commit 3207dcd into iTowns:master Dec 10, 2024
9 checks passed
@HoloTheDrunk HoloTheDrunk changed the title refactor: migrate TileBuilder to typescript refactor(TilleBuillder): migrate to TypeScript Dec 10, 2024
@HoloTheDrunk HoloTheDrunk changed the title refactor(TilleBuillder): migrate to TypeScript refactor(TileBuilder): migrate to TypeScript Dec 10, 2024
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