1 | import { BufferGeometry } from "../core/BufferGeometry.js";
|
2 | import { Object3D, Object3DEventMap } from "../core/Object3D.js";
|
3 | import { SpriteMaterial } from "../materials/Materials.js";
|
4 | import { Vector2 } from "../math/Vector2.js";
|
5 |
|
6 | /**
|
7 | * A {@link Sprite} is a plane that always faces towards the camera, generally with a partially transparent texture applied.
|
8 | * @remarks Sprites do not cast shadows, setting `castShadow = true` will have no effect.
|
9 | * @example
|
10 | * ```typescript
|
11 | * const map = new THREE.TextureLoader().load('sprite.png');
|
12 | * const material = new THREE.SpriteMaterial({
|
13 | * map: map
|
14 | * });
|
15 | * const {@link Sprite} = new THREE.Sprite(material);
|
16 | * scene.add(sprite);
|
17 | * ```
|
18 | * @see {@link https://threejs.org/docs/index.html#api/en/objects/Sprite | Official Documentation}
|
19 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Sprite.js | Source}
|
20 | */
|
21 | export class Sprite<TEventMap extends Object3DEventMap = Object3DEventMap> extends Object3D<TEventMap> {
|
22 | /**
|
23 | * Creates a new Sprite.
|
24 | * @param material An instance of {@link THREE.SpriteMaterial | SpriteMaterial}. Default {@link THREE.SpriteMaterial | `new SpriteMaterial()`}, _with white color_.
|
25 | */
|
26 | constructor(material?: SpriteMaterial);
|
27 |
|
28 | /**
|
29 | * Read-only flag to check if a given object is of type { Sprite}.
|
30 | * This is a _constant_ value
|
31 | * `true`
|
32 | */
|
33 | readonly isSprite: true;
|
34 |
|
35 | /**
|
36 | * @override
|
37 | * @defaultValue `Sprite`
|
38 | */
|
39 | override readonly type: string | "Sprite";
|
40 |
|
41 | /**
|
42 | * Whether the object gets rendered into shadow map.
|
43 | * No effect in {@link Sprite}.
|
44 | * @ignore
|
45 | * @hidden
|
46 | * @defaultValue `false`
|
47 | */
|
48 | override castShadow: false;
|
49 |
|
50 | geometry: BufferGeometry;
|
51 |
|
52 | /**
|
53 | * An instance of {@link THREE.SpriteMaterial | SpriteMaterial}, defining the object's appearance.
|
54 | * @defaultValue {@link THREE.SpriteMaterial | `new SpriteMaterial()`}, _with white color_.
|
55 | */
|
56 | material: SpriteMaterial;
|
57 |
|
58 | /**
|
59 | * The sprite's anchor point, and the point around which the {@link Sprite} rotates.
|
60 | * A value of (0.5, 0.5) corresponds to the midpoint of the sprite.
|
61 | * A value of (0, 0) corresponds to the lower left corner of the sprite.
|
62 | * @defaultValue {@link THREE.Vector2 | `new Vector2(0.5, 0.5)`}.
|
63 | */
|
64 | center: Vector2;
|
65 | }
|