Extract duplicated Three.js boilerplate into shared utilities#10
Closed
CloudAI-X wants to merge 1 commit into
Closed
Extract duplicated Three.js boilerplate into shared utilities#10CloudAI-X wants to merge 1 commit into
CloudAI-X wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The skill files repeated the same setup/teardown boilerplate over and over — renderer/scene bootstrap, the
requestAnimationFrameloop, resize handling, resource disposal, and the mouse→NDC conversion (the(clientX / innerWidth) * 2 - 1line alone appeared ~8× inthreejs-interaction). This PR extracts those patterns into a single shared module and points the examples at it.New shared module
lib/three-utils.js(ESM,threeas a peer dep):Docs refactor — duplicated blocks now import the helpers instead of re-implementing them:
threejs-interaction: all pointer→NDC conversions replaced withgetPointerNDC(...).threejs-animation/threejs-postprocessing: Quick Start loops usecreateRenderLoop(the latter renders through thecomposer); postprocessing resize usesbindResizewith anonResizecallback for pass-specific resolutions.threejs-fundamentals: keeps its explanatory boilerplate (it's the reference) but cross-references the helpers.skills/threejs-utils/SKILL.mddocuments the API;README.mdgets a row + a Shared Utilities section.Tooling — the repo had none. Added
package.json(Prettier +node --test),test/three-utils.test.mjs(6 tests for the pure helpersgetPointerNDC/disposeObject/clampedPixelRatio), a.github/workflows/ci.ymlrunningformat:check+test, and.gitignore/.prettierignore. All existing markdown was already Prettier-clean, soprettier --check .passes repo-wide.Notes
The
threeversion pin uses a widely-used release published well over a week ago;threeis declared as a peer dependency since consumers bring their own.Link to Devin session: https://app.devin.ai/sessions/f592e1dac0c44cc68b9bb49a2947e933
Requested by: @CloudAI-X