@@ -376,6 +376,7 @@ self.onmessage = ({ data: msg }) => {
376376 resetLightsOnStart : false ,
377377 renderThread : 'worker' ,
378378 cameraFollow : false ,
379+ cameraFollowName : 'default' ,
379380 } ;
380381
381382 class LightExtension {
@@ -395,6 +396,7 @@ self.onmessage = ({ data: msg }) => {
395396 this . resetLightsOnStart = RENDER_DEFAULTS . resetLightsOnStart ;
396397 this . renderThread = RENDER_DEFAULTS . renderThread ;
397398 this . cameraFollow = RENDER_DEFAULTS . cameraFollow ;
399+ this . cameraFollowName = RENDER_DEFAULTS . cameraFollowName ;
398400
399401 this . inclusionMode = 'Blacklist' ;
400402 this . _inclusionList = [ ] ;
@@ -475,6 +477,7 @@ self.onmessage = ({ data: msg }) => {
475477 resetLightsOnStart : this . resetLightsOnStart ,
476478 renderThread : this . renderThread ,
477479 cameraFollow : this . cameraFollow ,
480+ cameraFollowName : this . cameraFollowName ,
478481 inclusionMode : this . inclusionMode ,
479482 inclusionList : [ ...this . _inclusionList ] ,
480483 } ;
@@ -497,6 +500,7 @@ self.onmessage = ({ data: msg }) => {
497500 this . colorTemp = pending . colorTemp ;
498501 this . resetLightsOnStart = pending . resetLightsOnStart ;
499502 this . cameraFollow = pending . cameraFollow ;
503+ this . cameraFollowName = pending . cameraFollowName ;
500504 this . inclusionMode = pending . inclusionMode ;
501505 this . _inclusionList = [ ...( pending . inclusionList || [ ] ) ] ;
502506 this . _markDirty ( ) ;
@@ -533,6 +537,7 @@ self.onmessage = ({ data: msg }) => {
533537 this . colorTemp = snapshot . colorTemp ;
534538 this . resetLightsOnStart = snapshot . resetLightsOnStart ;
535539 this . cameraFollow = snapshot . cameraFollow ;
540+ this . cameraFollowName = snapshot . cameraFollowName ;
536541 if ( this . renderThread !== snapshot . renderThread ) {
537542 this . renderThread = snapshot . renderThread ;
538543 this . _switchRenderThread ( this . renderThread ) ;
@@ -908,6 +913,7 @@ self.onmessage = ({ data: msg }) => {
908913 resetLightsOnStart : this . resetLightsOnStart ,
909914 renderThread : this . renderThread ,
910915 cameraFollow : this . cameraFollow ,
916+ cameraFollowName : this . cameraFollowName ,
911917 inclusionMode : this . inclusionMode ,
912918 inclusionList : [ ...this . _inclusionList ] ,
913919 } ;
@@ -935,6 +941,7 @@ self.onmessage = ({ data: msg }) => {
935941 this . _switchRenderThread ( this . renderThread ) ;
936942 }
937943 if ( typeof data . cameraFollow === 'boolean' ) this . cameraFollow = data . cameraFollow ;
944+ if ( typeof data . cameraFollowName === 'string' ) this . cameraFollowName = data . cameraFollowName ;
938945 if ( typeof data . inclusionMode === 'string' ) this . inclusionMode = data . inclusionMode ;
939946 if ( Array . isArray ( data . inclusionList ) ) this . _inclusionList = data . inclusionList ;
940947 this . _markDirty ( ) ;
@@ -1313,7 +1320,7 @@ self.onmessage = ({ data: msg }) => {
13131320 const runtime = Scratch . vm . runtime ;
13141321 if ( typeof runtime . getCamera !== 'function' ) return null ;
13151322 try {
1316- return runtime . getCamera ( 'default' ) ;
1323+ return runtime . getCamera ( this . cameraFollowName || 'default' ) ;
13171324 } catch ( e ) {
13181325 return null ;
13191326 }
@@ -1324,6 +1331,11 @@ self.onmessage = ({ data: msg }) => {
13241331 this . _markDirty ( ) ;
13251332 }
13261333
1334+ setCameraFollowName ( args ) {
1335+ this . cameraFollowName = Scratch . Cast . toString ( args . NAME ) || 'default' ;
1336+ this . _markDirty ( ) ;
1337+ }
1338+
13271339 _fillUBOData ( w , h ) {
13281340 const lights = Object . values ( this . lights ) ;
13291341 const n = lights . length ;
@@ -1598,6 +1610,7 @@ self.onmessage = ({ data: msg }) => {
15981610 this . colorTemp = RENDER_DEFAULTS . colorTemp ;
15991611 this . resetLightsOnStart = RENDER_DEFAULTS . resetLightsOnStart ;
16001612 this . cameraFollow = RENDER_DEFAULTS . cameraFollow ;
1613+ this . cameraFollowName = RENDER_DEFAULTS . cameraFollowName ;
16011614 this . renderThread = RENDER_DEFAULTS . renderThread ;
16021615 this . _switchRenderThread ( this . renderThread ) ;
16031616 this . _saveRenderSettings ( ) ;
@@ -1631,6 +1644,8 @@ self.onmessage = ({ data: msg }) => {
16311644 return this . renderThread ;
16321645 case 'cameraFollow' :
16331646 return this . cameraFollow ? 'on' : 'off' ;
1647+ case 'cameraFollowName' :
1648+ return this . cameraFollowName ;
16341649 default :
16351650 return '' ;
16361651 }
@@ -1725,6 +1740,18 @@ self.onmessage = ({ data: msg }) => {
17251740 }
17261741 }
17271742 } ,
1743+ {
1744+ opcode : 'setCameraFollowName' ,
1745+ blockType : Scratch . BlockType . COMMAND ,
1746+ hideFromPalette : ! isPenguinMod ,
1747+ text : 'set camera to follow [NAME]' ,
1748+ arguments : {
1749+ NAME : {
1750+ type : Scratch . ArgumentType . STRING ,
1751+ defaultValue : 'default'
1752+ }
1753+ }
1754+ } ,
17281755 '---' ,
17291756 '---' ,
17301757 {
@@ -2183,7 +2210,7 @@ self.onmessage = ({ data: msg }) => {
21832210 } ,
21842211 settingMenu : {
21852212 acceptReporters : false ,
2186- items : [ 'shadowOpacity' , 'ambient' , 'bloomAmount' , 'bloomRadius' , 'bloomThreshold' , 'pixelated' , 'pixelSize' , 'contrast' , 'colorTemp' , 'resetLightsOnStart' , 'renderThread' , 'cameraFollow' ]
2213+ items : [ 'shadowOpacity' , 'ambient' , 'bloomAmount' , 'bloomRadius' , 'bloomThreshold' , 'pixelated' , 'pixelSize' , 'contrast' , 'colorTemp' , 'resetLightsOnStart' , 'renderThread' , 'cameraFollow' , 'cameraFollowName' ]
21872214 } ,
21882215 renderThreadMenu : {
21892216 acceptReporters : false ,
0 commit comments