Skip to content

Commit

Permalink
Merge pull request #17 from 2gis/TILES-5025
Browse files Browse the repository at this point in the history
refreshResizeFrame
  • Loading branch information
Kuznecoff authored Feb 10, 2023
2 parents 6f0fb4e + 90f1791 commit f5a428d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@2gis/deck2gis-layer",
"version": "1.1.6",
"version": "1.1.7",
"description": "",
"main": "dist/deck2gislayer.js",
"typings": "dist/types/index.d.ts",
Expand Down
11 changes: 9 additions & 2 deletions src/deckgl2gisLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
updateLayer,
drawLayer,
initDeck2gisProps,
onMapResize,
} from './utils';
import type { Deck, Layer } from '@deck.gl/core/typed';
import { CustomRenderProps, DeckCustomLayer } from './types';
Expand Down Expand Up @@ -178,14 +179,21 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
) {
return;
}
const mapSize = this.map.getSize();
if (this.deck.width !== mapSize[0] || this.deck.height !== mapSize[1]) {
(this.deck as any).animationLoop._resizeCanvasDrawingBuffer();
(this.deck as any).animationLoop._resizeViewport();
const renderTarget = this.frameBuffer.bind(this.gl);
onMapResize(this.map, this.deck, renderTarget);
}
const { _2gisData } = this.deck.props as CustomRenderProps;
_2gisData._2gisCurrentViewport = undefined;
const gl = this.gl;
this.frameBuffer.bind(gl);
gl.clearColor(1, 1, 1, 0);

if (_2gisData._2gisFramestart) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
_2gisData._2gisCurrentViewport = undefined;
_2gisData._2gisFramestart = false;
} else {
gl.clear(gl.COLOR_BUFFER_BIT);
Expand All @@ -195,7 +203,6 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
drawLayer(this.deck, this.map, this);

gl.bindFramebuffer(gl.FRAMEBUFFER, null);
const mapSize = this.map.getSize();
const texture = this.frameBuffer.getTexture();
texture.enable(gl, 0);
this.program.enable(gl);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function onMapMove(deck: Deck, map: Map): void {
* @hidden
* @internal
*/
function onMapResize(map: Map, deck: Deck, renderTarget: RenderTarget) {
export function onMapResize(map: Map, deck: Deck, renderTarget: RenderTarget) {
const mapSize = map.getSize();
const gl = map.getWebGLContext();
const size = [mapSize[0] * window.devicePixelRatio, mapSize[1] * window.devicePixelRatio];
Expand Down

0 comments on commit f5a428d

Please sign in to comment.