p5 2.2.3 → 2.3.0-rc.0
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 +9 -11
- package/dist/accessibility/describe.js +0 -1
- package/dist/accessibility/gridOutput.js +0 -1
- package/dist/accessibility/index.js +9 -10
- package/dist/accessibility/outputs.js +0 -1
- package/dist/accessibility/textOutput.js +0 -1
- package/dist/app.js +11 -10
- package/dist/app.node.js +122 -0
- package/dist/color/color_conversion.js +9 -11
- package/dist/color/creating_reading.js +1 -1
- package/dist/color/index.js +2 -2
- package/dist/color/p5.Color.js +1 -1
- package/dist/color/setting.js +25 -12
- package/dist/{constants-BdTiYOQI.js → constants-CYF6mp5_.js} +2 -2
- package/dist/core/States.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +28 -29
- package/dist/core/filterShaders.js +1 -1
- package/dist/core/friendly_errors/fes_core.js +9 -8
- package/dist/core/friendly_errors/file_errors.js +1 -2
- package/dist/core/friendly_errors/index.js +1 -1
- package/dist/core/friendly_errors/param_validator.js +737 -640
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/friendly_errors/stacktrace.js +0 -1
- package/dist/core/helpers.js +3 -4
- package/dist/core/init.js +24 -21
- package/dist/core/internationalization.js +1 -1
- package/dist/core/legacy.js +9 -11
- package/dist/core/main.js +9 -10
- package/dist/core/p5.Graphics.js +5 -5
- package/dist/core/p5.Renderer.js +3 -3
- package/dist/core/p5.Renderer2D.js +9 -10
- package/dist/core/p5.Renderer3D.js +5 -5
- package/dist/core/rendering.js +5 -5
- package/dist/core/structure.js +0 -1
- package/dist/core/transform.js +7 -16
- package/dist/{creating_reading-C7hu6sg1.js → creating_reading-DLkHH80h.js} +11 -8
- package/dist/data/local_storage.js +0 -1
- package/dist/dom/dom.js +2 -3
- package/dist/dom/index.js +2 -2
- package/dist/dom/p5.Element.js +2 -2
- package/dist/dom/p5.MediaElement.js +2 -2
- package/dist/events/acceleration.js +5 -3
- package/dist/events/keyboard.js +0 -1
- package/dist/events/pointer.js +0 -2
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +19 -12
- package/dist/image/image.js +5 -5
- package/dist/image/index.js +5 -5
- package/dist/image/loading_displaying.js +5 -5
- package/dist/image/p5.Image.js +3 -3
- package/dist/image/pixels.js +0 -1
- package/dist/io/files.js +5 -5
- package/dist/io/index.js +5 -5
- package/dist/io/p5.Table.js +0 -1
- package/dist/io/p5.TableRow.js +0 -1
- package/dist/io/p5.XML.js +0 -1
- package/dist/{ir_builders-Cd6rU9Vm.js → ir_builders-C2ebb6Lu.js} +234 -1
- package/dist/{main-H_nu4eDs.js → main-D2MtO721.js} +107 -136
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/calculation.js +0 -1
- package/dist/math/index.js +3 -1
- package/dist/math/math.js +3 -17
- package/dist/math/noise.js +0 -1
- package/dist/math/p5.Matrix.js +1 -2
- package/dist/math/p5.Vector.js +233 -279
- package/dist/math/patch-vector.js +75 -0
- package/dist/math/random.js +0 -1
- package/dist/math/trigonometry.js +3 -4
- package/dist/{p5.Renderer-BmD2P6Wv.js → p5.Renderer-C0Kzy71d.js} +31 -24
- package/dist/{rendering-CC8JNTwG.js → rendering-CvNr0bB8.js} +732 -44
- package/dist/shape/2d_primitives.js +1 -4
- package/dist/shape/attributes.js +43 -8
- package/dist/shape/curves.js +0 -1
- package/dist/shape/custom_shapes.js +260 -5
- package/dist/shape/index.js +2 -2
- package/dist/shape/vertex.js +0 -2
- package/dist/strands/ir_builders.js +1 -1
- package/dist/strands/ir_types.js +5 -1
- package/dist/strands/p5.strands.js +286 -31
- package/dist/strands/strands_api.js +179 -8
- package/dist/strands/strands_codegen.js +26 -8
- 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_ternary.js +56 -0
- package/dist/strands/strands_transpiler.js +416 -251
- package/dist/strands_glslBackend-i-ReKgZo.js +423 -0
- package/dist/type/index.js +3 -3
- package/dist/type/lib/Typr.js +1 -1
- package/dist/type/p5.Font.js +3 -3
- package/dist/type/textCore.js +31 -24
- package/dist/utilities/conversion.js +0 -1
- package/dist/utilities/time_date.js +0 -1
- package/dist/utilities/utility_functions.js +0 -1
- package/dist/webgl/3d_primitives.js +5 -5
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShapeBuilder.js +26 -1
- package/dist/webgl/enums.js +1 -1
- package/dist/webgl/index.js +8 -9
- package/dist/webgl/interaction.js +8 -4
- package/dist/webgl/light.js +5 -5
- package/dist/webgl/loading.js +60 -21
- package/dist/webgl/material.js +5 -5
- package/dist/webgl/p5.Camera.js +5 -5
- package/dist/webgl/p5.Framebuffer.js +5 -5
- package/dist/webgl/p5.Geometry.js +3 -5
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +17 -21
- package/dist/webgl/p5.Shader.js +129 -36
- package/dist/webgl/p5.Texture.js +5 -5
- package/dist/webgl/strands_glslBackend.js +5 -386
- package/dist/webgl/text.js +5 -5
- package/dist/webgl/utils.js +5 -5
- package/dist/webgl2Compatibility-DA7DLMuq.js +7 -0
- package/dist/webgpu/index.js +7 -3
- package/dist/webgpu/p5.RendererWebGPU.js +1036 -180
- package/dist/webgpu/shaders/color.js +1 -1
- package/dist/webgpu/shaders/compute.js +32 -0
- package/dist/webgpu/shaders/functions/randomComputeWGSL.js +31 -0
- package/dist/webgpu/shaders/functions/randomVertWGSL.js +30 -0
- package/dist/webgpu/shaders/functions/randomWGSL.js +30 -0
- package/dist/webgpu/shaders/line.js +1 -1
- package/dist/webgpu/shaders/material.js +3 -3
- package/dist/webgpu/strands_wgslBackend.js +137 -15
- package/lib/p5.esm.js +4088 -1950
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +4088 -1950
- package/lib/p5.min.js +1 -1
- package/lib/p5.webgpu.esm.js +1638 -306
- package/lib/p5.webgpu.js +1637 -305
- package/lib/p5.webgpu.min.js +1 -1
- package/package.json +6 -1
- package/types/global.d.ts +4137 -2396
- package/types/p5.d.ts +2702 -1658
- package/dist/noise3DGLSL-Bwrdi4gi.js +0 -9
package/dist/webgl/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as renderer3D, p as primitives3D,
|
|
1
|
+
import { r as renderer3D, p as primitives3D, a as light, m as material, c as camera, b as framebuffer, t as texture } from '../rendering-CvNr0bB8.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,15 @@ 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-
|
|
12
|
-
import '../creating_reading-
|
|
11
|
+
import '../constants-CYF6mp5_.js';
|
|
12
|
+
import '../creating_reading-DLkHH80h.js';
|
|
13
13
|
import 'colorjs.io/fn';
|
|
14
14
|
import '../color/color_spaces/hsb.js';
|
|
15
|
+
import '../strands/ir_types.js';
|
|
15
16
|
import '../dom/p5.Element.js';
|
|
16
17
|
import '../dom/p5.File.js';
|
|
17
18
|
import '../io/p5.XML.js';
|
|
18
|
-
import '../p5.Renderer-
|
|
19
|
+
import '../p5.Renderer-C0Kzy71d.js';
|
|
19
20
|
import '../image/filters.js';
|
|
20
21
|
import '../math/p5.Vector.js';
|
|
21
22
|
import '../shape/custom_shapes.js';
|
|
@@ -30,7 +31,6 @@ import '../shape/vertex.js';
|
|
|
30
31
|
import '../color/setting.js';
|
|
31
32
|
import 'omggif';
|
|
32
33
|
import '../io/csv.js';
|
|
33
|
-
import 'gifenc';
|
|
34
34
|
import '../image/pixels.js';
|
|
35
35
|
import '../core/transform.js';
|
|
36
36
|
import './GeometryBuilder.js';
|
|
@@ -51,15 +51,14 @@ import '../type/unicodeRanges.js';
|
|
|
51
51
|
import '../type/lib/Typr.js';
|
|
52
52
|
import 'pako';
|
|
53
53
|
import '@davepagurek/bezier-path';
|
|
54
|
-
import '
|
|
55
|
-
import '../strands/ir_types.js';
|
|
54
|
+
import '../strands_glslBackend-i-ReKgZo.js';
|
|
56
55
|
import '../strands/ir_dag.js';
|
|
57
56
|
import '../strands/strands_FES.js';
|
|
58
|
-
import '../ir_builders-
|
|
57
|
+
import '../ir_builders-C2ebb6Lu.js';
|
|
59
58
|
import '../strands/ir_cfg.js';
|
|
60
59
|
import '../strands/strands_builtins.js';
|
|
61
60
|
import './shaderHookUtils.js';
|
|
62
|
-
import '../
|
|
61
|
+
import '../webgl2Compatibility-DA7DLMuq.js';
|
|
63
62
|
|
|
64
63
|
function webgl(p5){
|
|
65
64
|
p5.registerAddon(renderer3D);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a5 as GRID, a6 as AXES } from '../constants-CYF6mp5_.js';
|
|
2
2
|
import { Vector } from '../math/p5.Vector.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @module 3D
|
|
6
6
|
* @submodule Interaction
|
|
7
7
|
* @for p5
|
|
8
|
-
* @requires core
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
10
|
|
|
@@ -371,8 +370,11 @@ function interaction(p5, fn){
|
|
|
371
370
|
// accelerate rotate velocity
|
|
372
371
|
this._renderer.rotateVelocity.add(
|
|
373
372
|
deltaTheta * rotateAccelerationFactor,
|
|
374
|
-
deltaPhi * rotateAccelerationFactor
|
|
373
|
+
deltaPhi * rotateAccelerationFactor,
|
|
374
|
+
0
|
|
375
375
|
);
|
|
376
|
+
|
|
377
|
+
//console.log("added");
|
|
376
378
|
}
|
|
377
379
|
if (this._renderer.rotateVelocity.magSq() > 0.000001) {
|
|
378
380
|
// if freeRotation is true, the camera always rotates freely in the direction the pointer moves
|
|
@@ -391,8 +393,10 @@ function interaction(p5, fn){
|
|
|
391
393
|
}
|
|
392
394
|
// damping
|
|
393
395
|
this._renderer.rotateVelocity.mult(damping);
|
|
396
|
+
//console.log("multiplied", damping, this._renderer.rotateVelocity);
|
|
397
|
+
|
|
394
398
|
} else {
|
|
395
|
-
this._renderer.rotateVelocity.set(0, 0);
|
|
399
|
+
this._renderer.rotateVelocity.set(0, 0, 0);
|
|
396
400
|
}
|
|
397
401
|
|
|
398
402
|
// move process
|
package/dist/webgl/light.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as default } from '../rendering-CvNr0bB8.js';
|
|
2
2
|
import '../math/p5.Vector.js';
|
|
3
|
-
import '../creating_reading-
|
|
4
|
-
import '../constants-
|
|
3
|
+
import '../creating_reading-DLkHH80h.js';
|
|
4
|
+
import '../constants-CYF6mp5_.js';
|
|
5
|
+
import '../strands/ir_types.js';
|
|
5
6
|
import '../dom/p5.Element.js';
|
|
6
7
|
import '../dom/p5.File.js';
|
|
7
8
|
import '../io/p5.XML.js';
|
|
8
9
|
import 'colorjs.io/fn';
|
|
9
10
|
import '../color/color_spaces/hsb.js';
|
|
10
|
-
import '../p5.Renderer-
|
|
11
|
+
import '../p5.Renderer-C0Kzy71d.js';
|
|
11
12
|
import '../image/filters.js';
|
|
12
13
|
import '../shape/custom_shapes.js';
|
|
13
14
|
import '../core/States.js';
|
|
@@ -21,7 +22,6 @@ import '../shape/vertex.js';
|
|
|
21
22
|
import '../color/setting.js';
|
|
22
23
|
import 'omggif';
|
|
23
24
|
import '../io/csv.js';
|
|
24
|
-
import 'gifenc';
|
|
25
25
|
import '../image/pixels.js';
|
|
26
26
|
import '../core/transform.js';
|
|
27
27
|
import './GeometryBuilder.js';
|
package/dist/webgl/loading.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Geometry } from './p5.Geometry.js';
|
|
2
2
|
import { Vector } from '../math/p5.Vector.js';
|
|
3
|
-
import {
|
|
4
|
-
import '../constants-
|
|
3
|
+
import { d as request } from '../rendering-CvNr0bB8.js';
|
|
4
|
+
import '../constants-CYF6mp5_.js';
|
|
5
5
|
import './p5.DataArray.js';
|
|
6
6
|
import '../io/utilities.js';
|
|
7
|
-
import '../creating_reading-
|
|
7
|
+
import '../creating_reading-DLkHH80h.js';
|
|
8
8
|
import 'colorjs.io/fn';
|
|
9
9
|
import '../color/color_spaces/hsb.js';
|
|
10
|
+
import '../strands/ir_types.js';
|
|
10
11
|
import '../dom/p5.Element.js';
|
|
11
12
|
import '../dom/p5.File.js';
|
|
12
13
|
import '../io/p5.XML.js';
|
|
13
|
-
import '../p5.Renderer-
|
|
14
|
+
import '../p5.Renderer-C0Kzy71d.js';
|
|
14
15
|
import '../image/filters.js';
|
|
15
16
|
import '../shape/custom_shapes.js';
|
|
16
17
|
import '../core/States.js';
|
|
@@ -23,7 +24,6 @@ import '../shape/vertex.js';
|
|
|
23
24
|
import '../color/setting.js';
|
|
24
25
|
import 'omggif';
|
|
25
26
|
import '../io/csv.js';
|
|
26
|
-
import 'gifenc';
|
|
27
27
|
import '../image/pixels.js';
|
|
28
28
|
import '../core/transform.js';
|
|
29
29
|
import './GeometryBuilder.js';
|
|
@@ -46,8 +46,6 @@ import '../math/trigonometry.js';
|
|
|
46
46
|
* @module Shape
|
|
47
47
|
* @submodule 3D Models
|
|
48
48
|
* @for p5
|
|
49
|
-
* @requires core
|
|
50
|
-
* @requires p5.Geometry
|
|
51
49
|
*/
|
|
52
50
|
|
|
53
51
|
|
|
@@ -601,7 +599,6 @@ function loading(p5, fn){
|
|
|
601
599
|
const usedVerts = {}; // Track colored vertices
|
|
602
600
|
let currentMaterial = null;
|
|
603
601
|
let hasColoredVertices = false;
|
|
604
|
-
let hasColorlessVertices = false;
|
|
605
602
|
for (let line = 0; line < lines.length; ++line) {
|
|
606
603
|
// Each line is a separate object (vertex, face, vertex normal, etc)
|
|
607
604
|
// For each line, split it into tokens on whitespace. The first token
|
|
@@ -656,7 +653,7 @@ function loading(p5, fn){
|
|
|
656
653
|
model.uvs.push(loadedVerts.vt.at(vertParts[1]) ?
|
|
657
654
|
loadedVerts.vt.at(vertParts[1]).slice() : [0, 0]);
|
|
658
655
|
model.vertexNormals.push(loadedVerts.vn.at(vertParts[2]) ?
|
|
659
|
-
loadedVerts.vn.at(vertParts[2]).copy() : new Vector());
|
|
656
|
+
loadedVerts.vn.at(vertParts[2]).copy() : new Vector(0, 0, 0));
|
|
660
657
|
|
|
661
658
|
usedVerts[vertString][currentMaterial] = vertIndex;
|
|
662
659
|
face.push(vertIndex);
|
|
@@ -671,7 +668,7 @@ function loading(p5, fn){
|
|
|
671
668
|
model.vertexColors.push(materialDiffuseColor[2]);
|
|
672
669
|
model.vertexColors.push(1);
|
|
673
670
|
} else {
|
|
674
|
-
|
|
671
|
+
model.vertexColors.push(-1, -1, -1, -1);
|
|
675
672
|
}
|
|
676
673
|
} else {
|
|
677
674
|
face.push(usedVerts[vertString][currentMaterial]);
|
|
@@ -693,9 +690,8 @@ function loading(p5, fn){
|
|
|
693
690
|
if (model.vertexNormals.length === 0) {
|
|
694
691
|
model.computeNormals();
|
|
695
692
|
}
|
|
696
|
-
if (hasColoredVertices
|
|
697
|
-
|
|
698
|
-
throw new Error('Model coloring is inconsistent. Either all vertices should have colors or none should.');
|
|
693
|
+
if (!hasColoredVertices) {
|
|
694
|
+
model.vertexColors = [];
|
|
699
695
|
}
|
|
700
696
|
|
|
701
697
|
return model;
|
|
@@ -1005,7 +1001,7 @@ function loading(p5, fn){
|
|
|
1005
1001
|
/**
|
|
1006
1002
|
* Draws a <a href="#/p5.Geometry">p5.Geometry</a> object to the canvas.
|
|
1007
1003
|
*
|
|
1008
|
-
* The parameter, `model`, is the
|
|
1004
|
+
* The first parameter, `model`, is the
|
|
1009
1005
|
* <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
|
|
1010
1006
|
* <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
|
|
1011
1007
|
* <a href="#/p5/buildGeometry">buildGeometry()</a>. They can also be loaded from
|
|
@@ -1013,11 +1009,7 @@ function loading(p5, fn){
|
|
|
1013
1009
|
*
|
|
1014
1010
|
* Note: `model()` can only be used in WebGL mode.
|
|
1015
1011
|
*
|
|
1016
|
-
*
|
|
1017
|
-
* @param {p5.Geometry} model 3D shape to be drawn.
|
|
1018
|
-
*
|
|
1019
|
-
* @param {Number} [count=1] number of instances to draw.
|
|
1020
|
-
* @example
|
|
1012
|
+
* ```js example
|
|
1021
1013
|
* // Click and drag the mouse to view the scene from different angles.
|
|
1022
1014
|
*
|
|
1023
1015
|
* let shape;
|
|
@@ -1045,8 +1037,9 @@ function loading(p5, fn){
|
|
|
1045
1037
|
* function createShape() {
|
|
1046
1038
|
* cone();
|
|
1047
1039
|
* }
|
|
1040
|
+
* ```
|
|
1048
1041
|
*
|
|
1049
|
-
*
|
|
1042
|
+
* ```js example
|
|
1050
1043
|
* // Click and drag the mouse to view the scene from different angles.
|
|
1051
1044
|
*
|
|
1052
1045
|
* let shape;
|
|
@@ -1092,8 +1085,9 @@ function loading(p5, fn){
|
|
|
1092
1085
|
* cylinder(3, 20);
|
|
1093
1086
|
* pop();
|
|
1094
1087
|
* }
|
|
1088
|
+
* ```
|
|
1095
1089
|
*
|
|
1096
|
-
*
|
|
1090
|
+
* ```js example
|
|
1097
1091
|
* // Click and drag the mouse to view the scene from different angles.
|
|
1098
1092
|
*
|
|
1099
1093
|
* let shape;
|
|
@@ -1115,6 +1109,51 @@ function loading(p5, fn){
|
|
|
1115
1109
|
* // Draw the shape.
|
|
1116
1110
|
* model(shape);
|
|
1117
1111
|
* }
|
|
1112
|
+
* ```
|
|
1113
|
+
*
|
|
1114
|
+
* Multiple instances can be drawn at once with `model(geometry, count)`. On its own,
|
|
1115
|
+
* all the instances get drawn to the same spot, but you can use
|
|
1116
|
+
* <a href="#/p5/instanceID">`instanceID()`</a> inside of a shader to handle each instance.
|
|
1117
|
+
* At large counts, this often runs faster than using a `for` loop.
|
|
1118
|
+
*
|
|
1119
|
+
* ```js example
|
|
1120
|
+
* let instancesShader;
|
|
1121
|
+
* let instance;
|
|
1122
|
+
* let count = 5;
|
|
1123
|
+
*
|
|
1124
|
+
* function drawInstance() {
|
|
1125
|
+
* sphere(15);
|
|
1126
|
+
* }
|
|
1127
|
+
*
|
|
1128
|
+
* function setup() {
|
|
1129
|
+
* createCanvas(200, 200, WEBGL);
|
|
1130
|
+
* instance = buildGeometry(drawInstance);
|
|
1131
|
+
* instancesShader = buildMaterialShader(drawSpaced);
|
|
1132
|
+
* }
|
|
1133
|
+
*
|
|
1134
|
+
* function drawSpaced() {
|
|
1135
|
+
* worldInputs.begin();
|
|
1136
|
+
* // Spread spheres evenly across the canvas based on their index
|
|
1137
|
+
* let spacing = width / count;
|
|
1138
|
+
* worldInputs.position.x +=
|
|
1139
|
+
* (instanceID() - (count - 1) / 2) * spacing;
|
|
1140
|
+
* worldInputs.end();
|
|
1141
|
+
* }
|
|
1142
|
+
*
|
|
1143
|
+
* function draw() {
|
|
1144
|
+
* background(220);
|
|
1145
|
+
* lights();
|
|
1146
|
+
* noStroke();
|
|
1147
|
+
* fill('red');
|
|
1148
|
+
* shader(instancesShader);
|
|
1149
|
+
* model(instance, count);
|
|
1150
|
+
* }
|
|
1151
|
+
* ```
|
|
1152
|
+
*
|
|
1153
|
+
* @method model
|
|
1154
|
+
* @param {p5.Geometry} model 3D shape to be drawn.
|
|
1155
|
+
*
|
|
1156
|
+
* @param {Number} [count=1] number of instances to draw.
|
|
1118
1157
|
*/
|
|
1119
1158
|
fn.model = function (model, count = 1) {
|
|
1120
1159
|
this._assert3d('model');
|
package/dist/webgl/material.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import '../constants-
|
|
2
|
-
export { m as default } from '../rendering-
|
|
1
|
+
import '../constants-CYF6mp5_.js';
|
|
2
|
+
export { m as default } from '../rendering-CvNr0bB8.js';
|
|
3
3
|
import './p5.Shader.js';
|
|
4
|
-
import '../creating_reading-
|
|
4
|
+
import '../creating_reading-DLkHH80h.js';
|
|
5
|
+
import '../strands/ir_types.js';
|
|
5
6
|
import '../dom/p5.Element.js';
|
|
6
7
|
import '../dom/p5.File.js';
|
|
7
8
|
import '../io/p5.XML.js';
|
|
8
9
|
import 'colorjs.io/fn';
|
|
9
10
|
import '../color/color_spaces/hsb.js';
|
|
10
|
-
import '../p5.Renderer-
|
|
11
|
+
import '../p5.Renderer-C0Kzy71d.js';
|
|
11
12
|
import '../image/filters.js';
|
|
12
13
|
import '../math/p5.Vector.js';
|
|
13
14
|
import '../shape/custom_shapes.js';
|
|
@@ -22,7 +23,6 @@ import '../shape/vertex.js';
|
|
|
22
23
|
import '../color/setting.js';
|
|
23
24
|
import 'omggif';
|
|
24
25
|
import '../io/csv.js';
|
|
25
|
-
import 'gifenc';
|
|
26
26
|
import '../image/pixels.js';
|
|
27
27
|
import '../core/transform.js';
|
|
28
28
|
import './GeometryBuilder.js';
|
package/dist/webgl/p5.Camera.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
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-
|
|
4
|
+
export { C as Camera, c as default } from '../rendering-CvNr0bB8.js';
|
|
5
5
|
import '../math/Matrices/Matrix.js';
|
|
6
|
-
import '../constants-
|
|
6
|
+
import '../constants-CYF6mp5_.js';
|
|
7
7
|
import '../math/Matrices/MatrixInterface.js';
|
|
8
|
-
import '../creating_reading-
|
|
8
|
+
import '../creating_reading-DLkHH80h.js';
|
|
9
9
|
import 'colorjs.io/fn';
|
|
10
10
|
import '../color/color_spaces/hsb.js';
|
|
11
|
+
import '../strands/ir_types.js';
|
|
11
12
|
import '../dom/p5.Element.js';
|
|
12
13
|
import '../dom/p5.File.js';
|
|
13
14
|
import '../io/p5.XML.js';
|
|
14
|
-
import '../p5.Renderer-
|
|
15
|
+
import '../p5.Renderer-C0Kzy71d.js';
|
|
15
16
|
import '../image/filters.js';
|
|
16
17
|
import '../shape/custom_shapes.js';
|
|
17
18
|
import '../core/States.js';
|
|
@@ -25,7 +26,6 @@ import '../shape/vertex.js';
|
|
|
25
26
|
import '../color/setting.js';
|
|
26
27
|
import 'omggif';
|
|
27
28
|
import '../io/csv.js';
|
|
28
|
-
import 'gifenc';
|
|
29
29
|
import '../image/pixels.js';
|
|
30
30
|
import '../core/transform.js';
|
|
31
31
|
import './GeometryBuilder.js';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import '../constants-
|
|
2
|
-
import '../creating_reading-
|
|
3
|
-
export { w as Framebuffer, v as FramebufferCamera, F as FramebufferTexture,
|
|
1
|
+
import '../constants-CYF6mp5_.js';
|
|
2
|
+
import '../creating_reading-DLkHH80h.js';
|
|
3
|
+
export { w as Framebuffer, v as FramebufferCamera, F as FramebufferTexture, b as default } from '../rendering-CvNr0bB8.js';
|
|
4
4
|
import 'colorjs.io/fn';
|
|
5
5
|
import '../color/color_spaces/hsb.js';
|
|
6
|
+
import '../strands/ir_types.js';
|
|
6
7
|
import '../dom/p5.Element.js';
|
|
7
8
|
import '../dom/p5.File.js';
|
|
8
9
|
import '../io/p5.XML.js';
|
|
9
|
-
import '../p5.Renderer-
|
|
10
|
+
import '../p5.Renderer-C0Kzy71d.js';
|
|
10
11
|
import '../image/filters.js';
|
|
11
12
|
import '../math/p5.Vector.js';
|
|
12
13
|
import '../shape/custom_shapes.js';
|
|
@@ -21,7 +22,6 @@ import '../shape/vertex.js';
|
|
|
21
22
|
import '../color/setting.js';
|
|
22
23
|
import 'omggif';
|
|
23
24
|
import '../io/csv.js';
|
|
24
|
-
import 'gifenc';
|
|
25
25
|
import '../image/pixels.js';
|
|
26
26
|
import '../core/transform.js';
|
|
27
27
|
import './GeometryBuilder.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a8 as FLAT, a9 as SMOOTH } from '../constants-CYF6mp5_.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';
|
|
@@ -7,8 +7,6 @@ import { downloadFile } from '../io/utilities.js';
|
|
|
7
7
|
* @module Shape
|
|
8
8
|
* @submodule 3D Primitives
|
|
9
9
|
* @for p5
|
|
10
|
-
* @requires core
|
|
11
|
-
* @requires p5.Geometry
|
|
12
10
|
*/
|
|
13
11
|
|
|
14
12
|
|
|
@@ -329,7 +327,7 @@ class Geometry {
|
|
|
329
327
|
* let saveBtn;
|
|
330
328
|
* function setup() {
|
|
331
329
|
* createCanvas(200, 200, WEBGL);
|
|
332
|
-
* myModel = buildGeometry(function()
|
|
330
|
+
* myModel = buildGeometry(function() {
|
|
333
331
|
* for (let i = 0; i < 5; i++) {
|
|
334
332
|
* push();
|
|
335
333
|
* translate(
|
|
@@ -1204,7 +1202,7 @@ class Geometry {
|
|
|
1204
1202
|
// initialize the vertexNormals array with empty vectors
|
|
1205
1203
|
vertexNormals.length = 0;
|
|
1206
1204
|
for (iv = 0; iv < vertices.length; ++iv) {
|
|
1207
|
-
vertexNormals.push(new Vector());
|
|
1205
|
+
vertexNormals.push(new Vector(0, 0, 0));
|
|
1208
1206
|
}
|
|
1209
1207
|
|
|
1210
1208
|
// loop through all the faces adding its normal to the normal
|
package/dist/webgl/p5.Quat.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
1
|
+
import { ad as WEBGL, ab 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, n as CORNER, U as UNSIGNED_BYTE, g as LINEAR, aG as LINEAR_MIPMAP, a7 as TEXTURE, F as FLOAT, d as UNSIGNED_INT, H as HALF_FLOAT } from '../constants-CYF6mp5_.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-CvNr0bB8.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-
|
|
6
|
-
import { I as Image } from '../p5.Renderer-
|
|
7
|
-
import { glslBackend } from '
|
|
5
|
+
import { R as RGB, h as RGBA } from '../creating_reading-DLkHH80h.js';
|
|
6
|
+
import { I as Image } from '../p5.Renderer-C0Kzy71d.js';
|
|
7
|
+
import { g as glslBackend } from '../strands_glslBackend-i-ReKgZo.js';
|
|
8
8
|
import '../strands/ir_types.js';
|
|
9
9
|
import { getShaderHookTypes } from './shaderHookUtils.js';
|
|
10
|
-
import { f as filterBaseVert, a as filterBaseFrag,
|
|
10
|
+
import { f as filterBaseVert, a as filterBaseFrag, w as webgl2CompatibilityShader } from '../webgl2Compatibility-DA7DLMuq.js';
|
|
11
11
|
import '../dom/p5.Element.js';
|
|
12
12
|
import '../dom/p5.File.js';
|
|
13
13
|
import '../io/p5.XML.js';
|
|
@@ -23,7 +23,6 @@ import '../color/setting.js';
|
|
|
23
23
|
import 'omggif';
|
|
24
24
|
import '../io/csv.js';
|
|
25
25
|
import '../io/utilities.js';
|
|
26
|
-
import 'gifenc';
|
|
27
26
|
import '../image/pixels.js';
|
|
28
27
|
import '../image/filters.js';
|
|
29
28
|
import '../core/transform.js';
|
|
@@ -47,7 +46,7 @@ import '../core/filterShaders.js';
|
|
|
47
46
|
import '../math/trigonometry.js';
|
|
48
47
|
import '../strands/ir_dag.js';
|
|
49
48
|
import '../strands/strands_FES.js';
|
|
50
|
-
import '../ir_builders-
|
|
49
|
+
import '../ir_builders-C2ebb6Lu.js';
|
|
51
50
|
import '../strands/ir_cfg.js';
|
|
52
51
|
import '../strands/strands_builtins.js';
|
|
53
52
|
|
|
@@ -55,9 +54,9 @@ var lightingShader = "#define PI 3.141592\n\nprecision highp float;\nprecision h
|
|
|
55
54
|
|
|
56
55
|
var normalVert = "IN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\n#define HOOK_DEFINES\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\nuniform mat3 uModelNormalMatrix;\nuniform mat3 uCameraNormalMatrix;\n#else\nuniform mat4 uModelViewMatrix;\nuniform mat3 uNormalMatrix;\n#endif\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uMaterialColor;\nuniform bool uUseVertexColor;\n\nOUT vec3 vVertexNormal;\nOUT highp vec2 vVertTexCoord;\nOUT vec4 vColor;\n\nstruct Vertex {\n vec3 position;\n vec3 normal;\n vec2 texCoord;\n vec4 color;\n};\n\nvoid main(void) {\n HOOK_beforeVertex();\n\n Vertex inputs;\n inputs.position = aPosition;\n inputs.normal = aNormal;\n inputs.texCoord = aTexCoord;\n inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;\n#ifdef AUGMENTED_HOOK_getObjectInputs\n inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uModelNormalMatrix * inputs.normal;\n inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n // Already multiplied by the model matrix, just apply view\n inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uCameraNormalMatrix * inputs.normal;\n#else\n // Apply both at once\n inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uNormalMatrix * inputs.normal;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n // Pass varyings to fragment shader\n vVertTexCoord = inputs.texCoord;\n vVertexNormal = normalize(inputs.normal);\n vColor = inputs.color;\n\n gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);\n\n HOOK_afterVertex();\n}\n";
|
|
57
56
|
|
|
58
|
-
var normalFrag = "IN vec3 vVertexNormal;\nvoid main(void) {\n HOOK_beforeFragment();\n OUT_COLOR = HOOK_getFinalColor(vec4(vVertexNormal, 1.0));\n HOOK_afterFragment();\n}
|
|
57
|
+
var normalFrag = "IN vec3 vVertexNormal;\nIN highp vec2 vVertTexCoord;\nvoid main(void) {\n HOOK_beforeFragment();\n OUT_COLOR = HOOK_getFinalColor(vec4(vVertexNormal, 1.0), vVertTexCoord);\n HOOK_afterFragment();\n}";
|
|
59
58
|
|
|
60
|
-
var basicFrag = "IN vec4 vColor;\nvoid main(void) {\n HOOK_beforeFragment();\n OUT_COLOR = HOOK_getFinalColor(vColor);\n OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n HOOK_afterFragment();\n}
|
|
59
|
+
var basicFrag = "IN vec4 vColor;\nIN highp vec2 vVertTexCoord;\nvoid main(void) {\n HOOK_beforeFragment();\n OUT_COLOR = HOOK_getFinalColor(vColor, vVertTexCoord);\n OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n HOOK_afterFragment();\n}";
|
|
61
60
|
|
|
62
61
|
var lightVert = "// include lighting.glgl\n\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nuniform bool uUseVertexColor;\nuniform vec4 uMaterialColor;\n\nOUT highp vec2 vVertTexCoord;\nOUT vec3 vDiffuseColor;\nOUT vec3 vSpecularColor;\nOUT vec4 vColor;\n\nvoid main(void) {\n\n vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * viewModelPosition;\n\n vec3 vertexNormal = normalize(uNormalMatrix * aNormal);\n vVertTexCoord = aTexCoord;\n\n totalLight(viewModelPosition.xyz, vertexNormal, vDiffuseColor, vSpecularColor);\n\n for (int i = 0; i < 8; i++) {\n if (i < uAmbientLightCount) {\n vDiffuseColor += uAmbientColor[i];\n }\n }\n \n vColor = ((uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor);\n}\n";
|
|
63
62
|
|
|
@@ -65,7 +64,7 @@ var lightTextureFrag = "uniform vec4 uTint;\nuniform sampler2D uSampler;\nunifor
|
|
|
65
64
|
|
|
66
65
|
var phongVert = "precision highp int;\n\n#define HOOK_DEFINES\n\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\nuniform mat3 uModelNormalMatrix;\nuniform mat3 uCameraNormalMatrix;\n#else\nuniform mat4 uModelViewMatrix;\nuniform mat3 uNormalMatrix;\n#endif\nuniform mat4 uProjectionMatrix;\n\nuniform bool uUseVertexColor;\nuniform vec4 uMaterialColor;\n\nOUT vec3 vNormal;\nOUT vec2 vTexCoord;\nOUT vec3 vViewPosition;\nOUT vec3 vAmbientColor;\nOUT vec4 vColor;\n\nstruct Vertex {\n vec3 position;\n vec3 normal;\n vec2 texCoord;\n vec4 color;\n};\n\nvoid main(void) {\n HOOK_beforeVertex();\n\n Vertex inputs;\n inputs.position = aPosition;\n inputs.normal = aNormal;\n inputs.texCoord = aTexCoord;\n inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;\n#ifdef AUGMENTED_HOOK_getObjectInputs\n inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uModelNormalMatrix * inputs.normal;\n inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n // Already multiplied by the model matrix, just apply view\n inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uCameraNormalMatrix * inputs.normal;\n#else\n // Apply both at once\n inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uNormalMatrix * inputs.normal;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n // Pass varyings to fragment shader\n vViewPosition = inputs.position;\n vTexCoord = inputs.texCoord;\n vNormal = inputs.normal;\n vColor = inputs.color;\n\n gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);\n HOOK_afterVertex();\n}\n";
|
|
67
66
|
|
|
68
|
-
var phongFrag = "// include lighting.glsl\nprecision highp int;\n\nuniform bool uHasSetAmbient;\nuniform vec3 uAmbientColor;\nuniform vec4 uSpecularMatColor;\nuniform vec4 uAmbientMatColor;\nuniform vec4 uEmissiveMatColor;\n\nuniform vec4 uTint;\nuniform sampler2D uSampler;\nuniform bool isTexture;\n\nIN vec3 vNormal;\nIN vec2 vTexCoord;\nIN vec3 vViewPosition;\nIN vec4 vColor;\n\nstruct ColorComponents {\n vec3 baseColor;\n float opacity;\n vec3 ambientColor;\n vec3 specularColor;\n vec3 diffuse;\n vec3 ambient;\n vec3 specular;\n vec3 emissive;\n};\n\nstruct Inputs {\n vec3 normal;\n vec2 texCoord;\n vec3 ambientLight;\n vec3 ambientMaterial;\n vec3 specularMaterial;\n vec3 emissiveMaterial;\n vec4 color;\n float shininess;\n float metalness;\n};\n\nvoid main(void) {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.normal = normalize(vNormal);\n inputs.texCoord = vTexCoord;\n inputs.ambientLight = uAmbientColor;\n inputs.color = isTexture\n ? TEXTURE(uSampler, vTexCoord) * (vec4(uTint.rgb/255., 1.) * uTint.a/255.)\n : vColor;\n if (isTexture && inputs.color.a > 0.0) {\n // Textures come in with premultiplied alpha. Temporarily unpremultiply it\n // so hooks users don't have to think about premultiplied alpha.\n inputs.color.rgb /= inputs.color.a;\n }\n inputs.shininess = uShininess;\n inputs.metalness = uMetallic;\n inputs.ambientMaterial = uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb;\n inputs.specularMaterial = uSpecularMatColor.rgb;\n inputs.emissiveMaterial = uEmissiveMatColor.rgb;\n inputs = HOOK_getPixelInputs(inputs);\n\n vec3 diffuse;\n vec3 specular;\n totalLight(vViewPosition, inputs.normal, inputs.shininess, inputs.metalness, diffuse, specular);\n\n // Calculating final color as result of all lights (plus emissive term).\n\n vec4 baseColor = inputs.color;\n ColorComponents c;\n c.opacity = baseColor.a;\n c.baseColor = baseColor.rgb;\n c.ambientColor = inputs.ambientMaterial;\n c.specularColor = inputs.specularMaterial;\n c.diffuse = diffuse;\n c.ambient = inputs.ambientLight;\n c.specular = specular;\n c.emissive = inputs.emissiveMaterial;\n OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c));\n OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n HOOK_afterFragment();\n}\n";
|
|
67
|
+
var phongFrag = "// include lighting.glsl\nprecision highp int;\n\nuniform bool uHasSetAmbient;\nuniform vec3 uAmbientColor;\nuniform vec4 uSpecularMatColor;\nuniform vec4 uAmbientMatColor;\nuniform vec4 uEmissiveMatColor;\n\nuniform vec4 uTint;\nuniform sampler2D uSampler;\nuniform bool isTexture;\n\nIN vec3 vNormal;\nIN vec2 vTexCoord;\nIN vec3 vViewPosition;\nIN vec4 vColor;\n\nstruct ColorComponents {\n vec3 baseColor;\n float opacity;\n vec3 ambientColor;\n vec3 specularColor;\n vec3 diffuse;\n vec3 ambient;\n vec3 specular;\n vec3 emissive;\n};\n\nstruct Inputs {\n vec3 normal;\n vec2 texCoord;\n vec3 ambientLight;\n vec3 ambientMaterial;\n vec3 specularMaterial;\n vec3 emissiveMaterial;\n vec4 color;\n float shininess;\n float metalness;\n};\n\nvoid main(void) {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.normal = normalize(vNormal);\n inputs.texCoord = vTexCoord;\n inputs.ambientLight = uAmbientColor;\n inputs.color = isTexture\n ? TEXTURE(uSampler, vTexCoord) * (vec4(uTint.rgb/255., 1.) * uTint.a/255.)\n : vColor;\n if (isTexture && inputs.color.a > 0.0) {\n // Textures come in with premultiplied alpha. Temporarily unpremultiply it\n // so hooks users don't have to think about premultiplied alpha.\n inputs.color.rgb /= inputs.color.a;\n }\n inputs.shininess = uShininess;\n inputs.metalness = uMetallic;\n inputs.ambientMaterial = uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb;\n inputs.specularMaterial = uSpecularMatColor.rgb;\n inputs.emissiveMaterial = uEmissiveMatColor.rgb;\n inputs = HOOK_getPixelInputs(inputs);\n\n vec3 diffuse;\n vec3 specular;\n totalLight(vViewPosition, inputs.normal, inputs.shininess, inputs.metalness, diffuse, specular);\n\n // Calculating final color as result of all lights (plus emissive term).\n\n vec4 baseColor = inputs.color;\n ColorComponents c;\n c.opacity = baseColor.a;\n c.baseColor = baseColor.rgb;\n c.ambientColor = inputs.ambientMaterial;\n c.specularColor = inputs.specularMaterial;\n c.diffuse = diffuse;\n c.ambient = inputs.ambientLight;\n c.specular = specular;\n c.emissive = inputs.emissiveMaterial;\n OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c), vTexCoord);\n OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n HOOK_afterFragment();\n}\n";
|
|
69
68
|
|
|
70
69
|
var fontVert = "IN vec3 aPosition;\nIN vec2 aTexCoord;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uGlyphRect;\nuniform float uGlyphOffset;\n\nOUT vec2 vTexCoord;\n\nvoid main() {\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n // scale by the size of the glyph's rectangle\n positionVec4.xy *= uGlyphRect.zw - uGlyphRect.xy;\n\n // Expand glyph bounding boxes by 1px on each side to give a bit of room\n // for antialiasing\n vec3 newOrigin = (uModelViewMatrix * vec4(0., 0., 0., 1.)).xyz;\n vec3 newDX = (uModelViewMatrix * vec4(1., 0., 0., 1.)).xyz;\n vec3 newDY = (uModelViewMatrix * vec4(0., 1., 0., 1.)).xyz;\n vec2 pixelScale = vec2(\n 1. / length(newOrigin - newDX),\n 1. / length(newOrigin - newDY)\n );\n vec2 offset = pixelScale * normalize(aTexCoord - vec2(0.5, 0.5));\n vec2 textureOffset = offset * (1. / vec2(\n uGlyphRect.z - uGlyphRect.x,\n uGlyphRect.w - uGlyphRect.y\n ));\n\n // move to the corner of the glyph\n positionVec4.xy += uGlyphRect.xy;\n\n // move to the letter's line offset\n positionVec4.x += uGlyphOffset;\n\n positionVec4.xy += offset;\n \n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n vTexCoord = aTexCoord + textureOffset;\n}\n";
|
|
71
70
|
|
|
@@ -73,7 +72,7 @@ var fontFrag = "#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\
|
|
|
73
72
|
|
|
74
73
|
var lineVert = "/*\n Part of the Processing project - http://processing.org\n Copyright (c) 2012-15 The Processing Foundation\n Copyright (c) 2004-12 Ben Fry and Casey Reas\n Copyright (c) 2001-04 Massachusetts Institute of Technology\n This library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation, version 2.1.\n This library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n You should have received a copy of the GNU Lesser General\n Public License along with this library; if not, write to the\n Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n Boston, MA 02111-1307 USA\n*/\n\n#define PROCESSING_LINE_SHADER\n\n#define HOOK_DEFINES\n\nprecision highp int;\nprecision highp float;\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\n#else\nuniform mat4 uModelViewMatrix;\n#endif\n\nuniform mat4 uProjectionMatrix;\nuniform float uStrokeWeight;\n\nuniform bool uUseLineColor;\nuniform bool uSimpleLines;\nuniform vec4 uMaterialColor;\n\nuniform vec4 uViewport;\nuniform int uPerspective;\nuniform int uStrokeJoin;\n\nIN vec3 aPosition;\nIN vec3 aTangentIn;\nIN vec3 aTangentOut;\nIN float aSide;\nIN vec4 aVertexColor;\n\nOUT vec4 vColor;\nOUT vec2 vTangent;\nOUT vec2 vCenter;\nOUT vec2 vPosition;\nOUT float vMaxDist;\nOUT float vCap;\nOUT float vJoin;\nOUT float vStrokeWeight;\n\nvec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {\n // Rotate and translate so a starts at the origin and goes out to the right\n bPoint -= aPoint;\n vec2 rotatedBFrom = vec2(\n bPoint.x*aDir.x + bPoint.y*aDir.y,\n bPoint.y*aDir.x - bPoint.x*aDir.y\n );\n vec2 bTo = bPoint + bDir;\n vec2 rotatedBTo = vec2(\n bTo.x*aDir.x + bTo.y*aDir.y,\n bTo.y*aDir.x - bTo.x*aDir.y\n );\n float intersectionDistance =\n rotatedBTo.x + (rotatedBFrom.x - rotatedBTo.x) * rotatedBTo.y /\n (rotatedBTo.y - rotatedBFrom.y);\n return aPoint + aDir * intersectionDistance;\n}\n\nstruct StrokeVertex {\n vec3 position;\n vec3 tangentIn;\n vec3 tangentOut;\n vec4 color;\n float weight;\n};\n\nvoid main() {\n HOOK_beforeVertex();\n\n if (!uSimpleLines) {\n // Caps have one of either the in or out tangent set to 0\n vCap = (aTangentIn == vec3(0.)) != (aTangentOut == vec3(0.)) ? 1. : 0.;\n\n // Joins have two unique, defined tangents\n vJoin = (\n aTangentIn != vec3(0.) &&\n aTangentOut != vec3(0.) &&\n aTangentIn != aTangentOut\n ) ? 1. : 0.;\n }\n\n StrokeVertex inputs;\n inputs.position = aPosition.xyz;\n inputs.color = uUseLineColor ? aVertexColor : uMaterialColor;\n inputs.weight = uStrokeWeight;\n inputs.tangentIn = aTangentIn;\n inputs.tangentOut = aTangentOut;\n\n#ifdef AUGMENTED_HOOK_getObjectInputs\n inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.tangentIn = (uModelMatrix * vec4(aTangentIn, 0.)).xyz;\n inputs.tangentOut = (uModelMatrix * vec4(aTangentOut, 0.)).xyz;\n inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n // Already multiplied by the model matrix, just apply view\n inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.tangentIn = (uViewMatrix * vec4(aTangentIn, 0.)).xyz;\n inputs.tangentOut = (uViewMatrix * vec4(aTangentOut, 0.)).xyz;\n#else\n // Apply both at once\n inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.tangentIn = (uModelViewMatrix * vec4(aTangentIn, 0.)).xyz;\n inputs.tangentOut = (uModelViewMatrix * vec4(aTangentOut, 0.)).xyz;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n vec4 posp = vec4(inputs.position, 1.);\n vec4 posqIn = vec4(inputs.position + inputs.tangentIn, 1.);\n vec4 posqOut = vec4(inputs.position + inputs.tangentOut, 1.);\n vStrokeWeight = inputs.weight;\n\n float facingCamera = pow(\n // The word space tangent's z value is 0 if it's facing the camera\n abs(normalize(posqIn-posp).z),\n\n // Using pow() here to ramp `facingCamera` up from 0 to 1 really quickly\n // so most lines get scaled and don't get clipped\n 0.25\n );\n\n // Moving vertices slightly toward the camera\n // to avoid depth-fighting with the fill triangles.\n // A mix of scaling and offsetting is used based on distance\n // Discussion here:\n // https://github.com/processing/p5.js/issues/7200 \n\n // using a scale <1 moves the lines towards nearby camera\n // in order to prevent popping effects due to half of\n // the line disappearing behind the geometry faces.\n float zDistance = -posp.z; \n float distanceFactor = smoothstep(0.0, 800.0, zDistance); \n \n // Discussed here:\n // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848 \n float scale = mix(1., 0.995, facingCamera);\n float dynamicScale = mix(scale, 1.0, distanceFactor); // Closer = more scale, farther = less\n\n posp.xyz = posp.xyz * dynamicScale;\n posqIn.xyz = posqIn.xyz * dynamicScale;\n posqOut.xyz = posqOut.xyz * dynamicScale;\n\n // Moving vertices slightly toward camera when far away \n // https://github.com/processing/p5.js/issues/6956 \n float zOffset = mix(0., -1., facingCamera);\n float dynamicZAdjustment = mix(0.0, zOffset, distanceFactor); // Closer = less zAdjustment, farther = more\n\n posp.z -= dynamicZAdjustment;\n posqIn.z -= dynamicZAdjustment;\n posqOut.z -= dynamicZAdjustment;\n \n vec4 p = uProjectionMatrix * posp;\n vec4 qIn = uProjectionMatrix * posqIn;\n vec4 qOut = uProjectionMatrix * posqOut;\n\n // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])\n // screen_p = (p.xy/p.w + <1,1>) * 0.5 * uViewport.zw\n\n // prevent division by W by transforming the tangent formula (div by 0 causes\n // the line to disappear, see https://github.com/processing/processing/issues/5183)\n // t = screen_q - screen_p\n //\n // tangent is normalized and we don't care which aDirection it points to (+-)\n // t = +- normalize( screen_q - screen_p )\n // t = +- normalize( (q.xy/q.w+<1,1>)*0.5*uViewport.zw - (p.xy/p.w+<1,1>)*0.5*uViewport.zw )\n //\n // extract common factor, <1,1> - <1,1> cancels out\n // t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * uViewport.zw )\n //\n // convert to common divisor\n // t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * uViewport.zw )\n //\n // remove the common scalar divisor/factor, not needed due to normalize and +-\n // (keep uViewport - can't remove because it has different components for x and y\n // and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)\n // t = +- normalize( (q.xy*p.w - p.xy*q.w) * uViewport.zw )\n\n vec2 tangentIn = normalize((qIn.xy*p.w - p.xy*qIn.w) * uViewport.zw);\n vec2 tangentOut = normalize((qOut.xy*p.w - p.xy*qOut.w) * uViewport.zw);\n\n vec2 curPerspScale;\n if(uPerspective == 1) {\n // Perspective ---\n // convert from world to clip by multiplying with projection scaling factor\n // to get the right thickness (see https://github.com/processing/processing/issues/5182)\n\n // The y value of the projection matrix may be flipped if rendering to a Framebuffer.\n // Multiplying again by its sign here negates the flip to get just the scale.\n curPerspScale = (uProjectionMatrix * vec4(1, sign(uProjectionMatrix[1][1]), 0, 0)).xy;\n } else {\n // No Perspective ---\n // multiply by W (to cancel out division by W later in the pipeline) and\n // convert from screen to clip (derived from clip to screen above)\n curPerspScale = p.w / (0.5 * uViewport.zw);\n }\n\n vec2 offset;\n if (vJoin == 1. && !uSimpleLines) {\n vTangent = normalize(tangentIn + tangentOut);\n vec2 normalIn = vec2(-tangentIn.y, tangentIn.x);\n vec2 normalOut = vec2(-tangentOut.y, tangentOut.x);\n float side = sign(aSide);\n float sideEnum = abs(aSide);\n\n // We generate vertices for joins on either side of the centerline, but\n // the \"elbow\" side is the only one needing a join. By not setting the\n // offset for the other side, all its vertices will end up in the same\n // spot and not render, effectively discarding it.\n if (sign(dot(tangentOut, vec2(-tangentIn.y, tangentIn.x))) != side) {\n // Side enums:\n // 1: the side going into the join\n // 2: the middle of the join\n // 3: the side going out of the join\n if (sideEnum == 2.) {\n // Calculate the position + tangent on either side of the join, and\n // find where the lines intersect to find the elbow of the join\n vec2 c = (posp.xy/posp.w + vec2(1.,1.)) * 0.5 * uViewport.zw;\n vec2 intersection = lineIntersection(\n c + (side * normalIn * inputs.weight / 2.),\n tangentIn,\n c + (side * normalOut * inputs.weight / 2.),\n tangentOut\n );\n offset = (intersection - c);\n\n // When lines are thick and the angle of the join approaches 180, the\n // elbow might be really far from the center. We'll apply a limit to\n // the magnitude to avoid lines going across the whole screen when this\n // happens.\n float mag = length(offset);\n float maxMag = 3. * inputs.weight;\n if (mag > maxMag) {\n offset *= maxMag / mag;\n }\n } else if (sideEnum == 1.) {\n offset = side * normalIn * inputs.weight / 2.;\n } else if (sideEnum == 3.) {\n offset = side * normalOut * inputs.weight / 2.;\n }\n }\n if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 avgNormal = vec2(-vTangent.y, vTangent.x);\n vMaxDist = abs(dot(avgNormal, normalIn * inputs.weight / 2.));\n } else {\n vMaxDist = inputs.weight / 2.;\n }\n } else {\n vec2 tangent = aTangentIn == vec3(0.) ? tangentOut : tangentIn;\n\n vTangent = tangent;\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n float normalOffset = sign(aSide);\n // Caps will have side values of -2 or 2 on the edge of the cap that\n // extends out from the line\n float tangentOffset = abs(aSide) - 1.;\n offset = (normal * normalOffset + tangent * tangentOffset) *\n inputs.weight * 0.5;\n vMaxDist = inputs.weight / 2.;\n }\n\n vCenter = p.xy;\n vPosition = vCenter + offset;\n vColor = inputs.color;\n\n gl_Position.xy = p.xy + offset.xy * curPerspScale;\n gl_Position.zw = p.zw;\n \n HOOK_afterVertex();\n}\n";
|
|
75
74
|
|
|
76
|
-
var lineFrag = "precision highp int;\nprecision highp float;\n\nuniform vec4 uMaterialColor;\nuniform int uStrokeCap;\nuniform int uStrokeJoin;\n\nIN vec4 vColor;\nIN vec2 vTangent;\nIN vec2 vCenter;\nIN vec2 vPosition;\nIN float vStrokeWeight;\nIN float vMaxDist;\nIN float vCap;\nIN float vJoin;\n\nfloat distSquared(vec2 a, vec2 b) {\n vec2 aToB = b - a;\n return dot(aToB, aToB);\n}\n\nstruct Inputs {\n vec4 color;\n vec2 tangent;\n vec2 center;\n vec2 position;\n float strokeWeight;\n};\n\nvoid main() {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.color = vColor;\n inputs.tangent = vTangent;\n inputs.center = vCenter;\n inputs.position = vPosition;\n inputs.strokeWeight = vStrokeWeight;\n inputs = HOOK_getPixelInputs(inputs);\n\n if (vCap > 0.) {\n if (\n uStrokeCap == STROKE_CAP_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (\n uStrokeCap == STROKE_CAP_SQUARE &&\n HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)\n ) {\n discard;\n // Use full area for PROJECT\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n } else if (vJoin > 0.) {\n if (\n uStrokeJoin == STROKE_JOIN_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);\n if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {\n discard;\n }\n // Use full area for MITER\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n }\n OUT_COLOR = HOOK_getFinalColor(vec4(inputs.color.rgb, 1.) * inputs.color.a);\n HOOK_afterFragment();\n}\n";
|
|
75
|
+
var lineFrag = "precision highp int;\nprecision highp float;\n\nuniform vec4 uMaterialColor;\nuniform int uStrokeCap;\nuniform int uStrokeJoin;\n\nIN vec4 vColor;\nIN vec2 vTangent;\nIN vec2 vCenter;\nIN vec2 vPosition;\nIN float vStrokeWeight;\nIN float vMaxDist;\nIN float vCap;\nIN float vJoin;\n\nfloat distSquared(vec2 a, vec2 b) {\n vec2 aToB = b - a;\n return dot(aToB, aToB);\n}\n\nstruct Inputs {\n vec4 color;\n vec2 tangent;\n vec2 center;\n vec2 position;\n float strokeWeight;\n};\n\nvoid main() {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.color = vColor;\n inputs.tangent = vTangent;\n inputs.center = vCenter;\n inputs.position = vPosition;\n inputs.strokeWeight = vStrokeWeight;\n inputs = HOOK_getPixelInputs(inputs);\n\n if (vCap > 0.) {\n if (\n uStrokeCap == STROKE_CAP_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (\n uStrokeCap == STROKE_CAP_SQUARE &&\n HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)\n ) {\n discard;\n // Use full area for PROJECT\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n } else if (vJoin > 0.) {\n if (\n uStrokeJoin == STROKE_JOIN_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);\n if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {\n discard;\n }\n // Use full area for MITER\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n }\n OUT_COLOR = HOOK_getFinalColor(vec4(inputs.color.rgb, 1.) * inputs.color.a, vec2(0.0, 0.0));\n HOOK_afterFragment();\n}\n";
|
|
77
76
|
|
|
78
77
|
var imageLightVert = "precision highp float;\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\n\nOUT vec3 localPos;\nOUT vec3 vWorldNormal;\nOUT vec3 vWorldPosition;\nOUT vec2 vTexCoord;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nvoid main() {\n // Multiply the position by the matrix.\n vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * viewModelPosition; \n \n // orient the normals and pass to the fragment shader\n vWorldNormal = uNormalMatrix * aNormal;\n \n // send the view position to the fragment shader\n vWorldPosition = (uModelViewMatrix * vec4(aPosition, 1.0)).xyz;\n \n localPos = vWorldPosition;\n vTexCoord = aTexCoord;\n}\n\n\n/*\nin the vertex shader we'll compute the world position and world oriented normal of the vertices and pass those to the fragment shader as varyings.\n*/\n";
|
|
79
78
|
|
|
@@ -571,7 +570,7 @@ class RendererGL extends Renderer3D {
|
|
|
571
570
|
|
|
572
571
|
/**
|
|
573
572
|
* Loads the pixels data for this canvas into the pixels[] attribute.
|
|
574
|
-
* Note that
|
|
573
|
+
* Note that set() does not work.
|
|
575
574
|
* Any pixel manipulation must be done directly to the pixels[] array.
|
|
576
575
|
*
|
|
577
576
|
* @private
|
|
@@ -764,7 +763,7 @@ class RendererGL extends Renderer3D {
|
|
|
764
763
|
color.a = components.opacity;
|
|
765
764
|
return color;
|
|
766
765
|
}`,
|
|
767
|
-
"vec4 getFinalColor": "(vec4 color) { return color; }",
|
|
766
|
+
"vec4 getFinalColor": "(vec4 color, vec2 texCoord) { return color; }",
|
|
768
767
|
"void afterFragment": "() {}",
|
|
769
768
|
},
|
|
770
769
|
}
|
|
@@ -801,7 +800,7 @@ class RendererGL extends Renderer3D {
|
|
|
801
800
|
},
|
|
802
801
|
fragment: {
|
|
803
802
|
"void beforeFragment": "() {}",
|
|
804
|
-
"vec4 getFinalColor": "(vec4 color) { return color; }",
|
|
803
|
+
"vec4 getFinalColor": "(vec4 color, vec2 texCoord) { return color; }",
|
|
805
804
|
"void afterFragment": "() {}",
|
|
806
805
|
},
|
|
807
806
|
}
|
|
@@ -829,7 +828,7 @@ class RendererGL extends Renderer3D {
|
|
|
829
828
|
},
|
|
830
829
|
fragment: {
|
|
831
830
|
"void beforeFragment": "() {}",
|
|
832
|
-
"vec4 getFinalColor": "(vec4 color) { return color; }",
|
|
831
|
+
"vec4 getFinalColor": "(vec4 color, vec2 texCoord) { return color; }",
|
|
833
832
|
"void afterFragment": "() {}",
|
|
834
833
|
},
|
|
835
834
|
}
|
|
@@ -861,7 +860,7 @@ class RendererGL extends Renderer3D {
|
|
|
861
860
|
fragment: {
|
|
862
861
|
"void beforeFragment": "() {}",
|
|
863
862
|
"Inputs getPixelInputs": "(Inputs inputs) { return inputs; }",
|
|
864
|
-
"vec4 getFinalColor": "(vec4 color) { return color; }",
|
|
863
|
+
"vec4 getFinalColor": "(vec4 color, vec2 texCoord) { return color; }",
|
|
865
864
|
"bool shouldDiscard": "(bool outside) { return outside; }",
|
|
866
865
|
"void afterFragment": "() {}",
|
|
867
866
|
},
|
|
@@ -1170,6 +1169,7 @@ class RendererGL extends Renderer3D {
|
|
|
1170
1169
|
);
|
|
1171
1170
|
}
|
|
1172
1171
|
|
|
1172
|
+
shader._compiled = true;
|
|
1173
1173
|
shader._glProgram = program;
|
|
1174
1174
|
shader._vertShader = vertShader;
|
|
1175
1175
|
shader._fragShader = fragShader;
|
|
@@ -1945,10 +1945,6 @@ class RendererGL extends Renderer3D {
|
|
|
1945
1945
|
}
|
|
1946
1946
|
}
|
|
1947
1947
|
|
|
1948
|
-
getNoiseShaderSnippet() {
|
|
1949
|
-
return noiseGLSL;
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
1948
|
}
|
|
1953
1949
|
|
|
1954
1950
|
function rendererGL(p5, fn) {
|