88 updateLayer ,
99 drawLayer ,
1010 initDeck2gisProps ,
11+ onMapResize ,
1112} from './utils' ;
1213import type { Deck , Layer } from '@deck.gl/core/typed' ;
1314import { CustomRenderProps , DeckCustomLayer } from './types' ;
@@ -178,14 +179,21 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
178179 ) {
179180 return ;
180181 }
182+ const mapSize = this . map . getSize ( ) ;
183+ if ( this . deck . width !== mapSize [ 0 ] || this . deck . height !== mapSize [ 1 ] ) {
184+ ( this . deck as any ) . animationLoop . _resizeCanvasDrawingBuffer ( ) ;
185+ ( this . deck as any ) . animationLoop . _resizeViewport ( ) ;
186+ const renderTarget = this . frameBuffer . bind ( this . gl ) ;
187+ onMapResize ( this . map , this . deck , renderTarget ) ;
188+ }
181189 const { _2gisData } = this . deck . props as CustomRenderProps ;
182- _2gisData . _2gisCurrentViewport = undefined ;
183190 const gl = this . gl ;
184191 this . frameBuffer . bind ( gl ) ;
185192 gl . clearColor ( 1 , 1 , 1 , 0 ) ;
186193
187194 if ( _2gisData . _2gisFramestart ) {
188195 gl . clear ( gl . COLOR_BUFFER_BIT | gl . DEPTH_BUFFER_BIT ) ;
196+ _2gisData . _2gisCurrentViewport = undefined ;
189197 _2gisData . _2gisFramestart = false ;
190198 } else {
191199 gl . clear ( gl . COLOR_BUFFER_BIT ) ;
@@ -195,7 +203,6 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
195203 drawLayer ( this . deck , this . map , this ) ;
196204
197205 gl . bindFramebuffer ( gl . FRAMEBUFFER , null ) ;
198- const mapSize = this . map . getSize ( ) ;
199206 const texture = this . frameBuffer . getTexture ( ) ;
200207 texture . enable ( gl , 0 ) ;
201208 this . program . enable ( gl ) ;
0 commit comments