diff --git a/src/extensions/scratch3_video_sensing/index.js b/src/extensions/scratch3_video_sensing/index.js index 58796cf0e..145a204d4 100644 --- a/src/extensions/scratch3_video_sensing/index.js +++ b/src/extensions/scratch3_video_sensing/index.js @@ -117,7 +117,6 @@ class Scratch3VideoSensingBlocks { const offset = time - this._lastUpdate; if (offset > Scratch3VideoSensingBlocks.INTERVAL) { const frame = this.runtime.ioDevices.video.getFrame({ - mirror: true, format: Video.FORMAT_IMAGE_DATA, dimensions: Scratch3VideoSensingBlocks.DIMENSIONS }); @@ -340,12 +339,14 @@ class Scratch3VideoSensingBlocks { } videoToggle (args) { + // imported blocks have VIDEO_STATE "off", "on", "on-flipped" as opposed to the numerics? const state = Number(args.VIDEO_STATE); // 1 == off, 2 & 3 are on (3 is flipped) - if (state > 1) { - this.runtime.ioDevices.video.requestVideo(); - } else { + if (args.VIDEO_STATE === 'off' || state === 1) { this.runtime.ioDevices.video.disableVideo(); + } else { + this.runtime.ioDevices.video.requestVideo(); + this.runtime.ioDevices.video.mirror = args.VIDEO_STATE === 'on' || state === 2; } } diff --git a/src/io/video.js b/src/io/video.js index c1888e1ac..f5e36a56c 100644 --- a/src/io/video.js +++ b/src/io/video.js @@ -8,6 +8,12 @@ class Video { */ this.runtime = runtime; + /** + * Default value for mirrored frames. + * @type boolean + */ + this.mirror = true; + /** * Cache frames for this many ms. * @type number @@ -136,7 +142,7 @@ class Video { */ getFrame ({ dimensions = Video.DIMENSIONS, - mirror = true, + mirror = this.mirror, format = Video.FORMAT_IMAGE_DATA, cacheTimeout = this._frameCacheTimeout }) {