const THREE = SupEngine . THREE ; export default class TextRendererGeometry extends THREE . BufferGeometry { width : number ; height : number ; constructor ( width , height , widthSegments , heightSegments ) { super ( ) ; this . type = "TextRendererGeometry" ; this . width = width ; this . height = height ; const vertices = new Float32Array ( widthSegments * heightSegments * 4 * 3 ) ; const normals = new Float32Array ( widthSegments * heightSegments * 4 * 3 ) ; const uvs = new Float32Array ( widthSegments * heightSegments * 4 * 2 ) ; let indices ; if ( vertices . length / 3 > 65535 ) indices = new Uint32Array ( widthSegments * heightSegments * 6 ) ; else indices = new Uint16Array ( widthSegments * heightSegments * 6 ) ; let offset = 0 ; let offset2 = 0 ; let offset3 = 0 ; for ( let iy = 0 ; iy < heightSegments ; iy ++ ) { const y = iy * height / heightSegments ; for ( let ix = 0 ; ix < widthSegments ; ix ++ ) { const x = ix * width / widthSegments ; vertices [ offset + 0 ] = x ; vertices [ offset + 1 ] = y ; normals [ offset + 2 ] = 1 ; uvs [ offset2 + 0 ] = ix / widthSegments ; uvs [ offset2 + 1 ] = iy / heightSegments ; vertices [ offset + 3 ] = x + width / widthSegments ; vertices [ offset + 4 ] = y ; normals [ offset + 5 ] = 1 ; uvs [ offset2 + 2 ] = ( ix + 1 ) / widthSegments ; uvs [ offset2 + 3 ] = iy / heightSegments ; vertices [ offset + 6 ] = x + width / widthSegments ; vertices [ offset + 7 ] = y + height / heightSegments ; normals [ offset + 8 ] = 1 ; uvs [ offset2 + 4 ] = ( ix + 1 ) / widthSegments ; uvs [ offset2 + 5 ] = ( iy + 1 ) / heightSegments ; vertices [ offset + 9 ] = x ; vertices [ offset + 10 ] = y + height / heightSegments ; normals [ offset + 11 ] = 1 ; uvs [ offset2 + 6 ] = ix / widthSegments ; uvs [ offset2 + 7 ] = ( iy + 1 ) / heightSegments ; const ref = ( ix + iy * widthSegments ) * 4 ; indices [ offset3 + 0 ] = ref + 0 ; indices [ offset3 + 1 ] = ref + 1 ; indices [ offset3 + 2 ] = ref + 2 ; indices [ offset3 + 3 ] = ref + 0 ; indices [ offset3 + 4 ] = ref + 3 ; indices [ offset3 + 5 ] = ref + 2 ; offset += 4 * 3 ; offset2 += 4 * 2 ; offset3 += 6 ; } } this . setIndex ( new THREE . BufferAttribute ( indices , 1 ) ) ; this . addAttribute ( "position" , new THREE . BufferAttribute ( vertices , 3 ) ) ; this . addAttribute ( "normal" , new THREE . BufferAttribute ( normals , 3 ) ) ; this . addAttribute ( "uv" , new THREE . BufferAttribute ( uvs , 2 ) ) ; } }