playcanvas / playcanvas/engine
SpriteComponent _showFrame ignores SpriteComponent.material
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 9m
- Merged PRs (30d)
- 218
Description
Hi! It looks like according to the code referenced below, _showFrame in SpriteComponent initially creates its _meshInstance using the sprite component's material, but then immediately and subsequently always overwrites it with system.defaultMaterial. I suspect this crept in when support for the sliced & tiled modes came in. Should this be considered a bug now? It makes an animated sprite's material impossible to override, e.g. if you want to change the blend mode, or apply shader effects.
https://github.com/playcanvas/engine/blob/cf28baf6f1ccd5568597946c62c1696a4ad9919e/src/framework/components/sprite/component.js#L659-L692
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/framework/components/sprite/component.js around lines 659-692, starting at _showFrame and tracing how the sprite component material and system.defaultMaterial are assigned. Confirm the expected material behavior for animated sprites, then verify that an overridden material remains effective for blend modes or shader effects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100