Skip to content

docs: add Motion and Model Viewer examples to PlayCanvas React section#1040

Merged
willeastcott merged 3 commits into
mainfrom
react-examples-motion-model-viewer
Jun 10, 2026
Merged

docs: add Motion and Model Viewer examples to PlayCanvas React section#1040
willeastcott merged 3 commits into
mainfrom
react-examples-motion-model-viewer

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Summary

Recreates the Motion and Model Viewer examples from the retired playcanvas-react.vercel.app docs site (removed in playcanvas/react#274) as siblings of the existing Physics example under /user-manual/react/examples/.

Model Viewer

A glb viewer with environment lighting, background grid, shadow catcher and auto-rotating orbit controls. Reuses the existing Grid, ShadowCatcher, PostEffects and AutoRotate components plus the lambo.glb/environment.png assets already in static/assets/, so no new assets are needed.

Motion

The "Hover" demo: a capsule that springs to a larger scale on hover, reveals orbiting decoration primitives that track the pointer, and animates light intensities — all driven by springs from the Motion library. The MotionEntity/MotionLight bridge components (Motion spring values → PlayCanvas entity transforms) are included in the displayed source, since that integration is the point of the example. The original's Tailwind overlay was rewritten with inline styles.

Other changes

  • Adds motion as a dependency (the one new package this needs)
  • Adds both pages to sidebars.js under the React Examples category
  • Mirrors both pages into the ja locale per the localization rule in AGENTS.md

Verification

  • Ran the dev server and loaded both pages in a browser: both compile and render correctly (model viewer shows the car/grid scene, motion shows the capsule with the rotation spring visibly applied on mount).
  • The hover interaction uses the exact same pointer-events path as the live interactivity example; synthetic JS events can't drive the GPU picker in an automated browser, so the hover effect itself is worth a quick manual check on the preview deploy.
  • npm run lint passes (0 errors).
  • Pre-existing console noise (GSplat deprecation shims, uSceneColorMap message from the shared PostEffects/lambo setup) appears identically on the existing React index page and is untouched by this PR.

🤖 Generated with Claude Code

Ports the Motion and Model Viewer examples from the retired
playcanvas-react.vercel.app docs site as siblings of the existing
Physics example.

- Model Viewer: glb viewer with environment lighting, grid, shadow
  catcher and auto-rotating orbit controls, reusing the existing
  Grid/ShadowCatcher/PostEffects/AutoRotate components and lambo.glb
- Motion: demonstrates driving entity transforms and light intensities
  with springs from the Motion animation library, including the
  MotionEntity/MotionLight bridge components in the displayed source
- Adds the motion package as a dependency
- Adds both pages to the sidebar and mirrors them in the ja locale

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

This PR adds two new PlayCanvas React live examples (Model Viewer and Motion) to the React section of the user manual, recreating content from the retired playcanvas-react.vercel.app docs site and wiring the pages into the docs sidebar (including Japanese locale equivalents).

Changes:

  • Added new React example components: ModelViewerExample (GLB viewer) and MotionExample (Motion springs driving entity/light animation).
  • Added new docs pages for both examples in docs/ and mirrored them in i18n/ja/.
  • Added the motion package dependency and linked the new pages in sidebars.js.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/playcanvas-react/examples/MotionExample.jsx New Motion-driven hover demo using Motion springs + PlayCanvas React entities/scripts.
src/components/playcanvas-react/examples/ModelViewerExample.jsx New GLB model viewer example reusing existing staging components (grid/shadow catcher/post FX/autorotate).
docs/user-manual/react/examples/motion.mdx New English docs page embedding the Motion example + source.
docs/user-manual/react/examples/model-viewer.mdx New English docs page embedding the Model Viewer example + source.
i18n/ja/docusaurus-plugin-content-docs/current/user-manual/react/examples/motion.mdx Japanese translation of the Motion example docs page.
i18n/ja/docusaurus-plugin-content-docs/current/user-manual/react/examples/model-viewer.mdx Japanese translation of the Model Viewer docs page.
sidebars.js Adds both examples under React → Examples in the sidebar.
package.json Adds motion dependency required by the Motion example.
package-lock.json Locks motion (and its transitive deps) for reproducible installs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/playcanvas-react/examples/MotionExample.jsx
Comment thread src/components/playcanvas-react/examples/MotionExample.jsx
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Move the light intensity script to module scope and pass the motion
  value via props instead of defining a per-render class with a closure;
  guard against the light component being unavailable
- Normalize pointer coordinates by canvas size in MouseRotatesEntity and
  unregister the mousemove handler in destroy()

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@willeastcott willeastcott merged commit d051229 into main Jun 10, 2026
3 checks passed
@willeastcott willeastcott deleted the react-examples-motion-model-viewer branch June 10, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants