|
@@ -541,14 +541,14 @@ export class Session extends AREventTarget<SessionEventType>
|
541
|
541
|
// render user media
|
542
|
542
|
if(this._primarySource !== null) {
|
543
|
543
|
const media = this._primarySource._internalMedia;
|
544
|
|
- this._renderMedia(ctx, media);
|
|
544
|
+ this._renderMedia(ctx, media, true);
|
545
|
545
|
}
|
546
|
546
|
|
547
|
|
- // render output image(s)
|
|
547
|
+ // render output image(s) for debugging
|
548
|
548
|
for(let i = 0; i < this._trackers.length; i++) {
|
549
|
549
|
const media = this._trackers[i]._output.image;
|
550
|
550
|
if(media !== undefined)
|
551
|
|
- this._renderMedia(ctx, media);
|
|
551
|
+ this._renderMedia(ctx, media, false);
|
552
|
552
|
}
|
553
|
553
|
|
554
|
554
|
// render gizmos
|
|
@@ -559,18 +559,21 @@ export class Session extends AREventTarget<SessionEventType>
|
559
|
559
|
* Render a SpeedyMedia
|
560
|
560
|
* @param ctx rendering context
|
561
|
561
|
* @param media
|
|
562
|
+ * @param stretch
|
562
|
563
|
*/
|
563
|
|
- private _renderMedia(ctx: CanvasRenderingContext2D, media: SpeedyMedia): void
|
|
564
|
+ private _renderMedia(ctx: CanvasRenderingContext2D, media: SpeedyMedia, stretch: boolean): void
|
564
|
565
|
{
|
565
|
566
|
const canvas = ctx.canvas;
|
|
567
|
+ const width = stretch ? canvas.width : media.width;
|
|
568
|
+ const height = stretch ? canvas.height : media.height;
|
566
|
569
|
|
567
|
570
|
if(media.type != 'data') {
|
568
|
571
|
const image = media.source as Exclude<SpeedyMediaSourceNativeElement, ImageData>;
|
569
|
|
- ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
572
|
+ ctx.drawImage(image, 0, 0, width, height);
|
570
|
573
|
}
|
571
|
574
|
else {
|
572
|
575
|
const image = media.source as ImageData;
|
573
|
|
- ctx.putImageData(image, 0, 0, 0, 0, canvas.width, canvas.height);
|
|
576
|
+ ctx.putImageData(image, 0, 0, 0, 0, width, height);
|
574
|
577
|
}
|
575
|
578
|
}
|
576
|
579
|
|