p5 1.11.9 → 1.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/lib/p5.js +62 -60
- package/lib/p5.min.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,6 +102,7 @@ Lead/Mentor Alumni
|
|
|
102
102
|
| Graphics (p5.strands) | [@lukeplowden](https://github.com/lukeplowden) |
|
|
103
103
|
| Graphics (WebGL) | [@RandomGamingDev](https://github.com/RandomGamingDev), [@aferriss](https://github.com/aferriss), [@davepagurek](https://github.com/davepagurek), [@lukeplowden](https://github.com/lukeplowden), [@perminder-17](https://github.com/perminder-17) |
|
|
104
104
|
| i18n (hi) | [@Divyansh013](https://github.com/Divyansh013), [@takshittt](https://github.com/takshittt) |
|
|
105
|
+
| i18n (ko) | [@hana-cho](https://github.com/hana-cho) |
|
|
105
106
|
| i18n (zh) | [@limzykenneth](https://github.com/limzykenneth), [@lirenjie95](https://github.com/lirenjie95) |
|
|
106
107
|
| Math | [@GregStanton](https://github.com/GregStanton), [@holomorfo](https://github.com/holomorfo) |
|
|
107
108
|
| p5.js-website | [@clairep94](https://github.com/clairep94), [@ksen0](https://github.com/ksen0) |
|
|
@@ -112,7 +113,7 @@ Lead/Mentor Alumni
|
|
|
112
113
|
|
|
113
114
|
## Contributors
|
|
114
115
|
|
|
115
|
-
We recognize all types of contributions. This project follows the [all-contributors specification](https://github.com/all-contributors/all-contributors) and the [Emoji Key](https://
|
|
116
|
+
We recognize all types of contributions. This project follows the [all-contributors specification](https://github.com/all-contributors/all-contributors) and the [Emoji Key](https://github.com/all-contributors/all-contributors/blob/master/docs/emoji-key.md) ✨ for contribution types. Instructions to add yourself or add contribution emojis to your name are [here](https://github.com/processing/p5.js/issues/2309). You can also post an issue or comment on a pull request with the text: `@all-contributors please add @YOUR-USERNAME for THINGS` (where `THINGS` is a comma-separated list of entries from the [list of possible contribution types](https://github.com/all-contributors/all-contributors/blob/master/docs/emoji-key.md)) and our nice bot will add you.
|
|
116
117
|
|
|
117
118
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
118
119
|
<!-- prettier-ignore-start -->
|
|
@@ -1163,6 +1164,17 @@ We recognize all types of contributions. This project follows the [all-contribut
|
|
|
1163
1164
|
<td align="center" valign="top" width="16.66%"><a href="https://github.com/shivasankaran18"><img src="https://avatars.githubusercontent.com/u/148421597?v=4?s=64" width="64px;" alt="Shiva"/><br /><sub><b>Shiva</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=shivasankaran18" title="Documentation">📖</a></td>
|
|
1164
1165
|
<td align="center" valign="top" width="16.66%"><a href="https://github.com/madhav2348"><img src="https://avatars.githubusercontent.com/u/161720210?v=4?s=64" width="64px;" alt="Madhav Majumdar"/><br /><sub><b>Madhav Majumdar</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=madhav2348" title="Code">💻</a></td>
|
|
1165
1166
|
<td align="center" valign="top" width="16.66%"><a href="https://github.com/nking07049925"><img src="https://avatars.githubusercontent.com/u/11886663?v=4?s=64" width="64px;" alt="Nikita Korol"/><br /><sub><b>Nikita Korol</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=nking07049925" title="Code">💻</a></td>
|
|
1167
|
+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/skools-here"><img src="https://avatars.githubusercontent.com/u/174816600?v=4?s=64" width="64px;" alt="skools-here"/><br /><sub><b>skools-here</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=skools-here" title="Code">💻</a></td>
|
|
1168
|
+
<td align="center" valign="top" width="16.66%"><a href="https://leetcode.com/u/mudit_mah/"><img src="https://avatars.githubusercontent.com/u/140621191?v=4?s=64" width="64px;" alt="Mudit Maheshwari"/><br /><sub><b>Mudit Maheshwari</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=mudit06mah" title="Documentation">📖</a></td>
|
|
1169
|
+
<td align="center" valign="top" width="16.66%"><a href="http://acgillette.net"><img src="https://avatars.githubusercontent.com/u/18038450?v=4?s=64" width="64px;" alt="AC"/><br /><sub><b>AC</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=acgillette" title="Code">💻</a></td>
|
|
1170
|
+
</tr>
|
|
1171
|
+
<tr>
|
|
1172
|
+
<td align="center" valign="top" width="16.66%"><a href="https://darrenshaw.org"><img src="https://avatars.githubusercontent.com/u/157414?v=4?s=64" width="64px;" alt="Darren Shaw"/><br /><sub><b>Darren Shaw</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=shawdm" title="Documentation">📖</a></td>
|
|
1173
|
+
<td align="center" valign="top" width="16.66%"><a href="http://ericrabinowitz.com/"><img src="https://avatars.githubusercontent.com/u/3066943?v=4?s=64" width="64px;" alt="Eric Rabinowitz"/><br /><sub><b>Eric Rabinowitz</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=ericrav" title="Documentation">📖</a></td>
|
|
1174
|
+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/abuharish02"><img src="https://avatars.githubusercontent.com/u/111338069?v=4?s=64" width="64px;" alt="Abu Harish Faridi"/><br /><sub><b>Abu Harish Faridi</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=abuharish02" title="Documentation">📖</a></td>
|
|
1175
|
+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/vivekbopaliya"><img src="https://avatars.githubusercontent.com/u/122638553?v=4?s=64" width="64px;" alt="Vivek"/><br /><sub><b>Vivek</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=vivekbopaliya" title="Code">💻</a> <a href="#design-vivekbopaliya" title="Design">🎨</a> <a href="#userTesting-vivekbopaliya" title="User Testing">📓</a> <a href="#blog-vivekbopaliya" title="Blogposts">📝</a></td>
|
|
1176
|
+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Iron-56"><img src="https://avatars.githubusercontent.com/u/79905912?v=4?s=64" width="64px;" alt="Nandu Krishna"/><br /><sub><b>Nandu Krishna</b></sub></a><br /><a href="https://github.com/processing/p5.js/issues?q=author%3AIron-56" title="Bug reports">🐛</a> <a href="https://github.com/processing/p5.js/commits?author=Iron-56" title="Code">💻</a></td>
|
|
1177
|
+
<td align="center" valign="top" width="16.66%"><a href="https://dorinetipo.vercel.app/"><img src="https://avatars.githubusercontent.com/u/105214329?v=4?s=64" width="64px;" alt="Dorine Tipo "/><br /><sub><b>Dorine Tipo </b></sub></a><br /><a href="#blog-MissTipo" title="Blogposts">📝</a> <a href="https://github.com/processing/p5.js/commits?author=MissTipo" title="Code">💻</a> <a href="#eventOrganizing-MissTipo" title="Event Organizing">📋</a> <a href="#research-MissTipo" title="Research">🔬</a> <a href="#promotion-MissTipo" title="Promotion">📣</a> <a href="#tutorial-MissTipo" title="Tutorials">✅</a></td>
|
|
1166
1178
|
</tr>
|
|
1167
1179
|
</tbody>
|
|
1168
1180
|
</table>
|
package/lib/p5.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! p5.js v1.11.
|
|
1
|
+
/*! p5.js v1.11.10 August 23, 2025 */
|
|
2
2
|
(function (f) {
|
|
3
3
|
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
4
4
|
module.exports = f()
|
|
@@ -1504,22 +1504,22 @@
|
|
|
1504
1504
|
'params': [
|
|
1505
1505
|
{
|
|
1506
1506
|
'name': 'a',
|
|
1507
|
-
'description': '<p>coordinate of first
|
|
1507
|
+
'description': '<p>coordinate of first anchor point.</p>\n',
|
|
1508
1508
|
'type': 'Number'
|
|
1509
1509
|
},
|
|
1510
1510
|
{
|
|
1511
1511
|
'name': 'b',
|
|
1512
|
-
'description': '<p>coordinate of first
|
|
1512
|
+
'description': '<p>coordinate of first control point.</p>\n',
|
|
1513
1513
|
'type': 'Number'
|
|
1514
1514
|
},
|
|
1515
1515
|
{
|
|
1516
1516
|
'name': 'c',
|
|
1517
|
-
'description': '<p>coordinate of second
|
|
1517
|
+
'description': '<p>coordinate of second control point.</p>\n',
|
|
1518
1518
|
'type': 'Number'
|
|
1519
1519
|
},
|
|
1520
1520
|
{
|
|
1521
1521
|
'name': 'd',
|
|
1522
|
-
'description': '<p>coordinate of second
|
|
1522
|
+
'description': '<p>coordinate of second anchor point.</p>\n',
|
|
1523
1523
|
'type': 'Number'
|
|
1524
1524
|
},
|
|
1525
1525
|
{
|
|
@@ -1709,22 +1709,22 @@
|
|
|
1709
1709
|
'params': [
|
|
1710
1710
|
{
|
|
1711
1711
|
'name': 'a',
|
|
1712
|
-
'description': '<p>coordinate of first
|
|
1712
|
+
'description': '<p>coordinate of first control point.</p>\n',
|
|
1713
1713
|
'type': 'Number'
|
|
1714
1714
|
},
|
|
1715
1715
|
{
|
|
1716
1716
|
'name': 'b',
|
|
1717
|
-
'description': '<p>coordinate of first
|
|
1717
|
+
'description': '<p>coordinate of first anchor point.</p>\n',
|
|
1718
1718
|
'type': 'Number'
|
|
1719
1719
|
},
|
|
1720
1720
|
{
|
|
1721
1721
|
'name': 'c',
|
|
1722
|
-
'description': '<p>coordinate of second
|
|
1722
|
+
'description': '<p>coordinate of second anchor point.</p>\n',
|
|
1723
1723
|
'type': 'Number'
|
|
1724
1724
|
},
|
|
1725
1725
|
{
|
|
1726
1726
|
'name': 'd',
|
|
1727
|
-
'description': '<p>coordinate of second
|
|
1727
|
+
'description': '<p>coordinate of second control point.</p>\n',
|
|
1728
1728
|
'type': 'Number'
|
|
1729
1729
|
},
|
|
1730
1730
|
{
|
|
@@ -54037,17 +54037,11 @@
|
|
|
54037
54037
|
var noCols = 10;
|
|
54038
54038
|
var x = args[0];
|
|
54039
54039
|
var y = args[1];
|
|
54040
|
-
if (x < 0 || x >= canvasWidth || y < 0 || y >= canvasHeight) {
|
|
54041
|
-
return null;
|
|
54042
|
-
}
|
|
54043
54040
|
var locX = Math.floor(x / canvasWidth * noRows);
|
|
54044
54041
|
var locY = Math.floor(y / canvasHeight * noCols);
|
|
54045
|
-
|
|
54046
|
-
|
|
54047
|
-
|
|
54048
|
-
if (locY === noCols) {
|
|
54049
|
-
locY = locY - 1;
|
|
54050
|
-
}
|
|
54042
|
+
// clamp out of bounds values
|
|
54043
|
+
locX = Math.min(Math.max(locX, 0), noRows - 1);
|
|
54044
|
+
locY = Math.min(Math.max(locY, 0), noCols - 1);
|
|
54051
54045
|
return {
|
|
54052
54046
|
locX: locX,
|
|
54053
54047
|
locY: locY
|
|
@@ -59315,7 +59309,7 @@
|
|
|
59315
59309
|
* @property {String} VERSION
|
|
59316
59310
|
* @final
|
|
59317
59311
|
*/
|
|
59318
|
-
var VERSION = '1.11.
|
|
59312
|
+
var VERSION = '1.11.10';
|
|
59319
59313
|
// GRAPHICS RENDERER
|
|
59320
59314
|
/**
|
|
59321
59315
|
* The default, two-dimensional renderer.
|
|
@@ -75059,10 +75053,10 @@
|
|
|
75059
75053
|
* between them.
|
|
75060
75054
|
*
|
|
75061
75055
|
* @method bezierPoint
|
|
75062
|
-
* @param {Number} a coordinate of first
|
|
75063
|
-
* @param {Number} b coordinate of first
|
|
75064
|
-
* @param {Number} c coordinate of second
|
|
75065
|
-
* @param {Number} d coordinate of second
|
|
75056
|
+
* @param {Number} a coordinate of first anchor point.
|
|
75057
|
+
* @param {Number} b coordinate of first control point.
|
|
75058
|
+
* @param {Number} c coordinate of second control point.
|
|
75059
|
+
* @param {Number} d coordinate of second anchor point.
|
|
75066
75060
|
* @param {Number} t amount to interpolate between 0 and 1.
|
|
75067
75061
|
* @return {Number} coordinate of the point on the curve.
|
|
75068
75062
|
*
|
|
@@ -75647,10 +75641,10 @@
|
|
|
75647
75641
|
* between them.
|
|
75648
75642
|
*
|
|
75649
75643
|
* @method curvePoint
|
|
75650
|
-
* @param {Number} a coordinate of first
|
|
75651
|
-
* @param {Number} b coordinate of first
|
|
75652
|
-
* @param {Number} c coordinate of second
|
|
75653
|
-
* @param {Number} d coordinate of second
|
|
75644
|
+
* @param {Number} a coordinate of first control point.
|
|
75645
|
+
* @param {Number} b coordinate of first anchor point.
|
|
75646
|
+
* @param {Number} c coordinate of second anchor point.
|
|
75647
|
+
* @param {Number} d coordinate of second control point.
|
|
75654
75648
|
* @param {Number} t amount to interpolate between 0 and 1.
|
|
75655
75649
|
* @return {Number} coordinate of a point on the curve.
|
|
75656
75650
|
*
|
|
@@ -90243,6 +90237,11 @@
|
|
|
90243
90237
|
*
|
|
90244
90238
|
* Note: `movedX` continues updating even when
|
|
90245
90239
|
* <a href="#/p5/requestPointerLock">requestPointerLock()</a> is active.
|
|
90240
|
+
* But keep in mind that during an active pointer lock, mouseX and pmouseX
|
|
90241
|
+
* are locked, so `movedX` is based on
|
|
90242
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX">the MouseEvent's movementX value</a>
|
|
90243
|
+
* (which may behave differently in different browsers when the user
|
|
90244
|
+
* is zoomed in or out).
|
|
90246
90245
|
*
|
|
90247
90246
|
* @property {Number} movedX
|
|
90248
90247
|
* @readOnly
|
|
@@ -90288,6 +90287,11 @@
|
|
|
90288
90287
|
*
|
|
90289
90288
|
* Note: `movedY` continues updating even when
|
|
90290
90289
|
* <a href="#/p5/requestPointerLock">requestPointerLock()</a> is active.
|
|
90290
|
+
* But keep in mind that during an active pointer lock, mouseX and pmouseX
|
|
90291
|
+
* are locked, so `movedX` is based on
|
|
90292
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX">the MouseEvent's movementX value</a>
|
|
90293
|
+
* (which may behave differently in different browsers when the user
|
|
90294
|
+
* is zoomed in or out).
|
|
90291
90295
|
*
|
|
90292
90296
|
* @property {Number} movedY
|
|
90293
90297
|
* @readOnly
|
|
@@ -90332,14 +90336,10 @@
|
|
|
90332
90336
|
/**
|
|
90333
90337
|
* A `Number` system variable that tracks the mouse's horizontal position.
|
|
90334
90338
|
*
|
|
90335
|
-
*
|
|
90339
|
+
* `mouseX` keeps track of the mouse's position relative to the
|
|
90336
90340
|
* top-left corner of the canvas. For example, if the mouse is 50 pixels from
|
|
90337
90341
|
* the left edge of the canvas, then `mouseX` will be 50.
|
|
90338
90342
|
*
|
|
90339
|
-
* In WebGL mode, `mouseX` keeps track of the mouse's position relative to the
|
|
90340
|
-
* center of the canvas. For example, if the mouse is 50 pixels to the right
|
|
90341
|
-
* of the canvas' center, then `mouseX` will be 50.
|
|
90342
|
-
*
|
|
90343
90343
|
* If touch is used instead of the mouse, then `mouseX` will hold the
|
|
90344
90344
|
* x-coordinate of the most recent touch point.
|
|
90345
90345
|
*
|
|
@@ -90442,14 +90442,10 @@
|
|
|
90442
90442
|
/**
|
|
90443
90443
|
* A `Number` system variable that tracks the mouse's vertical position.
|
|
90444
90444
|
*
|
|
90445
|
-
*
|
|
90445
|
+
* `mouseY` keeps track of the mouse's position relative to the
|
|
90446
90446
|
* top-left corner of the canvas. For example, if the mouse is 50 pixels from
|
|
90447
90447
|
* the top edge of the canvas, then `mouseY` will be 50.
|
|
90448
90448
|
*
|
|
90449
|
-
* In WebGL mode, `mouseY` keeps track of the mouse's position relative to the
|
|
90450
|
-
* center of the canvas. For example, if the mouse is 50 pixels below the
|
|
90451
|
-
* canvas' center, then `mouseY` will be 50.
|
|
90452
|
-
*
|
|
90453
90449
|
* If touch is used instead of the mouse, then `mouseY` will hold the
|
|
90454
90450
|
* y-coordinate of the most recent touch point.
|
|
90455
90451
|
*
|
|
@@ -90553,16 +90549,12 @@
|
|
|
90553
90549
|
* A `Number` system variable that tracks the mouse's previous horizontal
|
|
90554
90550
|
* position.
|
|
90555
90551
|
*
|
|
90556
|
-
*
|
|
90552
|
+
* `pmouseX` keeps track of the mouse's position relative to the
|
|
90557
90553
|
* top-left corner of the canvas. Its value is
|
|
90558
90554
|
* <a href="#/p5/mouseX">mouseX</a> from the previous frame. For example, if
|
|
90559
90555
|
* the mouse was 50 pixels from the left edge of the canvas during the last
|
|
90560
90556
|
* frame, then `pmouseX` will be 50.
|
|
90561
90557
|
*
|
|
90562
|
-
* In WebGL mode, `pmouseX` keeps track of the mouse's position relative to the
|
|
90563
|
-
* center of the canvas. For example, if the mouse was 50 pixels to the right
|
|
90564
|
-
* of the canvas' center during the last frame, then `pmouseX` will be 50.
|
|
90565
|
-
*
|
|
90566
90558
|
* If touch is used instead of the mouse, then `pmouseX` will hold the
|
|
90567
90559
|
* x-coordinate of the last touch point.
|
|
90568
90560
|
*
|
|
@@ -90621,16 +90613,12 @@
|
|
|
90621
90613
|
* A `Number` system variable that tracks the mouse's previous vertical
|
|
90622
90614
|
* position.
|
|
90623
90615
|
*
|
|
90624
|
-
*
|
|
90616
|
+
* `pmouseY` keeps track of the mouse's position relative to the
|
|
90625
90617
|
* top-left corner of the canvas. Its value is
|
|
90626
90618
|
* <a href="#/p5/mouseY">mouseY</a> from the previous frame. For example, if
|
|
90627
90619
|
* the mouse was 50 pixels from the top edge of the canvas during the last
|
|
90628
90620
|
* frame, then `pmouseY` will be 50.
|
|
90629
90621
|
*
|
|
90630
|
-
* In WebGL mode, `pmouseY` keeps track of the mouse's position relative to the
|
|
90631
|
-
* center of the canvas. For example, if the mouse was 50 pixels below the
|
|
90632
|
-
* canvas' center during the last frame, then `pmouseY` will be 50.
|
|
90633
|
-
*
|
|
90634
90622
|
* If touch is used instead of the mouse, then `pmouseY` will hold the
|
|
90635
90623
|
* y-coordinate of the last touch point.
|
|
90636
90624
|
*
|
|
@@ -91037,10 +91025,24 @@
|
|
|
91037
91025
|
this._setProperty('mouseY', mousePos.y);
|
|
91038
91026
|
this._setProperty('winMouseX', mousePos.winX);
|
|
91039
91027
|
this._setProperty('winMouseY', mousePos.winY);
|
|
91040
|
-
|
|
91041
|
-
|
|
91042
|
-
|
|
91043
|
-
|
|
91028
|
+
if (document.pointerLockElement === null) {
|
|
91029
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Document/pointerLockElement
|
|
91030
|
+
// "The pointerLockElement ... is null if lock is pending, pointer is unlocked,
|
|
91031
|
+
// or the target is in another document."
|
|
91032
|
+
// In this case, we use mouseX/Y and pmouseX/Y to calculate the distance,
|
|
91033
|
+
// which allows movedX/Y to look consistent at different zoom levels across
|
|
91034
|
+
// browsers.
|
|
91035
|
+
var deltaX = this.mouseX - this.pmouseX;
|
|
91036
|
+
var deltaY = this.mouseY - this.pmouseY;
|
|
91037
|
+
this._setProperty('movedX', deltaX);
|
|
91038
|
+
this._setProperty('movedY', deltaY);
|
|
91039
|
+
} else {
|
|
91040
|
+
// Because mouseX/Y and pmouseX/Y are locked, the elements movementX/Y
|
|
91041
|
+
// is used for movedX/Y - this may behave differently on different
|
|
91042
|
+
// browsers at different zoom levels.
|
|
91043
|
+
this._setProperty('movedX', e.movementX);
|
|
91044
|
+
this._setProperty('movedY', e.movementY);
|
|
91045
|
+
}
|
|
91044
91046
|
}
|
|
91045
91047
|
if (!this._hasMouseInteracted) {
|
|
91046
91048
|
this._updateMouseCoords();
|
|
@@ -128135,18 +128137,18 @@
|
|
|
128135
128137
|
* to the pixel at coordinates `(u, v)` within an image. For example, the
|
|
128136
128138
|
* corners of a rectangular image are mapped to the corners of a rectangle by default:
|
|
128137
128139
|
*
|
|
128138
|
-
*
|
|
128140
|
+
* ```js
|
|
128139
128141
|
* // Apply the image as a texture.
|
|
128140
128142
|
* texture(img);
|
|
128141
128143
|
*
|
|
128142
128144
|
* // Draw the rectangle.
|
|
128143
128145
|
* rect(0, 0, 30, 50);
|
|
128144
|
-
*
|
|
128146
|
+
* ```
|
|
128145
128147
|
*
|
|
128146
128148
|
* If the image in the code snippet above has dimensions of 300 x 500 pixels,
|
|
128147
128149
|
* the same result could be achieved as follows:
|
|
128148
128150
|
*
|
|
128149
|
-
*
|
|
128151
|
+
* ```js
|
|
128150
128152
|
* // Apply the image as a texture.
|
|
128151
128153
|
* texture(img);
|
|
128152
128154
|
*
|
|
@@ -128170,7 +128172,7 @@
|
|
|
128170
128172
|
* vertex(0, 50, 0, 0, 500);
|
|
128171
128173
|
*
|
|
128172
128174
|
* endShape();
|
|
128173
|
-
*
|
|
128175
|
+
* ```
|
|
128174
128176
|
*
|
|
128175
128177
|
* `textureMode()` changes the coordinate system for uv coordinates.
|
|
128176
128178
|
*
|
|
@@ -128180,7 +128182,7 @@
|
|
|
128180
128182
|
* be helpful for using the same code for multiple images of different sizes.
|
|
128181
128183
|
* For example, the code snippet above could be rewritten as follows:
|
|
128182
128184
|
*
|
|
128183
|
-
*
|
|
128185
|
+
* ```js
|
|
128184
128186
|
* // Set the texture mode to use normalized coordinates.
|
|
128185
128187
|
* textureMode(NORMAL);
|
|
128186
128188
|
*
|
|
@@ -128207,7 +128209,7 @@
|
|
|
128207
128209
|
* vertex(0, 50, 0, 0, 1);
|
|
128208
128210
|
*
|
|
128209
128211
|
* endShape();
|
|
128210
|
-
*
|
|
128212
|
+
* ```
|
|
128211
128213
|
*
|
|
128212
128214
|
* By default, `mode` is `IMAGE`, which scales uv coordinates to the
|
|
128213
128215
|
* dimensions of the image. Calling `textureMode(IMAGE)` applies the default.
|
|
@@ -141288,8 +141290,8 @@
|
|
|
141288
141290
|
phongFrag: lightingShader + '// include lighting.glsl\nprecision highp int;\n\nuniform bool uHasSetAmbient;\nuniform vec4 uSpecularMatColor;\nuniform vec4 uAmbientMatColor;\nuniform vec4 uEmissiveMatColor;\n\nuniform vec4 uTint;\nuniform sampler2D uSampler;\nuniform bool isTexture;\n\nIN vec3 vNormal;\nIN vec2 vTexCoord;\nIN vec3 vViewPosition;\nIN vec3 vAmbientColor;\nIN vec4 vColor;\n\nstruct ColorComponents {\n vec3 baseColor;\n float opacity;\n vec3 ambientColor;\n vec3 specularColor;\n vec3 diffuse;\n vec3 ambient;\n vec3 specular;\n vec3 emissive;\n};\n\nstruct Inputs {\n vec3 normal;\n vec2 texCoord;\n vec3 ambientLight;\n vec3 ambientMaterial;\n vec3 specularMaterial;\n vec3 emissiveMaterial;\n vec4 color;\n float shininess;\n float metalness;\n};\n\nvoid main(void) {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.normal = normalize(vNormal);\n inputs.texCoord = vTexCoord;\n inputs.ambientLight = vAmbientColor;\n inputs.color = isTexture\n // Textures come in with premultiplied alpha. To apply tint and still have\n // premultiplied alpha output, we need to multiply the RGB channels by the\n // tint RGB, and all channels by the tint alpha.\n ? TEXTURE(uSampler, vTexCoord) * vec4(uTint.rgb/255., 1.) * (uTint.a/255.)\n // Colors come in with unmultiplied alpha, so we need to multiply the RGB\n // channels by alpha to convert it to premultiplied alpha.\n : vec4(vColor.rgb * vColor.a, vColor.a);\n inputs.shininess = uShininess;\n inputs.metalness = uMetallic;\n inputs.ambientMaterial = uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb;\n inputs.specularMaterial = uSpecularMatColor.rgb;\n inputs.emissiveMaterial = uEmissiveMatColor.rgb;\n inputs = HOOK_getPixelInputs(inputs);\n\n vec3 diffuse;\n vec3 specular;\n totalLight(vViewPosition, inputs.normal, inputs.shininess, inputs.metalness, diffuse, specular);\n\n // Calculating final color as result of all lights (plus emissive term).\n\n vec2 texCoord = inputs.texCoord;\n vec4 baseColor = inputs.color;\n ColorComponents c;\n c.opacity = baseColor.a;\n c.baseColor = baseColor.rgb;\n c.ambientColor = inputs.ambientMaterial;\n c.specularColor = inputs.specularMaterial;\n c.diffuse = diffuse;\n c.ambient = inputs.ambientLight;\n c.specular = specular;\n c.emissive = inputs.emissiveMaterial;\n OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c));\n HOOK_afterFragment();\n}\n',
|
|
141289
141291
|
fontVert: 'IN vec3 aPosition;\nIN vec2 aTexCoord;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uGlyphRect;\nuniform float uGlyphOffset;\n\nOUT vec2 vTexCoord;\nOUT float w;\n\nvoid main() {\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n // scale by the size of the glyph\'s rectangle\n positionVec4.xy *= uGlyphRect.zw - uGlyphRect.xy;\n\n // Expand glyph bounding boxes by 1px on each side to give a bit of room\n // for antialiasing\n vec3 newOrigin = (uModelViewMatrix * vec4(0., 0., 0., 1.)).xyz;\n vec3 newDX = (uModelViewMatrix * vec4(1., 0., 0., 1.)).xyz;\n vec3 newDY = (uModelViewMatrix * vec4(0., 1., 0., 1.)).xyz;\n vec2 pixelScale = vec2(\n 1. / length(newOrigin - newDX),\n 1. / length(newOrigin - newDY)\n );\n vec2 offset = pixelScale * normalize(aTexCoord - vec2(0.5, 0.5)) * vec2(1., -1.);\n vec2 textureOffset = offset * (1. / vec2(\n uGlyphRect.z - uGlyphRect.x,\n uGlyphRect.w - uGlyphRect.y\n ));\n\n // move to the corner of the glyph\n positionVec4.xy += uGlyphRect.xy;\n\n // move to the letter\'s line offset\n positionVec4.x += uGlyphOffset;\n\n positionVec4.xy += offset;\n \n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n vTexCoord = aTexCoord + textureOffset;\n w = gl_Position.w;\n}\n',
|
|
141290
141292
|
fontFrag: '#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n\n#if 0\n // simulate integer math using floats\n\t#define int float\n\t#define ivec2 vec2\n\t#define INT(x) float(x)\n\n\tint ifloor(float v) { return floor(v); }\n\tivec2 ifloor(vec2 v) { return floor(v); }\n\n#else\n // use native integer math\n\tprecision highp int;\n\t#define INT(x) x\n\n\tint ifloor(float v) { return int(v); }\n\tint ifloor(int v) { return v; }\n\tivec2 ifloor(vec2 v) { return ivec2(v); }\n\n#endif\n\nuniform sampler2D uSamplerStrokes;\nuniform sampler2D uSamplerRowStrokes;\nuniform sampler2D uSamplerRows;\nuniform sampler2D uSamplerColStrokes;\nuniform sampler2D uSamplerCols;\n\nuniform ivec2 uStrokeImageSize;\nuniform ivec2 uCellsImageSize;\nuniform ivec2 uGridImageSize;\n\nuniform ivec2 uGridOffset;\nuniform ivec2 uGridSize;\nuniform vec4 uMaterialColor;\n\nIN vec2 vTexCoord;\n\n// some helper functions\nint ROUND(float v) { return ifloor(v + 0.5); }\nivec2 ROUND(vec2 v) { return ifloor(v + 0.5); }\nfloat saturate(float v) { return clamp(v, 0.0, 1.0); }\nvec2 saturate(vec2 v) { return clamp(v, 0.0, 1.0); }\n\nint mul(float v1, int v2) {\n return ifloor(v1 * float(v2));\n}\n\nivec2 mul(vec2 v1, ivec2 v2) {\n return ifloor(v1 * vec2(v2) + 0.5);\n}\n\n// unpack a 16-bit integer from a float vec2\nint getInt16(vec2 v) {\n ivec2 iv = ROUND(v * 255.0);\n return iv.x * INT(128) + iv.y;\n}\n\nvec2 pixelScale;\nvec2 coverage = vec2(0.0);\nvec2 weight = vec2(0.5);\nconst float minDistance = 1.0/8192.0;\nconst float hardness = 1.05; // amount of antialias\n\n// the maximum number of curves in a glyph\nconst int N = INT(250);\n\n// retrieves an indexed pixel from a sampler\nvec4 getTexel(sampler2D sampler, int pos, ivec2 size) {\n int width = size.x;\n int y = ifloor(pos / width);\n int x = pos - y * width; // pos % width\n\n return TEXTURE(sampler, (vec2(x, y) + 0.5) / vec2(size));\n}\n\nvoid calulateCrossings(vec2 p0, vec2 p1, vec2 p2, out vec2 C1, out vec2 C2) {\n\n // get the coefficients of the quadratic in t\n vec2 a = p0 - p1 * 2.0 + p2;\n vec2 b = p0 - p1;\n vec2 c = p0 - vTexCoord;\n\n // found out which values of \'t\' it crosses the axes\n vec2 surd = sqrt(max(vec2(0.0), b * b - a * c));\n vec2 t1 = ((b - surd) / a).yx;\n vec2 t2 = ((b + surd) / a).yx;\n\n // approximate straight lines to avoid rounding errors\n if (abs(a.y) < 0.001)\n t1.x = t2.x = c.y / (2.0 * b.y);\n\n if (abs(a.x) < 0.001)\n t1.y = t2.y = c.x / (2.0 * b.x);\n\n // plug into quadratic formula to find the corrdinates of the crossings\n C1 = ((a * t1 - b * 2.0) * t1 + c) * pixelScale;\n C2 = ((a * t2 - b * 2.0) * t2 + c) * pixelScale;\n}\n\nvoid coverageX(vec2 p0, vec2 p1, vec2 p2) {\n\n vec2 C1, C2;\n calulateCrossings(p0, p1, p2, C1, C2);\n\n // determine on which side of the x-axis the points lie\n bool y0 = p0.y > vTexCoord.y;\n bool y1 = p1.y > vTexCoord.y;\n bool y2 = p2.y > vTexCoord.y;\n\n // could web be under the curve (after t1)?\n if (y1 ? !y2 : y0) {\n // add the coverage for t1\n coverage.x += saturate(C1.x + 0.5);\n // calculate the anti-aliasing for t1\n weight.x = min(weight.x, abs(C1.x));\n }\n\n // are we outside the curve (after t2)?\n if (y1 ? !y0 : y2) {\n // subtract the coverage for t2\n coverage.x -= saturate(C2.x + 0.5);\n // calculate the anti-aliasing for t2\n weight.x = min(weight.x, abs(C2.x));\n }\n}\n\n// this is essentially the same as coverageX, but with the axes swapped\nvoid coverageY(vec2 p0, vec2 p1, vec2 p2) {\n\n vec2 C1, C2;\n calulateCrossings(p0, p1, p2, C1, C2);\n\n bool x0 = p0.x > vTexCoord.x;\n bool x1 = p1.x > vTexCoord.x;\n bool x2 = p2.x > vTexCoord.x;\n\n if (x1 ? !x2 : x0) {\n coverage.y -= saturate(C1.y + 0.5);\n weight.y = min(weight.y, abs(C1.y));\n }\n\n if (x1 ? !x0 : x2) {\n coverage.y += saturate(C2.y + 0.5);\n weight.y = min(weight.y, abs(C2.y));\n }\n}\n\nvoid main() {\n\n // calculate the pixel scale based on screen-coordinates\n pixelScale = hardness / fwidth(vTexCoord);\n\n // which grid cell is this pixel in?\n ivec2 gridCoord = ifloor(vTexCoord * vec2(uGridSize));\n\n // intersect curves in this row\n {\n // the index into the row info bitmap\n int rowIndex = gridCoord.y + uGridOffset.y;\n // fetch the info texel\n vec4 rowInfo = getTexel(uSamplerRows, rowIndex, uGridImageSize);\n // unpack the rowInfo\n int rowStrokeIndex = getInt16(rowInfo.xy);\n int rowStrokeCount = getInt16(rowInfo.zw);\n\n for (int iRowStroke = INT(0); iRowStroke < N; iRowStroke++) {\n if (iRowStroke >= rowStrokeCount)\n break;\n\n // each stroke is made up of 3 points: the start and control point\n // and the start of the next curve.\n // fetch the indices of this pair of strokes:\n vec4 strokeIndices = getTexel(uSamplerRowStrokes, rowStrokeIndex++, uCellsImageSize);\n\n // unpack the stroke index\n int strokePos = getInt16(strokeIndices.xy);\n\n // fetch the two strokes\n vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);\n vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);\n\n // calculate the coverage\n coverageX(stroke0.xy, stroke0.zw, stroke1.xy);\n }\n }\n\n // intersect curves in this column\n {\n int colIndex = gridCoord.x + uGridOffset.x;\n vec4 colInfo = getTexel(uSamplerCols, colIndex, uGridImageSize);\n int colStrokeIndex = getInt16(colInfo.xy);\n int colStrokeCount = getInt16(colInfo.zw);\n \n for (int iColStroke = INT(0); iColStroke < N; iColStroke++) {\n if (iColStroke >= colStrokeCount)\n break;\n\n vec4 strokeIndices = getTexel(uSamplerColStrokes, colStrokeIndex++, uCellsImageSize);\n\n int strokePos = getInt16(strokeIndices.xy);\n vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);\n vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);\n coverageY(stroke0.xy, stroke0.zw, stroke1.xy);\n }\n }\n\n weight = saturate(1.0 - weight * 2.0);\n float distance = max(weight.x + weight.y, minDistance); // manhattan approx.\n float antialias = abs(dot(coverage, weight) / distance);\n float cover = min(abs(coverage.x), abs(coverage.y));\n OUT_COLOR = vec4(uMaterialColor.rgb, 1.) * uMaterialColor.a;\n OUT_COLOR *= saturate(max(antialias, cover));\n}\n',
|
|
141291
|
-
lineVert: lineDefs + '/*\n Part of the Processing project - http://processing.org\n Copyright (c) 2012-15 The Processing Foundation\n Copyright (c) 2004-12 Ben Fry and Casey Reas\n Copyright (c) 2001-04 Massachusetts Institute of Technology\n This library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation, version 2.1.\n This library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n You should have received a copy of the GNU Lesser General\n Public License along with this library; if not, write to the\n Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n Boston, MA 02111-1307 USA\n*/\n\n#define PROCESSING_LINE_SHADER\n\nprecision
|
|
141292
|
-
lineFrag: lineDefs + 'precision
|
|
141293
|
+
lineVert: lineDefs + '/*\n Part of the Processing project - http://processing.org\n Copyright (c) 2012-15 The Processing Foundation\n Copyright (c) 2004-12 Ben Fry and Casey Reas\n Copyright (c) 2001-04 Massachusetts Institute of Technology\n This library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation, version 2.1.\n This library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n You should have received a copy of the GNU Lesser General\n Public License along with this library; if not, write to the\n Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n Boston, MA 02111-1307 USA\n*/\n\n#define PROCESSING_LINE_SHADER\n\nprecision highp int;\nprecision highp float;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform float uStrokeWeight;\n\nuniform bool uUseLineColor;\nuniform vec4 uMaterialColor;\n\nuniform vec4 uViewport;\nuniform int uPerspective;\nuniform int uStrokeJoin;\n\nIN vec4 aPosition;\nIN vec3 aTangentIn;\nIN vec3 aTangentOut;\nIN float aSide;\nIN vec4 aVertexColor;\n\nOUT vec4 vColor;\nOUT vec2 vTangent;\nOUT vec2 vCenter;\nOUT vec2 vPosition;\nOUT float vMaxDist;\nOUT float vCap;\nOUT float vJoin;\nOUT float vStrokeWeight;\n\nvec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {\n // Rotate and translate so a starts at the origin and goes out to the right\n bPoint -= aPoint;\n vec2 rotatedBFrom = vec2(\n bPoint.x*aDir.x + bPoint.y*aDir.y,\n bPoint.y*aDir.x - bPoint.x*aDir.y\n );\n vec2 bTo = bPoint + bDir;\n vec2 rotatedBTo = vec2(\n bTo.x*aDir.x + bTo.y*aDir.y,\n bTo.y*aDir.x - bTo.x*aDir.y\n );\n float intersectionDistance =\n rotatedBTo.x + (rotatedBFrom.x - rotatedBTo.x) * rotatedBTo.y /\n (rotatedBTo.y - rotatedBFrom.y);\n return aPoint + aDir * intersectionDistance;\n}\n\nvoid main() {\n HOOK_beforeVertex();\n // Caps have one of either the in or out tangent set to 0\n vCap = (aTangentIn == vec3(0.)) != (aTangentOut == (vec3(0.)))\n ? 1. : 0.;\n\n // Joins have two unique, defined tangents\n vJoin = (\n aTangentIn != vec3(0.) &&\n aTangentOut != vec3(0.) &&\n aTangentIn != aTangentOut\n ) ? 1. : 0.;\n\n vec4 localPosition = vec4(HOOK_getLocalPosition(aPosition.xyz), 1.);\n vec4 posp = vec4(HOOK_getWorldPosition((uModelViewMatrix * localPosition).xyz), 1.);\n vec4 posqIn = posp + uModelViewMatrix * vec4(aTangentIn, 0);\n vec4 posqOut = posp + uModelViewMatrix * vec4(aTangentOut, 0);\n float strokeWeight = HOOK_getStrokeWeight(uStrokeWeight);\n vStrokeWeight = strokeWeight;\n\n float facingCamera = pow(\n // The word space tangent\'s z value is 0 if it\'s facing the camera\n abs(normalize(posqIn-posp).z),\n\n // Using pow() here to ramp `facingCamera` up from 0 to 1 really quickly\n // so most lines get scaled and don\'t get clipped\n 0.25\n );\n\n // Moving vertices slightly toward the camera\n // to avoid depth-fighting with the fill triangles.\n // A mix of scaling and offsetting is used based on distance\n // Discussion here:\n // https://github.com/processing/p5.js/issues/7200 \n\n // using a scale <1 moves the lines towards nearby camera\n // in order to prevent popping effects due to half of\n // the line disappearing behind the geometry faces.\n float zDistance = -posp.z; \n float distanceFactor = smoothstep(0.0, 800.0, zDistance); \n \n // Discussed here:\n // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848 \n float scale = mix(1., 0.995, facingCamera);\n float dynamicScale = mix(scale, 1.0, distanceFactor); // Closer = more scale, farther = less\n\n posp.xyz = posp.xyz * dynamicScale;\n posqIn.xyz = posqIn.xyz * dynamicScale;\n posqOut.xyz = posqOut.xyz * dynamicScale;\n\n // Moving vertices slightly toward camera when far away \n // https://github.com/processing/p5.js/issues/6956 \n float zOffset = mix(0., -1., facingCamera);\n float dynamicZAdjustment = mix(0.0, zOffset, distanceFactor); // Closer = less zAdjustment, farther = more\n\n posp.z -= dynamicZAdjustment;\n posqIn.z -= dynamicZAdjustment;\n posqOut.z -= dynamicZAdjustment;\n \n vec4 p = uProjectionMatrix * posp;\n vec4 qIn = uProjectionMatrix * posqIn;\n vec4 qOut = uProjectionMatrix * posqOut;\n vCenter = HOOK_getLineCenter(p.xy);\n\n // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])\n // screen_p = (p.xy/p.w + <1,1>) * 0.5 * uViewport.zw\n\n // prevent division by W by transforming the tangent formula (div by 0 causes\n // the line to disappear, see https://github.com/processing/processing/issues/5183)\n // t = screen_q - screen_p\n //\n // tangent is normalized and we don\'t care which aDirection it points to (+-)\n // t = +- normalize( screen_q - screen_p )\n // t = +- normalize( (q.xy/q.w+<1,1>)*0.5*uViewport.zw - (p.xy/p.w+<1,1>)*0.5*uViewport.zw )\n //\n // extract common factor, <1,1> - <1,1> cancels out\n // t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * uViewport.zw )\n //\n // convert to common divisor\n // t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * uViewport.zw )\n //\n // remove the common scalar divisor/factor, not needed due to normalize and +-\n // (keep uViewport - can\'t remove because it has different components for x and y\n // and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)\n // t = +- normalize( (q.xy*p.w - p.xy*q.w) * uViewport.zw )\n\n vec2 tangentIn = normalize((qIn.xy*p.w - p.xy*qIn.w) * uViewport.zw);\n vec2 tangentOut = normalize((qOut.xy*p.w - p.xy*qOut.w) * uViewport.zw);\n\n vec2 curPerspScale;\n if(uPerspective == 1) {\n // Perspective ---\n // convert from world to clip by multiplying with projection scaling factor\n // to get the right thickness (see https://github.com/processing/processing/issues/5182)\n\n // The y value of the projection matrix may be flipped if rendering to a Framebuffer.\n // Multiplying again by its sign here negates the flip to get just the scale.\n curPerspScale = (uProjectionMatrix * vec4(1, sign(uProjectionMatrix[1][1]), 0, 0)).xy;\n } else {\n // No Perspective ---\n // multiply by W (to cancel out division by W later in the pipeline) and\n // convert from screen to clip (derived from clip to screen above)\n curPerspScale = p.w / (0.5 * uViewport.zw);\n }\n\n vec2 offset;\n if (vJoin == 1.) {\n vTangent = normalize(tangentIn + tangentOut);\n vec2 normalIn = vec2(-tangentIn.y, tangentIn.x);\n vec2 normalOut = vec2(-tangentOut.y, tangentOut.x);\n float side = sign(aSide);\n float sideEnum = abs(aSide);\n\n // We generate vertices for joins on either side of the centerline, but\n // the "elbow" side is the only one needing a join. By not setting the\n // offset for the other side, all its vertices will end up in the same\n // spot and not render, effectively discarding it.\n if (sign(dot(tangentOut, vec2(-tangentIn.y, tangentIn.x))) != side) {\n // Side enums:\n // 1: the side going into the join\n // 2: the middle of the join\n // 3: the side going out of the join\n if (sideEnum == 2.) {\n // Calculate the position + tangent on either side of the join, and\n // find where the lines intersect to find the elbow of the join\n vec2 c = (posp.xy/posp.w + vec2(1.,1.)) * 0.5 * uViewport.zw;\n vec2 intersection = lineIntersection(\n c + (side * normalIn * strokeWeight / 2.),\n tangentIn,\n c + (side * normalOut * strokeWeight / 2.),\n tangentOut\n );\n offset = (intersection - c);\n\n // When lines are thick and the angle of the join approaches 180, the\n // elbow might be really far from the center. We\'ll apply a limit to\n // the magnitude to avoid lines going across the whole screen when this\n // happens.\n float mag = length(offset);\n float maxMag = 3. * strokeWeight;\n if (mag > maxMag) {\n offset *= maxMag / mag;\n }\n } else if (sideEnum == 1.) {\n offset = side * normalIn * strokeWeight / 2.;\n } else if (sideEnum == 3.) {\n offset = side * normalOut * strokeWeight / 2.;\n }\n }\n if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 avgNormal = vec2(-vTangent.y, vTangent.x);\n vMaxDist = abs(dot(avgNormal, normalIn * strokeWeight / 2.));\n } else {\n vMaxDist = strokeWeight / 2.;\n }\n } else {\n vec2 tangent = aTangentIn == vec3(0.) ? tangentOut : tangentIn;\n vTangent = tangent;\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n float normalOffset = sign(aSide);\n // Caps will have side values of -2 or 2 on the edge of the cap that\n // extends out from the line\n float tangentOffset = abs(aSide) - 1.;\n offset = (normal * normalOffset + tangent * tangentOffset) *\n strokeWeight * 0.5;\n vMaxDist = strokeWeight / 2.;\n }\n vPosition = HOOK_getLinePosition(vCenter + offset);\n\n gl_Position.xy = p.xy + offset.xy * curPerspScale;\n gl_Position.zw = p.zw;\n \n vColor = HOOK_getVertexColor(uUseLineColor ? aVertexColor : uMaterialColor);\n HOOK_afterVertex();\n}\n',
|
|
141294
|
+
lineFrag: lineDefs + 'precision highp int;\nprecision highp float;\n\nuniform vec4 uMaterialColor;\nuniform int uStrokeCap;\nuniform int uStrokeJoin;\n\nIN vec4 vColor;\nIN vec2 vTangent;\nIN vec2 vCenter;\nIN vec2 vPosition;\nIN float vStrokeWeight;\nIN float vMaxDist;\nIN float vCap;\nIN float vJoin;\n\nfloat distSquared(vec2 a, vec2 b) {\n vec2 aToB = b - a;\n return dot(aToB, aToB);\n}\n\nstruct Inputs {\n vec4 color;\n vec2 tangent;\n vec2 center;\n vec2 position;\n float strokeWeight;\n};\n\nvoid main() {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.color = vColor;\n inputs.tangent = vTangent;\n inputs.center = vCenter;\n inputs.position = vPosition;\n inputs.strokeWeight = vStrokeWeight;\n inputs = HOOK_getPixelInputs(inputs);\n\n if (vCap > 0.) {\n if (\n uStrokeCap == STROKE_CAP_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (\n uStrokeCap == STROKE_CAP_SQUARE &&\n HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)\n ) {\n discard;\n // Use full area for PROJECT\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n } else if (vJoin > 0.) {\n if (\n uStrokeJoin == STROKE_JOIN_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);\n if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {\n discard;\n }\n // Use full area for MITER\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n }\n OUT_COLOR = HOOK_getFinalColor(vec4(inputs.color.rgb, 1.) * inputs.color.a);\n HOOK_afterFragment();\n}\n',
|
|
141293
141295
|
pointVert: 'IN vec3 aPosition;\nuniform float uPointSize;\nOUT float vStrokeWeight;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvoid main() {\n HOOK_beforeVertex();\n vec4 viewModelPosition = vec4(HOOK_getWorldPosition(\n (uModelViewMatrix * vec4(HOOK_getLocalPosition(aPosition), 1.0)).xyz\n ), 1.);\n gl_Position = uProjectionMatrix * viewModelPosition; \n\n float pointSize = HOOK_getPointSize(uPointSize);\n\n\tgl_PointSize = pointSize;\n\tvStrokeWeight = pointSize;\n HOOK_afterVertex();\n}\n',
|
|
141294
141296
|
pointFrag: 'precision mediump int;\nuniform vec4 uMaterialColor;\nIN float vStrokeWeight;\n\nvoid main(){\n HOOK_beforeFragment();\n float mask = 0.0;\n\n // make a circular mask using the gl_PointCoord (goes from 0 - 1 on a point)\n // might be able to get a nicer edge on big strokeweights with smoothstep but slightly less performant\n\n mask = step(0.98, length(gl_PointCoord * 2.0 - 1.0));\n\n // if strokeWeight is 1 or less lets just draw a square\n // this prevents weird artifacting from carving circles when our points are really small\n // if strokeWeight is larger than 1, we just use it as is\n\n mask = mix(0.0, mask, clamp(floor(vStrokeWeight - 0.5),0.0,1.0));\n\n // throw away the borders of the mask\n // otherwise we get weird alpha blending issues\n\n if(HOOK_shouldDiscard(mask > 0.98)){\n discard;\n }\n\n OUT_COLOR = HOOK_getFinalColor(vec4(uMaterialColor.rgb, 1.) * uMaterialColor.a);\n HOOK_afterFragment();\n}\n',
|
|
141295
141297
|
imageLightVert: 'precision highp float;\nattribute vec3 aPosition;\nattribute vec3 aNormal;\nattribute vec2 aTexCoord;\n\nvarying vec3 localPos;\nvarying vec3 vWorldNormal;\nvarying vec3 vWorldPosition;\nvarying vec2 vTexCoord;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nvoid main() {\n // Multiply the position by the matrix.\n vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * viewModelPosition; \n \n // orient the normals and pass to the fragment shader\n vWorldNormal = uNormalMatrix * aNormal;\n \n // send the view position to the fragment shader\n vWorldPosition = (uModelViewMatrix * vec4(aPosition, 1.0)).xyz;\n \n localPos = vWorldPosition;\n vTexCoord = aTexCoord;\n}\n\n\n/*\nin the vertex shader we\'ll compute the world position and world oriented normal of the vertices and pass those to the fragment shader as varyings.\n*/\n',
|
|
@@ -143745,7 +143747,7 @@
|
|
|
143745
143747
|
* ensures that p5 is using a 3d renderer. throws an error if not.
|
|
143746
143748
|
*/
|
|
143747
143749
|
_main.default.prototype._assert3d = function (name) {
|
|
143748
|
-
if (!this._renderer.isP3D) throw new Error(''.concat(name, '() is only supported in WEBGL mode. If you\'d like to use 3D graphics and WebGL, see
|
|
143750
|
+
if (!this._renderer.isP3D) throw new Error(''.concat(name, '() is only supported in WEBGL mode. If you\'d like to use 3D graphics and WebGL, see https://p5js.org/examples/3d-geometries/ for more information.'));
|
|
143749
143751
|
};
|
|
143750
143752
|
// function to initialize GLU Tesselator
|
|
143751
143753
|
_main.default.RendererGL.prototype.tessyVertexSize = 12;
|