Skip to content

Sprite issues #7956

@kdrnic

Description

@kdrnic

The current THREE.Sprite implementation has a number of issues.

  • Sprites can't have their texture translated, that is you can't change UVs, so you can't use them for explosions or other effects
  • You can't translate the image of a sprite, that is, the center of the texture is aligned with the origin of the object and you can't move it horizontally or vertically
  • Sprites can't be rotated independently, as rotation is set in their material. If you want to rotate sprites independently you must assign each one a different material, even if they share the same texture. I see no reason the rotation attribute couldn't and shouldn't be stored on the Sprite structure instead of the SpriteMaterial structure.
  • The BufferGeometry in the sprite is make-believe and actually ignored, which is not only inefficient as it is also confusing as it implies you can rotate, translate and animate the sprite by changing it, but you can't

The last one is actually quite interesting.
See https://github.com/mrdoob/three.js/blob/master/src/objects/Sprite.js#L12
and https://github.com/mrdoob/three.js/blob/master/src/renderers/webgl/plugins/SpritePlugin.js#L24
I even tested this by commenting out the BufferGeometry creation in THREE.Sprite, and sprites continued working.

Meanwhile I imagine the workaround is to use a Mesh with a PlaneGeometry and a .lookAt(camera.position) in every loop in place of Sprites if one needs the features mentioned above.

Fixing this issue I imagine is not terribly difficult.

Here is my suggested plan:

  • Move rotation from SpriteMaterial to Sprite (and take rotation from Sprite instead of SpriteMaterial in SpritePlugin)
  • Either add an UV array and a translation array to Sprite, and use that in SpritePlugin, or actually use the BufferGeometry already in Sprite
  • Depending on the above, remove the BufferGeometry from Sprite

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions