refactor(sprite): SpriteAnimationClip class fields, layer typings, and docs#8679
Merged
Merged
Conversation
…helpers Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…onents Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the sprite animation clip/component API surface and documentation so SpriteAnimationClip uses explicit class fields, SpriteComponent layer helpers remain hidden from generated docs while staying type-checkable, and the sprite component docs link to the animated sprite example.
Changes:
- Moved
SpriteAnimationClipinstance state into declared class fields and simplified constructor initialization. - Switched
SpriteComponent#addToLayers/removeFromLayersfrom@privateto@ignoreto preserve typings without publishing them in API docs. - Added a relevant animated-sprite example link to the
SpriteComponentclass JSDoc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/framework/components/sprite/sprite-animation-clip.js |
Refactors clip state into class fields and reorders constructor property assignment. |
src/framework/components/sprite/component.js |
Updates SpriteComponent docs and changes layer helper JSDoc visibility. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
150
to
+153
| this.fps = data.fps || 0; | ||
| this.loop = data.loop || false; | ||
|
|
||
| this._playing = false; | ||
| this._paused = false; | ||
|
|
||
| this._time = 0; | ||
| this.name = data.name; | ||
| this.spriteAsset = data.spriteAsset; |
Comment on lines
+120
to
+130
| /** | ||
| * @type {string|undefined} | ||
| */ | ||
| name; | ||
|
|
||
| /** | ||
| * @type {number} | ||
| */ | ||
| fps = 0; | ||
|
|
||
| /** |
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
Migrates
SpriteAnimationClipinstance state to class fields (aligned withSpriteComponent), orders constructor data assignments to match JSDoc, and replaces@privatewith@ignoreonaddToLayers/removeFromLayersso internal callers type-check while API docs stay unchanged. Adds sprite Relevant Engine API examples onSpriteComponentand aligns constructor@paramJSDoc line wrapping with other components.Changes
_component,_frame,_sprite,_spriteAsset,_playing,_paused,_time,name,fps, andloopas class fields with JSDoc; constructor only assignscomponent, thenfps,loop,name, andspriteAssetfromdata.addToLayersandremoveFromLayersuse/** @ignore */instead of/** @private */so they emit as public inplaycanvas.d.ts(same pattern as other@ignorehelpers).ParticleSystemComponentand others).@paramdescriptions (matchModelComponent/CameraComponentconvention).Public API
No intentional changes.
addToLayersandremoveFromLayerswere already callable at runtime; typings now match.