Socket
Socket
Sign inDemoInstall

three.textsprite

Package Overview
Dependencies
2
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    three.textsprite

Automatically computes the optimal font size depending on the distance to the camera and the size of the renderer canvas.


Version published
Weekly downloads
118
increased by63.89%
Maintainers
1
Install size
20.7 kB
Created
Weekly downloads
 

Readme

Source

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: 'Carpe Diem',
  },  
});
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. If 0, the canvas is redrawn immediately whenever TextSprite is rendered, otherwise the redrawing is deferred.


.minFontSize = 0

The minimum font size.


.maxFontSize = Infinity

The maximum font size.


.dispose()

Disposes the texture and the material.

Keywords

FAQs

Last updated on 30 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc