Skip to content

Conversation

@aleksanderkatan
Copy link
Contributor

@aleksanderkatan aleksanderkatan commented Dec 22, 2025

Changes:

  • add common folder to examples,
  • import all common files when opening in StackBlitz,
  • list used common files in our examples,
  • rewrite setup-orbit-camera.ts to be common (only where it was already used).

@aleksanderkatan aleksanderkatan linked an issue Dec 22, 2025 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Dec 22, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@32f0a1b938e25c3ae5e9dba172a8b9091c34b948
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@32f0a1b938e25c3ae5e9dba172a8b9091c34b948
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@32f0a1b938e25c3ae5e9dba172a8b9091c34b948

benchmark
view benchmark

commit
view commit

Copy link

Copilot AI left a comment

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 introduces a common folder for shared code between documentation examples to reduce duplication. The primary change involves moving the setup-orbit-camera.ts utility from individual example directories to a centralized common location.

  • Establishes infrastructure to handle common files across examples with proper type definitions
  • Refactors setup-orbit-camera.ts to be a shared utility with enhanced touch gesture support (pinch-to-zoom)
  • Updates build tooling to automatically include relevant common files in StackBlitz exports and code editor views

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
apps/typegpu-docs/src/utils/examples/types.ts Adds ExampleCommonFile type to distinguish common files from example-specific files
apps/typegpu-docs/src/examples/simulation/gravity/setup-orbit-camera.ts Removes local copy of orbit camera utility (moved to common folder)
apps/typegpu-docs/src/examples/simulation/gravity/schemas.ts Updates import path to reference common folder
apps/typegpu-docs/src/examples/simulation/gravity/index.ts Updates import path to reference common folder
apps/typegpu-docs/src/examples/rendering/phong-reflection/index.ts Updates import path and removes export keywords from shader functions
apps/typegpu-docs/src/examples/exampleContent.ts Adds common file loading logic with glob patterns and path extraction
apps/typegpu-docs/src/examples/common/setup-orbit-camera.ts New centralized orbit camera utility with enhanced pinch-to-zoom support
apps/typegpu-docs/src/components/stackblitz/openInStackBlitz.ts Updates to include common files in StackBlitz projects with proper path rewriting
apps/typegpu-docs/src/components/ExampleView.tsx Adds filtering logic to include only relevant common files per example
apps/typegpu-docs/src/components/ExamplePage.tsx Passes common files to ExampleView component
apps/typegpu-docs/src/components/CodeEditor.tsx Updates path handling to support both example and common file paths

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

@aleksanderkatan aleksanderkatan marked this pull request as ready for review December 22, 2025 12:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

];

for (const common of commonFiles) {
for (const src of srcFiles) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this change allow common file to reference each other, and show up in the tabs?

Suggested change
for (const src of srcFiles) {
for (const src of [...srcFiles, ...commonFiles]) {

Copy link
Contributor Author

@aleksanderkatan aleksanderkatan Jan 9, 2026

Choose a reason for hiding this comment

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

Not really. Or, I guess, it would, but with a side effect. If common1.ts references common2.ts, then common2.ts would be included in every example, regardless of whether the example uses common1.ts or not. We would need to do a BFS or something.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. Could you create an issue for this so we can do it in another PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: Allow for shared common code between examples

3 participants