diff options
| author | Gubolin <gubolin@fantasymail.de> | 2014-08-17 18:29:13 +0200 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2014-08-17 18:29:13 +0200 |
| commit | b17afbc1aa1e25309c58f493511a0615e020af7f (patch) | |
| tree | 278030cf1977e04ddf15dd65e9a0a26f4ea15641 /threads.js | |
| parent | 672dba7c414e027c899bb51892367cfc7e5976e4 (diff) | |
| download | snap-b17afbc1aa1e25309c58f493511a0615e020af7f.tar.gz snap-b17afbc1aa1e25309c58f493511a0615e020af7f.zip | |
add camera streaming predicate
Diffstat (limited to 'threads.js')
| -rw-r--r-- | threads.js | 39 |
1 files changed, 25 insertions, 14 deletions
@@ -2424,26 +2424,33 @@ Process.prototype.reportColorIsTouchingColor = function (color1, color2) { return false; }; +Process.prototype.reportStreamingCamera = function () { + var stage = this.homeContext.receiver.parentThatIsA(StageMorph); + return stage.streamingCamera; +}; + Process.prototype.reportCameraMotion = function () { - var thisObj = this.blockReceiver(); - var motionCanvas = this.getCameraMotionCanvas(); - var motion = this.getCameraMotion(motionCanvas, thisObj); - if (motion > 10) { - return true; - } else { - return false; + if (this.reportStreamingCamera()) { + var thisObj = this.blockReceiver(); + var motionCanvas = this.getCameraMotionCanvas(); + var motion = this.getCameraMotion(motionCanvas, thisObj); + if (motion > 10) { + return true; + } } + return false; }; Process.prototype.reportCameraDirection = function () { - var thisObj = this.blockReceiver(); - var motionCanvas = this.getCameraMotionCanvas(); - var motion = this.getCameraMotion(motionCanvas, thisObj); - if (motion > 10) { - return this.getCameraDirection(motionCanvas); - } else { - return 0; + if (this.reportStreamingCamera()) { + var thisObj = this.blockReceiver(); + var motionCanvas = this.getCameraMotionCanvas(); + var motion = this.getCameraMotion(motionCanvas, thisObj); + if (motion > 10) { + return this.getCameraDirection(motionCanvas); + } } + return 0; }; Process.prototype.reportDistanceTo = function (name) { @@ -2771,6 +2778,8 @@ Process.prototype.doStreamCamera = function () { stage.trailsCanvas = newCanvas(stage.dimensions); } + stage.streamingCamera = false; + if (video === null) { video = document.createElement('video'); video.width = stage.dimensions.x; @@ -2817,6 +2826,7 @@ Process.prototype.doStreamCamera = function () { } context.drawImage(video, 0, 0, video.width, video.height); stage.changed(); + stage.streamingCamera = true; } catch (e) { if (e.name !== 'NS_ERROR_NOT_AVAILABLE') { // https://bugzilla.mozilla.org/show_bug.cgi?id=879717 @@ -2832,6 +2842,7 @@ Process.prototype.doStreamCamera = function () { Process.prototype.doStopCamera = function () { var stage = this.homeContext.receiver.parentThatIsA(StageMorph); if (stage) { + stage.streamingCamera = false; stage.threads.processes.forEach(function (thread) { if (thread.context) { if (thread.context.activeStream) { |
