123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import type { Color4 } from "../../Maths/math.color";
- import { Path2 } from "../../Maths/math.path";
- import type { Vector4 } from "../../Maths/math.vector";
- import type { Scene } from "../../scene";
- import type { Nullable } from "../../types";
- import { Mesh } from "../mesh";
- /**
- * Parser inspired by https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/FontLoader.js
- */
- /**
- * Represents glyph data generated by http://gero3.github.io/facetype.js/
- */
- export interface IGlyphData {
- /** Commands used to draw (line, move, curve, etc..) */
- o: string;
- /** Width */
- ha: number;
- }
- /**
- * Represents font data generated by http://gero3.github.io/facetype.js/
- */
- export interface IFontData {
- /**
- * Font resolution
- */
- resolution: number;
- /** Underline tickness */
- underlineThickness: number;
- /** Bounding box */
- boundingBox: {
- yMax: number;
- yMin: number;
- };
- /** List of supported glyphs */
- glyphs: {
- [key: string]: IGlyphData;
- };
- }
- declare class ShapePath {
- private _paths;
- private _tempPaths;
- private _holes;
- private _currentPath;
- private _resolution;
- /** Create the ShapePath used to support glyphs
- * @param resolution defines the resolution used to determine the number of points per curve (default is 4)
- */
- constructor(resolution: number);
- /** Move the virtual cursor to a coordinate
- * @param x defines the x coordinate
- * @param y defines the y coordinate
- */
- moveTo(x: number, y: number): void;
- /** Draw a line from the virtual cursor to a given coordinate
- * @param x defines the x coordinate
- * @param y defines the y coordinate
- */
- lineTo(x: number, y: number): void;
- /** Create a quadratic curve from the virtual cursor to a given coordinate
- * @param cpx defines the x coordinate of the control point
- * @param cpy defines the y coordinate of the control point
- * @param x defines the x coordinate of the end point
- * @param y defines the y coordinate of the end point
- */
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
- /**
- * Create a bezier curve from the virtual cursor to a given coordinate
- * @param cpx1 defines the x coordinate of the first control point
- * @param cpy1 defines the y coordinate of the first control point
- * @param cpx2 defines the x coordinate of the second control point
- * @param cpy2 defines the y coordinate of the second control point
- * @param x defines the x coordinate of the end point
- * @param y defines the y coordinate of the end point
- */
- bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): void;
- /** Extract holes based on CW / CCW */
- extractHoles(): void;
- /** Gets the list of paths */
- get paths(): Path2[];
- /** Gets the list of holes */
- get holes(): Path2[];
- }
- /**
- * Creates shape paths from a text and font
- * @param text the text
- * @param size size of the font
- * @param resolution resolution of the font
- * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)
- * @returns array of ShapePath objects
- */
- export declare function CreateTextShapePaths(text: string, size: number, resolution: number, fontData: IFontData): ShapePath[];
- /**
- * Create a text mesh
- * @param name defines the name of the mesh
- * @param text defines the text to use to build the mesh
- * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)
- * @param options defines options used to create the mesh
- * @param scene defines the hosting scene
- * @param earcutInjection can be used to inject your own earcut reference
- * @returns a new Mesh
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/text
- */
- export declare function CreateText(name: string, text: string, fontData: IFontData, options?: {
- size?: number;
- resolution?: number;
- depth?: number;
- sideOrientation?: number;
- faceUV?: Vector4[];
- faceColors?: Color4[];
- perLetterFaceUV?: (letterIndex: number) => Vector4[];
- perLetterFaceColors?: (letterIndex: number) => Color4[];
- }, scene?: Nullable<Scene>, earcutInjection?: any): Nullable<Mesh>;
- export {};
|