Skip to content

Commit

Permalink
update viewport if necessary, fix maptalks/issues#499
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn authored and deyihu committed Nov 7, 2023
1 parent 002d643 commit ad79d5b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const TEMP_POINT = new maptalks.Point(0, 0);
const TEMP_VECTOR3 = new THREE.Vector3();
const heightCache = new Map();
const KEY_FBO = '__webglFramebuffer';
const TEMP_V4 = new THREE.Vector4();

// const MATRIX4 = new THREE.Matrix4();

Expand Down Expand Up @@ -1630,6 +1631,11 @@ class ThreeRenderer extends maptalks.renderer.CanvasLayerRenderer {
this.context.render(this.scene, this.camera);
renderTargetProps[KEY_FBO] = threeCreatedFBO;
} else {
const { width, height } = this.canvas;
const viewport = this.context.getViewport(TEMP_V4);
if (viewport.width !== width || viewport.height !== height) {
this.context.setViewport(0, 0, width, height);
}
this.context.render(this.scene, this.camera);
}
this.context.setRenderTarget(null);
Expand Down

0 comments on commit ad79d5b

Please sign in to comment.