Skip to content

Conversation

adzhindzhi
Copy link
Contributor

@adzhindzhi adzhindzhi commented Sep 1, 2025

Resolves

UEPR-312

Proposed Changes

  • Delete commented out and unused code
  • Remove unused properties from FACE_SENSING_STATE
  • Mark private methods and properties with underscore for consistency
  • Add method/propery docs
  • Extract some generic methods to utils.js
  • Other minor improvements

Reason for Changes

Get the face sensing code ready for production

- Delete commented out and unused code
- Remove unused properties from FACE_SENSING_STATE
- Mark private methods and properties with underscore for consistency
- Add method/propery docs
- Extract some generic methods to utils.js
- Other minor improvements
@adzhindzhi adzhindzhi requested a review from a team as a code owner September 1, 2025 11:38
@adzhindzhi adzhindzhi requested a review from KManolov3 September 1, 2025 12:38
Copy link
Contributor

@KManolov3 KManolov3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much cleaner now :)

Comment on lines +1072 to +1081
/**
* Determine if the drawable is touching a rectangle.
*
* @param {int} drawableID The ID of the drawable to check.
* @param {int} left - The left X coordinate of the rectangle.
* @param {int} top - The top Y coordinate of the rectangle.
* @param {int} right - The right X coordinate of the rectangle.
* @param {int} bottom - The bottom Y coordinate of the rectangle.
* @returns {boolean} If the drawable has any pixels that would draw in the rectangle area
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎
If you run across missing or incorrect JSDoc that's making your life difficult, please feel very free to fix it up. Some of the JSDoc in here, especially in the VM and renderer, was written in the early days of JSDoc and (more importantly) the early days of our (at least my) understanding of JSDoc and JavaScript in general, so some of it is wrong or invalid, and a lot of it is just missing.

TL;DR: Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'd like to move to TS when and where it makes sense, but that's a long walk...)

@@ -232,7 +264,6 @@ class Scratch3FaceSensingBlocks {
blockType: BlockType.COMMAND,
filter: [TargetType.SPRITE]
},
'---',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these separators intentionally removed? It seems OK to me; just double-checking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separators were there by design and should not be removed - please put them back

Comment on lines +23 to +24
x: position.x - 240,
y: 180 - position.y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃

@@ -756,7 +756,7 @@ class RenderedTarget extends Target {
* Return whether touching a point.
* @param {number} x X coordinate of test point.
* @param {number} y Y coordinate of test point.
* @return {boolean} True iff the rendered target is touching the point.
* @return {boolean} True if the rendered target is touching the point.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with these changes, but just as an FYI, I think in each of these cases the "iff" was intended as an abbreviation for "if and only if" rather than being a typo. On the other hand, that's excessively fancy and maybe not even strictly true. Also—and this may be the strongest argument in favor of this change—red squiggly lines are annoying. :D

@ericrosenbaum
Copy link
Contributor

While we're fixing comments - in the extension index.js line 28 Class for the motion-related blocks in Scratch 3.0 should be fixed to say "Face Sensing blocks"

@ericrosenbaum
Copy link
Contributor

This is great so far - there are actually a few additional bits of code that can be removed. They are all related to the idea of "attachment," which I prototyped but decided not to use.

If you're interested, I talk about the different ideas we tried, including an "attach" block, and how we settled on the final design, in this talk from last year's Blockly summit.

The stop button event is wired up to _clearAttachments and that function uses _getFaceSensingState which uses DEFAULT_FACE_SENSING_STATE. All of that can be removed.

Copy link
Contributor

@ericrosenbaum ericrosenbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've suggested a couple of changes - they could also be done in a follow-up PR.

Copy link
Contributor

@ericrosenbaum ericrosenbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one last thing I found to remove is the STATE_KEY. Thanks!

@adzhindzhi adzhindzhi merged commit 257dc82 into scratchfoundation:UEPR-282-face-sensing Sep 11, 2025
7 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants