Skip to content

Commit 2d4e3a3

Browse files
committed
fix: revert unwanted cleanup and remove some additional unused code
1 parent 325c7ec commit 2d4e3a3

File tree

2 files changed

+8
-50
lines changed

2 files changed

+8
-50
lines changed

packages/scratch-vm/src/extensions/scratch3_face_sensing/index.js

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const ArgumentType = require('../../extension-support/argument-type');
22
const BlockType = require('../../extension-support/block-type');
3-
const Clone = require('../../util/clone');
43
const MathUtil = require('../../util/math-util');
54
const formatMessage = require('format-message');
65
const Video = require('../../io/video');
@@ -25,7 +24,7 @@ const menuIconURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iN
2524
const blockIconURI = 'data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQwIiB3aWR0aD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDIzLjg0IDIxLjQ2Ij4KICAgIDxjaXJjbGUgZmlsbD0iI2ZmZiIgY3g9IjguMzUiIGN5PSI5LjY1IiByPSIuOTciLz4KICAgIDxjaXJjbGUgZmlsbD0iI2ZmZiIgY3g9IjE0LjE5IiBjeT0iOS42NSIgcj0iLjk3Ii8+CiAgICA8cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTEuMjcsNC4xNGMtMy45NCwwLTcuMTMsMy4xOS03LjEzLDcuMTNzMy4xOSw3LjEzLDcuMTMsNy4xMyw3LjEzLTMuMTksNy4xMy03LjEzLTMuMTktNy4xMy03LjEzLTcuMTNaTTExLjI3LDUuNDRjMy4yMiwwLDUuODQsMi42MSw1Ljg0LDUuODRzLTIuNjEsNS44NC01Ljg0LDUuODQtNS44NC0yLjYxLTUuODQtNS44NCwyLjYxLTUuODQsNS44NC01Ljg0WiIvPgogICAgPHBhdGggZmlsbD0iI2ZmYmYwMCIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9I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w2LjA2Yy0uMzEsMC0uNTctLjI1LS41Ny0uNTd2LTMuMjloLTMuMzFjLS4zMSwwLS41Ny0uMjUtLjU3LS41N3MuMjUtLjU3LjU3LS41N2gzLjg4Yy4zMSwwLC41Ny4yNS41Ny41N3YzLjg2YzAsLjMxLS4yNS41Ny0uNTcuNTdaIi8+CiAgICA8cGF0aCBmaWxsPSIjMGI4ZTY5IiBkPSJNNS40NCwyMS40NkgxLjU5Yy0uMzEsMC0uNTctLjI1LS41Ny0uNTd2LTMuODJjMC0uMzEuMjUtLjU3LjU3LS41N3MuNTcuMjUuNTcuNTd2My4yNWgzLjI4Yy4zMSwwLC41Ny4yNS41Ny41N3MtLjI1LjU3LS41Ny41N1oiLz4KPC9zdmc+Cg==';
2625

2726
/**
28-
* Class for the motion-related blocks in Scratch 3.0
27+
* Class for the Face sensing blocks in Scratch 3.0
2928
* @param {Runtime} runtime - the runtime instantiating this block package.
3029
* @constructor
3130
*/
@@ -89,9 +88,6 @@ class Scratch3FaceSensingBlocks {
8988
this._loop();
9089
}
9190
});
92-
93-
this._clearAttachments = this._clearAttachments.bind(this);
94-
this.runtime.on('PROJECT_STOP_ALL', this._clearAttachments);
9591
}
9692

9793
/**
@@ -120,16 +116,6 @@ class Scratch3FaceSensingBlocks {
120116
return 'Scratch.faceSensing';
121117
}
122118

123-
/**
124-
* The default face sensing state, to be used when a target has no existing state.
125-
* @type {FaceSensingState}
126-
*/
127-
static get DEFAULT_FACE_SENSING_STATE () {
128-
return {
129-
attachedToPartNumber: null
130-
};
131-
}
132-
133119
/**
134120
* Maximum length of face detection history
135121
* @type {number}
@@ -191,25 +177,6 @@ class Scratch3FaceSensingBlocks {
191177
// if there's a mix of true and false values, do not change the result
192178
}
193179

194-
/**
195-
* Retrieve the face-sensing state for a given target.
196-
* If no state exists yet, clone the default and set it on the target.
197-
*
198-
* @param {Target} target - collect face sensing state for this target.
199-
* @returns {FaceSensingState} the face sensing state associated with that target.
200-
* @private
201-
*/
202-
_getFaceSensingState (target) {
203-
let faceSensingState = target.getCustomState(Scratch3FaceSensingBlocks.STATE_KEY);
204-
205-
if (!faceSensingState) {
206-
faceSensingState = Clone.simple(Scratch3FaceSensingBlocks.DEFAULT_FACE_SENSING_STATE);
207-
target.setCustomState(Scratch3FaceSensingBlocks.STATE_KEY, faceSensingState);
208-
}
209-
210-
return faceSensingState;
211-
}
212-
213180
/**
214181
* @returns {object} metadata for this extension and its blocks.
215182
*/
@@ -264,6 +231,7 @@ class Scratch3FaceSensingBlocks {
264231
blockType: BlockType.COMMAND,
265232
filter: [TargetType.SPRITE]
266233
},
234+
'---',
267235
{
268236
opcode: 'whenTilted',
269237
text: formatMessage({
@@ -306,6 +274,7 @@ class Scratch3FaceSensingBlocks {
306274
}),
307275
blockType: BlockType.HAT
308276
},
277+
'---',
309278
{
310279
opcode: 'faceIsDetected',
311280
text: formatMessage({
@@ -547,17 +516,6 @@ class Scratch3FaceSensingBlocks {
547516
const pos = this._getPartPosition(args.PART);
548517
util.target.setXY(pos.x, pos.y);
549518
}
550-
551-
/**
552-
* Reset any attachments between sprites and facial keypoints.
553-
* @private
554-
*/
555-
_clearAttachments () {
556-
this.runtime.targets.forEach(target => {
557-
const state = this._getFaceSensingState(target);
558-
state.attachedToPartNumber = null;
559-
});
560-
}
561519
}
562520

563521
module.exports = Scratch3FaceSensingBlocks;

packages/scratch-vm/src/sprites/rendered-target.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ class RenderedTarget extends Target {
756756
* Return whether touching a point.
757757
* @param {number} x X coordinate of test point.
758758
* @param {number} y Y coordinate of test point.
759-
* @return {boolean} True if the rendered target is touching the point.
759+
* @return {boolean} True iff the rendered target is touching the point.
760760
*/
761761
isTouchingPoint (x, y) {
762762
if (this.renderer) {
@@ -795,7 +795,7 @@ class RenderedTarget extends Target {
795795

796796
/**
797797
* Return whether touching a stage edge.
798-
* @return {boolean} True if the rendered target is touching the stage edge.
798+
* @return {boolean} True iff the rendered target is touching the stage edge.
799799
*/
800800
isTouchingEdge () {
801801
if (this.renderer) {
@@ -815,7 +815,7 @@ class RenderedTarget extends Target {
815815
/**
816816
* Return whether touching any of a named sprite's clones.
817817
* @param {string} spriteName Name of the sprite.
818-
* @return {boolean} True if touching a clone of the sprite.
818+
* @return {boolean} True iff touching a clone of the sprite.
819819
*/
820820
isTouchingSprite (spriteName) {
821821
spriteName = Cast.toString(spriteName);
@@ -835,7 +835,7 @@ class RenderedTarget extends Target {
835835
/**
836836
* Return whether touching a color.
837837
* @param {Array.<number>} rgb [r,g,b], values between 0-255.
838-
* @return {Promise.<boolean>} True if the rendered target is touching the color.
838+
* @return {Promise.<boolean>} True iff the rendered target is touching the color.
839839
*/
840840
isTouchingColor (rgb) {
841841
if (this.renderer) {
@@ -848,7 +848,7 @@ class RenderedTarget extends Target {
848848
* Return whether rendered target's color is touching a color.
849849
* @param {object} targetRgb {Array.<number>} [r,g,b], values between 0-255.
850850
* @param {object} maskRgb {Array.<number>} [r,g,b], values between 0-255.
851-
* @return {Promise.<boolean>} True if the color is touching the color.
851+
* @return {Promise.<boolean>} True iff the color is touching the color.
852852
*/
853853
colorIsTouchingColor (targetRgb, maskRgb) {
854854
if (this.renderer) {

0 commit comments

Comments
 (0)