p5 2.3.0 → 2.3.1-rc.2

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.
Files changed (103) hide show
  1. package/README.md +3 -11
  2. package/dist/accessibility/color_namer.js +7 -7
  3. package/dist/accessibility/index.js +7 -7
  4. package/dist/app.js +7 -7
  5. package/dist/app.node.js +7 -7
  6. package/dist/color/color_conversion.js +7 -7
  7. package/dist/color/creating_reading.js +1 -1
  8. package/dist/color/index.js +2 -2
  9. package/dist/color/p5.Color.js +1 -1
  10. package/dist/color/setting.js +10 -10
  11. package/dist/{constants-Dv6ZqA6s.js → constants-DkQDfqzw.js} +8 -8
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +3 -3
  14. package/dist/core/filterShaders.js +1 -1
  15. package/dist/core/friendly_errors/fes_core.js +1 -1
  16. package/dist/core/friendly_errors/file_errors.js +1 -1
  17. package/dist/core/friendly_errors/index.js +1 -1
  18. package/dist/core/friendly_errors/param_validator.js +489 -466
  19. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  20. package/dist/core/helpers.js +1 -1
  21. package/dist/core/init.js +7 -7
  22. package/dist/core/internationalization.js +1 -1
  23. package/dist/core/legacy.js +7 -7
  24. package/dist/core/main.js +7 -7
  25. package/dist/core/p5.Graphics.js +4 -4
  26. package/dist/core/p5.Renderer.js +3 -3
  27. package/dist/core/p5.Renderer2D.js +7 -7
  28. package/dist/core/p5.Renderer3D.js +4 -4
  29. package/dist/core/rendering.js +4 -4
  30. package/dist/{creating_reading-DLkHH80h.js → creating_reading-Dyt2y-6S.js} +25 -17
  31. package/dist/dom/dom.js +2 -2
  32. package/dist/dom/index.js +2 -2
  33. package/dist/dom/p5.Element.js +2 -2
  34. package/dist/dom/p5.MediaElement.js +2 -2
  35. package/dist/events/pointer.js +15 -0
  36. package/dist/image/const.js +1 -1
  37. package/dist/image/filterRenderer2D.js +6 -6
  38. package/dist/image/image.js +4 -4
  39. package/dist/image/index.js +4 -4
  40. package/dist/image/loading_displaying.js +4 -4
  41. package/dist/image/p5.Image.js +3 -3
  42. package/dist/io/files.js +4 -4
  43. package/dist/io/index.js +4 -4
  44. package/dist/{ir_builders-C8mrXj5z.js → ir_builders-CMXkjMoV.js} +34 -24
  45. package/dist/{main-BR2ALC_6.js → main-CAqj0AHr.js} +41 -210
  46. package/dist/math/Matrices/Matrix.js +1 -1
  47. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  48. package/dist/math/calculation.js +669 -84
  49. package/dist/math/index.js +1 -1
  50. package/dist/math/p5.Matrix.js +1 -1
  51. package/dist/math/p5.Vector.js +9 -1
  52. package/dist/math/patch-vector.js +3 -1
  53. package/dist/math/trigonometry.js +399 -48
  54. package/dist/{p5.Renderer-XOvhEbJn.js → p5.Renderer-Bf-YLpi6.js} +2 -2
  55. package/dist/{rendering-C5lX6zKm.js → rendering-BowMW0pZ.js} +32 -13
  56. package/dist/shape/2d_primitives.js +1 -1
  57. package/dist/shape/attributes.js +4 -3
  58. package/dist/shape/custom_shapes.js +205 -3
  59. package/dist/shape/index.js +2 -2
  60. package/dist/strands/ir_builders.js +1 -1
  61. package/dist/strands/p5.strands.js +26 -9
  62. package/dist/strands/strands_FES.js +8 -1
  63. package/dist/strands/strands_api.js +316 -21
  64. package/dist/strands/strands_conditionals.js +1 -1
  65. package/dist/strands/strands_for.js +1 -1
  66. package/dist/strands/strands_node.js +1 -1
  67. package/dist/strands/strands_ternary.js +1 -1
  68. package/dist/{strands_glslBackend-D6G3UyCs.js → strands_glslBackend-DMhOnoGl.js} +2 -2
  69. package/dist/type/index.js +3 -3
  70. package/dist/type/p5.Font.js +13 -4
  71. package/dist/type/textCore.js +3 -3
  72. package/dist/webgl/3d_primitives.js +4 -4
  73. package/dist/webgl/GeometryBuilder.js +1 -1
  74. package/dist/webgl/ShapeBuilder.js +50 -1
  75. package/dist/webgl/enums.js +1 -1
  76. package/dist/webgl/index.js +6 -6
  77. package/dist/webgl/interaction.js +1 -1
  78. package/dist/webgl/light.js +4 -4
  79. package/dist/webgl/loading.js +4 -4
  80. package/dist/webgl/material.js +4 -4
  81. package/dist/webgl/p5.Camera.js +4 -4
  82. package/dist/webgl/p5.Framebuffer.js +4 -4
  83. package/dist/webgl/p5.Geometry.js +1 -1
  84. package/dist/webgl/p5.Quat.js +1 -1
  85. package/dist/webgl/p5.RendererGL.js +20 -9
  86. package/dist/webgl/p5.Shader.js +5 -1
  87. package/dist/webgl/p5.Texture.js +4 -4
  88. package/dist/webgl/strands_glslBackend.js +2 -2
  89. package/dist/webgl/text.js +4 -4
  90. package/dist/webgl/utils.js +4 -4
  91. package/dist/webgpu/index.js +2 -2
  92. package/dist/webgpu/p5.RendererWebGPU.js +6 -2
  93. package/dist/webgpu/strands_wgslBackend.js +2 -2
  94. package/lib/p5.esm.js +2358 -911
  95. package/lib/p5.esm.min.js +1 -1
  96. package/lib/p5.js +2358 -911
  97. package/lib/p5.min.js +1 -1
  98. package/lib/p5.webgpu.esm.js +44 -9
  99. package/lib/p5.webgpu.js +44 -9
  100. package/lib/p5.webgpu.min.js +1 -1
  101. package/package.json +1 -1
  102. package/types/global.d.ts +5785 -2850
  103. package/types/p5.d.ts +3016 -1531
@@ -11,7 +11,7 @@ const _PI = Math.PI;
11
11
  * @property {String} VERSION
12
12
  * @final
13
13
  */
14
- const VERSION = '2.3.0';
14
+ const VERSION = '2.3.1-rc.2';
15
15
 
16
16
  // GRAPHICS RENDERER
17
17
  /**
@@ -27,18 +27,18 @@ const VERSION = '2.3.0';
27
27
  const P2D = 'p2d';
28
28
 
29
29
  /**
30
- * A high-dynamic-range (HDR) variant of the default, two-dimensional renderer.
30
+ * An expanded color space (P3) variant of the default, two-dimensional renderer.
31
31
  *
32
32
  * When available, this mode can allow for extended color ranges and more
33
33
  * dynamic color representation. Use it similarly to `P2D`:
34
- * `createCanvas(400, 400, P2DHDR)`.
34
+ * `createCanvas(400, 400, P2DP3)`.
35
35
  *
36
- * @typedef {'p2d-hdr'} P2DHDR
37
- * @property {P2DHDR} P2DHDR
36
+ * @typedef {'p2d-p3'} P2DP3
37
+ * @property {P2DP3} P2DP3
38
38
  * @final
39
39
  */
40
40
 
41
- const P2DHDR = 'p2d-hdr';
41
+ const P2DP3 = 'p2d-p3';
42
42
 
43
43
  /**
44
44
  * One of the two render modes in p5.js, used for computationally intensive tasks like 3D rendering and shaders.
@@ -1339,7 +1339,7 @@ var constants = /*#__PURE__*/Object.freeze({
1339
1339
  OPTION: OPTION,
1340
1340
  OVERLAY: OVERLAY,
1341
1341
  P2D: P2D,
1342
- P2DHDR: P2DHDR,
1342
+ P2DP3: P2DP3,
1343
1343
  PATH: PATH,
1344
1344
  PI: PI,
1345
1345
  PIE: PIE,
@@ -3057,6 +3057,13 @@ function userError(errorType, errorMessage) {
3057
3057
  throw new Error(prefixedMessage);
3058
3058
  }
3059
3059
 
3060
+ function dimensionMismatchError(declaredDim,actualDim,varName){
3061
+ userError(
3062
+ 'dimension mismatch',
3063
+ `Cannot assign a value of dimension ${actualDim} to \`${varName}\`, which expects dimension ${declaredDim}.`
3064
+ );
3065
+ }
3066
+
3060
3067
  function getOrCreateNode(graph, node) {
3061
3068
  // const key = getNodeKey(node);
3062
3069
  // const existing = graph.cache.get(key);
@@ -3224,6 +3231,16 @@ class StrandsNode {
3224
3231
 
3225
3232
  // For varying variables, we need both assignment generation AND a way to reference by identifier
3226
3233
  if (this._originalIdentifier) {
3234
+ const valueDim = value?.isStrandsNode
3235
+ ? value.dimension
3236
+ : (Array.isArray(value) ? value.length : 1);
3237
+ if (valueDim !== this._originalDimension && valueDim !== 1){
3238
+ dimensionMismatchError(
3239
+ this._originalDimension,
3240
+ valueDim,
3241
+ this._originalIdentifier
3242
+ );
3243
+ }
3227
3244
  // Create a variable node for the target (the varying variable)
3228
3245
  const { id: targetVarID } = variableNode(
3229
3246
  this.strandsContext,
@@ -3276,6 +3293,16 @@ class StrandsNode {
3276
3293
 
3277
3294
  // For varying variables, create swizzle assignment
3278
3295
  if (this._originalIdentifier) {
3296
+ const valueDim = value?.isStrandsNode
3297
+ ? value.dimension
3298
+ : (Array.isArray(value) ? value.length : 1);
3299
+ if (valueDim !== swizzlePattern.length && valueDim !== 1){
3300
+ dimensionMismatchError(
3301
+ swizzlePattern.length,
3302
+ valueDim,
3303
+ `${this._originalIdentifier}.${swizzlePattern}`
3304
+ );
3305
+ }
3279
3306
  // Create a variable node for the target with swizzle
3280
3307
  const { id: targetVarID } = variableNode(
3281
3308
  this.strandsContext,
@@ -3839,7 +3866,11 @@ function swizzleTrap(id, dimension, strandsContext, onRebind) {
3839
3866
  scalars.push(createStrandsNode(id, dimension, strandsContext));
3840
3867
  }
3841
3868
  } else {
3842
- userError('type error', `Swizzle assignment: RHS vector does not match LHS vector (need ${chars.length}, got ${value.dimension}).`);
3869
+ dimensionMismatchError(
3870
+ chars.length,
3871
+ value.dimension,
3872
+ `${target._originalIdentifier || 'value'}.${property}`
3873
+ );
3843
3874
  }
3844
3875
  } else if (Array.isArray(value)) {
3845
3876
  const flat = value.flat(Infinity);
@@ -4472,7 +4503,7 @@ const wgslBackend = {
4472
4503
  }
4473
4504
  const dag = strandsContext.dag;
4474
4505
  const rootNode = getNodeDataFromID(dag, rootNodeID);
4475
- if (isStructType(returnType)) {
4506
+ if (isStructType(returnType) && rootNode.identifier) {
4476
4507
  const structTypeInfo = returnType;
4477
4508
  for (let i = 0; i < structTypeInfo.properties.length; i++) {
4478
4509
  const prop = structTypeInfo.properties[i];
@@ -6358,6 +6389,10 @@ function rendererWebGPU(p5, fn) {
6358
6389
  );
6359
6390
  }
6360
6391
 
6392
+ supportsTriangleFan() {
6393
+ return false;
6394
+ }
6395
+
6361
6396
  viewport() {}
6362
6397
 
6363
6398
  zClipRange() {
package/lib/p5.webgpu.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * @property {String} VERSION
15
15
  * @final
16
16
  */
17
- const VERSION = '2.3.0';
17
+ const VERSION = '2.3.1-rc.2';
18
18
 
19
19
  // GRAPHICS RENDERER
20
20
  /**
@@ -30,18 +30,18 @@
30
30
  const P2D = 'p2d';
31
31
 
32
32
  /**
33
- * A high-dynamic-range (HDR) variant of the default, two-dimensional renderer.
33
+ * An expanded color space (P3) variant of the default, two-dimensional renderer.
34
34
  *
35
35
  * When available, this mode can allow for extended color ranges and more
36
36
  * dynamic color representation. Use it similarly to `P2D`:
37
- * `createCanvas(400, 400, P2DHDR)`.
37
+ * `createCanvas(400, 400, P2DP3)`.
38
38
  *
39
- * @typedef {'p2d-hdr'} P2DHDR
40
- * @property {P2DHDR} P2DHDR
39
+ * @typedef {'p2d-p3'} P2DP3
40
+ * @property {P2DP3} P2DP3
41
41
  * @final
42
42
  */
43
43
 
44
- const P2DHDR = 'p2d-hdr';
44
+ const P2DP3 = 'p2d-p3';
45
45
 
46
46
  /**
47
47
  * One of the two render modes in p5.js, used for computationally intensive tasks like 3D rendering and shaders.
@@ -1342,7 +1342,7 @@
1342
1342
  OPTION: OPTION,
1343
1343
  OVERLAY: OVERLAY,
1344
1344
  P2D: P2D,
1345
- P2DHDR: P2DHDR,
1345
+ P2DP3: P2DP3,
1346
1346
  PATH: PATH,
1347
1347
  PI: PI,
1348
1348
  PIE: PIE,
@@ -3060,6 +3060,13 @@ fn random(seed: f32, invocationId: vec3<u32>) -> f32 {
3060
3060
  throw new Error(prefixedMessage);
3061
3061
  }
3062
3062
 
3063
+ function dimensionMismatchError(declaredDim,actualDim,varName){
3064
+ userError(
3065
+ 'dimension mismatch',
3066
+ `Cannot assign a value of dimension ${actualDim} to \`${varName}\`, which expects dimension ${declaredDim}.`
3067
+ );
3068
+ }
3069
+
3063
3070
  function getOrCreateNode(graph, node) {
3064
3071
  // const key = getNodeKey(node);
3065
3072
  // const existing = graph.cache.get(key);
@@ -3227,6 +3234,16 @@ fn random(seed: f32, invocationId: vec3<u32>) -> f32 {
3227
3234
 
3228
3235
  // For varying variables, we need both assignment generation AND a way to reference by identifier
3229
3236
  if (this._originalIdentifier) {
3237
+ const valueDim = value?.isStrandsNode
3238
+ ? value.dimension
3239
+ : (Array.isArray(value) ? value.length : 1);
3240
+ if (valueDim !== this._originalDimension && valueDim !== 1){
3241
+ dimensionMismatchError(
3242
+ this._originalDimension,
3243
+ valueDim,
3244
+ this._originalIdentifier
3245
+ );
3246
+ }
3230
3247
  // Create a variable node for the target (the varying variable)
3231
3248
  const { id: targetVarID } = variableNode(
3232
3249
  this.strandsContext,
@@ -3279,6 +3296,16 @@ fn random(seed: f32, invocationId: vec3<u32>) -> f32 {
3279
3296
 
3280
3297
  // For varying variables, create swizzle assignment
3281
3298
  if (this._originalIdentifier) {
3299
+ const valueDim = value?.isStrandsNode
3300
+ ? value.dimension
3301
+ : (Array.isArray(value) ? value.length : 1);
3302
+ if (valueDim !== swizzlePattern.length && valueDim !== 1){
3303
+ dimensionMismatchError(
3304
+ swizzlePattern.length,
3305
+ valueDim,
3306
+ `${this._originalIdentifier}.${swizzlePattern}`
3307
+ );
3308
+ }
3282
3309
  // Create a variable node for the target with swizzle
3283
3310
  const { id: targetVarID } = variableNode(
3284
3311
  this.strandsContext,
@@ -3842,7 +3869,11 @@ fn random(seed: f32, invocationId: vec3<u32>) -> f32 {
3842
3869
  scalars.push(createStrandsNode(id, dimension, strandsContext));
3843
3870
  }
3844
3871
  } else {
3845
- userError('type error', `Swizzle assignment: RHS vector does not match LHS vector (need ${chars.length}, got ${value.dimension}).`);
3872
+ dimensionMismatchError(
3873
+ chars.length,
3874
+ value.dimension,
3875
+ `${target._originalIdentifier || 'value'}.${property}`
3876
+ );
3846
3877
  }
3847
3878
  } else if (Array.isArray(value)) {
3848
3879
  const flat = value.flat(Infinity);
@@ -4475,7 +4506,7 @@ fn random(seed: f32, invocationId: vec3<u32>) -> f32 {
4475
4506
  }
4476
4507
  const dag = strandsContext.dag;
4477
4508
  const rootNode = getNodeDataFromID(dag, rootNodeID);
4478
- if (isStructType(returnType)) {
4509
+ if (isStructType(returnType) && rootNode.identifier) {
4479
4510
  const structTypeInfo = returnType;
4480
4511
  for (let i = 0; i < structTypeInfo.properties.length; i++) {
4481
4512
  const prop = structTypeInfo.properties[i];
@@ -6361,6 +6392,10 @@ fn main(
6361
6392
  );
6362
6393
  }
6363
6394
 
6395
+ supportsTriangleFan() {
6396
+ return false;
6397
+ }
6398
+
6364
6399
  viewport() {}
6365
6400
 
6366
6401
  zClipRange() {