p5 2.3.0 → 2.3.1-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.
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 +2 -2
  11. package/dist/{constants-Dv6ZqA6s.js → constants-Bx3_xAam.js} +1 -1
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +1 -1
  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 +1 -1
  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-YUSK33h8.js} +8 -0
  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-BpW7VbDr.js} +39 -208
  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-op0Y1WO6.js} +2 -2
  55. package/dist/{rendering-C5lX6zKm.js → rendering-SZ71KIDM.js} +24 -9
  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 +1 -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 +6 -6
  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 +2 -2
  93. package/dist/webgpu/strands_wgslBackend.js +2 -2
  94. package/lib/p5.esm.js +1765 -405
  95. package/lib/p5.esm.min.js +1 -1
  96. package/lib/p5.js +1765 -405
  97. package/lib/p5.min.js +1 -1
  98. package/lib/p5.webgpu.esm.js +34 -3
  99. package/lib/p5.webgpu.js +34 -3
  100. package/lib/p5.webgpu.min.js +1 -1
  101. package/package.json +1 -1
  102. package/types/global.d.ts +5539 -2604
  103. package/types/p5.d.ts +2917 -1432
@@ -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.1';
15
15
 
16
16
  // GRAPHICS RENDERER
17
17
  /**
@@ -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];
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.1';
18
18
 
19
19
  // GRAPHICS RENDERER
20
20
  /**
@@ -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];