20.0.0 • Published 5 years ago

three.textsprite v20.0.0

Weekly downloads
625
License
MIT
Repository
github
Last release
5 years ago

THREE.TextSprite

class THREE.TextSprite extends THREE.Sprite

An instance of TextSprite automatically computes the optimal font size depending on the distance to the camera and the size of the renderer canvas.

demo

Try it out!

dependencies

setup

npm

npm i three.textsprite

ES module

import TextSprite from 'three.textsprite';

browser

<script src="https://unpkg.com/three"></script>
<script src="https://unpkg.com/three.texttexture"></script>
<script src="https://unpkg.com/three.textsprite"></script>

The class TextSprite will be available under the namespace THREE.

members

.constructor({
  material,
  maxFontSize,
  minFontSize,
  redrawInterval,
  textSize,
  texture,
})
argumentdescription
materialThe parameters to pass to the constructor of SpriteMaterial.
textureThe parameters to pass to the constructor of TextTexture.
let sprite = new THREE.TextSprite({
  material: {
    color: 0xffbbff,
    fog: true,
  },
  redrawInterval: 250,
  textSize: 10,
  texture: {
    fontFamily: 'Arial, Helvetica, sans-serif',
    text: 'Be happy. Be bright. Be you.',
  },  
});
scene.add(sprite);

.isTextSprite = true

Used to check whether this is an instance of TextSprite.

You should not change this, as it is used internally for optimisation.


.textSize = 1

The size of the text.


.redrawInterval = 1

The minimum time that must elapse before the canvas is redrawn.


.minFontSize = 0

The minimum font size.


.maxFontSize = Infinity

The maximum font size.


.dispose()

Disposes the texture and the material.

20.0.0

5 years ago

19.0.0

5 years ago

18.10.25

5 years ago

18.10.24

6 years ago

18.8.6

6 years ago

18.7.14

6 years ago

18.6.7

6 years ago

18.3.19

6 years ago

18.3.3

6 years ago

18.1.16

6 years ago

17.11.23

6 years ago

17.11.21

6 years ago

17.11.5

7 years ago

17.10.2-2.2

7 years ago

17.10.2-2.1

7 years ago

17.10.22

7 years ago

17.9.10

7 years ago

17.8.6

7 years ago