@@ -47,6 +47,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor)
4747`
4848
4949interface IASCIIEffectProps {
50+ font ?: string
5051 characters ?: string
5152 fontSize ?: number
5253 cellSize ?: number
@@ -56,6 +57,7 @@ interface IASCIIEffectProps {
5657
5758class ASCIIEffect extends Effect {
5859 constructor ( {
60+ font = 'arial' ,
5961 characters = ` .:,'-^=*+?!|0#X%WM@` ,
6062 fontSize = 54 ,
6163 cellSize = 16 ,
@@ -75,12 +77,12 @@ class ASCIIEffect extends Effect {
7577 const charactersTextureUniform = this . uniforms . get ( 'uCharacters' )
7678
7779 if ( charactersTextureUniform ) {
78- charactersTextureUniform . value = this . createCharactersTexture ( characters , fontSize )
80+ charactersTextureUniform . value = this . createCharactersTexture ( characters , font , fontSize )
7981 }
8082 }
8183
8284 /** 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 {
8486 const canvas = document . createElement ( 'canvas' )
8587 const SIZE = 1024
8688 const MAX_PER_ROW = 16
@@ -95,7 +97,7 @@ class ASCIIEffect extends Effect {
9597 }
9698
9799 context . clearRect ( 0 , 0 , SIZE , SIZE )
98- context . font = `${ fontSize } px arial `
100+ context . font = `${ fontSize } px ${ font } `
99101 context . textAlign = 'center'
100102 context . textBaseline = 'middle'
101103 context . fillStyle = '#fff'
0 commit comments