@@ -47,6 +47,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor)
47
47
`
48
48
49
49
interface IASCIIEffectProps {
50
+ font ?: string
50
51
characters ?: string
51
52
fontSize ?: number
52
53
cellSize ?: number
@@ -56,6 +57,7 @@ interface IASCIIEffectProps {
56
57
57
58
class ASCIIEffect extends Effect {
58
59
constructor ( {
60
+ font = 'arial' ,
59
61
characters = ` .:,'-^=*+?!|0#X%WM@` ,
60
62
fontSize = 54 ,
61
63
cellSize = 16 ,
@@ -75,12 +77,12 @@ class ASCIIEffect extends Effect {
75
77
const charactersTextureUniform = this . uniforms . get ( 'uCharacters' )
76
78
77
79
if ( charactersTextureUniform ) {
78
- charactersTextureUniform . value = this . createCharactersTexture ( characters , fontSize )
80
+ charactersTextureUniform . value = this . createCharactersTexture ( characters , font , fontSize )
79
81
}
80
82
}
81
83
82
84
/** Draws the characters on a Canvas and returns a texture */
83
- public createCharactersTexture ( characters : string , fontSize : number ) : THREE . Texture {
85
+ public createCharactersTexture ( characters : string , font : string , fontSize : number ) : THREE . Texture {
84
86
const canvas = document . createElement ( 'canvas' )
85
87
const SIZE = 1024
86
88
const MAX_PER_ROW = 16
@@ -95,7 +97,7 @@ class ASCIIEffect extends Effect {
95
97
}
96
98
97
99
context . clearRect ( 0 , 0 , SIZE , SIZE )
98
- context . font = `${ fontSize } px arial `
100
+ context . font = `${ fontSize } px ${ font } `
99
101
context . textAlign = 'center'
100
102
context . textBaseline = 'middle'
101
103
context . fillStyle = '#fff'
0 commit comments