import * as THREE from "three" ; import { UnicodeUtils } from "../utils/UnicodeUtils" ; import { Font } from "./FontCatalog" ; /**
 * Structure containing all the required information necessary to render a BMFont glyph using
 * [[TextCanvas]].
 */ export class GlyphData { /**
     * Unicode character represented by this glyph.
     */ readonly character : string ; /**
     * Glyph' direction.
     */ readonly direction : UnicodeUtils . Direction ; /**
     * Array containing the positions for all corners of this glyph.
     */ positions : THREE . Vector3 [ ] = [ ] ; /**
     * Array containing the source texture coordinates for all corners of this glyph.
     * Used to sample the original texture atlas pages.
     */ sourceTextureCoordinates : THREE . Vector2 [ ] = [ ] ; /**
     * Array containing the dynamic texture coordinates for all corners of this glyph.
     * Used to sample the dynamic texture atlas page.
     */ dynamicTextureCoordinates : THREE . Vector2 [ ] = [ ] ; /**
     * Source texture atlas' page copy index.
     */ copyIndex : number = 0 ; /**
     * Flag indicating if glyph can be currently rendered.
     */ isInCache : boolean = false ; param codePoint param block param width param height param advanceX param offsetX param offsetY param u0 param v0 param u1 param v1 param texture param font param isReplacement returns constructor ( readonly codePoint , readonly block , readonly width , readonly height , readonly advanceX , readonly offsetX , readonly offsetY , u0 , v0 , u1 , v1 , readonly texture , readonly font , readonly isReplacement = false ) { this . character = String . fromCodePoint ( codePoint ) ; this . direction = UnicodeUtils . getDirection ( codePoint , block ) ; const left = this . offsetX ; const right = left + this . width ; const top = font . metrics . lineHeight - this . offsetY ; const bottom = top - this . height ; this . positions . push ( new THREE . Vector3 ( left , bottom , 1.0 ) , new THREE . Vector3 ( right , bottom , 1.0 ) , new THREE . Vector3 ( left , top , 1.0 ) , new THREE . Vector3 ( right , top , 1.0 ) ) ; this . sourceTextureCoordinates . push ( new THREE . Vector2 ( u0 , v0 ) , new THREE . Vector2 ( u1 , v0 ) , new THREE . Vector2 ( u0 , v1 ) , new THREE . Vector2 ( u1 , v1 ) ) ; this . dynamicTextureCoordinates . push ( new THREE . Vector2 ( 0.0 , 0.0 ) , new THREE . Vector2 ( 1.0 , 0.0 ) , new THREE . Vector2 ( 0.0 , 1.0 ) , new THREE . Vector2 ( 1.0 , 1.0 ) ) ; } returns clone ( ) { return new GlyphData ( this . codePoint , this . block , this . width , this . height , this . advanceX , this . offsetX , this . offsetY , this . sourceTextureCoordinates [ 0 ] . x , this . sourceTextureCoordinates [ 0 ] . y , this . sourceTextureCoordinates [ 3 ] . x , this . sourceTextureCoordinates [ 3 ] . y , this . texture , this . font , this . isReplacement ) ; } }