Feature/ray tracing#34
Conversation
…d manipulation - Introduced StringTileMap and StringTileMapCell types for representing a grid of tiles. - Implemented parseStringTileMap function to convert a string representation into a structured tile map. - Added utility functions to retrieve tiles, calculate centered points, and find specific tiles within the map.
There was a problem hiding this comment.
Pull request overview
This PR adds renderer-agnostic 2D ray-tracing utilities (visibility polygons, ray/segment hits, and capped diffuse bounce layers), introduces string-authored tile-map parsing/query helpers, and reorganizes/extends Storybook demos and documentation to showcase the new capabilities.
Changes:
- Added
ray-tracinghelpers with optional surface-color tinting and bounce-layer tracing, plus a new ray-traced apartment Storybook demo. - Added
string-tile-mapparsing and lookup helpers, plus a new interactive isometric dungeon demo using the text-authored map pattern. - Updated docs/Storybook navigation and bumped package version to
4.10.2.
Reviewed changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| WHATSNEW.md | Notes new ray tracing + Storybook reorg additions. |
| src/string-tile-map.ts | New string tile-map parser + lookup/coordinate helpers. |
| src/ray-tracing.ts | New 2D ray tracing + visibility + bounce-layer helpers. |
| src/index.ts | Exports new tile-map and ray-tracing APIs/types. |
| src/tests/string-tile-map.test.ts | Adds unit tests for tile-map parsing and queries. |
| src/tests/ray-tracing.test.ts | Adds unit tests for ray casting, visibility, and bounces. |
| src/tests/coverage.test.ts | Extends coverage export list for new APIs. |
| src/stories/systems/systems-demos.ts | Adds “Ray-traced apartment” demo + new ray-tracing imports/types. |
| src/stories/systems/README.md | Updates Storybook grouping explanation + documents ray-traced apartment story. |
| src/stories/systems/Presentation.stories.ts | Moves/renames sidebar group and exports RayTracedApartment story. |
| src/stories/systems/ScreenEffects.stories.ts | Renames sidebar path for player effects stories. |
| src/stories/systems/EnvironmentScreenEffects.stories.ts | Renames sidebar path for environment effects stories. |
| src/stories/systems/ComboEffects.stories.ts | Renames sidebar path for combo effects stories. |
| src/stories/systems/AtmosphericEffects.stories.ts | Renames sidebar path for atmospheric effects stories. |
| src/stories/systems/Input.stories.ts | Renames sidebar path for input stories. |
| src/stories/systems/PlayerData.stories.ts | Renames sidebar path for player data stories. |
| src/stories/systems/Achievements.stories.ts | Renames sidebar path for achievement stories. |
| src/stories/systems/Physics.stories.ts | Renames sidebar path for physics stories. |
| src/stories/systems/Audio.stories.ts | Renames sidebar path for spatial-audio stories. |
| src/stories/Showcase.stories.ts | Renames “Live Systems” panel label to “Live Features”. |
| src/stories/GameArena.stories.ts | Improves pointer dragging state handling for view control. |
| src/stories/arcade-camera-demos.ts | Adds editable string-map dungeon demo, wheel zoom, keyboard movement; reuses FPS corridor scene. |
| src/stories/README.md | Updates Storybook section descriptions and grouping. |
| src/README.md | Documents new tile-map and ray-tracing helper modules. |
| README.md | Documents new features and updated Storybook grouping; adds ray-tracing section. |
| API.md | Adds API docs for string tile maps and ray tracing; updates Storybook paths. |
| package.json | Version bump to 4.10.2. |
| package-lock.json | Lockfile version bump to 4.10.2. |
| const sourceRows = text | ||
| .replace(/\t/g, " ") | ||
| .split("\n") | ||
| .map((row) => row.replace(/\s+$/u, "")) | ||
| .filter((row) => row.length > 0); |
| const determinant = | ||
| rayDirection.x * segmentDirection.y - rayDirection.y * segmentDirection.x; | ||
|
|
||
| if (Math.abs(determinant) < Number.EPSILON) { | ||
| return; |
| const base = parseRayTracingHexColor(baseColor); | ||
| const surface = parseRayTracingHexColor(surfaceColor); | ||
|
|
||
| if (!base || !surface) { | ||
| return baseColor; | ||
| } |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59ed6b7cdb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const normalizeTile = options.normalizeTile ?? ((tile: string) => tile as TTile); | ||
| const sourceRows = text | ||
| .replace(/\t/g, " ") | ||
| .split("\n") |
There was a problem hiding this comment.
Preserve trailing space tiles when parsing maps
When callers use a non-space emptyTile to distinguish playable floor spaces from padded void (as the new dungeon demo does with _), this trim turns any intentional spaces at the end of a row into missing cells that are then padded with the empty tile. For example, parsing "S \n###" with emptyTile: "_" yields S__ instead of preserving the two floor cells, so editable text maps cannot represent floor tiles on the right edge of ragged rows.
Useful? React with 👍 / 👎.
This pull request introduces new 2D ray tracing helpers to the engine, allowing for visibility polygon calculations, ray/segment intersection checks, capped light bounces, and improved lighting demos. It also adds string tile-map helpers for authoring and querying grid-based maps as text. The documentation has been updated to reflect these new features, and Storybook demos have been reorganized and expanded to better showcase the engine’s capabilities.
New Features
Documentation and Demo Updates
README.md,API.md,src/README.md, andWHATSNEW.mdto document the new ray tracing and tile map features, and reorganized Storybook demo references for clarity and improved navigation. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Test Coverage
Version Bump
4.10.2to reflect the new features and improvements.