Skip to content
Merged
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
13 changes: 8 additions & 5 deletions 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.1
// Version V.1.0.11

(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 @@ -278,14 +278,17 @@
render.exports.Drawable.prototype.updateVisible = function (isVisible) {
if (!this[cameraSymbol]) setupState(this);
if (isVisible && this._visible !== isVisible) {
const camSystem = this[cameraSymbol];
const safeOgSZ = camSystem.ogSZ !== 0 ? camSystem.ogSZ : 1e-10;
const updatedScale = [this.scale[0] / safeOgSZ, this.scale[1] / safeOgSZ];

// save some renderer calls, packing this all into one
// while running only when isVisible is true combines this
// into a single renderer call
Copy link
Member

Choose a reason for hiding this comment

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

this doesnt matter but updateProperties is not faster, it just calls updatePosition etc. one-by-one

this[cameraSymbol].needsRefresh = true;
this.updateProperties({
position: this._position,
direction: this._direction,
scale: this.scale,
position: translatePosition(this._position, true, camSystem),
direction: this._direction + camSystem.ogDir,
scale: updatedScale,
});
}
ogUpdateVisible.call(this, isVisible);
Expand All @@ -309,7 +312,7 @@
runtime.on("PROJECT_LOADED", () => {
const stored = runtime.extensionStorage["SPcamera"];
if (stored)
stored.cams.forEach((cam) => {

Check warning on line 315 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 @@ -645,12 +648,12 @@
});
objectNames.push({ text: Scratch.translate("Stage"), value: "_stage_" });

if (runtime.ext_videoSensing)

Check warning on line 651 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 656 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