account for viewport rotation in addition to tiledImage rotation

This commit is contained in:
Tom 2024-02-09 15:19:40 -05:00
parent 5b2c6d7ed9
commit d4e82d374e
2 changed files with 10 additions and 5 deletions

View File

@ -242,7 +242,10 @@
if ( tiledImage.placeholderFillStyle && tiledImage._hasOpaqueTile === false ) { if ( tiledImage.placeholderFillStyle && tiledImage._hasOpaqueTile === false ) {
this._drawPlaceholder(tiledImage); this._drawPlaceholder(tiledImage);
} }
this._drawPlaceholder(tiledImage);
if(!window.draw){
return;
}
if(tilesToDraw.length === 0 || tiledImage.getOpacity() === 0){ if(tilesToDraw.length === 0 || tiledImage.getOpacity() === 0){
return; return;
} }
@ -1095,13 +1098,13 @@
fillStyle = tiledImage.placeholderFillStyle; fillStyle = tiledImage.placeholderFillStyle;
} }
context.save(); this._offsetForRotation({degrees: this.viewer.viewport.getRotation(true)});
context.fillStyle = fillStyle; context.fillStyle = fillStyle;
context.translate(rect.x, rect.y); context.translate(rect.x, rect.y);
context.rotate(Math.PI / 180 * bounds.degrees); context.rotate(Math.PI / 180 * bounds.degrees);
context.translate(-rect.x, -rect.y); context.translate(-rect.x, -rect.y);
context.fillRect(rect.x, rect.y, rect.width, rect.height); context.fillRect(rect.x, rect.y, rect.width, rect.height);
context.restore(); this._restoreRotationChanges();
} }

View File

@ -64,8 +64,10 @@
crossOriginPolicy: 'Anonymous' crossOriginPolicy: 'Anonymous'
}); });
viewer.addOnceHandler('canvas-click', function(event) { let swapped = false;
if (event.quick) { viewer.addHandler('canvas-click', function(event) {
if (event.quick && !swapped) {
swapped = true;
var standin = viewer.world.getItemAt(0); var standin = viewer.world.getItemAt(0);
var standinBounds = standin.getBounds(); var standinBounds = standin.getBounds();
viewer.viewport.fitBounds(standinBounds); viewer.viewport.fitBounds(standinBounds);