summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2014-08-17 18:29:13 +0200
committerGubolin <gubolin@fantasymail.de>2014-08-17 18:29:13 +0200
commitb17afbc1aa1e25309c58f493511a0615e020af7f (patch)
tree278030cf1977e04ddf15dd65e9a0a26f4ea15641 /threads.js
parent672dba7c414e027c899bb51892367cfc7e5976e4 (diff)
downloadsnap-b17afbc1aa1e25309c58f493511a0615e020af7f.tar.gz
snap-b17afbc1aa1e25309c58f493511a0615e020af7f.zip
add camera streaming predicate
Diffstat (limited to 'threads.js')
-rw-r--r--threads.js39
1 files changed, 25 insertions, 14 deletions
diff --git a/threads.js b/threads.js
index 44b01f1..2d03fc7 100644
--- a/threads.js
+++ b/threads.js
@@ -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) {