11const ArgumentType = require ( '../../extension-support/argument-type' ) ;
22const BlockType = require ( '../../extension-support/block-type' ) ;
3- const Clone = require ( '../../util/clone' ) ;
43const MathUtil = require ( '../../util/math-util' ) ;
54const formatMessage = require ( 'format-message' ) ;
65const Video = require ( '../../io/video' ) ;
@@ -25,7 +24,7 @@ const menuIconURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iN
2524const blockIconURI = 'data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQwIiB3aWR0aD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDIzLjg0IDIxLjQ2Ij4KICAgIDxjaXJjbGUgZmlsbD0iI2ZmZiIgY3g9IjguMzUiIGN5PSI5LjY1IiByPSIuOTciLz4KICAgIDxjaXJjbGUgZmlsbD0iI2ZmZiIgY3g9IjE0LjE5IiBjeT0iOS42NSIgcj0iLjk3Ii8+CiAgICA8cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTEuMjcsNC4xNGMtMy45NCwwLTcuMTMsMy4xOS03LjEzLDcuMTNzMy4xOSw3LjEzLDcuMTMsNy4xMyw3LjEzLTMuMTksNy4xMy03LjEzLTMuMTktNy4xMy03LjEzLTcuMTNaTTExLjI3LDUuNDRjMy4yMiwwLDUuODQsMi42MSw1Ljg0LDUuODRzLTIuNjEsNS44NC01Ljg0LDUuODQtNS44NC0yLjYxLTUuODQtNS44NCwyLjYxLTUuODQsNS44NC01Ljg0WiIvPgogICAgPHBhdGggZmlsbD0iI2ZmYmYwMCIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9IiMwYjhlNjkiIHN0cm9rZS1taXRlcmxpbWl0PSIyIiBzdHJva2Utd2lkdGg9Ii41cHgiIGQ9Ik0xNy41NywxMy44OGMuNTctLjE1LDEuMDItLjYsMS4xNy0xLjE3bC4zNS0xLjNjLjE2LS42MSwxLjA0LS42MSwxLjIsMGwuMz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uNTdaIi8+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
563521module . exports = Scratch3FaceSensingBlocks ;
0 commit comments