@@ -4,7 +4,7 @@ import frag0 from './renderpasses/renderpass0/frag.js';
44import vert from './renderpasses/renderpass0/vert.js' ;
55import * as dat from 'datgui' ;
66import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs' ;
7- import { countImageColors , loadImage , readTags , sprite , strToCodes , strToImage } from './utils.js' ;
7+ import { countImageColors , readTags } from './utils.js' ;
88
99/**
1010 * @type {Points }
@@ -14,7 +14,7 @@ const gui = new dat.GUI({ name: 'Points GUI' });
1414const folderOptions = gui . addFolder ( 'options' ) ;
1515const folderControls = gui . addFolder ( 'controls' ) ;
1616const folderSongs = gui . addFolder ( 'songs' ) ;
17- const MAXCHARS = 30 ;
17+ const size = { x : 8 , y : 22 } , offset = - 32 , atlasPath = 'src/img/inconsolata_regular_8x22.png' ;
1818
1919let audio = null ;
2020let loop = false ;
@@ -79,10 +79,7 @@ async function playSong(song) {
7979 audio && audio . pause ( ) && ( audio = null ) ;
8080 audio = points . setAudio ( 'audio' , audioUrl , options . volume , false , false ) ;
8181
82- points . setUniform ( 'numChars' , title . length < MAXCHARS ? title . length : MAXCHARS ) ;
83-
84- const songNameImg = strToImage ( title , atlas , size ) ;
85- await points . setTextureImage ( 'songName' , songNameImg ) ;
82+ await points . setTextureString ( 'songName' , title , atlasPath , size , offset ) ;
8683
8784 let artworkLoaded = 0 ;
8885 song ?. artworkColors && points . setStorageMap ( 'artworkColors' , song ?. artworkColors . flat ( ) ) ;
@@ -191,11 +188,8 @@ async function onCompleteTags(result) {
191188 }
192189
193190 folderSongs . add ( song , 'fn' ) . name ( song . name ) ;
194- points . setUniform ( 'numChars' , title . length < MAXCHARS ? title . length : MAXCHARS ) ;
195- // points.setStorageMap('chars', strToCodes(title));
196191
197- const songNameImg = strToImage ( title , atlas , size ) ;
198- await points . setTextureImage ( 'songName' , songNameImg ) ;
192+ await points . setTextureString ( 'songName' , title , atlasPath , size , offset ) ;
199193}
200194
201195async function onErrorTags ( response ) {
@@ -375,25 +369,13 @@ points.setUniform('showMessage', 1);
375369points . setUniform ( 'rand' , 0 ) ;
376370points . setUniform ( 'progress' , 0 ) ;
377371points . setUniform ( 'artworkLoaded' , 0 ) ;
378- // points.setUniform('somecolor', colors.color2, 'vec3f');
379- points . setUniform ( 'numChars' , 12 ) ;
380372// points.setStorageMap('chars', strToCodes('Gravity Pull'), 'array<f32>')// TODO: setStorageMap doesn't work with u32 wrong sized
381373points . setStorageMap ( 'artworkColors' , Array ( 16 ) . fill ( 1 ) , 'array<vec4f>' ) ;
382374points . setStorage ( 'variables' , 'Variables' ) ;
383- await points . setTextureImage ( 'font' , './src/img/inconsolata_regular_8x22.png' ) ;
384-
385-
386-
387- const size = { x : 8 , y : 22 } ;
388- const atlas = await loadImage ( 'src/img/inconsolata_regular_8x22.png' ) ;
389- const messageStringImg = strToImage ( 'Select a song to Play' , atlas , size ) ;
390- await points . setTextureImage ( 'messageString' , messageStringImg ) ;
391-
392-
393375
394- const songNameImg = strToImage ( 'Gravity Pull' , atlas , size ) ;
395- await points . setTextureImage ( 'songName' , songNameImg ) ;
396376
377+ await points . setTextureString ( 'messageString' , 'Select a song to Play' , atlasPath , size , offset ) ;
378+ await points . setTextureString ( 'songName' , 'Gravity Pull' , atlasPath , size , offset ) ;
397379
398380const renderPasses = [
399381 new RenderPass ( vert , frag0 , null ) ,
0 commit comments