p5 2.2.1 → 2.2.2-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 (94) hide show
  1. package/dist/accessibility/color_namer.js +6 -6
  2. package/dist/accessibility/index.js +6 -6
  3. package/dist/app.js +6 -6
  4. package/dist/color/color_conversion.js +6 -6
  5. package/dist/color/creating_reading.js +1 -1
  6. package/dist/color/index.js +2 -2
  7. package/dist/color/p5.Color.js +1 -1
  8. package/dist/color/setting.js +2 -2
  9. package/dist/{constants-DQyACdzq.js → constants-DAnmXDew.js} +1 -1
  10. package/dist/core/constants.js +1 -1
  11. package/dist/core/environment.js +1 -1
  12. package/dist/core/filterShaders.js +1 -1
  13. package/dist/core/friendly_errors/fes_core.js +1 -1
  14. package/dist/core/friendly_errors/file_errors.js +1 -1
  15. package/dist/core/friendly_errors/index.js +1 -1
  16. package/dist/core/friendly_errors/param_validator.js +1 -1
  17. package/dist/core/friendly_errors/sketch_verifier.js +2 -2
  18. package/dist/core/helpers.js +1 -1
  19. package/dist/core/init.js +6 -6
  20. package/dist/core/internationalization.js +1 -1
  21. package/dist/core/legacy.js +6 -6
  22. package/dist/core/main.js +6 -6
  23. package/dist/core/p5.Graphics.js +4 -4
  24. package/dist/core/p5.Renderer.js +3 -3
  25. package/dist/core/p5.Renderer2D.js +6 -6
  26. package/dist/core/p5.Renderer3D.js +4 -4
  27. package/dist/core/rendering.js +4 -4
  28. package/dist/{creating_reading-ZXzcZEsb.js → creating_reading-C7hu6sg1.js} +2 -2
  29. package/dist/dom/dom.js +2 -2
  30. package/dist/dom/index.js +2 -2
  31. package/dist/dom/p5.Element.js +2 -2
  32. package/dist/dom/p5.MediaElement.js +2 -2
  33. package/dist/image/const.js +1 -1
  34. package/dist/image/filterRenderer2D.js +5 -5
  35. package/dist/image/image.js +4 -4
  36. package/dist/image/index.js +4 -4
  37. package/dist/image/loading_displaying.js +4 -4
  38. package/dist/image/p5.Image.js +3 -3
  39. package/dist/io/files.js +4 -4
  40. package/dist/io/index.js +4 -4
  41. package/dist/{ir_builders-DXNgaB9N.js → ir_builders-w12-GSxu.js} +37 -5
  42. package/dist/{main-DvN69W3f.js → main-E-swj5tF.js} +4 -4
  43. package/dist/math/Matrices/Matrix.js +1 -1
  44. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  45. package/dist/math/index.js +1 -1
  46. package/dist/math/p5.Matrix.js +1 -1
  47. package/dist/math/p5.Vector.js +1 -1
  48. package/dist/math/trigonometry.js +1 -1
  49. package/dist/{p5.Renderer-D-5LdCRz.js → p5.Renderer-DOk9UW65.js} +2 -2
  50. package/dist/{rendering-h9unX5K0.js → rendering-B8V5Zt4k.js} +58 -14
  51. package/dist/shape/2d_primitives.js +1 -1
  52. package/dist/shape/attributes.js +1 -1
  53. package/dist/shape/custom_shapes.js +2 -2
  54. package/dist/shape/index.js +2 -2
  55. package/dist/strands/ir_builders.js +1 -1
  56. package/dist/strands/p5.strands.js +1 -1
  57. package/dist/strands/strands_api.js +91 -31
  58. package/dist/strands/strands_conditionals.js +1 -1
  59. package/dist/strands/strands_for.js +2 -2
  60. package/dist/strands/strands_node.js +1 -1
  61. package/dist/type/index.js +3 -3
  62. package/dist/type/p5.Font.js +3 -3
  63. package/dist/type/textCore.js +3 -3
  64. package/dist/webgl/3d_primitives.js +4 -4
  65. package/dist/webgl/GeometryBuilder.js +1 -1
  66. package/dist/webgl/ShapeBuilder.js +1 -1
  67. package/dist/webgl/enums.js +1 -1
  68. package/dist/webgl/index.js +5 -5
  69. package/dist/webgl/interaction.js +1 -1
  70. package/dist/webgl/light.js +4 -4
  71. package/dist/webgl/loading.js +12 -14
  72. package/dist/webgl/material.js +4 -4
  73. package/dist/webgl/p5.Camera.js +4 -4
  74. package/dist/webgl/p5.Framebuffer.js +4 -4
  75. package/dist/webgl/p5.Geometry.js +1 -1
  76. package/dist/webgl/p5.Quat.js +1 -1
  77. package/dist/webgl/p5.RendererGL.js +5 -5
  78. package/dist/webgl/p5.Texture.js +4 -4
  79. package/dist/webgl/strands_glslBackend.js +1 -1
  80. package/dist/webgl/text.js +5 -5
  81. package/dist/webgl/utils.js +4 -4
  82. package/dist/webgpu/index.js +2 -2
  83. package/dist/webgpu/p5.RendererWebGPU.js +13 -4
  84. package/dist/webgpu/strands_wgslBackend.js +5 -4
  85. package/lib/p5.esm.js +196 -62
  86. package/lib/p5.esm.min.js +1 -1
  87. package/lib/p5.js +196 -62
  88. package/lib/p5.min.js +1 -1
  89. package/lib/p5.webgpu.esm.js +51 -9
  90. package/lib/p5.webgpu.js +51 -9
  91. package/lib/p5.webgpu.min.js +1 -1
  92. package/package.json +1 -1
  93. package/types/global.d.ts +1453 -1383
  94. package/types/p5.d.ts +729 -694
@@ -1,4 +1,4 @@
1
- import { u as unaryOpNode, c as createStrandsNode, s as statementNode, v as variableNode, S as StrandsNode, p as primitiveConstructorNode, f as functionCallNode, a as structInstanceNode, b as structConstructorNode, d as binaryOpNode } from '../ir_builders-DXNgaB9N.js';
1
+ import { u as unaryOpNode, c as createStrandsNode, s as statementNode, v as variableNode, S as StrandsNode, p as primitiveConstructorNode, f as functionCallNode, a as structInstanceNode, b as structConstructorNode, d as binaryOpNode } from '../ir_builders-w12-GSxu.js';
2
2
  import { OperatorTable, StatementType, NodeType, DataType, BaseType, BlockType, isStructType, structType } from './ir_types.js';
3
3
  import { strandsBuiltinFunctions } from './strands_builtins.js';
4
4
  import { StrandsConditional } from './strands_conditionals.js';
@@ -40,32 +40,45 @@ function _getBuiltinGlobalsCache(strandsContext) {
40
40
  return strandsContext._builtinGlobals
41
41
  }
42
42
 
43
- function getBuiltinGlobalNode(strandsContext, name) {
44
- const spec = BUILTIN_GLOBAL_SPECS[name];
45
- if (!spec) return null
46
-
43
+ function getOrCreateUniformNode(strandsContext, uniformName, typeInfo, defaultValueFn) {
47
44
  const cache = _getBuiltinGlobalsCache(strandsContext);
48
- const uniformName = `_p5_global_${name}`;
45
+
49
46
  const cached = cache.nodes.get(uniformName);
50
- if (cached) return cached
47
+ if (cached) return cached;
51
48
 
52
49
  if (!cache.uniformsAdded.has(uniformName)) {
53
50
  cache.uniformsAdded.add(uniformName);
54
51
  strandsContext.uniforms.push({
55
52
  name: uniformName,
56
- typeInfo: spec.typeInfo,
57
- defaultValue: () => {
58
- const p5Instance = strandsContext.renderer?._pInst || strandsContext.p5?.instance;
59
- return p5Instance ? spec.get(p5Instance) : undefined
60
- },
53
+ typeInfo,
54
+ defaultValue: defaultValueFn,
61
55
  });
62
56
  }
63
57
 
64
- const { id, dimension } = variableNode(strandsContext, spec.typeInfo, uniformName);
58
+ const { id, dimension } = variableNode(strandsContext, typeInfo, uniformName);
65
59
  const node = createStrandsNode(id, dimension, strandsContext);
66
- node._originalBuiltinName = name;
67
60
  cache.nodes.set(uniformName, node);
68
- return node
61
+ return node;
62
+ }
63
+
64
+ function getBuiltinGlobalNode(strandsContext, name) {
65
+ const spec = BUILTIN_GLOBAL_SPECS[name];
66
+ if (!spec) return null;
67
+
68
+ const uniformName = `_p5_global_${name}`;
69
+ const instance = strandsContext.renderer?._pInst || strandsContext.p5?.instance;
70
+
71
+ const node = getOrCreateUniformNode(
72
+ strandsContext,
73
+ uniformName,
74
+ spec.typeInfo,
75
+ () => {
76
+ return instance ? spec.get(instance) : undefined;
77
+ }
78
+ );
79
+
80
+ node._originalBuiltinName = name;
81
+ return node;
69
82
  }
70
83
 
71
84
  function installBuiltinGlobalAccessors(strandsContext) {
@@ -141,7 +154,7 @@ function initGlobalStrandsAPI(p5, fn, strandsContext) {
141
154
  }
142
155
 
143
156
  // Convert value to a StrandsNode if it isn't already
144
- const valueNode = value instanceof StrandsNode ? value : p5.strandsNode(value);
157
+ const valueNode = value?.isStrandsNode ? value : p5.strandsNode(value);
145
158
 
146
159
  // Create a new CFG block for the early return
147
160
  const earlyReturnBlockID = createBasicBlock(cfg, BlockType.DEFAULT);
@@ -228,6 +241,7 @@ function initGlobalStrandsAPI(p5, fn, strandsContext) {
228
241
  // Add noise function with backend-agnostic implementation
229
242
  const originalNoise = fn.noise;
230
243
  const originalNoiseDetail = fn.noiseDetail;
244
+ const originalMillis = fn.millis;
231
245
 
232
246
  strandsContext._noiseOctaves = null;
233
247
  strandsContext._noiseAmpFalloff = null;
@@ -290,6 +304,21 @@ function initGlobalStrandsAPI(p5, fn, strandsContext) {
290
304
  return createStrandsNode(id, dimension, strandsContext);
291
305
  };
292
306
 
307
+ fn.millis = function (...args) {
308
+ if (!strandsContext.active) {
309
+ return originalMillis.apply(this, args);
310
+ }
311
+ const instance = strandsContext.renderer?._pInst || strandsContext.p5?.instance;
312
+ return getOrCreateUniformNode(
313
+ strandsContext,
314
+ '_p5_global_millis',
315
+ DataType.float1,
316
+ () => {
317
+ return instance ? instance.millis() : undefined;
318
+ }
319
+ );
320
+ };
321
+
293
322
  // Next is type constructors and uniform functions.
294
323
  // For some of them, we have aliases so that you can write either a more human-readable
295
324
  // variant or also one more directly translated from GLSL, or to be more compatible with
@@ -356,12 +385,17 @@ function initGlobalStrandsAPI(p5, fn, strandsContext) {
356
385
  fn[typeInfo.fnName] = function(...args) {
357
386
  if (strandsContext.active) {
358
387
  if (args.length === 1 && args[0].dimension && args[0].dimension === typeInfo.dimension) {
359
- const { id, dimension } = functionCallNode(strandsContext, typeInfo.fnName, args, {
360
- overloads: [{
361
- params: [args[0].typeInfo()],
362
- returnType: typeInfo,
363
- }]
364
- });
388
+ const { id, dimension } = functionCallNode(
389
+ strandsContext,
390
+ strandsContext.backend.getTypeName(typeInfo.baseType, typeInfo.dimension),
391
+ args,
392
+ {
393
+ overloads: [{
394
+ params: [args[0].typeInfo()],
395
+ returnType: typeInfo,
396
+ }]
397
+ }
398
+ );
365
399
  return createStrandsNode(id, dimension, strandsContext);
366
400
  } else {
367
401
  // For vector types with a single argument, repeat it for each component
@@ -418,7 +452,7 @@ function createHookArguments(strandsContext, parameters){
418
452
  const oldDependsOn = dag.dependsOn[structNode.id];
419
453
  const newDependsOn = [...oldDependsOn];
420
454
  let newValueID;
421
- if (val instanceof StrandsNode) {
455
+ if (val?.isStrandsNode) {
422
456
  newValueID = val.id;
423
457
  }
424
458
  else {
@@ -450,7 +484,7 @@ function createHookArguments(strandsContext, parameters){
450
484
  return args;
451
485
  }
452
486
  function enforceReturnTypeMatch(strandsContext, expectedType, returned, hookName) {
453
- if (!(returned instanceof StrandsNode)) {
487
+ if (!(returned?.isStrandsNode)) {
454
488
  // try {
455
489
  const result = primitiveConstructorNode(strandsContext, expectedType, returned);
456
490
  return result.id;
@@ -472,7 +506,12 @@ function enforceReturnTypeMatch(strandsContext, expectedType, returned, hookName
472
506
  };
473
507
  if (receivedType.dimension !== expectedType.dimension) {
474
508
  if (receivedType.dimension !== 1) {
475
- userError('type error', `You have returned a vector with ${receivedType.dimension} components in ${hookName} when a ${expectedType.baseType + expectedType.dimension} was expected!`);
509
+ const receivedTypeDisplay = receivedType.baseType + (receivedType.dimension > 1 ? receivedType.dimension : '');
510
+ const expectedTypeDisplay = expectedType.baseType + expectedType.dimension;
511
+ userError('type error',
512
+ `You have returned a ${receivedTypeDisplay} in ${hookName} when a ${expectedTypeDisplay} was expected!\n\n` +
513
+ `Make sure your hook returns the correct type.`
514
+ );
476
515
  }
477
516
  else {
478
517
  const result = primitiveConstructorNode(strandsContext, expectedType, returned);
@@ -559,10 +598,27 @@ function createShaderHooksFunctions(strandsContext, fn, shader) {
559
598
  const handleRetVal = (retNode) => {
560
599
  if(isStructType(expectedReturnType)) {
561
600
  const expectedStructType = structType(expectedReturnType);
562
- if (retNode instanceof StrandsNode) {
601
+ if (retNode?.isStrandsNode) {
563
602
  const returnedNode = getNodeDataFromID(strandsContext.dag, retNode.id);
564
603
  if (returnedNode.baseType !== expectedStructType.typeName) {
565
- userError("type error", `You have returned a ${retNode.baseType} from ${hookType.name} when a ${expectedStructType.typeName} was expected.`);
604
+ const receivedTypeName = returnedNode.baseType || 'undefined';
605
+ const receivedDim = dag.dimensions[retNode.id];
606
+ const receivedTypeDisplay = receivedDim > 1 ?
607
+ `${receivedTypeName}${receivedDim}` : receivedTypeName;
608
+
609
+ const expectedProps = expectedStructType.properties
610
+ .map(p => p.name).join(', ');
611
+ userError('type error',
612
+ `You have returned a ${receivedTypeDisplay} from ${hookType.name} when a ${expectedStructType.typeName} was expected.\n\n` +
613
+ `The ${expectedStructType.typeName} struct has these properties: { ${expectedProps} }\n\n` +
614
+ `Instead of returning a different type, you should modify and return the ${expectedStructType.typeName} struct that was passed to your hook.\n\n` +
615
+ `For example:\n` +
616
+ `${hookType.name}((inputs) => {\n` +
617
+ ` // Modify properties of inputs\n` +
618
+ ` inputs.someProperty = ...;\n` +
619
+ ` return inputs; // Return the modified struct\n` +
620
+ `})`
621
+ );
566
622
  }
567
623
  const newDeps = returnedNode.dependsOn.slice();
568
624
  for (let i = 0; i < expectedStructType.properties.length; i++) {
@@ -581,10 +637,14 @@ function createShaderHooksFunctions(strandsContext, fn, shader) {
581
637
  const propName = expectedProp.name;
582
638
  const receivedValue = retNode[propName];
583
639
  if (receivedValue === undefined) {
584
- userError('type error', `You've returned an incomplete struct from ${hookType.name}.\n` +
585
- `Expected: { ${expectedReturnType.properties.map(p => p.name).join(', ')} }\n` +
586
- `Received: { ${Object.keys(retNode).join(', ')} }\n` +
587
- `All of the properties are required!`);
640
+ const expectedProps = expectedReturnType.properties.map(p => p.name).join(', ');
641
+ const receivedProps = Object.keys(retNode).join(', ');
642
+ userError('type error',
643
+ `You've returned an incomplete ${expectedStructType.typeName} struct from ${hookType.name}.\n\n` +
644
+ `Expected properties: { ${expectedProps} }\n` +
645
+ `Received properties: { ${receivedProps} }\n\n` +
646
+ `All properties are required! Make sure to include all properties in the returned struct.`
647
+ );
588
648
  }
589
649
  const expectedTypeInfo = expectedProp.dataType;
590
650
  const returnedPropID = enforceReturnTypeMatch(strandsContext, expectedTypeInfo, receivedValue, hookType.name);
@@ -1,7 +1,7 @@
1
1
  import { createBasicBlock, addEdge, pushBlock, popBlock, pushBlockForModification, recordInBasicBlock } from './ir_cfg.js';
2
2
  import { getOrCreateNode } from './ir_dag.js';
3
3
  import { BlockType, NodeType } from './ir_types.js';
4
- import { c as createStrandsNode } from '../ir_builders-DXNgaB9N.js';
4
+ import { c as createStrandsNode } from '../ir_builders-w12-GSxu.js';
5
5
  import { createPhiNode } from './strands_phi_utils.js';
6
6
  import './strands_FES.js';
7
7
  import './strands_builtins.js';
@@ -1,7 +1,7 @@
1
1
  import { createBasicBlock, addEdge, pushBlock, popBlock, pushBlockForModification, recordInBasicBlock } from './ir_cfg.js';
2
2
  import { getNodeDataFromID, createNodeData, getOrCreateNode } from './ir_dag.js';
3
3
  import { BlockType, NodeType, StatementType, OpCode, BaseType } from './ir_types.js';
4
- import { c as createStrandsNode, S as StrandsNode, p as primitiveConstructorNode } from '../ir_builders-DXNgaB9N.js';
4
+ import { c as createStrandsNode, p as primitiveConstructorNode } from '../ir_builders-w12-GSxu.js';
5
5
  import { createPhiNode } from './strands_phi_utils.js';
6
6
  import './strands_FES.js';
7
7
  import './strands_builtins.js';
@@ -310,7 +310,7 @@ class StrandsFor {
310
310
  let initialVar = this.initialCb();
311
311
 
312
312
  // Convert to StrandsNode if it's not already one
313
- if (!(initialVar instanceof StrandsNode)) {
313
+ if (!(initialVar?.isStrandsNode)) {
314
314
  const { id, dimension } = primitiveConstructorNode(this.strandsContext, { baseType: BaseType.FLOAT, dimension: 1 }, initialVar);
315
315
  initialVar = createStrandsNode(id, dimension, this.strandsContext);
316
316
  }
@@ -1,4 +1,4 @@
1
- export { S as StrandsNode, c as createStrandsNode } from '../ir_builders-DXNgaB9N.js';
1
+ export { S as StrandsNode, c as createStrandsNode } from '../ir_builders-w12-GSxu.js';
2
2
  import './ir_types.js';
3
3
  import './ir_dag.js';
4
4
  import './ir_cfg.js';
@@ -1,10 +1,10 @@
1
1
  import textCore from './textCore.js';
2
2
  import font from './p5.Font.js';
3
- import '../p5.Renderer-D-5LdCRz.js';
4
- import '../creating_reading-ZXzcZEsb.js';
3
+ import '../p5.Renderer-DOk9UW65.js';
4
+ import '../creating_reading-C7hu6sg1.js';
5
5
  import 'colorjs.io/fn';
6
6
  import '../color/color_spaces/hsb.js';
7
- import '../constants-DQyACdzq.js';
7
+ import '../constants-DAnmXDew.js';
8
8
  import '../image/filters.js';
9
9
  import '../math/p5.Vector.js';
10
10
  import '../shape/custom_shapes.js';
@@ -1,12 +1,12 @@
1
1
  import { textCoreConstants } from './textCore.js';
2
- import { v as CENTER, a9 as RIGHT, u as RADIUS } from '../constants-DQyACdzq.js';
2
+ import { v as CENTER, a9 as RIGHT, u as RADIUS } from '../constants-DAnmXDew.js';
3
3
  import { UnicodeRange } from '@japont/unicode-range';
4
4
  import { unicodeRanges } from './unicodeRanges.js';
5
5
  import { Vector } from '../math/p5.Vector.js';
6
6
  import Typr from './lib/Typr.js';
7
7
  import { createFromCommands } from '@davepagurek/bezier-path';
8
- import '../p5.Renderer-D-5LdCRz.js';
9
- import '../creating_reading-ZXzcZEsb.js';
8
+ import '../p5.Renderer-DOk9UW65.js';
9
+ import '../creating_reading-C7hu6sg1.js';
10
10
  import 'colorjs.io/fn';
11
11
  import '../color/color_spaces/hsb.js';
12
12
  import '../image/filters.js';
@@ -1,8 +1,8 @@
1
- import { R as Renderer } from '../p5.Renderer-D-5LdCRz.js';
2
- import '../creating_reading-ZXzcZEsb.js';
1
+ import { R as Renderer } from '../p5.Renderer-DOk9UW65.js';
2
+ import '../creating_reading-C7hu6sg1.js';
3
3
  import 'colorjs.io/fn';
4
4
  import '../color/color_spaces/hsb.js';
5
- import '../constants-DQyACdzq.js';
5
+ import '../constants-DAnmXDew.js';
6
6
  import '../image/filters.js';
7
7
  import '../math/p5.Vector.js';
8
8
  import '../shape/custom_shapes.js';
@@ -1,16 +1,16 @@
1
- import '../constants-DQyACdzq.js';
2
- export { p as default } from '../rendering-h9unX5K0.js';
1
+ import '../constants-DAnmXDew.js';
2
+ export { p as default } from '../rendering-B8V5Zt4k.js';
3
3
  import '../math/p5.Vector.js';
4
4
  import './p5.Geometry.js';
5
5
  import '../math/p5.Matrix.js';
6
6
  import '../math/Matrices/Matrix.js';
7
- import '../creating_reading-ZXzcZEsb.js';
7
+ import '../creating_reading-C7hu6sg1.js';
8
8
  import 'colorjs.io/fn';
9
9
  import '../color/color_spaces/hsb.js';
10
10
  import '../dom/p5.Element.js';
11
11
  import '../dom/p5.File.js';
12
12
  import '../io/p5.XML.js';
13
- import '../p5.Renderer-D-5LdCRz.js';
13
+ import '../p5.Renderer-DOk9UW65.js';
14
14
  import '../image/filters.js';
15
15
  import '../shape/custom_shapes.js';
16
16
  import '../core/States.js';
@@ -1,4 +1,4 @@
1
- import { T as TRIANGLE_STRIP, $ as QUAD_STRIP, _ as TRIANGLE_FAN, c as TRIANGLES } from '../constants-DQyACdzq.js';
1
+ import { T as TRIANGLE_STRIP, $ as QUAD_STRIP, _ as TRIANGLE_FAN, c as TRIANGLES } from '../constants-DAnmXDew.js';
2
2
  import '../math/p5.Matrix.js';
3
3
  import { Geometry } from './p5.Geometry.js';
4
4
  import { Matrix } from '../math/Matrices/Matrix.js';
@@ -1,4 +1,4 @@
1
- import { K as PATH, Z as QUADS, $ as QUAD_STRIP, T as TRIANGLE_STRIP, c as TRIANGLES, ad as IMAGE, Y as LINES, _ as TRIANGLE_FAN } from '../constants-DQyACdzq.js';
1
+ import { K as PATH, Z as QUADS, $ as QUAD_STRIP, T as TRIANGLE_STRIP, c as TRIANGLES, ad as IMAGE, Y as LINES, _ as TRIANGLE_FAN } from '../constants-DAnmXDew.js';
2
2
  import { Geometry } from './p5.Geometry.js';
3
3
  import libtess from 'libtess';
4
4
  import { Vector } from '../math/p5.Vector.js';
@@ -1,4 +1,4 @@
1
- import { a3 as constants } from '../constants-DQyACdzq.js';
1
+ import { a3 as constants } from '../constants-DAnmXDew.js';
2
2
 
3
3
  function getStrokeDefs(shaderConstant) {
4
4
  const STROKE_CAP_ENUM = {};
@@ -1,4 +1,4 @@
1
- import { r as renderer3D, p as primitives3D, l as light, m as material, c as camera, f as framebuffer, t as texture } from '../rendering-h9unX5K0.js';
1
+ import { r as renderer3D, p as primitives3D, l as light, m as material, c as camera, f as framebuffer, t as texture } from '../rendering-B8V5Zt4k.js';
2
2
  import interaction from './interaction.js';
3
3
  import loading from './loading.js';
4
4
  import text from './text.js';
@@ -8,14 +8,14 @@ import matrix from '../math/p5.Matrix.js';
8
8
  import geometry from './p5.Geometry.js';
9
9
  import dataArray from './p5.DataArray.js';
10
10
  import rendererGL from './p5.RendererGL.js';
11
- import '../constants-DQyACdzq.js';
12
- import '../creating_reading-ZXzcZEsb.js';
11
+ import '../constants-DAnmXDew.js';
12
+ import '../creating_reading-C7hu6sg1.js';
13
13
  import 'colorjs.io/fn';
14
14
  import '../color/color_spaces/hsb.js';
15
15
  import '../dom/p5.Element.js';
16
16
  import '../dom/p5.File.js';
17
17
  import '../io/p5.XML.js';
18
- import '../p5.Renderer-D-5LdCRz.js';
18
+ import '../p5.Renderer-DOk9UW65.js';
19
19
  import '../image/filters.js';
20
20
  import '../math/p5.Vector.js';
21
21
  import '../shape/custom_shapes.js';
@@ -55,7 +55,7 @@ import './strands_glslBackend.js';
55
55
  import '../strands/ir_types.js';
56
56
  import '../strands/ir_dag.js';
57
57
  import '../strands/strands_FES.js';
58
- import '../ir_builders-DXNgaB9N.js';
58
+ import '../ir_builders-w12-GSxu.js';
59
59
  import '../strands/ir_cfg.js';
60
60
  import '../strands/strands_builtins.js';
61
61
  import './shaderHookUtils.js';
@@ -1,4 +1,4 @@
1
- import { G as GRID, i as AXES } from '../constants-DQyACdzq.js';
1
+ import { G as GRID, i as AXES } from '../constants-DAnmXDew.js';
2
2
  import { Vector } from '../math/p5.Vector.js';
3
3
 
4
4
  /**
@@ -1,13 +1,13 @@
1
- export { l as default } from '../rendering-h9unX5K0.js';
1
+ export { l as default } from '../rendering-B8V5Zt4k.js';
2
2
  import '../math/p5.Vector.js';
3
- import '../creating_reading-ZXzcZEsb.js';
4
- import '../constants-DQyACdzq.js';
3
+ import '../creating_reading-C7hu6sg1.js';
4
+ import '../constants-DAnmXDew.js';
5
5
  import '../dom/p5.Element.js';
6
6
  import '../dom/p5.File.js';
7
7
  import '../io/p5.XML.js';
8
8
  import 'colorjs.io/fn';
9
9
  import '../color/color_spaces/hsb.js';
10
- import '../p5.Renderer-D-5LdCRz.js';
10
+ import '../p5.Renderer-DOk9UW65.js';
11
11
  import '../image/filters.js';
12
12
  import '../shape/custom_shapes.js';
13
13
  import '../core/States.js';
@@ -1,16 +1,16 @@
1
1
  import { Geometry } from './p5.Geometry.js';
2
2
  import { Vector } from '../math/p5.Vector.js';
3
- import { a as request } from '../rendering-h9unX5K0.js';
4
- import '../constants-DQyACdzq.js';
3
+ import { a as request } from '../rendering-B8V5Zt4k.js';
4
+ import '../constants-DAnmXDew.js';
5
5
  import './p5.DataArray.js';
6
6
  import '../io/utilities.js';
7
- import '../creating_reading-ZXzcZEsb.js';
7
+ import '../creating_reading-C7hu6sg1.js';
8
8
  import 'colorjs.io/fn';
9
9
  import '../color/color_spaces/hsb.js';
10
10
  import '../dom/p5.Element.js';
11
11
  import '../dom/p5.File.js';
12
12
  import '../io/p5.XML.js';
13
- import '../p5.Renderer-D-5LdCRz.js';
13
+ import '../p5.Renderer-DOk9UW65.js';
14
14
  import '../image/filters.js';
15
15
  import '../shape/custom_shapes.js';
16
16
  import '../core/States.js';
@@ -634,12 +634,10 @@ function loading(p5, fn){
634
634
  const vertString = tokens[vertexTokens[tokenInd]];
635
635
  let vertParts = vertString.split('/');
636
636
 
637
- // TODO: Faces can technically use negative numbers to refer to the
638
- // previous nth vertex. I haven't seen this used in practice, but
639
- // it might be good to implement this in the future.
640
-
641
637
  for (let i = 0; i < vertParts.length; i++) {
642
- vertParts[i] = parseInt(vertParts[i]) - 1;
638
+ let index = parseInt(vertParts[i]);
639
+ if (index > 0) index -= 1; // OBJ uses 1-based indexing
640
+ vertParts[i] = index;
643
641
  }
644
642
 
645
643
  if (!usedVerts[vertString]) {
@@ -648,11 +646,11 @@ function loading(p5, fn){
648
646
 
649
647
  if (usedVerts[vertString][currentMaterial] === undefined) {
650
648
  const vertIndex = model.vertices.length;
651
- model.vertices.push(loadedVerts.v[vertParts[0]].copy());
652
- model.uvs.push(loadedVerts.vt[vertParts[1]] ?
653
- loadedVerts.vt[vertParts[1]].slice() : [0, 0]);
654
- model.vertexNormals.push(loadedVerts.vn[vertParts[2]] ?
655
- loadedVerts.vn[vertParts[2]].copy() : new Vector());
649
+ model.vertices.push(loadedVerts.v.at(vertParts[0]).copy());
650
+ model.uvs.push(loadedVerts.vt.at(vertParts[1]) ?
651
+ loadedVerts.vt.at(vertParts[1]).slice() : [0, 0]);
652
+ model.vertexNormals.push(loadedVerts.vn.at(vertParts[2]) ?
653
+ loadedVerts.vn.at(vertParts[2]).copy() : new Vector());
656
654
 
657
655
  usedVerts[vertString][currentMaterial] = vertIndex;
658
656
  face.push(vertIndex);
@@ -1,13 +1,13 @@
1
- import '../constants-DQyACdzq.js';
2
- export { m as default } from '../rendering-h9unX5K0.js';
1
+ import '../constants-DAnmXDew.js';
2
+ export { m as default } from '../rendering-B8V5Zt4k.js';
3
3
  import './p5.Shader.js';
4
- import '../creating_reading-ZXzcZEsb.js';
4
+ import '../creating_reading-C7hu6sg1.js';
5
5
  import '../dom/p5.Element.js';
6
6
  import '../dom/p5.File.js';
7
7
  import '../io/p5.XML.js';
8
8
  import 'colorjs.io/fn';
9
9
  import '../color/color_spaces/hsb.js';
10
- import '../p5.Renderer-D-5LdCRz.js';
10
+ import '../p5.Renderer-DOk9UW65.js';
11
11
  import '../image/filters.js';
12
12
  import '../math/p5.Vector.js';
13
13
  import '../shape/custom_shapes.js';
@@ -1,17 +1,17 @@
1
1
  import '../math/p5.Matrix.js';
2
2
  import '../math/p5.Vector.js';
3
3
  import './p5.Quat.js';
4
- export { C as Camera, c as default } from '../rendering-h9unX5K0.js';
4
+ export { C as Camera, c as default } from '../rendering-B8V5Zt4k.js';
5
5
  import '../math/Matrices/Matrix.js';
6
- import '../constants-DQyACdzq.js';
6
+ import '../constants-DAnmXDew.js';
7
7
  import '../math/Matrices/MatrixInterface.js';
8
- import '../creating_reading-ZXzcZEsb.js';
8
+ import '../creating_reading-C7hu6sg1.js';
9
9
  import 'colorjs.io/fn';
10
10
  import '../color/color_spaces/hsb.js';
11
11
  import '../dom/p5.Element.js';
12
12
  import '../dom/p5.File.js';
13
13
  import '../io/p5.XML.js';
14
- import '../p5.Renderer-D-5LdCRz.js';
14
+ import '../p5.Renderer-DOk9UW65.js';
15
15
  import '../image/filters.js';
16
16
  import '../shape/custom_shapes.js';
17
17
  import '../core/States.js';
@@ -1,12 +1,12 @@
1
- import '../constants-DQyACdzq.js';
2
- import '../creating_reading-ZXzcZEsb.js';
3
- export { w as Framebuffer, v as FramebufferCamera, F as FramebufferTexture, f as default } from '../rendering-h9unX5K0.js';
1
+ import '../constants-DAnmXDew.js';
2
+ import '../creating_reading-C7hu6sg1.js';
3
+ export { w as Framebuffer, v as FramebufferCamera, F as FramebufferTexture, f as default } from '../rendering-B8V5Zt4k.js';
4
4
  import 'colorjs.io/fn';
5
5
  import '../color/color_spaces/hsb.js';
6
6
  import '../dom/p5.Element.js';
7
7
  import '../dom/p5.File.js';
8
8
  import '../io/p5.XML.js';
9
- import '../p5.Renderer-D-5LdCRz.js';
9
+ import '../p5.Renderer-DOk9UW65.js';
10
10
  import '../image/filters.js';
11
11
  import '../math/p5.Vector.js';
12
12
  import '../shape/custom_shapes.js';
@@ -1,4 +1,4 @@
1
- import { a7 as FLAT, a8 as SMOOTH } from '../constants-DQyACdzq.js';
1
+ import { a7 as FLAT, a8 as SMOOTH } from '../constants-DAnmXDew.js';
2
2
  import { DataArray } from './p5.DataArray.js';
3
3
  import { Vector } from '../math/p5.Vector.js';
4
4
  import { downloadFile } from '../io/utilities.js';
@@ -1,5 +1,5 @@
1
1
  import { Vector } from '../math/p5.Vector.js';
2
- import '../constants-DQyACdzq.js';
2
+ import '../constants-DAnmXDew.js';
3
3
 
4
4
  /**
5
5
  * @module Math
@@ -1,9 +1,9 @@
1
- import { ac as WEBGL, aa as WEBGL2, L as LIGHTEST, D as DARKEST, S as SUBTRACT, R as REPLACE, E as EXCLUSION, a as SCREEN, M as MULTIPLY, b as REMOVE, A as ADD, B as BLEND, c as TRIANGLES, p as CORNER, U as UNSIGNED_BYTE, g as LINEAR, aG as LINEAR_MIPMAP, h as TEXTURE, F as FLOAT, d as UNSIGNED_INT, H as HALF_FLOAT } from '../constants-DQyACdzq.js';
2
- import { R as Renderer3D, o as readPixelWebGL, q as readPixelsWebGL, M as MipmapTexture, h as getWebGLShaderAttributes, g as getWebGLUniformMetadata, s as setWebGLUniformValue, e as setWebGLTextureParams, j as populateGLSLHooks, u as checkWebGLCapabilities } from '../rendering-h9unX5K0.js';
1
+ import { ac as WEBGL, aa as WEBGL2, L as LIGHTEST, D as DARKEST, S as SUBTRACT, R as REPLACE, E as EXCLUSION, a as SCREEN, M as MULTIPLY, b as REMOVE, A as ADD, B as BLEND, c as TRIANGLES, p as CORNER, U as UNSIGNED_BYTE, g as LINEAR, aG as LINEAR_MIPMAP, h as TEXTURE, F as FLOAT, d as UNSIGNED_INT, H as HALF_FLOAT } from '../constants-DAnmXDew.js';
2
+ import { R as Renderer3D, o as readPixelWebGL, q as readPixelsWebGL, M as MipmapTexture, h as getWebGLShaderAttributes, g as getWebGLUniformMetadata, s as setWebGLUniformValue, e as setWebGLTextureParams, j as populateGLSLHooks, u as checkWebGLCapabilities } from '../rendering-B8V5Zt4k.js';
3
3
  import { getStrokeDefs } from './enums.js';
4
4
  import { Shader } from './p5.Shader.js';
5
- import { R as RGB, h as RGBA } from '../creating_reading-ZXzcZEsb.js';
6
- import { I as Image } from '../p5.Renderer-D-5LdCRz.js';
5
+ import { R as RGB, h as RGBA } from '../creating_reading-C7hu6sg1.js';
6
+ import { I as Image } from '../p5.Renderer-DOk9UW65.js';
7
7
  import { glslBackend } from './strands_glslBackend.js';
8
8
  import '../strands/ir_types.js';
9
9
  import { getShaderHookTypes } from './shaderHookUtils.js';
@@ -47,7 +47,7 @@ import '../core/filterShaders.js';
47
47
  import '../math/trigonometry.js';
48
48
  import '../strands/ir_dag.js';
49
49
  import '../strands/strands_FES.js';
50
- import '../ir_builders-DXNgaB9N.js';
50
+ import '../ir_builders-w12-GSxu.js';
51
51
  import '../strands/ir_cfg.js';
52
52
  import '../strands/strands_builtins.js';
53
53
 
@@ -1,11 +1,11 @@
1
- import '../constants-DQyACdzq.js';
1
+ import '../constants-DAnmXDew.js';
2
2
  import '../dom/p5.Element.js';
3
- import '../p5.Renderer-D-5LdCRz.js';
3
+ import '../p5.Renderer-DOk9UW65.js';
4
4
  import '../dom/p5.MediaElement.js';
5
- export { M as MipmapTexture, T as Texture, t as default } from '../rendering-h9unX5K0.js';
5
+ export { M as MipmapTexture, T as Texture, t as default } from '../rendering-B8V5Zt4k.js';
6
6
  import '../dom/p5.File.js';
7
7
  import '../io/p5.XML.js';
8
- import '../creating_reading-ZXzcZEsb.js';
8
+ import '../creating_reading-C7hu6sg1.js';
9
9
  import 'colorjs.io/fn';
10
10
  import '../color/color_spaces/hsb.js';
11
11
  import '../image/filters.js';
@@ -1,7 +1,7 @@
1
1
  import { NodeTypeToName, NodeType, OpCode, BaseType, OpCodeToSymbol, isStructType, StatementType, DataType, BlockType } from '../strands/ir_types.js';
2
2
  import { getNodeDataFromID, extractNodeTypeInfo } from '../strands/ir_dag.js';
3
3
  import { internalError } from '../strands/strands_FES.js';
4
- import { f as functionCallNode } from '../ir_builders-DXNgaB9N.js';
4
+ import { f as functionCallNode } from '../ir_builders-w12-GSxu.js';
5
5
  import '../strands/ir_cfg.js';
6
6
  import '../strands/strands_builtins.js';
7
7
 
@@ -1,15 +1,15 @@
1
- import { h as TEXTURE, c as TRIANGLES } from '../constants-DQyACdzq.js';
2
- import { R as Renderer3D } from '../rendering-h9unX5K0.js';
1
+ import { h as TEXTURE, c as TRIANGLES } from '../constants-DAnmXDew.js';
2
+ import { R as Renderer3D } from '../rendering-B8V5Zt4k.js';
3
3
  import { Vector } from '../math/p5.Vector.js';
4
4
  import { Geometry } from './p5.Geometry.js';
5
5
  import { Font, arrayCommandsToObjects } from '../type/p5.Font.js';
6
- import '../creating_reading-ZXzcZEsb.js';
6
+ import '../creating_reading-C7hu6sg1.js';
7
7
  import 'colorjs.io/fn';
8
8
  import '../color/color_spaces/hsb.js';
9
9
  import '../dom/p5.Element.js';
10
10
  import '../dom/p5.File.js';
11
11
  import '../io/p5.XML.js';
12
- import '../p5.Renderer-D-5LdCRz.js';
12
+ import '../p5.Renderer-DOk9UW65.js';
13
13
  import '../image/filters.js';
14
14
  import '../shape/custom_shapes.js';
15
15
  import '../core/States.js';
@@ -729,7 +729,7 @@ function text(p5, fn) {
729
729
 
730
730
  if (!p5.Font.hasGlyphData(this.states.textFont)) {
731
731
  console.log(
732
- 'WEBGL: only Opentype (.otf) and Truetype (.ttf) fonts with glyph data are supported'
732
+ 'WEBGL: only Opentype (.otf) and Truetype (.ttf) fonts with glyph data are supported. Make sure to set the font using textFont() before drawing text.'
733
733
  );
734
734
  return;
735
735
  }
@@ -1,12 +1,12 @@
1
- import '../constants-DQyACdzq.js';
2
- export { u as checkWebGLCapabilities, h as getWebGLShaderAttributes, g as getWebGLUniformMetadata, j as populateGLSLHooks, o as readPixelWebGL, q as readPixelsWebGL, e as setWebGLTextureParams, s as setWebGLUniformValue } from '../rendering-h9unX5K0.js';
3
- import '../creating_reading-ZXzcZEsb.js';
1
+ import '../constants-DAnmXDew.js';
2
+ export { u as checkWebGLCapabilities, h as getWebGLShaderAttributes, g as getWebGLUniformMetadata, j as populateGLSLHooks, o as readPixelWebGL, q as readPixelsWebGL, e as setWebGLTextureParams, s as setWebGLUniformValue } from '../rendering-B8V5Zt4k.js';
3
+ import '../creating_reading-C7hu6sg1.js';
4
4
  import 'colorjs.io/fn';
5
5
  import '../color/color_spaces/hsb.js';
6
6
  import '../dom/p5.Element.js';
7
7
  import '../dom/p5.File.js';
8
8
  import '../io/p5.XML.js';
9
- import '../p5.Renderer-D-5LdCRz.js';
9
+ import '../p5.Renderer-DOk9UW65.js';
10
10
  import '../image/filters.js';
11
11
  import '../math/p5.Vector.js';
12
12
  import '../shape/custom_shapes.js';