• Stars
    star
    158
  • Rank 236,497 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Optimally displays the text as a sprite.

THREE.TextSprite

class THREE.TextSprite extends THREE.Sprite

Optimally displays the text as a sprite.

demo

Try it out!

dependencies

setup

npm

npm i @seregpie/three.text-sprite

import TextSprite from '@seregpie/three.text-sprite';

browser

<script src="https://unpkg.com/three"></script>
<script src="https://unpkg.com/@seregpie/three.text-texture"></script>
<script src="https://unpkg.com/@seregpie/three.text-sprite"></script>

The class is globally available as THREE.TextSprite.

usage

let instance = new THREE.TextSprite({
  alignment: 'left',
  color: '#24ff00',
  fontFamily: '"Times New Roman", Times, serif',
  fontSize: 8,
  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'),
});
scene.add(instance);

Update the instance.

instance.fontFamily = 'Arial, Helvetica, sans-serif';
instance.fontStyle = 'normal';
instance.text = [
  'When this blazing sun is gone,',
  'When he nothing shines upon,',
  'Then you show your little light,',
  'Twinkle, twinkle, through the night.',
].join('\n');

members

constructor

new THREE.TextSprite({
  alignment: 'center',
  backgroundColor: 'rgba(0,0,0,0)',
  color: '#fff',
  fontFamily: 'sans-serif',
  fontSize: 1,
  fontStyle: 'normal',
  fontVariant: 'normal',
  fontWeight: 'normal',
  lineGap: 0.25,
  padding: 0.5,
  strokeColor: '#fff',
  strokeWidth: 0,
  text: '',
}, material)
argument description
alignment The horizontal text alignment. Possible values are 'center', 'left' and 'right'.
backgroundColor The background color.
color The color.
fontFamily The font family.
fontSize The font size.
fontStyle The font style.
fontVariant The font variant.
fontWeight The font weight.
lineGap The vertical distance between the text lines. The value is relative to the font size.
padding The space around the text. The value is relative to the font size.
strokeColor The stroke color.
strokeWidth The stroke width. The value is relative to the font size.
text The text.
material An instance of THREE.Material. If not provided, a default instance will be created.

properties

.isTextSprite = true

Used to check whether this is an instance of TextSprite.


.text

.fontFamily

.fontSize

.fontWeight

.fontVariant

.fontStyle

.color

.strokeWidth

.strokeColor

.alignment

.lineGap

.padding

.backgroundColor

methods

.dispose()

Disposes the texture and the material.

More Repositories

1

VueWordCloud

Generates a cloud out of the words.
JavaScript
377
star
2

VuetifyImageInput

Provides basic image editing tools.
JavaScript
131
star
3

THREE.TextTexture

A texture with the drawn text.
JavaScript
72
star
4

VueStorage

Allows the components to save and load their data across the browser sessions.
JavaScript
52
star
5

VueChart

A simple wrapper for Chart.js.
JavaScript
24
star
6

VueTween

Allows the components to tween their properties.
JavaScript
23
star
7

lodash.combinations

Calculates all possible combinations without repetition of a certain size.
JavaScript
20
star
8

lodash.product

Calculates the Cartesian product between multiple collections.
JavaScript
18
star
9

VueFlex

A flexbox grid system.
JavaScript
13
star
10

BronKerbosch

An implementation of the Bron-Kerbosch algorithm to find the maximal cliques in an undirected graph.
JavaScript
11
star
11

aframe-text-sprite

A wrapper for THREE.TextSprite.
JavaScript
11
star
12

DearImage

A class that represents a graphical image.
JavaScript
10
star
13

MaxDiff

An implementation of the MaxDiff technique to support the discrete ordering model.
JavaScript
9
star
14

THREE.TextPlane

Optimally displays the text as a plane.
JavaScript
8
star
15

VueInBrowserLoader

Loads a .vue file from the given URL and compiles it to a component directly in the browser.
JavaScript
7
star
16

VueResizeSensor

A Vue container that supports the resize event.
JavaScript
6
star
17

VueThree

A wrapper for THREE.
JavaScript
6
star
18

lodash.permutations

Calculates all possible permutations without repetition of a certain size.
JavaScript
6
star
19

lodash.multicombinations

Calculates all possible combinations with repetition of a certain size.
JavaScript
5
star
20

VueDragDrop

[WIP] A drag and drop solution.
JavaScript
4
star
21

ngx-advanced-forms

Everything to make your work with Angular forms easier.
TypeScript
4
star
22

aframe-text-plane

A wrapper for THREE.TextPlane.
JavaScript
4
star
23

lodash.multipermutations

Calculates all possible permutations with repetition of a certain size.
JavaScript
4
star
24

KMeans

Implementation of the k-means algorithm to partition the values into the clusters.
JavaScript
4
star
25

almete.WordCloud

Generates a cloud out of the words.
JavaScript
4
star
26

KMeansPlusPlus

Implementation of the k-means-plus-plus algorithm to partition the values into the clusters.
JavaScript
3
star
27

THREE.CameraFacingGroup

A group of objects that are always facing the camera.
JavaScript
3
star
28

aframe-drag-controls

A wrapper for THREE.DragControls.
JavaScript
3
star
29

VueFort

The state management for Vue.
JavaScript
3
star
30

NearestNeighborChain

Builds a hierarchy of the clusters.
JavaScript
3
star
31

DearImage.detectBackgroundColor

Detects the image background color.
JavaScript
3
star
32

VuetifyColorInput

A color input component for Vuetify.
JavaScript
3
star
33

VectorMath

A collection of mathematical functions for working with vectors.
JavaScript
2
star
34

ngx-craft

Everything to make your work with Angular easier.
TypeScript
2
star
35

VueSvg

Loads a SVG image as an inline SVG.
JavaScript
1
star
36

DearImage.detectColorScheme

Detects the image color scheme.
JavaScript
1
star
37

saveFile

Saves a file inside a browser.
JavaScript
1
star
38

EChartsVue

A simple Vue wrapper for ECharts.
JavaScript
1
star
39

aframe-grid-helper

A wrapper for THREE.GridHelper.
JavaScript
1
star
40

tag

Parses a template literal to a function.
JavaScript
1
star
41

KoaRoute

A simple route middleware.
JavaScript
1
star
42

XLSX.utils.sanitize_sheet_name

Sanitizes a string to be safe for the use as a sheet name by removing the invalid characters and limiting the length.
JavaScript
1
star
43

detectNearestBrowserLocale

Detects the nearest browser locale.
JavaScript
1
star
44

aframe-camera-facing-group

A wrapper for THREE.CameraFacingGroup.
JavaScript
1
star
45

detectNearestLocale

Detects the nearest preferred locale.
JavaScript
1
star
46

KoaSinglePage

A single page application middleware.
JavaScript
1
star
47

VueZingTouch

A wrapper for ZingTouch.
JavaScript
1
star
48

KoaBody

A simple body fetcher.
JavaScript
1
star
49

throttleAsync

Creates a throttled function.
JavaScript
1
star
50

debounceAsync

Creates a debounced function.
JavaScript
1
star
51

lodash.cloneJSON

Converts a JavaScript value to a JSON string and then parses it back to a JavaScript value.
JavaScript
1
star
52

XLSX.utils.cells_to_sheet

Converts an array of arrays of cell objects to a worksheet.
JavaScript
1
star
53

JustMyLuck

A collection of utility functions for working with randomness.
JavaScript
1
star