graphics-3d: expose prefers-reduced-motion

Ouverte
#458 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
71/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
typescript
Domaine
game-dev

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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?
Langage dominant
TypeScript
Étoiles
7
Forks
2
Merge moyen
1 j 17 h
PR mergées (30 j)
17

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de NanoForge-dev/Engine

Toutes les issues de NanoForge-dev/Engine

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.