mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Use a global mirror state
This commit is contained in:
parent
90166dc732
commit
46b4ef4d80
2 changed files with 12 additions and 5 deletions
|
@ -117,7 +117,6 @@ class Scratch3VideoSensingBlocks {
|
||||||
const offset = time - this._lastUpdate;
|
const offset = time - this._lastUpdate;
|
||||||
if (offset > Scratch3VideoSensingBlocks.INTERVAL) {
|
if (offset > Scratch3VideoSensingBlocks.INTERVAL) {
|
||||||
const frame = this.runtime.ioDevices.video.getFrame({
|
const frame = this.runtime.ioDevices.video.getFrame({
|
||||||
mirror: true,
|
|
||||||
format: Video.FORMAT_IMAGE_DATA,
|
format: Video.FORMAT_IMAGE_DATA,
|
||||||
dimensions: Scratch3VideoSensingBlocks.DIMENSIONS
|
dimensions: Scratch3VideoSensingBlocks.DIMENSIONS
|
||||||
});
|
});
|
||||||
|
@ -340,12 +339,14 @@ class Scratch3VideoSensingBlocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
videoToggle (args) {
|
videoToggle (args) {
|
||||||
|
// imported blocks have VIDEO_STATE "off", "on", "on-flipped" as opposed to the numerics?
|
||||||
const state = Number(args.VIDEO_STATE);
|
const state = Number(args.VIDEO_STATE);
|
||||||
// 1 == off, 2 & 3 are on (3 is flipped)
|
// 1 == off, 2 & 3 are on (3 is flipped)
|
||||||
if (state > 1) {
|
if (args.VIDEO_STATE === 'off' || state === 1) {
|
||||||
this.runtime.ioDevices.video.requestVideo();
|
|
||||||
} else {
|
|
||||||
this.runtime.ioDevices.video.disableVideo();
|
this.runtime.ioDevices.video.disableVideo();
|
||||||
|
} else {
|
||||||
|
this.runtime.ioDevices.video.requestVideo();
|
||||||
|
this.runtime.ioDevices.video.mirror = args.VIDEO_STATE === 'on' || state === 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,12 @@ class Video {
|
||||||
*/
|
*/
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for mirrored frames.
|
||||||
|
* @type boolean
|
||||||
|
*/
|
||||||
|
this.mirror = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache frames for this many ms.
|
* Cache frames for this many ms.
|
||||||
* @type number
|
* @type number
|
||||||
|
@ -136,7 +142,7 @@ class Video {
|
||||||
*/
|
*/
|
||||||
getFrame ({
|
getFrame ({
|
||||||
dimensions = Video.DIMENSIONS,
|
dimensions = Video.DIMENSIONS,
|
||||||
mirror = true,
|
mirror = this.mirror,
|
||||||
format = Video.FORMAT_IMAGE_DATA,
|
format = Video.FORMAT_IMAGE_DATA,
|
||||||
cacheTimeout = this._frameCacheTimeout
|
cacheTimeout = this._frameCacheTimeout
|
||||||
}) {
|
}) {
|
||||||
|
|
Loading…
Reference in a new issue