Skip to content

jamessteininger/aframe-text-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aframe-text-component

A text geometry component for A-Frame VR. The text geometry component (shape) can be paired with the material component (appearance).

screenshot

Usage

Install.

npm install aframe-text-component

Register.

AFrame = require('aframe-core');
AFrame.registerComponent('text', require('aframe-text-component').component);

Use.

<a-scene>
  <a-entity text="text: Hello, World!" material="color: blue"></a-entity>
</a-scene>

Using Different Fonts

The text component uses typeface.js, fonts defined in JS files for three.js. typeface fonts can be generated from regular fonts using this typeface font generator. You can also find some sample generated fonts, currently in the examples/fonts directory in the three.js repository.

By default, the text component only comes with one typeface font, Helvetiker (Regular). Each font is fairly large, from at least 60KB to hundreds of KBs.

To include a font for use with the text component, append or require the typeface font after this component. This component uses FontUtils which should be initialized before adding fonts.

For example in HTML:

<html>
  <head>
    <script src="aframe-core.js"></script>
    <script src="aframe-text-component.js"></script>
    <script src="myfont.typeface.js"></script>
  </head>
  <body>
    <a-assets>
      <a-mixin id="font" text="font: myfont"></a-mixin>
    </a-assets>
    <a-entity mixin="font" text="text: Hello"></a-entity>
    <a-entity mixin="font" text="text: World"></a-entity>
  </body>
</html>

Or in JS:

var AFrame = require('aframe-core');
var textComponent = require('aframe-text-component');
AFrame.registerComponent('text', textComponent);
require('./fonts/myfont.typeface');

Properties

Property Description Default Value
bevelEnabled false
bevelSize 8
bevelThickness 12
curveSegments 12
font helvetiker
height 0.05
size 0.5
style normal
text None
weight normal

Releases

No releases published

Packages

No packages published