Skip to content

feat(graphics-3d): Three.js 3D graphics library - #459

Merged
Tchips46 merged 16 commits into
mainfrom
feat/graphics-3d
Nov 6, 2026
Merged

Tchips46 merged 16 commits into
mainfrom
feat/graphics-3d

Conversation

@Tchips46

@Tchips46 Tchips46 commented Nov 5, 2026

Copy link
Copy Markdown
Member

Adds @nanoforge-dev/graphics-3d, the engine's 3D library built on Three.js (chosen in the benchmark).

  • Library: WebGPU renderer that falls back to WebGL2 (forceWebGL forces it). It renders once per engine tick, after the systems, never from its own loop, and follows the viewport like graphics-2d (contain / cover / fill). On clear it disposes everything and removes the canvas and window.__THREE__.
  • API on Context.graphics: scene, camera, renderer, backend, raycast, worldToScreen, and a replaceable render for post-processing.
  • Three.js access: re-exported from /three and /three/tsl. three is a peer dependency, so apps and add-ons share one copy.
  • Editor bridge: graphicsCamera feature (sends the camera's view/projection) and the graphics-capture command (screenshot that works while paused).
  • Performance: warns once above 2,000 draw calls and points to the docs.
  • Examples: cube-3d (first scene) and pong-3d (peer-to-peer; player camera behind their own paddle, spectator camera above the right end of the table).
  • Docs: getting started, advanced, performance, and an editor proposal for the 3D Scene screen.
  • CI: package added to labels, issue templates and release workflows.

Tests: 20 unit tests covering init/clear cycles, viewport fits, teardown, backend choice, the editor events and the custom render. Checked in Chrome only. p2p needs the unreleased CLI p2p build.

Closes #36. Follow-ups: #456, #457, #458, NanoForge-dev/components-systems#21.

WebGPURenderer with WebGL2 fallback (forceWebGL), rendered from the engine
tick only, following the viewport, full teardown, Three.js re-exported from
the /three and /three/tsl subpaths, editor graphics-camera feature and
graphics-capture command.
Keep the editor across restarts, since __editorInit runs once per app.
3D client for the network pong: each player sees the table from behind
its own paddle, spectators from above the right end. The server seats
players and sends spectators the game state.
@Tchips46
Tchips46 requested a review from Exeloo as a code owner November 5, 2026 18:05
@Tchips46 Tchips46 self-assigned this Nov 5, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 5, 2026

@josephinecr josephinecr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review of the new graphics-3d module and examples. Main issues: infinite recursion when wrapping render, blank canvas after a resize while paused, and a Context.graphics type conflict with graphics-2d. The rest are edge cases and minor perf/cleanup.

Tchips46 and others added 6 commits November 6, 2026 12:05
…ed camera and init cleanup

- render getter returns the active render step, so a wrapper no longer recurses
- redraw after a viewport change, so a paused game keeps its image
- graphics-capture answers an empty string when there is no renderer
- graphics-camera refreshes parent transforms (updateWorldMatrix)
- release the canvas and renderer when renderer.init() fails
- tag each paddle with a Paddle component carrying its seat
- drop a duplicated ternary in the server bounce
…camera matrices and raycaster

- without a viewport, observe the container and size the canvas at its window's pixel ratio
- send camera matrices from preallocated buffers, allocating only when they change
- reuse one Raycaster and one NDC vector across picks
@Tchips46 Tchips46 added the enhancement New feature or request label Nov 6, 2026
@Tchips46
Tchips46 requested a review from josephinecr November 6, 2026 13:16
@Tchips46
Tchips46 merged commit 7af6ace into main Nov 6, 2026
3 checks passed
@Tchips46
Tchips46 deleted the feat/graphics-3d branch November 6, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3D Graphics Library

2 participants