savoiardi/sprite

Sprite creation and sprite-specific transforms.

Three.js sprites are Object3D billboards with a center anchor and a sprite-specific material contract, so this module mirrors that split with a dedicated Sprite type plus safe conversions back to Object3D.

Types

A Three.js sprite.

pub type Sprite

Values

pub fn create(material: material.Material) -> Sprite

Creates a sprite from a sprite material.

pub fn create_default() -> Sprite

Creates a sprite with Three.js’s default sprite material.

pub fn from_object3d(
  object: object.Object3D,
) -> Result(Sprite, Nil)

Safely downcasts an object to a sprite.

pub fn get_center(sprite: Sprite) -> vec2.Vec2(Float)

Reads the sprite anchor in UV space.

pub fn is_sprite(object: object.Object3D) -> Bool

Returns whether an object is a sprite.

pub fn set_center(
  sprite: Sprite,
  center: vec2.Vec2(Float),
) -> Sprite

Sets the sprite anchor in UV space.

pub fn to_object3d(sprite: Sprite) -> object.Object3D

Views a sprite as an object.

Search Document