Skip to content

TextGenerator Tutorial

Viktor Kovacs edited this page Nov 10, 2016 · 2 revisions

Live demo

Here is the result of this tutorial

Font specification

JSModeler uses the font specification format generated with Facetype.js. You can generate your own specification, or use the one provided in the font folder next to the build.

Text generation

The first thing you have to do is to load the font specification json file. When it is loaded, you can generate 3D text using the loaded font specification:

JSM.LoadJsonFile ('font/firasans.json', function (jsonData) {
	var model = JSM.GenerateText (text, jsonData, 0.01, 1.5, 10);
	var meshes = JSM.ConvertModelToThreeMeshes (model);
	viewer.AddMeshes (meshes);
	viewer.Draw ();			
});