From 3cf45f4e07c362fe69233431ace87c5ae782bd3e Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 15 Oct 2019 12:10:14 -0400 Subject: [PATCH 1/3] Fix video sensing by calling updateMatrix manually before using isTouching --- src/extensions/scratch3_video_sensing/library.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extensions/scratch3_video_sensing/library.js b/src/extensions/scratch3_video_sensing/library.js index 04abc20ea..0f3c24f7d 100644 --- a/src/extensions/scratch3_video_sensing/library.js +++ b/src/extensions/scratch3_video_sensing/library.js @@ -289,6 +289,11 @@ class VideoMotion { _curr: curr } = this; + // The public APIs for Renderer#isTouching manage keeping the matrix and + // silhouette up-to-date, which is needed for drawable#isTouching to work + drawable.updateMatrix(); + if (drawable.skin) drawable.skin.updateSilhouette(); + // Restrict the region the amount and direction are built from to // the area of the current frame overlapped by the given drawable's // bounding box. From 69f30a4fb58101b422d1f9280310e34b914e1e9e Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 15 Oct 2019 12:25:15 -0400 Subject: [PATCH 2/3] Add updateMatrix to fake drawable test --- test/unit/extension_video_sensing.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit/extension_video_sensing.js b/test/unit/extension_video_sensing.js index 5a217589f..197c06e87 100644 --- a/test/unit/extension_video_sensing.js +++ b/test/unit/extension_video_sensing.js @@ -87,6 +87,8 @@ const isNearAngle = (actual, expect, optMargin = 10) => ( // A fake scratch-render drawable that will be used by VideoMotion to restrain // the area considered for motion detection in VideoMotion.getLocalMotion const fakeDrawable = { + updateMatrix () {}, // no-op, since isTouching always returns true + getFastBounds () { return { left: -120, From b13a40fb2e857168daa1eccec3b6399940021d7f Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 17 Oct 2019 11:01:22 -0400 Subject: [PATCH 3/3] Update src/extensions/scratch3_video_sensing/library.js Co-Authored-By: Karishma Chadha --- src/extensions/scratch3_video_sensing/library.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/scratch3_video_sensing/library.js b/src/extensions/scratch3_video_sensing/library.js index 0f3c24f7d..5a6ac344e 100644 --- a/src/extensions/scratch3_video_sensing/library.js +++ b/src/extensions/scratch3_video_sensing/library.js @@ -290,7 +290,7 @@ class VideoMotion { } = this; // The public APIs for Renderer#isTouching manage keeping the matrix and - // silhouette up-to-date, which is needed for drawable#isTouching to work + // silhouette up-to-date, which is needed for drawable#isTouching to work (used below) drawable.updateMatrix(); if (drawable.skin) drawable.skin.updateSilhouette();