support viewport flipping for clip and cropping polygons in webglviewer

This commit is contained in:
Tom 2024-02-21 18:12:22 -05:00
parent ae5f08b9bd
commit 5df791fc82

View File

@ -917,6 +917,12 @@
this._clippingContext.clearRect(0, 0, this._clippingCanvas.width, this._clippingCanvas.height); this._clippingContext.clearRect(0, 0, this._clippingCanvas.width, this._clippingCanvas.height);
this._clippingContext.save(); 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){ if(item._clip){
const polygon = [ const polygon = [
@ -936,7 +942,7 @@
this._clippingContext[i === 0 ? 'moveTo' : 'lineTo'](coord.x, coord.y); this._clippingContext[i === 0 ? 'moveTo' : 'lineTo'](coord.x, coord.y);
}); });
this._clippingContext.clip(); this._clippingContext.clip();
this._setClip() this._setClip();
} }
if(item._croppingPolygons){ if(item._croppingPolygons){
let polygons = item._croppingPolygons.map(polygon => { let polygons = item._croppingPolygons.map(polygon => {
@ -956,6 +962,13 @@
this._clippingContext.clip(); 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.drawImage(this._renderingCanvas, 0, 0);
this._clippingContext.restore(); this._clippingContext.restore();