p5 2.2.2 → 2.2.3-rc.1
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/dist/accessibility/color_namer.js +5 -5
- package/dist/accessibility/index.js +5 -5
- package/dist/app.js +5 -5
- package/dist/color/color_conversion.js +5 -5
- package/dist/color/index.js +1 -1
- package/dist/color/setting.js +1 -1
- package/dist/{constants-BxjhKpTv.js → constants-BUwWryrh.js} +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +7 -3
- package/dist/core/filterShaders.js +1 -1
- package/dist/core/friendly_errors/fes_core.js +1 -1
- package/dist/core/friendly_errors/file_errors.js +1 -1
- package/dist/core/friendly_errors/index.js +1 -1
- package/dist/core/friendly_errors/param_validator.js +2063 -2014
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/helpers.js +1 -1
- package/dist/core/init.js +5 -5
- package/dist/core/internationalization.js +1 -1
- package/dist/core/legacy.js +5 -5
- package/dist/core/main.js +5 -5
- package/dist/core/p5.Graphics.js +3 -3
- package/dist/core/p5.Renderer.js +2 -2
- package/dist/core/p5.Renderer2D.js +5 -5
- package/dist/core/p5.Renderer3D.js +3 -3
- package/dist/core/rendering.js +3 -3
- package/dist/dom/dom.js +1 -1
- package/dist/dom/index.js +1 -1
- package/dist/dom/p5.Element.js +1 -1
- package/dist/dom/p5.MediaElement.js +11 -4
- package/dist/events/pointer.js +4 -0
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +4 -4
- package/dist/image/image.js +3 -3
- package/dist/image/index.js +3 -3
- package/dist/image/loading_displaying.js +3 -3
- package/dist/image/p5.Image.js +2 -2
- package/dist/io/files.js +3 -3
- package/dist/io/index.js +3 -3
- package/dist/{ir_builders-w12-GSxu.js → ir_builders-Cd6rU9Vm.js} +48 -14
- package/dist/{main-DDs4QOnh.js → main-DFpoFdvM.js} +126 -36
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/index.js +1 -1
- package/dist/math/p5.Matrix.js +1 -1
- package/dist/math/p5.Vector.js +1 -1
- package/dist/math/trigonometry.js +1 -1
- package/dist/{p5.Renderer-BSGddFv7.js → p5.Renderer-D-EuAodU.js} +9 -2
- package/dist/{rendering-C9g7uSQ5.js → rendering-DE9-Hl7Y.js} +103 -78
- package/dist/shape/2d_primitives.js +1 -1
- package/dist/shape/attributes.js +1 -1
- package/dist/shape/custom_shapes.js +1 -1
- package/dist/shape/index.js +1 -1
- package/dist/strands/ir_builders.js +1 -1
- package/dist/strands/ir_dag.js +32 -2
- package/dist/strands/ir_types.js +18 -11
- package/dist/strands/p5.strands.js +24 -35
- package/dist/strands/strands_api.js +86 -41
- package/dist/strands/strands_codegen.js +0 -12
- package/dist/strands/strands_conditionals.js +1 -1
- package/dist/strands/strands_for.js +1 -1
- package/dist/strands/strands_node.js +1 -1
- package/dist/strands/strands_phi_utils.js +27 -9
- package/dist/strands/strands_transpiler.js +1237 -831
- package/dist/type/index.js +2 -2
- package/dist/type/p5.Font.js +7 -5
- package/dist/type/textCore.js +2 -2
- package/dist/webgl/3d_primitives.js +3 -3
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShapeBuilder.js +1 -1
- package/dist/webgl/enums.js +1 -1
- package/dist/webgl/index.js +4 -4
- package/dist/webgl/interaction.js +1 -1
- package/dist/webgl/light.js +3 -3
- package/dist/webgl/loading.js +41 -35
- package/dist/webgl/material.js +3 -3
- package/dist/webgl/p5.Camera.js +3 -3
- package/dist/webgl/p5.Framebuffer.js +3 -3
- package/dist/webgl/p5.Geometry.js +1 -1
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +4 -4
- package/dist/webgl/p5.Shader.js +14 -6
- package/dist/webgl/p5.Texture.js +3 -3
- package/dist/webgl/strands_glslBackend.js +1 -1
- package/dist/webgl/text.js +3 -3
- package/dist/webgl/utils.js +3 -3
- package/dist/webgpu/index.js +2 -2
- package/dist/webgpu/p5.RendererWebGPU.js +2 -2
- package/dist/webgpu/strands_wgslBackend.js +13 -4
- package/lib/p5.esm.js +3670 -2951
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +3670 -2951
- package/lib/p5.min.js +1 -1
- package/lib/p5.webgpu.esm.js +43 -21
- package/lib/p5.webgpu.js +43 -21
- package/lib/p5.webgpu.min.js +1 -1
- package/package.json +1 -1
- package/types/global.d.ts +1283 -1301
- package/types/p5.d.ts +655 -657
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { p as CORNER, t as CORNERS, v as CENTER, aB as COVER, aC as CONTAIN, a9 as RIGHT, aw as BOTTOM, B as BLEND, aD as FILL, ad as IMAGE, C as CLAMP, w as ROUND, Y as LINES, X as POINTS, c as TRIANGLES, ab as BLUR, D as DARKEST, L as LIGHTEST, A as ADD, S as SUBTRACT, a as SCREEN, E as EXCLUSION, R as REPLACE, M as MULTIPLY, b as REMOVE, as as BURN, ao as OVERLAY, ap as HARD_LIGHT, aq as SOFT_LIGHT, ar as DODGE, d as UNSIGNED_INT, U as UNSIGNED_BYTE, av as LEFT, ax as BASELINE, ay as TOP, aE as SIMPLE, aF as FULL, q as TWO_PI, Q as OPEN, a2 as NORMAL, V as CLOSE, at as PIE, au as CHORD, h as TEXTURE, P as P2D, g as LINEAR, aa as WEBGL2, N as NEAREST, aG as LINEAR_MIPMAP, f as REPEAT, e as MIRROR, F as FLOAT, ac as WEBGL, H as HALF_FLOAT } from './constants-
|
|
1
|
+
import { p as CORNER, t as CORNERS, v as CENTER, aB as COVER, aC as CONTAIN, a9 as RIGHT, aw as BOTTOM, B as BLEND, aD as FILL, ad as IMAGE, C as CLAMP, w as ROUND, Y as LINES, X as POINTS, c as TRIANGLES, ab as BLUR, D as DARKEST, L as LIGHTEST, A as ADD, S as SUBTRACT, a as SCREEN, E as EXCLUSION, R as REPLACE, M as MULTIPLY, b as REMOVE, as as BURN, ao as OVERLAY, ap as HARD_LIGHT, aq as SOFT_LIGHT, ar as DODGE, d as UNSIGNED_INT, U as UNSIGNED_BYTE, av as LEFT, ax as BASELINE, ay as TOP, aE as SIMPLE, aF as FULL, q as TWO_PI, Q as OPEN, a2 as NORMAL, V as CLOSE, at as PIE, au as CHORD, h as TEXTURE, P as P2D, g as LINEAR, aa as WEBGL2, N as NEAREST, aG as LINEAR_MIPMAP, f as REPEAT, e as MIRROR, F as FLOAT, ac as WEBGL, H as HALF_FLOAT } from './constants-BUwWryrh.js';
|
|
2
2
|
import { C as Color, c as creatingReading, h as RGBA, R as RGB } from './creating_reading-C7hu6sg1.js';
|
|
3
3
|
import { Element } from './dom/p5.Element.js';
|
|
4
|
-
import { R as Renderer, I as Image } from './p5.Renderer-
|
|
4
|
+
import { R as Renderer, I as Image } from './p5.Renderer-D-EuAodU.js';
|
|
5
5
|
import { MediaElement } from './dom/p5.MediaElement.js';
|
|
6
6
|
import primitives from './shape/2d_primitives.js';
|
|
7
7
|
import attributes from './shape/attributes.js';
|
|
@@ -1008,8 +1008,11 @@ function files(p5, fn){
|
|
|
1008
1008
|
|
|
1009
1009
|
try{
|
|
1010
1010
|
const { data } = await request(path, 'json');
|
|
1011
|
-
|
|
1012
|
-
|
|
1011
|
+
const cb = () => {
|
|
1012
|
+
if (successCallback) return successCallback(data);
|
|
1013
|
+
return data;
|
|
1014
|
+
};
|
|
1015
|
+
return this._internal ? this._internal(cb) : cb();
|
|
1013
1016
|
} catch(err) {
|
|
1014
1017
|
p5._friendlyFileLoadError(5, path);
|
|
1015
1018
|
if(errorCallback) {
|
|
@@ -1144,10 +1147,12 @@ function files(p5, fn){
|
|
|
1144
1147
|
|
|
1145
1148
|
try{
|
|
1146
1149
|
let { data } = await request(path, 'text');
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1150
|
+
const cb = () => {
|
|
1151
|
+
data = data.split(/\r?\n/);
|
|
1152
|
+
if (successCallback) return successCallback(data);
|
|
1153
|
+
return data;
|
|
1154
|
+
};
|
|
1155
|
+
return this._internal ? this._internal(cb) : cb();
|
|
1151
1156
|
} catch(err) {
|
|
1152
1157
|
p5._friendlyFileLoadError(3, path);
|
|
1153
1158
|
if(errorCallback) {
|
|
@@ -1231,28 +1236,30 @@ function files(p5, fn){
|
|
|
1231
1236
|
|
|
1232
1237
|
try{
|
|
1233
1238
|
let { data } = await request(path, 'text');
|
|
1239
|
+
const cb = () => {
|
|
1240
|
+
let ret = new p5.Table();
|
|
1241
|
+
data = parse(data, {
|
|
1242
|
+
separator
|
|
1243
|
+
});
|
|
1234
1244
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
if(header){
|
|
1241
|
-
ret.columns = data.shift();
|
|
1242
|
-
}else {
|
|
1243
|
-
ret.columns = Array(data[0].length).fill(null);
|
|
1244
|
-
}
|
|
1245
|
+
if(header){
|
|
1246
|
+
ret.columns = data.shift();
|
|
1247
|
+
}else {
|
|
1248
|
+
ret.columns = Array(data[0].length).fill(null);
|
|
1249
|
+
}
|
|
1245
1250
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1251
|
+
data.forEach(line => {
|
|
1252
|
+
const row = new p5.TableRow(line);
|
|
1253
|
+
ret.addRow(row);
|
|
1254
|
+
});
|
|
1250
1255
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
+
if (successCallback) {
|
|
1257
|
+
return successCallback(ret);
|
|
1258
|
+
} else {
|
|
1259
|
+
return ret;
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
return this._internal ? this._internal(cb) : cb();
|
|
1256
1263
|
} catch(err) {
|
|
1257
1264
|
p5._friendlyFileLoadError(2, path);
|
|
1258
1265
|
if(errorCallback) {
|
|
@@ -1416,11 +1423,13 @@ function files(p5, fn){
|
|
|
1416
1423
|
const parser = new DOMParser();
|
|
1417
1424
|
|
|
1418
1425
|
let { data } = await request(path, 'text');
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1426
|
+
const cb = () => {
|
|
1427
|
+
const parsedDOM = parser.parseFromString(data, 'application/xml');
|
|
1428
|
+
data = new p5.XML(parsedDOM);
|
|
1429
|
+
if (successCallback) return successCallback(data);
|
|
1430
|
+
return data;
|
|
1431
|
+
};
|
|
1432
|
+
return this._internal ? this._internal(cb) : cb();
|
|
1424
1433
|
} catch(err) {
|
|
1425
1434
|
p5._friendlyFileLoadError(1, path);
|
|
1426
1435
|
if(errorCallback) {
|
|
@@ -1464,9 +1473,12 @@ function files(p5, fn){
|
|
|
1464
1473
|
fn.loadBytes = async function (path, successCallback, errorCallback) {
|
|
1465
1474
|
try{
|
|
1466
1475
|
let { data } = await request(path, 'arrayBuffer');
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1476
|
+
const cb = () => {
|
|
1477
|
+
data = new Uint8Array(data);
|
|
1478
|
+
if (successCallback) return successCallback(data);
|
|
1479
|
+
return data;
|
|
1480
|
+
};
|
|
1481
|
+
return this._internal ? this._internal(cb) : cb();
|
|
1470
1482
|
} catch(err) {
|
|
1471
1483
|
p5._friendlyFileLoadError(6, path);
|
|
1472
1484
|
if(errorCallback) {
|
|
@@ -1519,8 +1531,11 @@ function files(p5, fn){
|
|
|
1519
1531
|
fn.loadBlob = async function(path, successCallback, errorCallback) {
|
|
1520
1532
|
try{
|
|
1521
1533
|
const { data } = await request(path, 'blob');
|
|
1522
|
-
|
|
1523
|
-
|
|
1534
|
+
const cb = () => {
|
|
1535
|
+
if (successCallback) return successCallback(data);
|
|
1536
|
+
return data;
|
|
1537
|
+
};
|
|
1538
|
+
return this._internal ? this._internal(cb) : cb();
|
|
1524
1539
|
} catch(err) {
|
|
1525
1540
|
if(errorCallback) {
|
|
1526
1541
|
return errorCallback(err);
|
|
@@ -2969,13 +2984,15 @@ function loadingDisplaying(p5, fn){
|
|
|
2969
2984
|
pImg.drawingContext.drawImage(img, 0, 0);
|
|
2970
2985
|
}
|
|
2971
2986
|
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2987
|
+
const cb = () => {
|
|
2988
|
+
pImg.modified = true;
|
|
2989
|
+
if(successCallback){
|
|
2990
|
+
return successCallback(pImg);
|
|
2991
|
+
}else {
|
|
2992
|
+
return pImg;
|
|
2993
|
+
}
|
|
2994
|
+
};
|
|
2995
|
+
return this._internal ? this._internal(cb) : cb();
|
|
2979
2996
|
|
|
2980
2997
|
} catch(err) {
|
|
2981
2998
|
p5._friendlyFileLoadError(0, path);
|
|
@@ -6017,6 +6034,17 @@ class Camera {
|
|
|
6017
6034
|
|
|
6018
6035
|
_cam.cameraType = this.cameraType;
|
|
6019
6036
|
|
|
6037
|
+
_cam.defaultAspectRatio = this.defaultAspectRatio;
|
|
6038
|
+
_cam.defaultEyeX = this.defaultEyeX;
|
|
6039
|
+
_cam.defaultEyeY = this.defaultEyeY;
|
|
6040
|
+
_cam.defaultEyeZ = this.defaultEyeZ;
|
|
6041
|
+
_cam.defaultCameraFOV = this.defaultCameraFOV;
|
|
6042
|
+
_cam.defaultCenterX = this.defaultCenterX;
|
|
6043
|
+
_cam.defaultCenterY = this.defaultCenterY;
|
|
6044
|
+
_cam.defaultCenterZ = this.defaultCenterZ;
|
|
6045
|
+
_cam.defaultCameraNear = this.defaultCameraNear;
|
|
6046
|
+
_cam.defaultCameraFar = this.defaultCameraFar;
|
|
6047
|
+
|
|
6020
6048
|
return _cam;
|
|
6021
6049
|
}
|
|
6022
6050
|
|
|
@@ -14831,7 +14859,7 @@ function material(p5, fn) {
|
|
|
14831
14859
|
* // Make a version of the shader with a hook overridden
|
|
14832
14860
|
* modifiedShader = myShader.modify(() => {
|
|
14833
14861
|
* // Create new uniforms and override the getColor hook
|
|
14834
|
-
* let t =
|
|
14862
|
+
* let t = millis() / 1000;
|
|
14835
14863
|
* getColor(() => {
|
|
14836
14864
|
* return [0, 0.5 + 0.5 * sin(t), 1, 1];
|
|
14837
14865
|
* });
|
|
@@ -14944,11 +14972,11 @@ function material(p5, fn) {
|
|
|
14944
14972
|
// Test if we've loaded GLSL or not by checking for the existence of `void main`
|
|
14945
14973
|
let loadedShader;
|
|
14946
14974
|
if (/void\s+main/.exec(fragString)) {
|
|
14947
|
-
loadedShader = this.createFilterShader(fragString, true);
|
|
14975
|
+
loadedShader = this._internal(() => this.createFilterShader(fragString, true));
|
|
14948
14976
|
} else {
|
|
14949
|
-
loadedShader = withGlobalStrands(this, () =>
|
|
14977
|
+
loadedShader = this._internal(() => withGlobalStrands(this, () =>
|
|
14950
14978
|
this.baseFilterShader().modify(new Function(fragString)),
|
|
14951
|
-
);
|
|
14979
|
+
));
|
|
14952
14980
|
}
|
|
14953
14981
|
|
|
14954
14982
|
if (successCallback) {
|
|
@@ -15077,7 +15105,7 @@ function material(p5, fn) {
|
|
|
15077
15105
|
* }
|
|
15078
15106
|
* ```
|
|
15079
15107
|
*
|
|
15080
|
-
* You can also animate your filters over time
|
|
15108
|
+
* You can also animate your filters over time using the `millis()` function.
|
|
15081
15109
|
*
|
|
15082
15110
|
* ```js example
|
|
15083
15111
|
* let myFilter;
|
|
@@ -15088,7 +15116,7 @@ function material(p5, fn) {
|
|
|
15088
15116
|
* }
|
|
15089
15117
|
*
|
|
15090
15118
|
* function gradient() {
|
|
15091
|
-
* let time =
|
|
15119
|
+
* let time = millis();
|
|
15092
15120
|
* filterColor.begin();
|
|
15093
15121
|
* filterColor.set(mix(
|
|
15094
15122
|
* [1, 0, 0, 1], // Red
|
|
@@ -15099,12 +15127,11 @@ function material(p5, fn) {
|
|
|
15099
15127
|
* }
|
|
15100
15128
|
*
|
|
15101
15129
|
* function draw() {
|
|
15102
|
-
* myFilter.setUniform('time', millis());
|
|
15103
15130
|
* filter(myFilter);
|
|
15104
15131
|
* }
|
|
15105
15132
|
* ```
|
|
15106
15133
|
*
|
|
15107
|
-
* We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by
|
|
15134
|
+
* We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by using the millis() function to get an up-to-date time value.
|
|
15108
15135
|
*
|
|
15109
15136
|
* ```js example
|
|
15110
15137
|
* let myFilter;
|
|
@@ -15116,7 +15143,7 @@ function material(p5, fn) {
|
|
|
15116
15143
|
* }
|
|
15117
15144
|
*
|
|
15118
15145
|
* function noiseShaderCallback() {
|
|
15119
|
-
* let time =
|
|
15146
|
+
* let time = millis();
|
|
15120
15147
|
* filterColor.begin();
|
|
15121
15148
|
* let coord = filterColor.texCoord;
|
|
15122
15149
|
*
|
|
@@ -15133,7 +15160,6 @@ function material(p5, fn) {
|
|
|
15133
15160
|
* }
|
|
15134
15161
|
*
|
|
15135
15162
|
* function draw() {
|
|
15136
|
-
* myFilter.setUniform("time", millis());
|
|
15137
15163
|
* filter(myFilter);
|
|
15138
15164
|
* }
|
|
15139
15165
|
* ```
|
|
@@ -15347,7 +15373,7 @@ function material(p5, fn) {
|
|
|
15347
15373
|
* }
|
|
15348
15374
|
*
|
|
15349
15375
|
* function material() {
|
|
15350
|
-
* let time =
|
|
15376
|
+
* let time = millis() / 1000;
|
|
15351
15377
|
* finalColor.begin();
|
|
15352
15378
|
* let r = 0.2 + 0.5 * abs(sin(time + 0));
|
|
15353
15379
|
* let g = 0.2 + 0.5 * abs(sin(time + 1));
|
|
@@ -15358,7 +15384,6 @@ function material(p5, fn) {
|
|
|
15358
15384
|
*
|
|
15359
15385
|
* function draw() {
|
|
15360
15386
|
* background(245, 245, 220);
|
|
15361
|
-
* myShader.setUniform('time', millis() / 1000);
|
|
15362
15387
|
* shader(myShader);
|
|
15363
15388
|
*
|
|
15364
15389
|
* rectMode(CENTER);
|
|
@@ -15834,7 +15859,7 @@ function material(p5, fn) {
|
|
|
15834
15859
|
* }
|
|
15835
15860
|
*
|
|
15836
15861
|
* function material() {
|
|
15837
|
-
* let time =
|
|
15862
|
+
* let time = millis();
|
|
15838
15863
|
* worldInputs.begin();
|
|
15839
15864
|
* worldInputs.position.y +=
|
|
15840
15865
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -15844,7 +15869,6 @@ function material(p5, fn) {
|
|
|
15844
15869
|
* function draw() {
|
|
15845
15870
|
* background(255);
|
|
15846
15871
|
* shader(myShader);
|
|
15847
|
-
* myShader.setUniform('time', millis());
|
|
15848
15872
|
* lights();
|
|
15849
15873
|
* noStroke();
|
|
15850
15874
|
* fill('red');
|
|
@@ -16013,7 +16037,6 @@ function material(p5, fn) {
|
|
|
16013
16037
|
* function draw() {
|
|
16014
16038
|
* background(255);
|
|
16015
16039
|
* shader(myShader);
|
|
16016
|
-
* myShader.setUniform('time', millis());
|
|
16017
16040
|
* lights();
|
|
16018
16041
|
* noStroke();
|
|
16019
16042
|
* fill('red');
|
|
@@ -16027,7 +16050,7 @@ function material(p5, fn) {
|
|
|
16027
16050
|
*
|
|
16028
16051
|
* ```js
|
|
16029
16052
|
* // myMaterial.js
|
|
16030
|
-
* let time =
|
|
16053
|
+
* let time = millis();
|
|
16031
16054
|
* worldInputs.begin();
|
|
16032
16055
|
* worldInputs.position.y +=
|
|
16033
16056
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -16055,7 +16078,7 @@ function material(p5, fn) {
|
|
|
16055
16078
|
fn.loadMaterialShader = async function (url, onSuccess, onFail) {
|
|
16056
16079
|
try {
|
|
16057
16080
|
const cb = await urlToStrandsCallback(url);
|
|
16058
|
-
let shader = withGlobalStrands(this, () => this.buildMaterialShader(cb));
|
|
16081
|
+
let shader = this._internal(() => withGlobalStrands(this, () => this.buildMaterialShader(cb)));
|
|
16059
16082
|
if (onSuccess) {
|
|
16060
16083
|
shader = onSuccess(shader) || shader;
|
|
16061
16084
|
}
|
|
@@ -16136,7 +16159,7 @@ function material(p5, fn) {
|
|
|
16136
16159
|
* }
|
|
16137
16160
|
*
|
|
16138
16161
|
* function material() {
|
|
16139
|
-
* let time =
|
|
16162
|
+
* let time = millis();
|
|
16140
16163
|
* worldInputs.begin();
|
|
16141
16164
|
* worldInputs.position.y +=
|
|
16142
16165
|
* 20. * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -16146,7 +16169,6 @@ function material(p5, fn) {
|
|
|
16146
16169
|
* function draw() {
|
|
16147
16170
|
* background(255);
|
|
16148
16171
|
* shader(myShader);
|
|
16149
|
-
* myShader.setUniform('time', millis());
|
|
16150
16172
|
* noStroke();
|
|
16151
16173
|
* sphere(50);
|
|
16152
16174
|
* }
|
|
@@ -16232,7 +16254,6 @@ function material(p5, fn) {
|
|
|
16232
16254
|
* function draw() {
|
|
16233
16255
|
* background(255);
|
|
16234
16256
|
* shader(myShader);
|
|
16235
|
-
* myShader.setUniform('time', millis());
|
|
16236
16257
|
* lights();
|
|
16237
16258
|
* noStroke();
|
|
16238
16259
|
* fill('red');
|
|
@@ -16246,7 +16267,7 @@ function material(p5, fn) {
|
|
|
16246
16267
|
*
|
|
16247
16268
|
* ```js
|
|
16248
16269
|
* // myMaterial.js
|
|
16249
|
-
* let time =
|
|
16270
|
+
* let time = millis();
|
|
16250
16271
|
* worldInputs.begin();
|
|
16251
16272
|
* worldInputs.position.y +=
|
|
16252
16273
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -16274,9 +16295,9 @@ function material(p5, fn) {
|
|
|
16274
16295
|
fn.loadNormalShader = async function (url, onSuccess, onFail) {
|
|
16275
16296
|
try {
|
|
16276
16297
|
const cb = await urlToStrandsCallback(url);
|
|
16277
|
-
let shader = this.withGlobalStrands(this, () =>
|
|
16298
|
+
let shader = this._internal(() => this.withGlobalStrands(this, () =>
|
|
16278
16299
|
this.buildNormalShader(cb),
|
|
16279
|
-
);
|
|
16300
|
+
));
|
|
16280
16301
|
if (onSuccess) {
|
|
16281
16302
|
shader = onSuccess(shader) || shader;
|
|
16282
16303
|
}
|
|
@@ -16339,7 +16360,7 @@ function material(p5, fn) {
|
|
|
16339
16360
|
* }
|
|
16340
16361
|
*
|
|
16341
16362
|
* function material() {
|
|
16342
|
-
* let time =
|
|
16363
|
+
* let time = millis();
|
|
16343
16364
|
* worldInputs.begin();
|
|
16344
16365
|
* worldInputs.position.y +=
|
|
16345
16366
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -16349,7 +16370,6 @@ function material(p5, fn) {
|
|
|
16349
16370
|
* function draw() {
|
|
16350
16371
|
* background(255);
|
|
16351
16372
|
* shader(myShader);
|
|
16352
|
-
* myShader.setUniform('time', millis());
|
|
16353
16373
|
* noStroke();
|
|
16354
16374
|
* fill('red');
|
|
16355
16375
|
* circle(0, 0, 50);
|
|
@@ -16398,7 +16418,6 @@ function material(p5, fn) {
|
|
|
16398
16418
|
* function draw() {
|
|
16399
16419
|
* background(255);
|
|
16400
16420
|
* shader(myShader);
|
|
16401
|
-
* myShader.setUniform('time', millis());
|
|
16402
16421
|
* lights();
|
|
16403
16422
|
* noStroke();
|
|
16404
16423
|
* fill('red');
|
|
@@ -16412,7 +16431,7 @@ function material(p5, fn) {
|
|
|
16412
16431
|
*
|
|
16413
16432
|
* ```js
|
|
16414
16433
|
* // myMaterial.js
|
|
16415
|
-
* let time =
|
|
16434
|
+
* let time = millis();
|
|
16416
16435
|
* worldInputs.begin();
|
|
16417
16436
|
* worldInputs.position.y +=
|
|
16418
16437
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -16440,7 +16459,7 @@ function material(p5, fn) {
|
|
|
16440
16459
|
fn.loadColorShader = async function (url, onSuccess, onFail) {
|
|
16441
16460
|
try {
|
|
16442
16461
|
const cb = await urlToStrandsCallback(url);
|
|
16443
|
-
let shader = withGlobalStrands(this, () => this.buildColorShader(cb));
|
|
16462
|
+
let shader = this._internal(() => withGlobalStrands(this, () => this.buildColorShader(cb)));
|
|
16444
16463
|
if (onSuccess) {
|
|
16445
16464
|
shader = onSuccess(shader) || shader;
|
|
16446
16465
|
}
|
|
@@ -16584,7 +16603,7 @@ function material(p5, fn) {
|
|
|
16584
16603
|
* }
|
|
16585
16604
|
*
|
|
16586
16605
|
* function material() {
|
|
16587
|
-
* let time =
|
|
16606
|
+
* let time = millis();
|
|
16588
16607
|
* worldInputs.begin();
|
|
16589
16608
|
* // Add a somewhat random offset to the weight
|
|
16590
16609
|
* // that varies based on position and time
|
|
@@ -16600,7 +16619,6 @@ function material(p5, fn) {
|
|
|
16600
16619
|
* function draw() {
|
|
16601
16620
|
* background(255);
|
|
16602
16621
|
* strokeShader(myShader);
|
|
16603
|
-
* myShader.setUniform('time', millis());
|
|
16604
16622
|
* strokeWeight(10);
|
|
16605
16623
|
* beginShape();
|
|
16606
16624
|
* for (let i = 0; i <= 50; i++) {
|
|
@@ -16701,7 +16719,7 @@ function material(p5, fn) {
|
|
|
16701
16719
|
fn.loadStrokeShader = async function (url, onSuccess, onFail) {
|
|
16702
16720
|
try {
|
|
16703
16721
|
const cb = await urlToStrandsCallback(url);
|
|
16704
|
-
let shader = withGlobalStrands(this, () => this.buildStrokeShader(cb));
|
|
16722
|
+
let shader = this._internal(() => withGlobalStrands(this, () => this.buildStrokeShader(cb)));
|
|
16705
16723
|
if (onSuccess) {
|
|
16706
16724
|
shader = onSuccess(shader) || shader;
|
|
16707
16725
|
}
|
|
@@ -18997,11 +19015,18 @@ class Texture {
|
|
|
18997
19015
|
this.isSrcMediaElement ||
|
|
18998
19016
|
this.isSrcHTMLElement
|
|
18999
19017
|
) {
|
|
19000
|
-
//
|
|
19001
|
-
|
|
19018
|
+
// createCapture elements that are flipped need
|
|
19019
|
+
// to go through a canvas
|
|
19020
|
+
if (this.isSrcMediaElement && this.src.flipped) {
|
|
19002
19021
|
this.src._ensureCanvas();
|
|
19022
|
+
textureData = this.src.canvas;
|
|
19023
|
+
} else {
|
|
19024
|
+
// if param is a video HTML element
|
|
19025
|
+
if (this.src._checkIfTextureNeedsUpdate) {
|
|
19026
|
+
this.src._checkIfTextureNeedsUpdate();
|
|
19027
|
+
}
|
|
19028
|
+
textureData = this.src.elt;
|
|
19003
19029
|
}
|
|
19004
|
-
textureData = this.src.elt;
|
|
19005
19030
|
} else if (this.isSrcP5Graphics || this.isSrcP5Renderer) {
|
|
19006
19031
|
textureData = this.src.canvas;
|
|
19007
19032
|
} else if (this.isImageData) {
|
package/dist/shape/attributes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as CORNER, t as CORNERS, u as RADIUS, v as CENTER, w as ROUND, x as SQUARE, y as PROJECT, z as BEVEL, I as MITER } from '../constants-
|
|
1
|
+
import { p as CORNER, t as CORNERS, u as RADIUS, v as CENTER, w as ROUND, x as SQUARE, y as PROJECT, z as BEVEL, I as MITER } from '../constants-BUwWryrh.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @module Shape
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as Color } from '../creating_reading-C7hu6sg1.js';
|
|
2
2
|
import { Vector } from '../math/p5.Vector.js';
|
|
3
|
-
import { J as INCLUDE, K as PATH, O as EMPTY_PATH, Q as OPEN, V as CLOSE, X as POINTS, Y as LINES, c as TRIANGLES, Z as QUADS, _ as TRIANGLE_FAN, T as TRIANGLE_STRIP, $ as QUAD_STRIP, a0 as EXCLUDE, a1 as JOIN } from '../constants-
|
|
3
|
+
import { J as INCLUDE, K as PATH, O as EMPTY_PATH, Q as OPEN, V as CLOSE, X as POINTS, Y as LINES, c as TRIANGLES, Z as QUADS, _ as TRIANGLE_FAN, T as TRIANGLE_STRIP, $ as QUAD_STRIP, a0 as EXCLUDE, a1 as JOIN } from '../constants-BUwWryrh.js';
|
|
4
4
|
import 'colorjs.io/fn';
|
|
5
5
|
import '../color/color_spaces/hsb.js';
|
|
6
6
|
|
package/dist/shape/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import attributes from './attributes.js';
|
|
|
3
3
|
import curves from './curves.js';
|
|
4
4
|
import vertex from './vertex.js';
|
|
5
5
|
import customShapes from './custom_shapes.js';
|
|
6
|
-
import '../constants-
|
|
6
|
+
import '../constants-BUwWryrh.js';
|
|
7
7
|
import '../core/helpers.js';
|
|
8
8
|
import '../creating_reading-C7hu6sg1.js';
|
|
9
9
|
import 'colorjs.io/fn';
|
|
@@ -2,5 +2,5 @@ import './ir_dag.js';
|
|
|
2
2
|
import './ir_cfg.js';
|
|
3
3
|
import './strands_FES.js';
|
|
4
4
|
import './ir_types.js';
|
|
5
|
-
export {
|
|
5
|
+
export { b as binaryOpNode, h as castToFloat, g as constructTypeFromIDs, f as functionCallNode, m as memberAccessNode, p as primitiveConstructorNode, e as scalarLiteralNode, s as statementNode, d as structConstructorNode, a as structInstanceNode, i as swizzleNode, j as swizzleTrap, u as unaryOpNode, v as variableNode } from '../ir_builders-Cd6rU9Vm.js';
|
|
6
6
|
import './strands_builtins.js';
|
package/dist/strands/ir_dag.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasePriority, NodeTypeRequiredFields, NodeTypeToName } from './ir_types.js';
|
|
1
|
+
import { BasePriority, NodeTypeRequiredFields, NodeTypeToName, BaseType } from './ir_types.js';
|
|
2
2
|
import { internalError } from './strands_FES.js';
|
|
3
3
|
|
|
4
4
|
/////////////////////////////////
|
|
@@ -81,6 +81,36 @@ function extractNodeTypeInfo(dag, nodeID) {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// Propagate a known type to an ASSIGN_ON_USE node and all its ASSIGN_ON_USE dependencies
|
|
85
|
+
function propagateTypeToAssignOnUse(dag, nodeId, baseType, dimension, visited = new Set()) {
|
|
86
|
+
// Avoid infinite loops
|
|
87
|
+
if (visited.has(nodeId)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
visited.add(nodeId);
|
|
91
|
+
|
|
92
|
+
const node = getNodeDataFromID(dag, nodeId);
|
|
93
|
+
|
|
94
|
+
// Only update if this node is ASSIGN_ON_USE
|
|
95
|
+
if (node.baseType !== BaseType.ASSIGN_ON_USE) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Update this node's type
|
|
100
|
+
dag.baseTypes[nodeId] = baseType;
|
|
101
|
+
dag.dimensions[nodeId] = dimension;
|
|
102
|
+
|
|
103
|
+
// Recursively propagate to any ASSIGN_ON_USE dependencies
|
|
104
|
+
if (node.dependsOn && node.dependsOn.length > 0) {
|
|
105
|
+
for (const depId of node.dependsOn) {
|
|
106
|
+
const dep = getNodeDataFromID(dag, depId);
|
|
107
|
+
if (dep.baseType === BaseType.ASSIGN_ON_USE) {
|
|
108
|
+
propagateTypeToAssignOnUse(dag, depId, baseType, dimension, visited);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
84
114
|
/////////////////////////////////
|
|
85
115
|
// Private functions
|
|
86
116
|
/////////////////////////////////
|
|
@@ -127,4 +157,4 @@ function validateNode(node){
|
|
|
127
157
|
}
|
|
128
158
|
}
|
|
129
159
|
|
|
130
|
-
export { createDirectedAcyclicGraph, createNodeData, extractNodeTypeInfo, getNodeDataFromID, getOrCreateNode };
|
|
160
|
+
export { createDirectedAcyclicGraph, createNodeData, extractNodeTypeInfo, getNodeDataFromID, getOrCreateNode, propagateTypeToAssignOnUse };
|
package/dist/strands/ir_types.js
CHANGED
|
@@ -37,6 +37,7 @@ const BaseType = {
|
|
|
37
37
|
BOOL: "bool",
|
|
38
38
|
MAT: "mat",
|
|
39
39
|
DEFER: "defer",
|
|
40
|
+
ASSIGN_ON_USE: "assign_on_use",
|
|
40
41
|
SAMPLER2D: "sampler2D",
|
|
41
42
|
SAMPLER: "sampler",
|
|
42
43
|
};
|
|
@@ -46,6 +47,7 @@ const BasePriority = {
|
|
|
46
47
|
[BaseType.BOOL]: 1,
|
|
47
48
|
[BaseType.MAT]: 0,
|
|
48
49
|
[BaseType.DEFER]: -1,
|
|
50
|
+
[BaseType.ASSIGN_ON_USE]: -2,
|
|
49
51
|
[BaseType.SAMPLER2D]: -10,
|
|
50
52
|
[BaseType.SAMPLER]: -11,
|
|
51
53
|
};
|
|
@@ -66,6 +68,7 @@ const DataType = {
|
|
|
66
68
|
mat3: { fnName: "mat3x3", baseType: BaseType.MAT, dimension:3, priority: 0, },
|
|
67
69
|
mat4: { fnName: "mat4x4", baseType: BaseType.MAT, dimension:4, priority: 0, },
|
|
68
70
|
defer: { fnName: null, baseType: BaseType.DEFER, dimension: null, priority: -1 },
|
|
71
|
+
assign_on_use: { fnName: null, baseType: BaseType.ASSIGN_ON_USE, dimension: null, priority: -2 },
|
|
69
72
|
sampler2D: { fnName: "sampler2D", baseType: BaseType.SAMPLER2D, dimension: 1, priority: -10 },
|
|
70
73
|
sampler: { fnName: "sampler", baseType: BaseType.SAMPLER, dimension: 1, priority: -11 },
|
|
71
74
|
};
|
|
@@ -137,7 +140,7 @@ const OpCode = {
|
|
|
137
140
|
}
|
|
138
141
|
};
|
|
139
142
|
const OperatorTable = [
|
|
140
|
-
{ arity: "unary", name: "not", symbol: "!", opCode: OpCode.Unary.LOGICAL_NOT },
|
|
143
|
+
{ arity: "unary", boolean: true, name: "not", symbol: "!", opCode: OpCode.Unary.LOGICAL_NOT },
|
|
141
144
|
{ arity: "unary", name: "neg", symbol: "-", opCode: OpCode.Unary.NEGATE },
|
|
142
145
|
{ arity: "unary", name: "plus", symbol: "+", opCode: OpCode.Unary.PLUS },
|
|
143
146
|
{ arity: "binary", name: "add", symbol: "+", opCode: OpCode.Binary.ADD },
|
|
@@ -145,14 +148,14 @@ const OperatorTable = [
|
|
|
145
148
|
{ arity: "binary", name: "mult", symbol: "*", opCode: OpCode.Binary.MULTIPLY },
|
|
146
149
|
{ arity: "binary", name: "div", symbol: "/", opCode: OpCode.Binary.DIVIDE },
|
|
147
150
|
{ arity: "binary", name: "mod", symbol: "%", opCode: OpCode.Binary.MODULO },
|
|
148
|
-
{ arity: "binary", name: "equalTo", symbol: "==", opCode: OpCode.Binary.EQUAL },
|
|
149
|
-
{ arity: "binary", name: "notEqual", symbol: "!=", opCode: OpCode.Binary.NOT_EQUAL },
|
|
150
|
-
{ arity: "binary", name: "greaterThan", symbol: ">", opCode: OpCode.Binary.GREATER_THAN },
|
|
151
|
-
{ arity: "binary", name: "greaterEqual", symbol: ">=", opCode: OpCode.Binary.GREATER_EQUAL },
|
|
152
|
-
{ arity: "binary", name: "lessThan", symbol: "<", opCode: OpCode.Binary.LESS_THAN },
|
|
153
|
-
{ arity: "binary", name: "lessEqual", symbol: "<=", opCode: OpCode.Binary.LESS_EQUAL },
|
|
154
|
-
{ arity: "binary", name: "and", symbol: "&&", opCode: OpCode.Binary.LOGICAL_AND },
|
|
155
|
-
{ arity: "binary", name: "or", symbol: "||", opCode: OpCode.Binary.LOGICAL_OR },
|
|
151
|
+
{ arity: "binary", boolean: true, name: "equalTo", symbol: "==", opCode: OpCode.Binary.EQUAL },
|
|
152
|
+
{ arity: "binary", boolean: true, name: "notEqual", symbol: "!=", opCode: OpCode.Binary.NOT_EQUAL },
|
|
153
|
+
{ arity: "binary", boolean: true, name: "greaterThan", symbol: ">", opCode: OpCode.Binary.GREATER_THAN },
|
|
154
|
+
{ arity: "binary", boolean: true, name: "greaterEqual", symbol: ">=", opCode: OpCode.Binary.GREATER_EQUAL },
|
|
155
|
+
{ arity: "binary", boolean: true, name: "lessThan", symbol: "<", opCode: OpCode.Binary.LESS_THAN },
|
|
156
|
+
{ arity: "binary", boolean: true, name: "lessEqual", symbol: "<=", opCode: OpCode.Binary.LESS_EQUAL },
|
|
157
|
+
{ arity: "binary", boolean: true, name: "and", symbol: "&&", opCode: OpCode.Binary.LOGICAL_AND },
|
|
158
|
+
{ arity: "binary", boolean: true, name: "or", symbol: "||", opCode: OpCode.Binary.LOGICAL_OR },
|
|
156
159
|
];
|
|
157
160
|
const ConstantFolding = {
|
|
158
161
|
[OpCode.Binary.ADD]: (a, b) => a + b,
|
|
@@ -173,7 +176,8 @@ const ConstantFolding = {
|
|
|
173
176
|
const OpCodeToSymbol = {};
|
|
174
177
|
const UnarySymbolToName = {};
|
|
175
178
|
const BinarySymbolToName = {};
|
|
176
|
-
|
|
179
|
+
const booleanOpCode = {};
|
|
180
|
+
for (const { symbol, opCode, name, arity, boolean } of OperatorTable) {
|
|
177
181
|
// SymbolToOpCode[symbol] = opCode;
|
|
178
182
|
OpCodeToSymbol[opCode] = symbol;
|
|
179
183
|
if (arity === 'unary') {
|
|
@@ -182,6 +186,9 @@ for (const { symbol, opCode, name, arity } of OperatorTable) {
|
|
|
182
186
|
if (arity === 'binary') {
|
|
183
187
|
BinarySymbolToName[symbol] = name;
|
|
184
188
|
}
|
|
189
|
+
if (boolean) {
|
|
190
|
+
booleanOpCode[opCode] = true;
|
|
191
|
+
}
|
|
185
192
|
}
|
|
186
193
|
const BlockType = {
|
|
187
194
|
GLOBAL: 'global',
|
|
@@ -200,4 +207,4 @@ const BlockTypeToName = Object.fromEntries(
|
|
|
200
207
|
Object.entries(BlockType).map(([key, val]) => [val, key])
|
|
201
208
|
);
|
|
202
209
|
|
|
203
|
-
export { BasePriority, BaseType, BinarySymbolToName, BlockType, BlockTypeToName, ConstantFolding, DataType, GenType, NodeType, NodeTypeRequiredFields, NodeTypeToName, OpCode, OpCodeToSymbol, OperatorTable, StatementType, TypeInfoFromGLSLName, UnarySymbolToName, isStructType, structType, typeEquals };
|
|
210
|
+
export { BasePriority, BaseType, BinarySymbolToName, BlockType, BlockTypeToName, ConstantFolding, DataType, GenType, NodeType, NodeTypeRequiredFields, NodeTypeToName, OpCode, OpCodeToSymbol, OperatorTable, StatementType, TypeInfoFromGLSLName, UnarySymbolToName, booleanOpCode, isStructType, structType, typeEquals };
|