Skip to content

Commit

Permalink
Merge branch 'TurboWarp:master' into midi
Browse files Browse the repository at this point in the history
  • Loading branch information
Brackets-Coder authored Nov 4, 2024
2 parents 9014297 + fedbe62 commit 43a5839
Show file tree
Hide file tree
Showing 14 changed files with 741 additions and 338 deletions.
12 changes: 6 additions & 6 deletions development/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,12 +860,12 @@ class Builder {
chokidar
.watch(
[
`${this.extensionsRoot}/**/*`,
`${this.imagesRoot}/**/*`,
`${this.websiteRoot}/**/*`,
`${this.docsRoot}/**/*`,
`${this.samplesRoot}/**/*`,
`${this.translationsRoot}/**/*`,
this.extensionsRoot,
this.imagesRoot,
this.websiteRoot,
this.docsRoot,
this.samplesRoot,
this.translationsRoot,
],
{
ignoreInitial: true,
Expand Down
51 changes: 49 additions & 2 deletions docs/Xeltalliv/simple3D.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
7. [Integration with other extensions](#ext-integration)
7.1. [Augmented Reality extension](#ar-integration)


## What is this <a name="description"></a>
**Simple 3D** is an extension by [Vadik1](https://scratch.mit.edu/users/Vadik1) meant to enable creation of GPU accelerated 3D projects. It is not designed for making graphically complex 3D projects (for that, see [Pen+ v7](https://github.com/TurboWarp/extensions/pull/1377) and [WebGL2](https://github.com/TurboWarp/extensions/discussions/378) extensions, both with programmable shaders) and instead it's main focus is allowing people to create 3D projects easily and quickly. Nevertheless, despite lack of programmable shaders, it is still quite powerful. It covers the wide range of usages from something as high level as making an [AR project in less than 20 blocks](#ar-example) with models loaded from OBJ files, to something more low level like doing all the calculations on CPU and streaming transformed polygons every frame (like [Pen+](https://extensions.turbowarp.org/obviousAlexC/penPlus.js)). And of course everything in-between.

Expand All @@ -41,6 +42,8 @@ So in short, **this extension does not have any kind of scenes, objects, cameras
3D models consist of vertices which together form primitives (points, lines, triangles). Each vertex has either 2D (XY) or 3D (XYZ) location described with 2 or 3 numbers respectively. Before drawing the mesh, you would usually set up transformation, which tells how to take those initial locations and transform them to correct location on your 2D screen. The typical way to do it, is to chain multiple simple transformations together. Simple transformations can be translation (offsetting), rotation, scaling, mirroring, skewing, etc.

## Drawing things <a name="simple-drawing"></a>
**Note:** For a more complete tutorial, see [here](https://xeltalliv.github.io/simple3d-extension/examples/) (external link).

For now let's not worry about transformations and just draw something as is.
First step would be to clear the screen:
```scratch
Expand Down Expand Up @@ -450,11 +453,12 @@ Length of supplied indices and weights lists have to match and be divisible by "
---
```scratch
set [my mesh] [original v] transforms [listTransforms v] :: sensing
set [my mesh] [current v] transforms [listTransforms v] :: sensing
```
Used for setting original and current transforms of each bone.
Transforms on how to get from original to current will be calculated and applied to vertices based on their bone indices and weights.
Supplied list of transforms must have length divisible by 16. If not, operation fails.
When setting one of the transforms, while the other one is not defined or has different length, the one being set will be set to both.
Setting original transforms is optional. Missing original transforms are treated as empty transforms.

---
```scratch
Expand Down Expand Up @@ -668,7 +672,19 @@ Use partial updates to add any extra polygons after the range that is being draw
To remove polygons, move the ones from the end of the drawing range to location of the remove one and then shring the drawing
range at the end.

Deafult for mesh is not set. Once set, cannot be undone.
Default for mesh is not set. Once set, cannot be undone.

---
```scratch
set [my mesh] instance draw limit (10) :: sensing
```
Normally, how many instances are drawn is determined by the length of supplied lists.
This block can be used to limit the amount of instances drawn to an even lower number.
This can be useful together with partial list updates to be able to dynamically change amount of drawn instances without having to reupload the entire list. That is, preallocating space for some amount of instances in advance, but drawing less. When new instance needs to be added, using partial updates to update the instance data of the next unused instance and then increasing the limit by 1. To remove an instance, the last instance can be moved in it's place and then the limit reduced by 1.

Setting to any value below 1 is equivalent to setting it to Infinity.

Default for mesh is Infinity.

---
```scratch
Expand Down Expand Up @@ -903,6 +919,37 @@ Internally extension stores everything with premultiplied alpha. When reading th
```
Allows reading properties of the current render target.

---
```scratch
set [viewport box v] to X1:(0) Y1:(0) X2:(100) Y2:(100) :: sensing
set [clipping box v] to X1:(0) Y1:(0) X2:(100) Y2:(100) :: sensing
set [readback box v] to X1:(0) Y1:(0) X2:(100) Y2:(100) :: sensing
```
Configures custom rectangular areas for different purposes for the currently active render target.
Viewport box specifies the area to which the rendered image will be stretched to cover from it's normal -1 to 1 range.
Clipping box specifies the area in which pixels are allowed to be modified.
Readback box specifies the area from which reading to list and reading to data URI blocks will read the pixels.

Note: coordinates are specified in **real pixels** starting from the bottom left corner, **not scratch units**. You can get the size of the Simple3D layer in pixels from either:
```scratch
(stage width :: sensing)
(stage height :: sensing)
(render target [width v] :: sensing)
(render target [height v] :: sensing)
```
And while it may match scratch units while the high quality pen is disabled, when **high quality pen is on**, the resolution will often be higher. Your projects need to account for that.

Note: Those custom areas can either be set or not set. When they aren't set, they use X1:`0` Y1:`0` X2:`render target width` Y2:`render target height` and automatically update with resolution changes. If you set them to custom values, you need to handle rescaling manually.

---
```scratch
clear [viewport box v] :: sensing
clear [clipping box v] :: sensing
clear [readback box v] :: sensing
```
Removes the custom rectangular areas configured by the block described above.


### Tinting and fog <a name="blocks-tinting-fog"></a>
```scratch
Expand Down
7 changes: 4 additions & 3 deletions extensions/Lily/lmsutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1240,19 +1240,20 @@
}

equalsExactly(args) {
// Intentionally not using Cast
return args.ONE === args.TWO;
}

notEqualTo(args) {
return args.INPUTA != args.INPUTB;
return Scratch.Cast.compare(args.INPUTA, args.INPUTB) !== 0;
}

moreThanEqual(args) {
return args.INPUTA >= args.INPUTB;
return Scratch.Cast.compare(args.INPUTA, args.INPUTB) >= 0;
}

lessThanEqual(args) {
return args.INPUTA <= args.INPUTB;
return Scratch.Cast.compare(args.INPUTA, args.INPUTB) <= 0;
}

stringCheckBoolean(args) {
Expand Down
63 changes: 50 additions & 13 deletions extensions/SharkPool/Font-Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@
arguments: {
NAME: {
type: Scratch.ArgumentType.STRING,
defaultValue: "Pusab",
defaultValue: "Lobster",
},
URL: {
type: Scratch.ArgumentType.STRING,
defaultValue: "",
defaultValue: "https://extensions.turbowarp.org/Lobster.woff2",
},
BACKUP: {
type: Scratch.ArgumentType.STRING,
Expand Down Expand Up @@ -236,15 +236,52 @@
},
],
},
FALLBACKS: [
"Sans Serif",
"Serif",
"Handwriting",
"Marker",
"Curly",
"Pixel",
"Scratch",
],
FALLBACKS: {
acceptReporters: false,
items: [
{
text: "Sans Serif",
value: "Sans Serif",
},
{
text: "Serif",
value: "Serif",
},
{
text: "Handwriting",
value: "Handwriting",
},
{
text: "Marker",
value: "Marker",
},
{
text: "Curly",
value: "Curly",
},
{
text: "Pixel",
value: "Pixel",
},
{
text: "Mopeds",
value: "Scratch",
},
{
text: "中文",
value: '"Microsoft YaHei", "微软雅黑", STXihei, "华文细黑"',
},
{
text: "한국어",
value: "Malgun Gothic",
},
{
text: "日本語",
value:
'"ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic"',
},
],
},
FILES: {
acceptReporters: true,
items: FONT_EXTENSIONS.map((i) => `.${i}`),
Expand Down Expand Up @@ -280,14 +317,14 @@

addSystemFont(args) {
const name = Scratch.Cast.toString(args.NAME);
if (fontManager.isValidFamily(name)) {
if (fontManager.isValidSystemFont(name)) {
fontManager.addSystemFont(name, Scratch.Cast.toString(args.BACKUP));
}
}

async addCustomFont(args) {
const name = Scratch.Cast.toString(args.NAME);
if (!fontManager.isValidFamily(name)) {
if (!fontManager.isValidCustomFont(name)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/Skyhigh173/bigint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Name: BigInt
// ID: skyhigh173BigInt
// Description: Math blocks that work on infinitely large integers (no decimals).
// By: Skyhigh173
// By: Skyhigh173 <https://scratch.mit.edu/users/Skyhigh173/>
// License: MIT
// Context: BigInt is short for "Big Integer" which can be infinitely big. "number" refers to normal numbers that have limits.

Expand Down
2 changes: 1 addition & 1 deletion extensions/Skyhigh173/json.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Name: JSON
// ID: skyhigh173JSON
// Description: Handle JSON strings and arrays.
// By: Skyhigh173
// By: Skyhigh173 <https://scratch.mit.edu/users/Skyhigh173/>
// License: MIT

(function (Scratch) {
Expand Down
Loading

0 comments on commit 43a5839

Please sign in to comment.