pub struct Sprite {
pub geometry: Rc<BufferGeometry>,
pub material: SpriteNodeMaterial,
pub center: Vector2,
pub count: usize,
}Expand description
The state Sprite adds to Object3D. It lives in a node’s Payload, as
Mesh’s does — see docs/scene-graph.md.
Fields§
§geometry: Rc<BufferGeometry>Sprite.geometry — the shared quad, the same Rc for every sprite.
material: SpriteNodeMaterialSprite.material.
center: Vector2Sprite.center — the sprite’s anchor point in its own quad, ( 0.5, 0.5 ) being the middle and ( 0, 0 ) the bottom left. Read by the
vertex shader through a reference( 'center', 'vec2', object ) uniform,
by raycast(), and by Frustum.intersectsSprite().
count: usizeSprite.count — the number of instances drawn, 1 by default. A
larger count draws the one quad that many times, and the material
tells the instances apart with instanceIndex or an instanced
attribute (webgpu_instance_sprites).
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub fn new(material: impl Into<Option<SpriteNodeMaterial>>) -> ObjectRef
pub fn new(material: impl Into<Option<SpriteNodeMaterial>>) -> ObjectRef
new Sprite( material ), as a scene-graph ObjectRef.
None is three’s default argument, new SpriteMaterial(), which under
WebGPURenderer is a SpriteNodeMaterial.
Sourcepub fn of(material: Option<SpriteNodeMaterial>) -> Self
pub fn of(material: Option<SpriteNodeMaterial>) -> Self
The Sprite state alone, for a caller that already has the node.
Sourcepub fn raycast(
&self,
matrix_world: &Matrix4,
object: &ObjectRef,
raycaster: &Raycaster,
intersects: &mut Vec<Intersection>,
)
pub fn raycast( &self, matrix_world: &Matrix4, object: &ObjectRef, raycaster: &Raycaster, intersects: &mut Vec<Intersection>, )
Sprite.raycast( raycaster, intersects ) — the quad as the vertex
shader places it, facing raycaster.camera, tested as two triangles
with no backface culling.
three.js logs an error when raycaster.camera is null and then
throws on reading it; the port logs the same message and hits nothing.