Socket
Socket
Sign inDemoInstall

three.texttexture

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three.texttexture

A texture with the drawn text.


Version published
Weekly downloads
109
increased by1.87%
Maintainers
1
Weekly downloads
 
Created
Source

THREE.TextTexture

class THREE.TextTexture extends THREE.Texture

An instance of TextTexture is a texture with the drawn text.

demo

Try it out!

setup

npm

npm i three.texttexture

es6

import TextTexture from 'three.texttexture';

node

let TextTexture = require('three.texttexture');

browser

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

The module is globally available as THREE.TextTexture.

members

constructor

new THREE.TextTexture({
  align: 'center',
  createCanvas() { /*...*/ },
  fillStyle: '#fff',
  fontFamily: 'sans-serif',
  fontSize: 16,
  fontStyle: 'normal',
  fontVariant: 'normal',
  fontWeight: 'normal',
  lineGap: 0.15,
  loadFontFace(family, style, variant, weight) { /*...*/ },
  padding: 0.25,
  strokeStyle: '#000',
  strokeWidth: 0,
  text: '',
})
argumentdescription
alignThe horizontal text alignment. Possible values are 'center', 'left' and 'right'.
createCanvasA function to create a new Canvas instance.
fillStyleThe fill color or style.
fontFamilyThe font family.
fontSizeThe font size.
fontStyleThe font style.
fontVariantThe font variant.
fontWeightThe font weight.
lineGapThe vertical distance between the text lines. The value is relative to the font size.
loadFontFaceA function to load a font face.
paddingThe space around the text. The value is relative to the font size.
strokeStyleThe stroke color or style.
strokeWidthThe stroke width. The value is relative to the font size.
textThe text.
let texture = new THREE.TextTexture({
  fontFamily: '"Times New Roman", Times, serif',
  fontSize: 32,
  fontStyle: 'italic',
  text: [
    'Twinkle, twinkle, little star,',
    'How I wonder what you are!',
    'Up above the world so high,',
    'Like a diamond in the sky.',
  ].join('\n'),
});
let material = new THREE.SpriteMaterial({
  color: 0xffffbb,
  map: texture,
});
let sprite = new THREE.Sprite(material);
await texture.redraw();
sprite.scale.setX(texture.image.width / texture.image.height).multiplyScalar(10);
scene.add(sprite);

properties

.text


.lines

read-only

The text splitted by the newline character.


.fontFamily


.fontSize


.fontWeight


.fontVariant


.fontStyle


.fillStyle


.strokeWidth


.strokeStyle


.align


.lineGap


.padding


.createCanvas


.loadFontFace


Provide a custom loadFontFace function to support the older browsers.

loadFontFace(family, style, variant, weight) {
  return (new FontFaceObserver(family, {style, weight})).load();
}

methods

.redraw()

Returns a Promise that resolves when the image is redrawn.

see also

Keywords

FAQs

Package last updated on 01 Oct 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc