Skip to content

refactor(sprite): SpriteAnimationClip class fields, layer typings, and docs#8679

Merged
willeastcott merged 3 commits into
mainfrom
refactor/sprite-animation-clip-class-fields
May 4, 2026
Merged

refactor(sprite): SpriteAnimationClip class fields, layer typings, and docs#8679
willeastcott merged 3 commits into
mainfrom
refactor/sprite-animation-clip-class-fields

Conversation

@willeastcott

@willeastcott willeastcott commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates SpriteAnimationClip instance state to class fields (aligned with SpriteComponent), orders constructor data assignments to match JSDoc, and replaces @private with @ignore on addToLayers / removeFromLayers so internal callers type-check while API docs stay unchanged. Adds sprite Relevant Engine API examples on SpriteComponent and aligns constructor @param JSDoc line wrapping with other components.

Changes

  • SpriteAnimationClip: declare _component, _frame, _sprite, _spriteAsset, _playing, _paused, _time, name, fps, and loop as class fields with JSDoc; constructor only assigns component, then fps, loop, name, and spriteAsset from data.
  • SpriteComponent: addToLayers and removeFromLayers use /** @ignore */ instead of /** @private */ so they emit as public in playcanvas.d.ts (same pattern as other @ignore helpers).
  • SpriteComponent class JSDoc: link to the Animated sprite engine example (same style as ParticleSystemComponent and others).
  • SpriteComponent constructor JSDoc: single-line @param descriptions (match ModelComponent / CameraComponent convention).

Public API

No intentional changes. addToLayers and removeFromLayers were already callable at runtime; typings now match.

…helpers

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…onents

Co-authored-by: Cursor <cursoragent@cursor.com>
@willeastcott willeastcott changed the title refactor(sprite): SpriteAnimationClip class fields and @ignore layer helpers refactor(sprite): SpriteAnimationClip class fields, layer typings, and docs May 4, 2026
@willeastcott willeastcott merged commit 29eef7d into main May 4, 2026
8 checks passed
@willeastcott willeastcott deleted the refactor/sprite-animation-clip-class-fields branch May 4, 2026 08:33

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 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 SpriteAnimationClip instance state into declared class fields and simplified constructor initialization.
  • Switched SpriteComponent#addToLayers / removeFromLayers from @private to @ignore to preserve typings without publishing them in API docs.
  • Added a relevant animated-sprite example link to the SpriteComponent class 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;

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

Labels

enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants