graphics-3d: expose prefers-reduced-motion

オープン
#458 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
71/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
game-dev

調査の方向性

Start in the graphics-3d package and trace how ctx.graphics is exposed and how __clear handles cleanup. Use the container's ownerDocument.defaultView for matchMedia, keep the value updated when the preference changes, and remove the listener during cleanup. Add documentation with a camera-shake example and test the behavior using a stubbed matchMedia.

索引モデルが issue の本文から書いたものです。

説明

enhancement modules:graphics-3d
Which package or utils is this feature request for?

graphics-3d

Feature

Some players get motion sickness from camera shake, fast camera moves or flashing effects. The OS setting prefers-reduced-motion tells us, but game code has no easy way to read it.

This is not specific to 3D: a 2D game (graphics-2d) needs the same flag.

Ideal solution or implementation

Expose ctx.graphics.prefersReducedMotion: boolean. It is backed by matchMedia("(prefers-reduced-motion: reduce)") on the container's window (container.ownerDocument.defaultView), and it updates live when the setting changes. The listener is removed on __clear (graphics-3d __clear).

Document it with an example (skip camera shake when it is true).

Acceptance criteria:

  • The flag is readable from game code and is true when (prefers-reduced-motion: reduce) matches.
  • It updates live when the media query fires change.
  • The change listener is removed on __clear.
  • A test covers the three points above with a stubbed matchMedia.
  • A docs page shows the example (skip camera shake when it is true).
Alternative solutions or implementations

A shared helper in @nanoforge-dev/common, or a core-provided value, so 2D games get it too. Core already reads a media query the same way for the pixel ratio (InternalViewportState._watchPixelRatio) and exposes the result to every library as ctx.viewport (context type).

Other context

Deferred from the first version of graphics-3d (benchmark criteria E2/E3).

Open questions (not recorded, ask the team):

  • Where does the flag live: in @nanoforge-dev/common / core (so graphics-2d games get it too), or in graphics-3d only?
主要言語
TypeScript
スター
7
フォーク
2
平均マージ
1日 17時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NanoForge-dev/Engine のほかの issue

NanoForge-dev/Engine の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。