Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion extensions/SharkPool/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// By: SharkPool
// License: MIT

// Version V.1.0.09
// Version V.1.0.1

(function (Scratch) {
"use strict";
Expand Down Expand Up @@ -43,7 +43,7 @@
// custom gui
function openModal(titleName, func) {
// in a Button Context, ScratchBlocks always exists
ScratchBlocks.prompt(

Check warning on line 46 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Property 'prompt' does not exist on type 'typeof ScratchBlocks'.
titleName,
"",
(value) => func(value),
Expand Down Expand Up @@ -114,9 +114,9 @@
};

const id = drawable._id;
render.updateDrawablePosition(id, fixedPos);

Check warning on line 117 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type 'any[]' is not assignable to parameter of type '[number, number]'. Target requires 2 element(s) but source may have fewer.
render.updateDrawableDirection(id, fixedDir);
render.updateDrawableScale(id, fixedScale);

Check warning on line 119 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type 'number[]' is not assignable to parameter of type '[number, number]'. Target requires 2 element(s) but source may have fewer.
}

function updateCamera(camera) {
Expand All @@ -129,9 +129,9 @@
const camSystem = drawable[cameraSymbol];
if (camSystem.name === camera) {
camSystem.needsRefresh = true;
drawable.updatePosition(drawable._position);

Check warning on line 132 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type 'V3' is not assignable to parameter of type '[number, number]'.
drawable.updateDirection(drawable._direction);
drawable.updateScale(drawable._scale);

Check warning on line 134 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type 'V3' is not assignable to parameter of type 'number'.
camSystem.needsRefresh = false;
}
}
Expand All @@ -151,8 +151,8 @@
ogPostSpriteInfo.call(this, data);
};

const ogPositionBubble = runtime.ext_scratch3_looks._positionBubble;

Check warning on line 154 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Property 'ext_scratch3_looks' does not exist on type 'Runtime'.
runtime.ext_scratch3_looks._positionBubble = function (target) {

Check warning on line 155 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Property 'ext_scratch3_looks' does not exist on type 'Runtime'.
// Expand the Bubble Limits to a Infinite Stage size if the camera
// goes beyond the set stage size
const drawable = render._allDrawables[target.drawableID];
Expand Down Expand Up @@ -274,6 +274,23 @@
}
};

const ogUpdateVisible = render.exports.Drawable.prototype.updateVisible;
render.exports.Drawable.prototype.updateVisible = function (isVisible) {
if (!this[cameraSymbol]) setupState(this);
if (isVisible) {
// save some renderer calls, packing this all into one
// while running only when isVisible is true combines this
// into a single renderer call
this[cameraSymbol].needsRefresh = true;
this.updateProperties({
position: this._position,
direction: this._direction,
scale: this.scale,
});
}
ogUpdateVisible.call(this, isVisible);
};

// Clones should inherit the parents camera
const ogInitDrawable = vm.exports.RenderedTarget.prototype.initDrawable;
vm.exports.RenderedTarget.prototype.initDrawable = function (layerGroup) {
Expand All @@ -292,7 +309,7 @@
runtime.on("PROJECT_LOADED", () => {
const stored = runtime.extensionStorage["SPcamera"];
if (stored)
stored.cams.forEach((cam) => {

Check warning on line 312 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Property 'cams' does not exist on type 'string | number | true | JSONSerializable[] | { [key: string]: JSONSerializable; }'. Property 'cams' does not exist on type 'string'.
allCameras[cam] = {
xy: [0, 0],
zoom: 1,
Expand Down Expand Up @@ -628,12 +645,12 @@
});
objectNames.push({ text: Scratch.translate("Stage"), value: "_stage_" });

if (runtime.ext_videoSensing)

Check warning on line 648 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Property 'ext_videoSensing' does not exist on type 'Runtime'.
objectNames.push({
text: Scratch.translate("video layer"),
value: "_video_",
});
if (runtime.ext_pen)

Check warning on line 653 in extensions/SharkPool/Camera.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Property 'ext_pen' does not exist on type 'Runtime'.
objectNames.push({
text: Scratch.translate("pen layer"),
value: "_pen_",
Expand Down