From 5df791fc82eb4323ed6de2e20c9d51be0558c738 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 21 Feb 2024 18:12:22 -0500 Subject: [PATCH] support viewport flipping for clip and cropping polygons in webglviewer --- src/webgldrawer.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/webgldrawer.js b/src/webgldrawer.js index c3619503..072cbde0 100644 --- a/src/webgldrawer.js +++ b/src/webgldrawer.js @@ -917,6 +917,12 @@ this._clippingContext.clearRect(0, 0, this._clippingCanvas.width, this._clippingCanvas.height); this._clippingContext.save(); + if(this.viewer.viewport.getFlip()){ + const point = new $.Point(this.canvas.width / 2, this.canvas.height / 2); + this._clippingContext.translate(point.x, 0); + this._clippingContext.scale(-1, 1); + this._clippingContext.translate(-point.x, 0); + } if(item._clip){ const polygon = [ @@ -936,7 +942,7 @@ this._clippingContext[i === 0 ? 'moveTo' : 'lineTo'](coord.x, coord.y); }); this._clippingContext.clip(); - this._setClip() + this._setClip(); } if(item._croppingPolygons){ let polygons = item._croppingPolygons.map(polygon => { @@ -956,6 +962,13 @@ this._clippingContext.clip(); } + if(this.viewer.viewport.getFlip()){ + const point = new $.Point(this.canvas.width / 2, this.canvas.height / 2); + this._clippingContext.translate(point.x, 0); + this._clippingContext.scale(-1, 1); + this._clippingContext.translate(-point.x, 0); + } + this._clippingContext.drawImage(this._renderingCanvas, 0, 0); this._clippingContext.restore();