Skip to content

Plane Text

Overview

The plane text prefab enables rendering 2D text in Babylon by integrating babylon-msdf-text. Plane Text can be created by calling createPlaneText(), create(), or bind() returning a Mesh or Selection. The returned mesh is an empty parent mesh of the rendered text. The default font included is Roboto Regular. To use a different font, generate a texture atlas and json specification for your font using the MSDF font generator.

Usage

js
//With createPlaneText() returns Mesh
anu.createPlaneText(name: string, options: {}, scene: Scene);

//With create() returns Mesh
anu.create('planeText', name: string, scene: Scene, options: {}, data: {});

//With bind() returns Selection
anu.bind('planeText', scene: Scene, options: {}, data: [{}]);

//With bind() from a Selection returns a new Selection
Selection.bind('planeText', options: {}, data: [{}]);

Options

PropertyValueDefault
text(string) text to be rendered'undefined'
size(number) scaling factor to be baked into the vertices1
opacity(number) opacity value between 0 and 11
align(string) horizontal alignment of the text, either 'left, 'center', or 'right''center'
color(Color3) color value of the mesh materialColor3.White()
font(json) json spec of the MSDF text fontroboto-standard.json
atlas(png) texture atlas of the MSDF text fontroboto-standard.png

Examples

js
let options = {
    text: 'Hello World',
    color: Color3.Green()
}

anu.createPlaneText('text2d', options, scene);