@@ -760,8 +760,13 @@ export class WebGLRenderer extends MapViewerRenderer<WebGLMapSquare> {
760760 this . app . resize ( width , height ) ;
761761 }
762762
763+ override rendererUpdate ( ) {
764+ const camera = this . mapViewer . camera ;
765+ camera . update ( this . app . width , this . app . height ) ;
766+ }
767+
763768 override render ( time : number , deltaTime : number , resized : boolean ) : void {
764- const frameStart = performance . now ( ) ;
769+ this . rendererStats . frameStart = performance . now ( ) ;
765770
766771 const frameCount = this . stats . frameCount ;
767772
@@ -807,22 +812,12 @@ export class WebGLRenderer extends MapViewerRenderer<WebGLMapSquare> {
807812 this . resolutionUni [ 1 ] = this . app . height ;
808813 }
809814
810- const inputManager = this . mapViewer . inputManager ;
811815 const camera = this . mapViewer . camera ;
812-
813- this . handleInput ( deltaTime ) ;
814-
815- camera . update ( this . app . width , this . app . height ) ;
816-
817- const renderDistance = this . mapViewer . renderDistance ;
818-
819- const mapManagerStart = performance . now ( ) ;
820- this . mapManager . update ( camera , frameCount , renderDistance , this . mapViewer . unloadDistance ) ;
821- const mapManagerTime = performance . now ( ) - mapManagerStart ;
822-
823816 this . cameraPosUni [ 0 ] = camera . getPosX ( ) ;
824817 this . cameraPosUni [ 1 ] = camera . getPosZ ( ) ;
825818
819+ const renderDistance = this . mapViewer . renderDistance ;
820+
826821 this . sceneUniformBuffer
827822 . set ( 0 , camera . viewProjMatrix as Float32Array )
828823 . set ( 1 , camera . viewMatrix as Float32Array )
@@ -840,12 +835,13 @@ export class WebGLRenderer extends MapViewerRenderer<WebGLMapSquare> {
840835 const currInteractions = this . interactions [ frameCount % this . interactions . length ] ;
841836
842837 const interactionsStart = performance . now ( ) ;
838+ const inputManager = this . mapViewer . inputManager ;
843839 if ( ! inputManager . isPointerLock ( ) ) {
844840 this . prepareInteractions ( currInteractions ) ;
845841 } else if ( this . hoveredMapIds . size > 0 ) {
846842 this . hoveredMapIds . clear ( ) ;
847843 }
848- const interactionsTime = performance . now ( ) - interactionsStart ;
844+ this . rendererStats . interactionsTime = performance . now ( ) - interactionsStart ;
849845
850846 if ( this . cullBackFace ) {
851847 this . app . enable ( PicoGL . CULL_FACE ) ;
@@ -864,26 +860,26 @@ export class WebGLRenderer extends MapViewerRenderer<WebGLMapSquare> {
864860
865861 const tickStart = performance . now ( ) ;
866862 this . tickPass ( timeSec , ticksElapsed , clientTicksElapsed ) ;
867- const tickTime = performance . now ( ) - tickStart ;
863+ this . tickTime = performance . now ( ) - tickStart ;
868864
869865 const npcDataTextureIndex = this . updateNpcDataTexture ( ) ;
870866 const npcDataTexture = this . npcDataTextureBuffer [ npcDataTextureIndex ] ;
871867
872868 this . app . disable ( PicoGL . BLEND ) ;
873869 const opaquePassStart = performance . now ( ) ;
874870 this . renderOpaquePass ( ) ;
875- const opaquePassTime = performance . now ( ) - opaquePassStart ;
871+ this . rendererStats . opaquePassTime = performance . now ( ) - opaquePassStart ;
876872 const opaqueNpcPassStart = performance . now ( ) ;
877873 this . renderOpaqueNpcPass ( npcDataTextureIndex , npcDataTexture ) ;
878- const opaqueNpcPassTime = performance . now ( ) - opaqueNpcPassStart ;
874+ this . rendererStats . opaqueNpcPassTime = performance . now ( ) - opaqueNpcPassStart ;
879875
880876 this . app . enable ( PicoGL . BLEND ) ;
881877 const transparentPassStart = performance . now ( ) ;
882878 this . renderTransparentPass ( ) ;
883- const transparentPassTime = performance . now ( ) - transparentPassStart ;
879+ this . rendererStats . transparentPassTime = performance . now ( ) - transparentPassStart ;
884880 const transparentNpcPassStart = performance . now ( ) ;
885881 this . renderTransparentNpcPass ( npcDataTextureIndex , npcDataTexture ) ;
886- const transparentNpcPassTime = performance . now ( ) - transparentNpcPassStart ;
882+ this . rendererStats . transparentNpcPassTime = performance . now ( ) - transparentNpcPassStart ;
887883
888884 // Can't sample from renderbuffer so blit to a texture for sampling.
889885 this . app . readFramebuffer ( this . framebuffer ) ;
@@ -934,52 +930,24 @@ export class WebGLRenderer extends MapViewerRenderer<WebGLMapSquare> {
934930 this . frameDrawCall . draw ( ) ;
935931 }
936932
933+ this . loadPending ( timeSec )
934+ }
935+
936+ loadPending ( timeSec : number ) {
937937 // Load new map squares
938938 const mapData = this . mapsToLoad . shift ( ) ;
939939 if ( mapData && this . isValidMapData ( mapData ) ) {
940940 this . loadMap (
941- this . mainProgram ,
942- this . mainAlphaProgram ,
943- this . npcProgram ,
944- this . textureArray ,
945- this . textureMaterials ,
946- this . sceneUniformBuffer ,
941+ this . mainProgram ! ,
942+ this . mainAlphaProgram ! ,
943+ this . npcProgram ! ,
944+ this . textureArray ! ,
945+ this . textureMaterials ! ,
946+ this . sceneUniformBuffer ! ,
947947 mapData ,
948948 timeSec ,
949949 ) ;
950950 }
951-
952- const frameTime = performance . now ( ) - frameStart ;
953-
954- if ( this . mapViewer . inputManager . isKeyDown ( "KeyH" ) ) {
955- this . mapViewer . debugText = `MapManager: ${ mapManagerTime . toFixed ( 2 ) } ms` ;
956- }
957- if ( this . mapViewer . inputManager . isKeyDown ( "KeyJ" ) ) {
958- this . mapViewer . debugText = `Interactions: ${ interactionsTime . toFixed ( 2 ) } ms` ;
959- }
960- if ( this . mapViewer . inputManager . isKeyDown ( "KeyK" ) ) {
961- this . mapViewer . debugText = `Tick: ${ tickTime . toFixed ( 2 ) } ms` ;
962- }
963- if ( this . mapViewer . inputManager . isKeyDown ( "KeyL" ) ) {
964- this . mapViewer . debugText = `Opaque Pass: ${ opaquePassTime . toFixed ( 2 ) } ms` ;
965- }
966- if ( this . mapViewer . inputManager . isKeyDown ( "KeyB" ) ) {
967- this . mapViewer . debugText = `Opaque Npc Pass: ${ opaqueNpcPassTime . toFixed ( 2 ) } ms` ;
968- }
969- if ( this . mapViewer . inputManager . isKeyDown ( "KeyN" ) ) {
970- this . mapViewer . debugText = `Transparent Pass: ${ transparentPassTime . toFixed ( 2 ) } ms` ;
971- }
972- if ( this . mapViewer . inputManager . isKeyDown ( "KeyM" ) ) {
973- this . mapViewer . debugText = `Transparent Npc Pass: ${ transparentNpcPassTime . toFixed (
974- 2 ,
975- ) } ms`;
976- }
977- if ( this . mapViewer . inputManager . isKeyDown ( "KeyV" ) ) {
978- this . mapViewer . debugText = `Frame Time: ${ frameTime . toFixed ( 2 ) } ms` ;
979- }
980- if ( this . mapViewer . inputManager . isKeyDown ( "KeyU" ) ) {
981- this . mapViewer . debugText = `Frame Time Js: ${ this . stats . frameTimeJs . toFixed ( 2 ) } ms` ;
982- }
983951 }
984952
985953 tickPass ( time : number , ticksElapsed : number , clientTicksElapsed : number ) : void {
0 commit comments