Atlaslog
Atlaslog / three.js / API reference / Sprite
three.js · API reference

Sprite

Quick answer

Sprite is a plane that always faces the camera, commonly used for map labels, icons, and glows. It requires a SpriteMaterial, positions through the inherited Object3D transform, and sizes itself with scale; center sets the anchor point. Set sizeAttenuation false for constant screen-size labels at any distance.

Last verified 2026-11-03 · three.js 0.160.0 · Cite this page
new THREE.Sprite ( material ) → Sprite
Key points
Example
function makeLabel(text) {
  const canvas = document.createElement('canvas');
  canvas.width = 256;
  canvas.height = 64;

  const ctx = canvas.getContext('2d');
  ctx.fillStyle = 'rgba(13, 17, 23, 0.82)';
  ctx.fillRect(0, 0, 256, 64);
  ctx.strokeStyle = '#4f9ef8';
  ctx.lineWidth = 3;
  ctx.strokeRect(1.5, 1.5, 253, 61);

  ctx.fillStyle = '#e6e8ec';
  ctx.font = '600 30px sans-serif';
  ctx.textAlign = 'center';
  ctx.textBaseline = 'middle';
  ctx.fillText(text, 128, 34);

  const texture = new THREE.CanvasTexture(canvas);
  texture.colorSpace = THREE.SRGBColorSpace;

  const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
    map: texture,
    transparent: true,
    depthWrite: false
  }));
  sprite.scale.set(8, 2, 1);   // 8 : 2 与画布 256 : 64 同比例
  return sprite;
}
material.sizeAttenuation = false;
sprite.scale.set(0.08, 0.02, 1);   // 此时数值只表达相对比例
material.depthTest = false;
sprite.renderOrder = 10;
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Sprite. https://www.jingweizhi.com/en/three/api/sprite.html (accessed 2026-11-03).