p5 2.0.1 → 2.0.3

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 (160) hide show
  1. package/dist/accessibility/color_namer.js +5 -5
  2. package/dist/accessibility/describe.js +10 -0
  3. package/dist/accessibility/index.js +5 -5
  4. package/dist/accessibility/outputs.js +21 -0
  5. package/dist/app.js +5 -5
  6. package/dist/color/color_conversion.js +5 -5
  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-C-g_eAdC.js → constants-BRcElHU3.js} +19 -3
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +6 -5
  14. package/dist/core/friendly_errors/fes_core.js +1 -1
  15. package/dist/core/friendly_errors/index.js +1 -1
  16. package/dist/core/friendly_errors/param_validator.js +46 -93
  17. package/dist/core/friendly_errors/sketch_reader.js +5 -5
  18. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  19. package/dist/core/friendly_errors/validate_params.js +5 -5
  20. package/dist/core/helpers.js +1 -1
  21. package/dist/core/init.js +5 -5
  22. package/dist/core/legacy.js +5 -5
  23. package/dist/core/main.js +5 -5
  24. package/dist/core/p5.Graphics.js +4 -4
  25. package/dist/core/p5.Renderer.js +3 -3
  26. package/dist/core/p5.Renderer2D.js +5 -5
  27. package/dist/core/rendering.js +4 -4
  28. package/dist/{creating_reading-D4AAKRbx.js → creating_reading-Cr8L2Jnm.js} +2 -2
  29. package/dist/dom/dom.js +10 -10
  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/events/acceleration.js +24 -24
  34. package/dist/events/keyboard.js +11 -6
  35. package/dist/image/const.js +1 -1
  36. package/dist/image/filterRenderer2D.js +4 -4
  37. package/dist/image/image.js +4 -4
  38. package/dist/image/index.js +4 -4
  39. package/dist/image/loading_displaying.js +4 -4
  40. package/dist/image/p5.Image.js +3 -3
  41. package/dist/image/pixels.js +1 -0
  42. package/dist/io/files.js +4 -4
  43. package/dist/io/index.js +4 -4
  44. package/dist/io/p5.TableRow.js +2 -2
  45. package/dist/{main-s72KWcUy.js → main-BKN5yFoS.js} +12 -9
  46. package/dist/math/Matrices/Matrix.js +1 -1
  47. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  48. package/dist/math/index.js +1 -1
  49. package/dist/math/math.js +1 -1
  50. package/dist/math/p5.Matrix.js +1 -1
  51. package/dist/math/p5.Vector.js +1 -1
  52. package/dist/math/trigonometry.js +1 -1
  53. package/dist/{p5.Renderer-CwAYZOC2.js → p5.Renderer-R23xoC7s.js} +5 -5
  54. package/dist/{rendering--aAe5aq3.js → rendering-CvUVN-Vb.js} +101 -66
  55. package/dist/shape/2d_primitives.js +1 -1
  56. package/dist/shape/attributes.js +1 -1
  57. package/dist/shape/custom_shapes.js +2 -2
  58. package/dist/shape/index.js +2 -2
  59. package/dist/type/index.js +3 -3
  60. package/dist/type/p5.Font.js +3 -5
  61. package/dist/type/textCore.js +4 -4
  62. package/dist/webgl/3d_primitives.js +4 -4
  63. package/dist/webgl/GeometryBuilder.js +1 -1
  64. package/dist/webgl/ShapeBuilder.js +1 -1
  65. package/dist/webgl/index.js +4 -4
  66. package/dist/webgl/interaction.js +1 -1
  67. package/dist/webgl/light.js +4 -4
  68. package/dist/webgl/loading.js +5 -4
  69. package/dist/webgl/material.js +4 -4
  70. package/dist/webgl/p5.Camera.js +4 -4
  71. package/dist/webgl/p5.Framebuffer.js +4 -4
  72. package/dist/webgl/p5.Geometry.js +1 -1
  73. package/dist/webgl/p5.Quat.js +1 -1
  74. package/dist/webgl/p5.RendererGL.js +4 -4
  75. package/dist/webgl/p5.Shader.js +4 -4
  76. package/dist/webgl/p5.Texture.js +4 -4
  77. package/dist/webgl/text.js +32 -34
  78. package/lib/p5.esm.js +289 -247
  79. package/lib/p5.js +289 -247
  80. package/lib/p5.min.js +1 -1
  81. package/package.json +1 -2
  82. package/types/accessibility/color_namer.d.ts +8 -0
  83. package/types/accessibility/describe.d.ts +184 -0
  84. package/types/accessibility/gridOutput.d.ts +8 -0
  85. package/types/accessibility/outputs.d.ts +235 -0
  86. package/types/accessibility/textOutput.d.ts +8 -0
  87. package/types/color/color_conversion.d.ts +47 -0
  88. package/types/color/creating_reading.d.ts +1348 -0
  89. package/types/color/p5.Color.d.ts +1070 -0
  90. package/types/color/setting.d.ts +2085 -0
  91. package/types/core/constants.d.ts +341 -0
  92. package/types/core/environment.d.ts +668 -0
  93. package/types/core/friendly_errors/fes_core.d.ts +8 -0
  94. package/types/core/friendly_errors/file_errors.d.ts +8 -0
  95. package/types/core/friendly_errors/param_validator.d.ts +30 -0
  96. package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
  97. package/types/core/friendly_errors/stacktrace.d.ts +11 -0
  98. package/types/core/friendly_errors/validate_params.d.ts +8 -0
  99. package/types/core/helpers.d.ts +8 -0
  100. package/types/core/legacy.d.ts +8 -0
  101. package/types/core/main.d.ts +5999 -0
  102. package/types/core/p5.Graphics.d.ts +484 -0
  103. package/types/core/p5.Renderer.d.ts +14 -0
  104. package/types/core/reference.d.ts +8 -0
  105. package/types/core/rendering.d.ts +481 -0
  106. package/types/core/structure.d.ts +492 -0
  107. package/types/core/transform.d.ts +1638 -0
  108. package/types/data/local_storage.d.ts +323 -0
  109. package/types/dom/dom.d.ts +1295 -0
  110. package/types/dom/p5.Element.d.ts +2011 -0
  111. package/types/dom/p5.File.d.ts +13 -0
  112. package/types/dom/p5.MediaElement.d.ts +1249 -0
  113. package/types/events/acceleration.d.ts +193 -0
  114. package/types/events/keyboard.d.ts +501 -0
  115. package/types/events/pointer.d.ts +782 -0
  116. package/types/global.d.ts +5544 -0
  117. package/types/image/filterRenderer2D.d.ts +54 -0
  118. package/types/image/image.d.ts +326 -0
  119. package/types/image/loading_displaying.d.ts +580 -0
  120. package/types/image/p5.Image.d.ts +5882 -0
  121. package/types/image/pixels.d.ts +832 -0
  122. package/types/io/files.d.ts +1447 -0
  123. package/types/io/p5.Table.d.ts +1247 -0
  124. package/types/io/p5.TableRow.d.ts +343 -0
  125. package/types/io/p5.XML.d.ts +1188 -0
  126. package/types/math/Matrices/Matrix.d.ts +1029 -0
  127. package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
  128. package/types/math/calculation.d.ts +923 -0
  129. package/types/math/math.d.ts +90 -0
  130. package/types/math/noise.d.ts +311 -0
  131. package/types/math/p5.Matrix.d.ts +8 -0
  132. package/types/math/p5.Vector.d.ts +3416 -0
  133. package/types/math/random.d.ts +267 -0
  134. package/types/math/trigonometry.d.ts +663 -0
  135. package/types/p5.d.ts +6666 -0
  136. package/types/shape/2d_primitives.d.ts +1033 -0
  137. package/types/shape/attributes.d.ts +466 -0
  138. package/types/shape/curves.d.ts +740 -0
  139. package/types/shape/custom_shapes.d.ts +888 -0
  140. package/types/shape/vertex.d.ts +1141 -0
  141. package/types/type/p5.Font.d.ts +575 -0
  142. package/types/type/textCore.d.ts +1198 -0
  143. package/types/utilities/conversion.d.ts +894 -0
  144. package/types/utilities/time_date.d.ts +295 -0
  145. package/types/utilities/utility_functions.d.ts +587 -0
  146. package/types/webgl/3d_primitives.d.ts +1432 -0
  147. package/types/webgl/ShaderGenerator.d.ts +8 -0
  148. package/types/webgl/interaction.d.ts +371 -0
  149. package/types/webgl/light.d.ts +1184 -0
  150. package/types/webgl/loading.d.ts +482 -0
  151. package/types/webgl/material.d.ts +2656 -0
  152. package/types/webgl/p5.Camera.d.ts +3023 -0
  153. package/types/webgl/p5.DataArray.d.ts +61 -0
  154. package/types/webgl/p5.Framebuffer.d.ts +760 -0
  155. package/types/webgl/p5.Geometry.d.ts +1191 -0
  156. package/types/webgl/p5.Quat.d.ts +45 -0
  157. package/types/webgl/p5.RendererGL.d.ts +234 -0
  158. package/types/webgl/p5.Shader.d.ts +660 -0
  159. package/types/webgl/p5.Texture.d.ts +61 -0
  160. package/types/webgl/text.d.ts +74 -0
@@ -0,0 +1,3023 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+
5
+ declare module 'p5' {
6
+ class Camera {
7
+ constructor(rendererGL: rendererGL);
8
+
9
+ /**
10
+ * The camera’s x-coordinate.By default, the camera’s x-coordinate is set to 0 in "world" space.
11
+ *
12
+ * @param
13
+ * @param
14
+ * @param
15
+ * @param
16
+ */
17
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
18
+
19
+ /**
20
+ * The camera’s y-coordinate.By default, the camera’s y-coordinate is set to 0 in "world" space.
21
+ *
22
+ * @param
23
+ * @param
24
+ * @param
25
+ * @param
26
+ */
27
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
28
+
29
+ /**
30
+ * The camera’s z-coordinate.By default, the camera’s z-coordinate is set to 800 in "world" space.
31
+ *
32
+ * @param
33
+ * @param
34
+ * @param
35
+ * @param
36
+ */
37
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
38
+
39
+ /**
40
+ * The x-coordinate of the place where the camera looks.By default, the camera looks at the origin `(0, 0, 0)` in "world" space, so
41
+ * `myCamera.centerX` is 0.
42
+ *
43
+ * @param
44
+ * @param
45
+ * @param
46
+ * @param
47
+ */
48
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
49
+
50
+ /**
51
+ * The y-coordinate of the place where the camera looks.By default, the camera looks at the origin `(0, 0, 0)` in "world" space, so
52
+ * `myCamera.centerY` is 0.
53
+ *
54
+ * @param
55
+ * @param
56
+ * @param
57
+ * @param
58
+ */
59
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
60
+
61
+ /**
62
+ * The y-coordinate of the place where the camera looks.By default, the camera looks at the origin `(0, 0, 0)` in "world" space, so
63
+ * `myCamera.centerZ` is 0.
64
+ *
65
+ * @param
66
+ * @param
67
+ * @param
68
+ * @param
69
+ */
70
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
71
+
72
+ /**
73
+ * The x-component of the camera's "up" vector.The camera's "up" vector orients its y-axis. By default, the "up" vector is
74
+ * `(0, 1, 0)`, so its x-component is 0 in "local" space.
75
+ *
76
+ * @param
77
+ * @param
78
+ * @param
79
+ * @param
80
+ */
81
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
82
+
83
+ /**
84
+ * The y-component of the camera's "up" vector.The camera's "up" vector orients its y-axis. By default, the "up" vector is
85
+ * `(0, 1, 0)`, so its y-component is 1 in "local" space.
86
+ *
87
+ * @param
88
+ * @param
89
+ * @param
90
+ * @param
91
+ */
92
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
93
+
94
+ /**
95
+ * The z-component of the camera's "up" vector.The camera's "up" vector orients its y-axis. By default, the "up" vector is
96
+ * `(0, 1, 0)`, so its z-component is 0 in "local" space.
97
+ *
98
+ * @param
99
+ * @param
100
+ * @param
101
+ * @param
102
+ */
103
+ perspective(fovy: any, aspect: any, near: any, far: any): void;
104
+
105
+ /**
106
+ * Sets a perspective projection for the camera.In a perspective projection, shapes that are further from the camera appear
107
+ * smaller than shapes that are near the camera. This technique, called
108
+ * foreshortening, creates realistic 3D scenes. It’s applied by default in new
109
+ * `p5.Camera` objects.`myCamera.perspective()` changes the camera’s perspective by changing its
110
+ * viewing frustum. The frustum is the volume of space that’s visible to the
111
+ * camera. The frustum’s shape is a pyramid with its top cut off. The camera
112
+ * is placed where the top of the pyramid should be and points towards the
113
+ * base of the pyramid. It views everything within the frustum.The first parameter, `fovy`, is the camera’s vertical field of view. It’s
114
+ * an angle that describes how tall or narrow a view the camera has. For
115
+ * example, calling `myCamera.perspective(0.5)` sets the camera’s vertical
116
+ * field of view to 0.5 radians. By default, `fovy` is calculated based on the
117
+ * sketch’s height and the camera’s default z-coordinate, which is 800. The
118
+ * formula for the default `fovy` is `2 * atan(height / 2 / 800)`.The second parameter, `aspect`, is the camera’s aspect ratio. It’s a number
119
+ * that describes the ratio of the top plane’s width to its height. For
120
+ * example, calling `myCamera.perspective(0.5, 1.5)` sets the camera’s field
121
+ * of view to 0.5 radians and aspect ratio to 1.5, which would make shapes
122
+ * appear thinner on a square canvas. By default, `aspect` is set to
123
+ * `width / height`.The third parameter, `near`, is the distance from the camera to the near
124
+ * plane. For example, calling `myCamera.perspective(0.5, 1.5, 100)` sets the
125
+ * camera’s field of view to 0.5 radians, its aspect ratio to 1.5, and places
126
+ * the near plane 100 pixels from the camera. Any shapes drawn less than 100
127
+ * pixels from the camera won’t be visible. By default, `near` is set to
128
+ * `0.1 * 800`, which is 1/10th the default distance between the camera and
129
+ * the origin.The fourth parameter, `far`, is the distance from the camera to the far
130
+ * plane. For example, calling `myCamera.perspective(0.5, 1.5, 100, 10000)`
131
+ * sets the camera’s field of view to 0.5 radians, its aspect ratio to 1.5,
132
+ * places the near plane 100 pixels from the camera, and places the far plane
133
+ * 10,000 pixels from the camera. Any shapes drawn more than 10,000 pixels
134
+ * from the camera won’t be visible. By default, `far` is set to `10 * 800`,
135
+ * which is 10 times the default distance between the camera and the origin.
136
+ *
137
+ * @param
138
+ * @param
139
+ * @param
140
+ * @param
141
+ */
142
+ perspective(fovy: number, aspect: number, near: number, far: number): void;
143
+
144
+ /**
145
+ * Sets an orthographic projection for the camera.In an orthographic projection, shapes with the same size always appear the
146
+ * same size, regardless of whether they are near or far from the camera.`myCamera.ortho()` changes the camera’s perspective by changing its viewing
147
+ * frustum from a truncated pyramid to a rectangular prism. The frustum is the
148
+ * volume of space that’s visible to the camera. The camera is placed in front
149
+ * of the frustum and views everything within the frustum. `myCamera.ortho()`
150
+ * has six optional parameters to define the viewing frustum.The first four parameters, `left`, `right`, `bottom`, and `top`, set the
151
+ * coordinates of the frustum’s sides, bottom, and top. For example, calling
152
+ * `myCamera.ortho(-100, 100, 200, -200)` creates a frustum that’s 200 pixels
153
+ * wide and 400 pixels tall. By default, these dimensions are set based on
154
+ * the sketch’s width and height, as in
155
+ * `myCamera.ortho(-width / 2, width / 2, -height / 2, height / 2)`.The last two parameters, `near` and `far`, set the distance of the
156
+ * frustum’s near and far plane from the camera. For example, calling
157
+ * `myCamera.ortho(-100, 100, 200, -200, 50, 1000)` creates a frustum that’s
158
+ * 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and
159
+ * ends 1,000 pixels from the camera. By default, `near` and `far` are set to
160
+ * 0 and `max(width, height) + 800`, respectively.
161
+ *
162
+ * @param
163
+ * @param
164
+ * @param
165
+ * @param
166
+ * @param
167
+ * @param
168
+ */
169
+ ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): void;
170
+
171
+ /**
172
+ * Sets the camera's frustum.In a frustum projection, shapes that are further from the camera appear
173
+ * smaller than shapes that are near the camera. This technique, called
174
+ * foreshortening, creates realistic 3D scenes.`myCamera.frustum()` changes the camera’s perspective by changing its
175
+ * viewing frustum. The frustum is the volume of space that’s visible to the
176
+ * camera. The frustum’s shape is a pyramid with its top cut off. The camera
177
+ * is placed where the top of the pyramid should be and points towards the
178
+ * base of the pyramid. It views everything within the frustum.The first four parameters, `left`, `right`, `bottom`, and `top`, set the
179
+ * coordinates of the frustum’s sides, bottom, and top. For example, calling
180
+ * `myCamera.frustum(-100, 100, 200, -200)` creates a frustum that’s 200
181
+ * pixels wide and 400 pixels tall. By default, these coordinates are set
182
+ * based on the sketch’s width and height, as in
183
+ * `myCamera.frustum(-width / 20, width / 20, height / 20, -height / 20)`.The last two parameters, `near` and `far`, set the distance of the
184
+ * frustum’s near and far plane from the camera. For example, calling
185
+ * `myCamera.frustum(-100, 100, 200, -200, 50, 1000)` creates a frustum that’s
186
+ * 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and ends
187
+ * 1,000 pixels from the camera. By default, near is set to `0.1 * 800`, which
188
+ * is 1/10th the default distance between the camera and the origin. `far` is
189
+ * set to `10 * 800`, which is 10 times the default distance between the
190
+ * camera and the origin.
191
+ *
192
+ * @param
193
+ * @param
194
+ * @param
195
+ * @param
196
+ * @param
197
+ * @param
198
+ */
199
+ frustum(left: number, right: number, bottom: number, top: number, near: number, far: number): void;
200
+
201
+ /**
202
+ * Rotates the camera left and right.Panning rotates the camera without changing its position. The rotation
203
+ * happens in the camera’s "local" space.The parameter, `angle`, is the angle the camera should rotate. Passing a
204
+ * positive angle, as in `myCamera.pan(0.001)`, rotates the camera to the
205
+ * right. Passing a negative angle, as in `myCamera.pan(-0.001)`, rotates the
206
+ * camera to the left.Note: Angles are interpreted based on the current
207
+ * angleMode().
208
+ *
209
+ * @param
210
+ * @param
211
+ */
212
+ pan(amount: any, angle: number): void;
213
+
214
+ /**
215
+ * Rotates the camera up and down.Tilting rotates the camera without changing its position. The rotation
216
+ * happens in the camera’s "local" space.The parameter, `angle`, is the angle the camera should rotate. Passing a
217
+ * positive angle, as in `myCamera.tilt(0.001)`, rotates the camera down.
218
+ * Passing a negative angle, as in `myCamera.tilt(-0.001)`, rotates the camera
219
+ * up.Note: Angles are interpreted based on the current
220
+ * angleMode().
221
+ *
222
+ * @param
223
+ * @param
224
+ */
225
+ tilt(amount: any, angle: number): void;
226
+
227
+ /**
228
+ * Points the camera at a location.`myCamera.lookAt()` changes the camera’s orientation without changing its
229
+ * position.The parameters, `x`, `y`, and `z`, are the coordinates in "world" space
230
+ * where the camera should point. For example, calling
231
+ * `myCamera.lookAt(10, 20, 30)` points the camera at the coordinates
232
+ * `(10, 20, 30)`.
233
+ *
234
+ * @param
235
+ * @param
236
+ * @param
237
+ */
238
+ lookAt(x: number, y: number, z: number): void;
239
+
240
+ /**
241
+ * Sets the position and orientation of the camera.`myCamera.camera()` allows objects to be viewed from different angles. It
242
+ * has nine parameters that are all optional.The first three parameters, `x`, `y`, and `z`, are the coordinates of the
243
+ * camera’s position in "world" space. For example, calling
244
+ * `myCamera.camera(0, 0, 0)` places the camera at the origin `(0, 0, 0)`. By
245
+ * default, the camera is placed at `(0, 0, 800)`.The next three parameters, `centerX`, `centerY`, and `centerZ` are the
246
+ * coordinates of the point where the camera faces in "world" space. For
247
+ * example, calling `myCamera.camera(0, 0, 0, 10, 20, 30)` places the camera
248
+ * at the origin `(0, 0, 0)` and points it at `(10, 20, 30)`. By default, the
249
+ * camera points at the origin `(0, 0, 0)`.The last three parameters, `upX`, `upY`, and `upZ` are the components of
250
+ * the "up" vector in "local" space. The "up" vector orients the camera’s
251
+ * y-axis. For example, calling
252
+ * `myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0)` places the camera at the
253
+ * origin `(0, 0, 0)`, points it at `(10, 20, 30)`, and sets the "up" vector
254
+ * to `(0, -1, 0)` which is like holding it upside-down. By default, the "up"
255
+ * vector is `(0, 1, 0)`.
256
+ *
257
+ * @param
258
+ * @param
259
+ * @param
260
+ * @param
261
+ * @param
262
+ * @param
263
+ * @param
264
+ * @param
265
+ * @param
266
+ * @param
267
+ * @param
268
+ * @param
269
+ */
270
+ camera(eyeX: any, eyeY: any, eyeZ: any, centerX: number, centerY: number, centerZ: number, upX: number, upY: number, upZ: number, x: number, y: number, z: number): void;
271
+
272
+ /**
273
+ * Moves the camera along its "local" axes without changing its orientation.The parameters, `x`, `y`, and `z`, are the distances the camera should
274
+ * move. For example, calling `myCamera.move(10, 20, 30)` moves the camera 10
275
+ * pixels to the right, 20 pixels down, and 30 pixels backward in its "local"
276
+ * space.
277
+ *
278
+ * @param
279
+ * @param
280
+ * @param
281
+ */
282
+ move(x: number, y: number, z: number): void;
283
+
284
+ /**
285
+ * Sets the camera’s position in "world" space without changing its
286
+ * orientation.The parameters, `x`, `y`, and `z`, are the coordinates where the camera
287
+ * should be placed. For example, calling `myCamera.setPosition(10, 20, 30)`
288
+ * places the camera at coordinates `(10, 20, 30)` in "world" space.
289
+ *
290
+ * @param
291
+ * @param
292
+ * @param
293
+ */
294
+ setPosition(x: number, y: number, z: number): void;
295
+
296
+ /**
297
+ * Sets the camera’s position, orientation, and projection by copying another
298
+ * camera.The parameter, `cam`, is the `p5.Camera` object to copy. For example, calling
299
+ * `cam2.set(cam1)` will set `cam2` using `cam1`’s configuration.
300
+ *
301
+ * @param
302
+ */
303
+ set(cam: p5.Camera): void;
304
+
305
+ /**
306
+ * Sets the camera’s position and orientation to values that are in-between
307
+ * those of two other cameras.`myCamera.slerp()` uses spherical linear interpolation to calculate a
308
+ * position and orientation that’s in-between two other cameras. Doing so is
309
+ * helpful for transitioning smoothly between two perspectives.The first two parameters, `cam0` and `cam1`, are the `p5.Camera` objects
310
+ * that should be used to set the current camera.The third parameter, `amt`, is the amount to interpolate between `cam0` and
311
+ * `cam1`. 0.0 keeps the camera’s position and orientation equal to `cam0`’s,
312
+ * 0.5 sets them halfway between `cam0`’s and `cam1`’s , and 1.0 sets the
313
+ * position and orientation equal to `cam1`’s.For example, calling `myCamera.slerp(cam0, cam1, 0.1)` sets cam’s position
314
+ * and orientation very close to `cam0`’s. Calling
315
+ * `myCamera.slerp(cam0, cam1, 0.9)` sets cam’s position and orientation very
316
+ * close to `cam1`’s.Note: All of the cameras must use the same projection.
317
+ *
318
+ * @param
319
+ * @param
320
+ * @param
321
+ */
322
+ slerp(cam0: p5.Camera, cam1: p5.Camera, amt: number): void;
323
+
324
+ }
325
+
326
+ /**
327
+ * The camera’s x-coordinate.By default, the camera’s x-coordinate is set to 0 in "world" space.
328
+ *
329
+ * @example <div>
330
+ * <code>
331
+ * let cam;
332
+ * let font;
333
+ *
334
+ * async function setup() {
335
+ * // Load a font and create a p5.Font object.
336
+ * font = await loadFont('assets/inconsolata.otf');
337
+ * createCanvas(100, 100, WEBGL);
338
+ *
339
+ * // Create a p5.Camera object.
340
+ * cam = createCamera();
341
+ *
342
+ * // Set the camera
343
+ * setCamera(cam);
344
+ *
345
+ * // Place the camera at the top-center.
346
+ * cam.setPosition(0, -400, 800);
347
+ *
348
+ * // Point the camera at the origin.
349
+ * cam.lookAt(0, 0, 0);
350
+ *
351
+ * describe(
352
+ * 'A white cube on a gray background. The text "eyeX: 0" is written in black beneath it.'
353
+ * );
354
+ * }
355
+ *
356
+ * function draw() {
357
+ * background(200);
358
+ *
359
+ * // Style the box.
360
+ * fill(255);
361
+ *
362
+ * // Draw the box.
363
+ * box();
364
+ *
365
+ * // Style the text.
366
+ * textAlign(CENTER);
367
+ * textSize(16);
368
+ * textFont(font);
369
+ * fill(0);
370
+ *
371
+ * // Display the value of eyeX, rounded to the nearest integer.
372
+ * text(`eyeX: ${round(cam.eyeX)}`, 0, 45);
373
+ * }
374
+ * </code>
375
+ * </div>
376
+ *
377
+ * <div>
378
+ * <code>
379
+ * let cam;
380
+ * let font;
381
+ *
382
+ * async function setup() {
383
+ * // Load a font and create a p5.Font object.
384
+ * font = await loadFont('assets/inconsolata.otf');
385
+ * createCanvas(100, 100, WEBGL);
386
+ *
387
+ * // Create a p5.Camera object.
388
+ * cam = createCamera();
389
+ *
390
+ * // Place the camera at the top-center.
391
+ * cam.setPosition(0, -400, 800);
392
+ *
393
+ * // Point the camera at the origin.
394
+ * cam.lookAt(0, 0, 0);
395
+ *
396
+ * describe(
397
+ * 'A white cube on a gray background. The cube appears to move left and right as the camera moves. The text "eyeX: X" is written in black beneath the cube. X oscillates between -25 and 25.'
398
+ * );
399
+ * }
400
+ *
401
+ * function draw() {
402
+ * background(200);
403
+ *
404
+ * // Style the box.
405
+ * fill(255);
406
+ *
407
+ * // Draw the box.
408
+ * box();
409
+ *
410
+ * // Style the text.
411
+ * textAlign(CENTER);
412
+ * textSize(16);
413
+ * textFont(font);
414
+ * fill(0);
415
+ *
416
+ * // Calculate the new x-coordinate.
417
+ * let x = 25 * sin(frameCount * 0.01);
418
+ *
419
+ * // Set the camera's position.
420
+ * cam.setPosition(x, -400, 800);
421
+ *
422
+ * // Display the value of eyeX, rounded to the nearest integer.
423
+ * text(`eyeX: ${round(cam.eyeX)}`, 0, 45);
424
+ * }
425
+ * </code>
426
+ * </div>
427
+ */
428
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
429
+
430
+ /**
431
+ * The camera’s y-coordinate.By default, the camera’s y-coordinate is set to 0 in "world" space.
432
+ *
433
+ * @example <div>
434
+ * <code>
435
+ * let cam;
436
+ * let font;
437
+ *
438
+ * async function setup() {
439
+ * // Load a font and create a p5.Font object.
440
+ * font = await loadFont('assets/inconsolata.otf');
441
+ * createCanvas(100, 100, WEBGL);
442
+ *
443
+ * // Create a p5.Camera object.
444
+ * cam = createCamera();
445
+ *
446
+ * // Place the camera at the top-center.
447
+ * cam.setPosition(0, -400, 800);
448
+ *
449
+ * // Point the camera at the origin.
450
+ * cam.lookAt(0, 0, 0);
451
+ *
452
+ * // Set the camera.
453
+ * setCamera(cam);
454
+ *
455
+ * describe(
456
+ * 'A white cube on a gray background. The text "eyeY: -400" is written in black beneath it.'
457
+ * );
458
+ * }
459
+ *
460
+ * function draw() {
461
+ * background(200);
462
+ *
463
+ * // Style the box.
464
+ * fill(255);
465
+ *
466
+ * // Draw the box.
467
+ * box();
468
+ *
469
+ * // Style the text.
470
+ * textAlign(CENTER);
471
+ * textSize(16);
472
+ * textFont(font);
473
+ * fill(0);
474
+ *
475
+ * // Display the value of eyeY, rounded to the nearest integer.
476
+ * text(`eyeY: ${round(cam.eyeY)}`, 0, 45);
477
+ * }
478
+ * </code>
479
+ * </div>
480
+ *
481
+ * <div>
482
+ * <code>
483
+ * let cam;
484
+ * let font;
485
+ *
486
+ * async function setup() {
487
+ * // Load a font and create a p5.Font object.
488
+ * font = await loadFont('assets/inconsolata.otf');
489
+ * createCanvas(100, 100, WEBGL);
490
+ *
491
+ * // Create a p5.Camera object.
492
+ * cam = createCamera();
493
+ *
494
+ * // Set the camera
495
+ * setCamera(cam);
496
+ *
497
+ * // Place the camera at the top-center.
498
+ * cam.setPosition(0, -400, 800);
499
+ *
500
+ * // Point the camera at the origin.
501
+ * cam.lookAt(0, 0, 0);
502
+ *
503
+ * describe(
504
+ * 'A white cube on a gray background. The cube appears to move up and down as the camera moves. The text "eyeY: Y" is written in black beneath the cube. Y oscillates between -374 and -425.'
505
+ * );
506
+ * }
507
+ *
508
+ * function draw() {
509
+ * background(200);
510
+ *
511
+ * // Style the box.
512
+ * fill(255);
513
+ *
514
+ * // Draw the box.
515
+ * box();
516
+ *
517
+ * // Style the text.
518
+ * textAlign(CENTER);
519
+ * textSize(16);
520
+ * textFont(font);
521
+ * fill(0);
522
+ *
523
+ * // Calculate the new y-coordinate.
524
+ * let y = 25 * sin(frameCount * 0.01) - 400;
525
+ *
526
+ * // Set the camera's position.
527
+ * cam.setPosition(0, y, 800);
528
+ *
529
+ * // Display the value of eyeY, rounded to the nearest integer.
530
+ * text(`eyeY: ${round(cam.eyeY)}`, 0, 45);
531
+ * }
532
+ * </code>
533
+ * </div>
534
+ */
535
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
536
+
537
+ /**
538
+ * The camera’s z-coordinate.By default, the camera’s z-coordinate is set to 800 in "world" space.
539
+ *
540
+ * @example <div>
541
+ * <code>
542
+ * let cam;
543
+ * let font;
544
+ *
545
+ * async function setup() {
546
+ * // Load a font and create a p5.Font object.
547
+ * font = await loadFont('assets/inconsolata.otf');
548
+ * createCanvas(100, 100, WEBGL);
549
+ *
550
+ * // Create a p5.Camera object.
551
+ * cam = createCamera();
552
+ *
553
+ * // Set the camera
554
+ * setCamera(cam);
555
+ *
556
+ * // Place the camera at the top-center.
557
+ * cam.setPosition(0, -400, 800);
558
+ *
559
+ * // Point the camera at the origin.
560
+ * cam.lookAt(0, 0, 0);
561
+ *
562
+ * describe(
563
+ * 'A white cube on a gray background. The text "eyeZ: 800" is written in black beneath it.'
564
+ * );
565
+ * }
566
+ *
567
+ * function draw() {
568
+ * background(200);
569
+ *
570
+ * // Style the box.
571
+ * fill(255);
572
+ *
573
+ * // Draw the box.
574
+ * box();
575
+ *
576
+ * // Style the text.
577
+ * textAlign(CENTER);
578
+ * textSize(16);
579
+ * textFont(font);
580
+ * fill(0);
581
+ *
582
+ * // Display the value of eyeZ, rounded to the nearest integer.
583
+ * text(`eyeZ: ${round(cam.eyeZ)}`, 0, 45);
584
+ * }
585
+ * </code>
586
+ * </div>
587
+ *
588
+ * <div>
589
+ * <code>
590
+ * let cam;
591
+ * let font;
592
+ *
593
+ * async function setup() {
594
+ * // Load a font and create a p5.Font object.
595
+ * font = await loadFont('assets/inconsolata.otf');
596
+ * createCanvas(100, 100, WEBGL);
597
+ *
598
+ * // Create a p5.Camera object.
599
+ * cam = createCamera();
600
+ *
601
+ * // Set the camera
602
+ * setCamera(cam);
603
+ *
604
+ * // Place the camera at the top-center.
605
+ * cam.setPosition(0, -400, 800);
606
+ *
607
+ * // Point the camera at the origin.
608
+ * cam.lookAt(0, 0, 0);
609
+ *
610
+ * describe(
611
+ * 'A white cube on a gray background. The cube appears to move forward and back as the camera moves. The text "eyeZ: Z" is written in black beneath the cube. Z oscillates between 700 and 900.'
612
+ * );
613
+ * }
614
+ *
615
+ * function draw() {
616
+ * background(200);
617
+ *
618
+ * // Style the box.
619
+ * fill(255);
620
+ *
621
+ * // Draw the box.
622
+ * box();
623
+ *
624
+ * // Style the text.
625
+ * textAlign(CENTER);
626
+ * textSize(16);
627
+ * textFont(font);
628
+ * fill(0);
629
+ *
630
+ * // Calculate the new z-coordinate.
631
+ * let z = 100 * sin(frameCount * 0.01) + 800;
632
+ *
633
+ * // Set the camera's position.
634
+ * cam.setPosition(0, -400, z);
635
+ *
636
+ * // Display the value of eyeZ, rounded to the nearest integer.
637
+ * text(`eyeZ: ${round(cam.eyeZ)}`, 0, 45);
638
+ * }
639
+ * </code>
640
+ * </div>
641
+ */
642
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
643
+
644
+ /**
645
+ * The x-coordinate of the place where the camera looks.By default, the camera looks at the origin `(0, 0, 0)` in "world" space, so
646
+ * `myCamera.centerX` is 0.
647
+ *
648
+ * @example <div>
649
+ * <code>
650
+ * let cam;
651
+ * let font;
652
+ *
653
+ * async function setup() {
654
+ * // Load a font and create a p5.Font object.
655
+ * font = await loadFont('assets/inconsolata.otf');
656
+ * createCanvas(100, 100, WEBGL);
657
+ *
658
+ * // Create a p5.Camera object.
659
+ * cam = createCamera();
660
+ *
661
+ * // Set the camera
662
+ * setCamera(cam);
663
+ *
664
+ * // Place the camera at the top-center.
665
+ * cam.setPosition(0, -400, 800);
666
+ *
667
+ * // Point the camera at (10, 20, -30).
668
+ * cam.lookAt(10, 20, -30);
669
+ *
670
+ * describe(
671
+ * 'A white cube on a gray background. The text "centerX: 10" is written in black beneath it.'
672
+ * );
673
+ * }
674
+ *
675
+ * function draw() {
676
+ * background(200);
677
+ *
678
+ * // Style the box.
679
+ * fill(255);
680
+ *
681
+ * // Draw the box.
682
+ * box();
683
+ *
684
+ * // Style the text.
685
+ * textAlign(CENTER);
686
+ * textSize(16);
687
+ * textFont(font);
688
+ * fill(0);
689
+ *
690
+ * // Display the value of centerX, rounded to the nearest integer.
691
+ * text(`centerX: ${round(cam.centerX)}`, 0, 45);
692
+ * }
693
+ * </code>
694
+ * </div>
695
+ *
696
+ * <div>
697
+ * <code>
698
+ * let cam;
699
+ * let font;
700
+ *
701
+ * async function setup() {
702
+ * // Load a font and create a p5.Font object.
703
+ * font = await loadFont('assets/inconsolata.otf');
704
+ * createCanvas(100, 100, WEBGL);
705
+ *
706
+ * // Create a p5.Camera object.
707
+ * cam = createCamera();
708
+ *
709
+ * // Set the camera
710
+ * setCamera(cam);
711
+ *
712
+ * // Place the camera at the top-right.
713
+ * cam.setPosition(100, -400, 800);
714
+ *
715
+ * // Point the camera at (10, 20, -30).
716
+ * cam.lookAt(10, 20, -30);
717
+ *
718
+ * describe(
719
+ * 'A white cube on a gray background. The cube appears to move left and right as the camera shifts its focus. The text "centerX: X" is written in black beneath the cube. X oscillates between -15 and 35.'
720
+ * );
721
+ * }
722
+ *
723
+ * function draw() {
724
+ * background(200);
725
+ *
726
+ * // Style the box.
727
+ * fill(255);
728
+ *
729
+ * // Draw the box.
730
+ * box();
731
+ *
732
+ * // Style the text.
733
+ * textAlign(CENTER);
734
+ * textSize(16);
735
+ * textFont(font);
736
+ * fill(0);
737
+ *
738
+ * // Calculate the new x-coordinate.
739
+ * let x = 25 * sin(frameCount * 0.01) + 10;
740
+ *
741
+ * // Point the camera.
742
+ * cam.lookAt(x, 20, -30);
743
+ *
744
+ * // Display the value of centerX, rounded to the nearest integer.
745
+ * text(`centerX: ${round(cam.centerX)}`, 0, 45);
746
+ * }
747
+ * </code>
748
+ * </div>
749
+ */
750
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
751
+
752
+ /**
753
+ * The y-coordinate of the place where the camera looks.By default, the camera looks at the origin `(0, 0, 0)` in "world" space, so
754
+ * `myCamera.centerY` is 0.
755
+ *
756
+ * @example <div>
757
+ * <code>
758
+ * let cam;
759
+ * let font;
760
+ *
761
+ * async function setup() {
762
+ * // Load a font and create a p5.Font object.
763
+ * font = await loadFont('assets/inconsolata.otf');
764
+ * createCanvas(100, 100, WEBGL);
765
+ *
766
+ * // Create a p5.Camera object.
767
+ * cam = createCamera();
768
+ *
769
+ * // Set the camera
770
+ * setCamera(cam);
771
+ *
772
+ * // Place the camera at the top-center.
773
+ * cam.setPosition(0, -400, 800);
774
+ *
775
+ * // Point the camera at (10, 20, -30).
776
+ * cam.lookAt(10, 20, -30);
777
+ *
778
+ * describe(
779
+ * 'A white cube on a gray background. The text "centerY: 20" is written in black beneath it.'
780
+ * );
781
+ * }
782
+ *
783
+ * function draw() {
784
+ * background(200);
785
+ *
786
+ * // Style the box.
787
+ * fill(255);
788
+ *
789
+ * // Draw the box.
790
+ * box();
791
+ *
792
+ * // Style the text.
793
+ * textAlign(CENTER);
794
+ * textSize(16);
795
+ * textFont(font);
796
+ * fill(0);
797
+ *
798
+ * // Display the value of centerY, rounded to the nearest integer.
799
+ * text(`centerY: ${round(cam.centerY)}`, 0, 45);
800
+ * }
801
+ * </code>
802
+ * </div>
803
+ *
804
+ * <div>
805
+ * <code>
806
+ * let cam;
807
+ * let font;
808
+ *
809
+ * async function setup() {
810
+ * // Load a font and create a p5.Font object.
811
+ * font = await loadFont('assets/inconsolata.otf');
812
+ * createCanvas(100, 100, WEBGL);
813
+ *
814
+ * // Create a p5.Camera object.
815
+ * cam = createCamera();
816
+ *
817
+ * // Set the camera
818
+ * setCamera(cam);
819
+ *
820
+ * // Place the camera at the top-right.
821
+ * cam.setPosition(100, -400, 800);
822
+ *
823
+ * // Point the camera at (10, 20, -30).
824
+ * cam.lookAt(10, 20, -30);
825
+ *
826
+ * describe(
827
+ * 'A white cube on a gray background. The cube appears to move up and down as the camera shifts its focus. The text "centerY: Y" is written in black beneath the cube. Y oscillates between -5 and 45.'
828
+ * );
829
+ * }
830
+ *
831
+ * function draw() {
832
+ * background(200);
833
+ *
834
+ * // Style the box.
835
+ * fill(255);
836
+ *
837
+ * // Draw the box.
838
+ * box();
839
+ *
840
+ * // Style the text.
841
+ * textAlign(CENTER);
842
+ * textSize(16);
843
+ * textFont(font);
844
+ * fill(0);
845
+ *
846
+ * // Calculate the new y-coordinate.
847
+ * let y = 25 * sin(frameCount * 0.01) + 20;
848
+ *
849
+ * // Point the camera.
850
+ * cam.lookAt(10, y, -30);
851
+ *
852
+ * // Display the value of centerY, rounded to the nearest integer.
853
+ * text(`centerY: ${round(cam.centerY)}`, 0, 45);
854
+ * }
855
+ * </code>
856
+ * </div>
857
+ */
858
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
859
+
860
+ /**
861
+ * The y-coordinate of the place where the camera looks.By default, the camera looks at the origin `(0, 0, 0)` in "world" space, so
862
+ * `myCamera.centerZ` is 0.
863
+ *
864
+ * @example <div>
865
+ * <code>
866
+ * let cam;
867
+ * let font;
868
+ *
869
+ * async function setup() {
870
+ * // Load a font and create a p5.Font object.
871
+ * font = await loadFont('assets/inconsolata.otf');
872
+ * createCanvas(100, 100, WEBGL);
873
+ *
874
+ * // Create a p5.Camera object.
875
+ * cam = createCamera();
876
+ *
877
+ * // Set the camera
878
+ * setCamera(cam);
879
+ *
880
+ * // Place the camera at the top-center.
881
+ * cam.setPosition(0, -400, 800);
882
+ *
883
+ * // Point the camera at (10, 20, -30).
884
+ * cam.lookAt(10, 20, -30);
885
+ *
886
+ * describe(
887
+ * 'A white cube on a gray background. The text "centerZ: -30" is written in black beneath it.'
888
+ * );
889
+ * }
890
+ *
891
+ * function draw() {
892
+ * background(200);
893
+ *
894
+ * // Style the box.
895
+ * fill(255);
896
+ *
897
+ * // Draw the box.
898
+ * box();
899
+ *
900
+ * // Style the text.
901
+ * textAlign(CENTER);
902
+ * textSize(16);
903
+ * textFont(font);
904
+ * fill(0);
905
+ *
906
+ * // Display the value of centerZ, rounded to the nearest integer.
907
+ * text(`centerZ: ${round(cam.centerZ)}`, 0, 45);
908
+ * }
909
+ * </code>
910
+ * </div>
911
+ *
912
+ * <div>
913
+ * <code>
914
+ * let cam;
915
+ * let font;
916
+ *
917
+ * async function setup() {
918
+ * // Load a font and create a p5.Font object.
919
+ * font = await loadFont('assets/inconsolata.otf');
920
+ * createCanvas(100, 100, WEBGL);
921
+ *
922
+ * // Create a p5.Camera object.
923
+ * cam = createCamera();
924
+ *
925
+ * // Place the camera at the top-right.
926
+ * cam.setPosition(100, -400, 800);
927
+ *
928
+ * // Point the camera at (10, 20, -30).
929
+ * cam.lookAt(10, 20, -30);
930
+ *
931
+ * describe(
932
+ * 'A white cube on a gray background. The cube appears to move forward and back as the camera shifts its focus. The text "centerZ: Z" is written in black beneath the cube. Z oscillates between -55 and -25.'
933
+ * );
934
+ * }
935
+ *
936
+ * function draw() {
937
+ * background(200);
938
+ *
939
+ * // Style the box.
940
+ * fill(255);
941
+ *
942
+ * // Draw the box.
943
+ * box();
944
+ *
945
+ * // Style the text.
946
+ * textAlign(CENTER);
947
+ * textSize(16);
948
+ * textFont(font);
949
+ * fill(0);
950
+ *
951
+ * // Calculate the new z-coordinate.
952
+ * let z = 25 * sin(frameCount * 0.01) - 30;
953
+ *
954
+ * // Point the camera.
955
+ * cam.lookAt(10, 20, z);
956
+ *
957
+ * // Display the value of centerZ, rounded to the nearest integer.
958
+ * text(`centerZ: ${round(cam.centerZ)}`, 0, 45);
959
+ * }
960
+ * </code>
961
+ * </div>
962
+ */
963
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
964
+
965
+ /**
966
+ * The x-component of the camera's "up" vector.The camera's "up" vector orients its y-axis. By default, the "up" vector is
967
+ * `(0, 1, 0)`, so its x-component is 0 in "local" space.
968
+ *
969
+ * @example <div>
970
+ * <code>
971
+ * let cam;
972
+ * let font;
973
+ *
974
+ * async function setup() {
975
+ * // Load a font and create a p5.Font object.
976
+ * font = await loadFont('assets/inconsolata.otf');
977
+ * createCanvas(100, 100, WEBGL);
978
+ *
979
+ * // Create a p5.Camera object.
980
+ * cam = createCamera();
981
+ *
982
+ * // Set the camera
983
+ * setCamera(cam);
984
+ *
985
+ * // Place the camera at the top-right: (100, -400, 800)
986
+ * // Point it at the origin: (0, 0, 0)
987
+ * // Set its "up" vector: (0, 1, 0).
988
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);
989
+ *
990
+ * describe(
991
+ * 'A white cube on a gray background. The text "upX: 0" is written in black beneath it.'
992
+ * );
993
+ * }
994
+ *
995
+ * function draw() {
996
+ * background(200);
997
+ *
998
+ * // Style the box.
999
+ * fill(255);
1000
+ *
1001
+ * // Draw the box.
1002
+ * box();
1003
+ *
1004
+ * // Style the text.
1005
+ * textAlign(CENTER);
1006
+ * textSize(16);
1007
+ * textFont(font);
1008
+ * fill(0);
1009
+ *
1010
+ * // Display the value of upX, rounded to the nearest tenth.
1011
+ * text(`upX: ${round(cam.upX, 1)}`, 0, 45);
1012
+ * }
1013
+ * </code>
1014
+ * </div>
1015
+ *
1016
+ * <div>
1017
+ * <code>
1018
+ * let cam;
1019
+ * let font;
1020
+ *
1021
+ * async function setup() {
1022
+ * // Load a font and create a p5.Font object.
1023
+ * font = await loadFont('assets/inconsolata.otf');
1024
+ * createCanvas(100, 100, WEBGL);
1025
+ *
1026
+ * // Create a p5.Camera object.
1027
+ * cam = createCamera();
1028
+ *
1029
+ * // Set the camera
1030
+ * setCamera(cam);
1031
+ *
1032
+ * // Place the camera at the top-right: (100, -400, 800)
1033
+ * // Point it at the origin: (0, 0, 0)
1034
+ * // Set its "up" vector: (0, 1, 0).
1035
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);
1036
+ *
1037
+ * describe(
1038
+ * 'A white cube on a gray background. The cube appears to rock back and forth. The text "upX: X" is written in black beneath it. X oscillates between -1 and 1.'
1039
+ * );
1040
+ * }
1041
+ *
1042
+ * function draw() {
1043
+ * background(200);
1044
+ *
1045
+ * // Style the box.
1046
+ * fill(255);
1047
+ *
1048
+ * // Draw the box.
1049
+ * box();
1050
+ *
1051
+ * // Style the text.
1052
+ * textAlign(CENTER);
1053
+ * textSize(16);
1054
+ * textFont(font);
1055
+ * fill(0);
1056
+ *
1057
+ * // Calculate the x-component.
1058
+ * let x = sin(frameCount * 0.01);
1059
+ *
1060
+ * // Update the camera's "up" vector.
1061
+ * cam.camera(100, -400, 800, 0, 0, 0, x, 1, 0);
1062
+ *
1063
+ * // Display the value of upX, rounded to the nearest tenth.
1064
+ * text(`upX: ${round(cam.upX, 1)}`, 0, 45);
1065
+ * }
1066
+ * </code>
1067
+ * </div>
1068
+ */
1069
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
1070
+
1071
+ /**
1072
+ * The y-component of the camera's "up" vector.The camera's "up" vector orients its y-axis. By default, the "up" vector is
1073
+ * `(0, 1, 0)`, so its y-component is 1 in "local" space.
1074
+ *
1075
+ * @example <div>
1076
+ * <code>
1077
+ * let cam;
1078
+ * let font;
1079
+ *
1080
+ * async function setup() {
1081
+ * // Load a font and create a p5.Font object.
1082
+ * font = await loadFont('assets/inconsolata.otf');
1083
+ * createCanvas(100, 100, WEBGL);
1084
+ *
1085
+ * // Create a p5.Camera object.
1086
+ * cam = createCamera();
1087
+ *
1088
+ * // Set the camera
1089
+ * setCamera(cam);
1090
+ *
1091
+ * // Place the camera at the top-right: (100, -400, 800)
1092
+ * // Point it at the origin: (0, 0, 0)
1093
+ * // Set its "up" vector: (0, 1, 0).
1094
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);
1095
+ *
1096
+ * describe(
1097
+ * 'A white cube on a gray background. The text "upY: 1" is written in black beneath it.'
1098
+ * );
1099
+ * }
1100
+ *
1101
+ * function draw() {
1102
+ * background(200);
1103
+ *
1104
+ * // Style the box.
1105
+ * fill(255);
1106
+ *
1107
+ * // Draw the box.
1108
+ * box();
1109
+ *
1110
+ * // Style the text.
1111
+ * textAlign(CENTER);
1112
+ * textSize(16);
1113
+ * textFont(font);
1114
+ * fill(0);
1115
+ *
1116
+ * // Display the value of upY, rounded to the nearest tenth.
1117
+ * text(`upY: ${round(cam.upY, 1)}`, 0, 45);
1118
+ * }
1119
+ * </code>
1120
+ * </div>
1121
+ *
1122
+ * <div>
1123
+ * <code>
1124
+ * let cam;
1125
+ * let font;
1126
+ *
1127
+ * async function setup() {
1128
+ * // Load a font and create a p5.Font object.
1129
+ * font = await loadFont('assets/inconsolata.otf');
1130
+ * createCanvas(100, 100, WEBGL);
1131
+ *
1132
+ * // Create a p5.Camera object.
1133
+ * cam = createCamera();
1134
+ *
1135
+ * // Set the camera
1136
+ * setCamera(cam);
1137
+ *
1138
+ * // Place the camera at the top-right: (100, -400, 800)
1139
+ * // Point it at the origin: (0, 0, 0)
1140
+ * // Set its "up" vector: (0, 1, 0).
1141
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);
1142
+ *
1143
+ * describe(
1144
+ * 'A white cube on a gray background. The cube flips upside-down periodically. The text "upY: Y" is written in black beneath it. Y oscillates between -1 and 1.'
1145
+ * );
1146
+ * }
1147
+ *
1148
+ * function draw() {
1149
+ * background(200);
1150
+ *
1151
+ * // Style the box.
1152
+ * fill(255);
1153
+ *
1154
+ * // Draw the box.
1155
+ * box();
1156
+ *
1157
+ * // Style the text.
1158
+ * textAlign(CENTER);
1159
+ * textSize(16);
1160
+ * textFont(font);
1161
+ * fill(0);
1162
+ *
1163
+ * // Calculate the y-component.
1164
+ * let y = sin(frameCount * 0.01);
1165
+ *
1166
+ * // Update the camera's "up" vector.
1167
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, y, 0);
1168
+ *
1169
+ * // Display the value of upY, rounded to the nearest tenth.
1170
+ * text(`upY: ${round(cam.upY, 1)}`, 0, 45);
1171
+ * }
1172
+ * </code>
1173
+ * </div>
1174
+ */
1175
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
1176
+
1177
+ /**
1178
+ * The z-component of the camera's "up" vector.The camera's "up" vector orients its y-axis. By default, the "up" vector is
1179
+ * `(0, 1, 0)`, so its z-component is 0 in "local" space.
1180
+ *
1181
+ * @example <div>
1182
+ * <code>
1183
+ * let cam;
1184
+ * let font;
1185
+ *
1186
+ * async function setup() {
1187
+ * // Load a font and create a p5.Font object.
1188
+ * font = await loadFont('assets/inconsolata.otf');
1189
+ * createCanvas(100, 100, WEBGL);
1190
+ *
1191
+ * // Create a p5.Camera object.
1192
+ * cam = createCamera();
1193
+ *
1194
+ * // Set the camera
1195
+ * setCamera(cam);
1196
+ *
1197
+ * // Place the camera at the top-right: (100, -400, 800)
1198
+ * // Point it at the origin: (0, 0, 0)
1199
+ * // Set its "up" vector: (0, 1, 0).
1200
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);
1201
+ *
1202
+ * describe(
1203
+ * 'A white cube on a gray background. The text "upZ: 0" is written in black beneath it.'
1204
+ * );
1205
+ * }
1206
+ *
1207
+ * function draw() {
1208
+ * background(200);
1209
+ *
1210
+ * // Style the box.
1211
+ * fill(255);
1212
+ *
1213
+ * // Draw the box.
1214
+ * box();
1215
+ *
1216
+ * // Style the text.
1217
+ * textAlign(CENTER);
1218
+ * textSize(16);
1219
+ * textFont(font);
1220
+ * fill(0);
1221
+ *
1222
+ * // Display the value of upZ, rounded to the nearest tenth.
1223
+ * text(`upZ: ${round(cam.upZ, 1)}`, 0, 45);
1224
+ * }
1225
+ * </code>
1226
+ * </div>
1227
+ *
1228
+ * <div>
1229
+ * <code>
1230
+ * let cam;
1231
+ * let font;
1232
+ *
1233
+ * async function setup() {
1234
+ * // Load a font and create a p5.Font object.
1235
+ * font = await loadFont('assets/inconsolata.otf');
1236
+ * createCanvas(100, 100, WEBGL);
1237
+ *
1238
+ * // Create a p5.Camera object.
1239
+ * cam = createCamera();
1240
+ *
1241
+ * // Set the camera
1242
+ * setCamera(cam);
1243
+ *
1244
+ * // Place the camera at the top-right: (100, -400, 800)
1245
+ * // Point it at the origin: (0, 0, 0)
1246
+ * // Set its "up" vector: (0, 1, 0).
1247
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);
1248
+ *
1249
+ * describe(
1250
+ * 'A white cube on a gray background. The cube appears to rock back and forth. The text "upZ: Z" is written in black beneath it. Z oscillates between -1 and 1.'
1251
+ * );
1252
+ * }
1253
+ *
1254
+ * function draw() {
1255
+ * background(200);
1256
+ *
1257
+ * // Style the box.
1258
+ * fill(255);
1259
+ *
1260
+ * // Draw the box.
1261
+ * box();
1262
+ *
1263
+ * // Style the text.
1264
+ * textAlign(CENTER);
1265
+ * textSize(16);
1266
+ * textFont(font);
1267
+ * fill(0);
1268
+ *
1269
+ * // Calculate the z-component.
1270
+ * let z = sin(frameCount * 0.01);
1271
+ *
1272
+ * // Update the camera's "up" vector.
1273
+ * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, z);
1274
+ *
1275
+ * // Display the value of upZ, rounded to the nearest tenth.
1276
+ * text(`upZ: ${round(cam.upZ, 1)}`, 0, 45);
1277
+ * }
1278
+ * </code>
1279
+ * </div>
1280
+ */
1281
+ function perspective(fovy: any, aspect: any, near: any, far: any): void;
1282
+
1283
+ /**
1284
+ * Sets a perspective projection for the camera.In a perspective projection, shapes that are further from the camera appear
1285
+ * smaller than shapes that are near the camera. This technique, called
1286
+ * foreshortening, creates realistic 3D scenes. It’s applied by default in new
1287
+ * `p5.Camera` objects.`myCamera.perspective()` changes the camera’s perspective by changing its
1288
+ * viewing frustum. The frustum is the volume of space that’s visible to the
1289
+ * camera. The frustum’s shape is a pyramid with its top cut off. The camera
1290
+ * is placed where the top of the pyramid should be and points towards the
1291
+ * base of the pyramid. It views everything within the frustum.The first parameter, `fovy`, is the camera’s vertical field of view. It’s
1292
+ * an angle that describes how tall or narrow a view the camera has. For
1293
+ * example, calling `myCamera.perspective(0.5)` sets the camera’s vertical
1294
+ * field of view to 0.5 radians. By default, `fovy` is calculated based on the
1295
+ * sketch’s height and the camera’s default z-coordinate, which is 800. The
1296
+ * formula for the default `fovy` is `2 * atan(height / 2 / 800)`.The second parameter, `aspect`, is the camera’s aspect ratio. It’s a number
1297
+ * that describes the ratio of the top plane’s width to its height. For
1298
+ * example, calling `myCamera.perspective(0.5, 1.5)` sets the camera’s field
1299
+ * of view to 0.5 radians and aspect ratio to 1.5, which would make shapes
1300
+ * appear thinner on a square canvas. By default, `aspect` is set to
1301
+ * `width / height`.The third parameter, `near`, is the distance from the camera to the near
1302
+ * plane. For example, calling `myCamera.perspective(0.5, 1.5, 100)` sets the
1303
+ * camera’s field of view to 0.5 radians, its aspect ratio to 1.5, and places
1304
+ * the near plane 100 pixels from the camera. Any shapes drawn less than 100
1305
+ * pixels from the camera won’t be visible. By default, `near` is set to
1306
+ * `0.1 * 800`, which is 1/10th the default distance between the camera and
1307
+ * the origin.The fourth parameter, `far`, is the distance from the camera to the far
1308
+ * plane. For example, calling `myCamera.perspective(0.5, 1.5, 100, 10000)`
1309
+ * sets the camera’s field of view to 0.5 radians, its aspect ratio to 1.5,
1310
+ * places the near plane 100 pixels from the camera, and places the far plane
1311
+ * 10,000 pixels from the camera. Any shapes drawn more than 10,000 pixels
1312
+ * from the camera won’t be visible. By default, `far` is set to `10 * 800`,
1313
+ * which is 10 times the default distance between the camera and the origin.
1314
+ *
1315
+ * @for p5.Camera
1316
+ * @param camera frustum vertical field of view. Defaults to
1317
+ * `2 * atan(height / 2 / 800)`.
1318
+ * @param camera frustum aspect ratio. Defaults to
1319
+ * `width / height`.
1320
+ * @param distance from the camera to the near clipping plane.
1321
+ * Defaults to `0.1 * 800`.
1322
+ * @param distance from the camera to the far clipping plane.
1323
+ * Defaults to `10 * 800`.
1324
+ * @example <div>
1325
+ * <code>
1326
+ * // Double-click to toggle between cameras.
1327
+ *
1328
+ * let cam1;
1329
+ * let cam2;
1330
+ * let isDefaultCamera = true;
1331
+ *
1332
+ * function setup() {
1333
+ * createCanvas(100, 100, WEBGL);
1334
+ *
1335
+ * // Create the first camera.
1336
+ * // Keep its default settings.
1337
+ * cam1 = createCamera();
1338
+ *
1339
+ * // Create the second camera.
1340
+ * cam2 = createCamera();
1341
+ *
1342
+ * // Place it at the top-right.
1343
+ * cam2.camera(400, -400, 800);
1344
+ *
1345
+ * // Set its fovy to 0.2.
1346
+ * // Set its aspect to 1.5.
1347
+ * // Set its near to 600.
1348
+ * // Set its far to 1200.
1349
+ * cam2.perspective(0.2, 1.5, 600, 1200);
1350
+ *
1351
+ * // Set the current camera to cam1.
1352
+ * setCamera(cam1);
1353
+ *
1354
+ * describe('A white cube on a gray background. The camera toggles between a frontal view and a skewed aerial view when the user double-clicks.');
1355
+ * }
1356
+ *
1357
+ * function draw() {
1358
+ * background(200);
1359
+ *
1360
+ * // Draw the box.
1361
+ * box();
1362
+ * }
1363
+ *
1364
+ * // Toggle the current camera when the user double-clicks.
1365
+ * function doubleClicked() {
1366
+ * if (isDefaultCamera === true) {
1367
+ * setCamera(cam2);
1368
+ * isDefaultCamera = false;
1369
+ * } else {
1370
+ * setCamera(cam1);
1371
+ * isDefaultCamera = true;
1372
+ * }
1373
+ * }
1374
+ * </code>
1375
+ * </div>
1376
+ *
1377
+ * <div>
1378
+ * <code>
1379
+ * // Double-click to toggle between cameras.
1380
+ *
1381
+ * let cam1;
1382
+ * let cam2;
1383
+ * let isDefaultCamera = true;
1384
+ *
1385
+ * function setup() {
1386
+ * createCanvas(100, 100, WEBGL);
1387
+ *
1388
+ * // Create the first camera.
1389
+ * // Keep its default settings.
1390
+ * cam1 = createCamera();
1391
+ *
1392
+ * // Create the second camera.
1393
+ * cam2 = createCamera();
1394
+ *
1395
+ * // Place it at the top-right.
1396
+ * cam2.camera(400, -400, 800);
1397
+ *
1398
+ * // Set its fovy to 0.2.
1399
+ * // Set its aspect to 1.5.
1400
+ * // Set its near to 600.
1401
+ * // Set its far to 1200.
1402
+ * cam2.perspective(0.2, 1.5, 600, 1200);
1403
+ *
1404
+ * // Set the current camera to cam1.
1405
+ * setCamera(cam1);
1406
+ *
1407
+ * describe('A white cube moves left and right on a gray background. The camera toggles between a frontal and a skewed aerial view when the user double-clicks.');
1408
+ * }
1409
+ *
1410
+ * function draw() {
1411
+ * background(200);
1412
+ *
1413
+ * // Translate the origin left and right.
1414
+ * let x = 100 * sin(frameCount * 0.01);
1415
+ * translate(x, 0, 0);
1416
+ *
1417
+ * // Draw the box.
1418
+ * box();
1419
+ * }
1420
+ *
1421
+ * // Toggle the current camera when the user double-clicks.
1422
+ * function doubleClicked() {
1423
+ * if (isDefaultCamera === true) {
1424
+ * setCamera(cam2);
1425
+ * isDefaultCamera = false;
1426
+ * } else {
1427
+ * setCamera(cam1);
1428
+ * isDefaultCamera = true;
1429
+ * }
1430
+ * }
1431
+ * </code>
1432
+ * </div>
1433
+ */
1434
+ function perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
1435
+
1436
+ /**
1437
+ * Sets an orthographic projection for the camera.In an orthographic projection, shapes with the same size always appear the
1438
+ * same size, regardless of whether they are near or far from the camera.`myCamera.ortho()` changes the camera’s perspective by changing its viewing
1439
+ * frustum from a truncated pyramid to a rectangular prism. The frustum is the
1440
+ * volume of space that’s visible to the camera. The camera is placed in front
1441
+ * of the frustum and views everything within the frustum. `myCamera.ortho()`
1442
+ * has six optional parameters to define the viewing frustum.The first four parameters, `left`, `right`, `bottom`, and `top`, set the
1443
+ * coordinates of the frustum’s sides, bottom, and top. For example, calling
1444
+ * `myCamera.ortho(-100, 100, 200, -200)` creates a frustum that’s 200 pixels
1445
+ * wide and 400 pixels tall. By default, these dimensions are set based on
1446
+ * the sketch’s width and height, as in
1447
+ * `myCamera.ortho(-width / 2, width / 2, -height / 2, height / 2)`.The last two parameters, `near` and `far`, set the distance of the
1448
+ * frustum’s near and far plane from the camera. For example, calling
1449
+ * `myCamera.ortho(-100, 100, 200, -200, 50, 1000)` creates a frustum that’s
1450
+ * 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and
1451
+ * ends 1,000 pixels from the camera. By default, `near` and `far` are set to
1452
+ * 0 and `max(width, height) + 800`, respectively.
1453
+ *
1454
+ * @for p5.Camera
1455
+ * @param x-coordinate of the frustum’s left plane. Defaults to `-width / 2`.
1456
+ * @param x-coordinate of the frustum’s right plane. Defaults to `width / 2`.
1457
+ * @param y-coordinate of the frustum’s bottom plane. Defaults to `height / 2`.
1458
+ * @param y-coordinate of the frustum’s top plane. Defaults to `-height / 2`.
1459
+ * @param z-coordinate of the frustum’s near plane. Defaults to 0.
1460
+ * @param z-coordinate of the frustum’s far plane. Defaults to `max(width, height) + 800`.
1461
+ * @example <div>
1462
+ * <code>
1463
+ * // Double-click to toggle between cameras.
1464
+ *
1465
+ * let cam1;
1466
+ * let cam2;
1467
+ * let isDefaultCamera = true;
1468
+ *
1469
+ * function setup() {
1470
+ * createCanvas(100, 100, WEBGL);
1471
+ *
1472
+ * // Create the first camera.
1473
+ * // Keep its default settings.
1474
+ * cam1 = createCamera();
1475
+ *
1476
+ * // Create the second camera.
1477
+ * cam2 = createCamera();
1478
+ *
1479
+ * // Apply an orthographic projection.
1480
+ * cam2.ortho();
1481
+ *
1482
+ * // Set the current camera to cam1.
1483
+ * setCamera(cam1);
1484
+ *
1485
+ * describe('A row of white cubes against a gray background. The camera toggles between a perspective and an orthographic projection when the user double-clicks.');
1486
+ * }
1487
+ *
1488
+ * function draw() {
1489
+ * background(200);
1490
+ *
1491
+ * // Translate the origin toward the camera.
1492
+ * translate(-10, 10, 500);
1493
+ *
1494
+ * // Rotate the coordinate system.
1495
+ * rotateY(-0.1);
1496
+ * rotateX(-0.1);
1497
+ *
1498
+ * // Draw the row of boxes.
1499
+ * for (let i = 0; i < 6; i += 1) {
1500
+ * translate(0, 0, -40);
1501
+ * box(10);
1502
+ * }
1503
+ * }
1504
+ *
1505
+ * // Toggle the current camera when the user double-clicks.
1506
+ * function doubleClicked() {
1507
+ * if (isDefaultCamera === true) {
1508
+ * setCamera(cam2);
1509
+ * isDefaultCamera = false;
1510
+ * } else {
1511
+ * setCamera(cam1);
1512
+ * isDefaultCamera = true;
1513
+ * }
1514
+ * }
1515
+ * </code>
1516
+ * </div>
1517
+ *
1518
+ * <div>
1519
+ * <code>
1520
+ * // Double-click to toggle between cameras.
1521
+ *
1522
+ * let cam1;
1523
+ * let cam2;
1524
+ * let isDefaultCamera = true;
1525
+ *
1526
+ * function setup() {
1527
+ * createCanvas(100, 100, WEBGL);
1528
+ *
1529
+ * // Create the first camera.
1530
+ * // Keep its default settings.
1531
+ * cam1 = createCamera();
1532
+ *
1533
+ * // Create the second camera.
1534
+ * cam2 = createCamera();
1535
+ *
1536
+ * // Apply an orthographic projection.
1537
+ * cam2.ortho();
1538
+ *
1539
+ * // Set the current camera to cam1.
1540
+ * setCamera(cam1);
1541
+ *
1542
+ * describe('A row of white cubes slither like a snake against a gray background. The camera toggles between a perspective and an orthographic projection when the user double-clicks.');
1543
+ * }
1544
+ *
1545
+ * function draw() {
1546
+ * background(200);
1547
+ *
1548
+ * // Translate the origin toward the camera.
1549
+ * translate(-10, 10, 500);
1550
+ *
1551
+ * // Rotate the coordinate system.
1552
+ * rotateY(-0.1);
1553
+ * rotateX(-0.1);
1554
+ *
1555
+ * // Draw the row of boxes.
1556
+ * for (let i = 0; i < 6; i += 1) {
1557
+ * push();
1558
+ * // Calculate the box's coordinates.
1559
+ * let x = 10 * sin(frameCount * 0.02 + i * 0.6);
1560
+ * let z = -40 * i;
1561
+ * // Translate the origin.
1562
+ * translate(x, 0, z);
1563
+ * // Draw the box.
1564
+ * box(10);
1565
+ * pop();
1566
+ * }
1567
+ * }
1568
+ *
1569
+ * // Toggle the current camera when the user double-clicks.
1570
+ * function doubleClicked() {
1571
+ * if (isDefaultCamera === true) {
1572
+ * setCamera(cam2);
1573
+ * isDefaultCamera = false;
1574
+ * } else {
1575
+ * setCamera(cam1);
1576
+ * isDefaultCamera = true;
1577
+ * }
1578
+ * }
1579
+ * </code>
1580
+ * </div>
1581
+ */
1582
+ function ortho(left?: number, right?: number, bottom?: number, top?: number, near?: number, far?: number): void;
1583
+
1584
+ /**
1585
+ * Sets the camera's frustum.In a frustum projection, shapes that are further from the camera appear
1586
+ * smaller than shapes that are near the camera. This technique, called
1587
+ * foreshortening, creates realistic 3D scenes.`myCamera.frustum()` changes the camera’s perspective by changing its
1588
+ * viewing frustum. The frustum is the volume of space that’s visible to the
1589
+ * camera. The frustum’s shape is a pyramid with its top cut off. The camera
1590
+ * is placed where the top of the pyramid should be and points towards the
1591
+ * base of the pyramid. It views everything within the frustum.The first four parameters, `left`, `right`, `bottom`, and `top`, set the
1592
+ * coordinates of the frustum’s sides, bottom, and top. For example, calling
1593
+ * `myCamera.frustum(-100, 100, 200, -200)` creates a frustum that’s 200
1594
+ * pixels wide and 400 pixels tall. By default, these coordinates are set
1595
+ * based on the sketch’s width and height, as in
1596
+ * `myCamera.frustum(-width / 20, width / 20, height / 20, -height / 20)`.The last two parameters, `near` and `far`, set the distance of the
1597
+ * frustum’s near and far plane from the camera. For example, calling
1598
+ * `myCamera.frustum(-100, 100, 200, -200, 50, 1000)` creates a frustum that’s
1599
+ * 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and ends
1600
+ * 1,000 pixels from the camera. By default, near is set to `0.1 * 800`, which
1601
+ * is 1/10th the default distance between the camera and the origin. `far` is
1602
+ * set to `10 * 800`, which is 10 times the default distance between the
1603
+ * camera and the origin.
1604
+ *
1605
+ * @for p5.Camera
1606
+ * @param x-coordinate of the frustum’s left plane. Defaults to `-width / 20`.
1607
+ * @param x-coordinate of the frustum’s right plane. Defaults to `width / 20`.
1608
+ * @param y-coordinate of the frustum’s bottom plane. Defaults to `height / 20`.
1609
+ * @param y-coordinate of the frustum’s top plane. Defaults to `-height / 20`.
1610
+ * @param z-coordinate of the frustum’s near plane. Defaults to `0.1 * 800`.
1611
+ * @param z-coordinate of the frustum’s far plane. Defaults to `10 * 800`.
1612
+ * @example <div>
1613
+ * <code>
1614
+ * // Double-click to toggle between cameras.
1615
+ *
1616
+ * let cam1;
1617
+ * let cam2;
1618
+ * let isDefaultCamera = true;
1619
+ *
1620
+ * function setup() {
1621
+ * createCanvas(100, 100, WEBGL);
1622
+ *
1623
+ * // Create the first camera.
1624
+ * // Keep its default settings.
1625
+ * cam1 = createCamera();
1626
+ *
1627
+ * // Create the second camera.
1628
+ * cam2 = createCamera();
1629
+ *
1630
+ * // Adjust the frustum.
1631
+ * // Center it.
1632
+ * // Set its width and height to 20 pixels.
1633
+ * // Place its near plane 300 pixels from the camera.
1634
+ * // Place its far plane 350 pixels from the camera.
1635
+ * cam2.frustum(-10, 10, -10, 10, 300, 350);
1636
+ *
1637
+ * // Set the current camera to cam1.
1638
+ * setCamera(cam1);
1639
+ *
1640
+ * describe(
1641
+ * 'A row of white cubes against a gray background. The camera zooms in on one cube when the user double-clicks.'
1642
+ * );
1643
+ * }
1644
+ *
1645
+ * function draw() {
1646
+ * background(200);
1647
+ *
1648
+ * // Translate the origin toward the camera.
1649
+ * translate(-10, 10, 600);
1650
+ *
1651
+ * // Rotate the coordinate system.
1652
+ * rotateY(-0.1);
1653
+ * rotateX(-0.1);
1654
+ *
1655
+ * // Draw the row of boxes.
1656
+ * for (let i = 0; i < 6; i += 1) {
1657
+ * translate(0, 0, -40);
1658
+ * box(10);
1659
+ * }
1660
+ * }
1661
+ *
1662
+ * // Toggle the current camera when the user double-clicks.
1663
+ * function doubleClicked() {
1664
+ * if (isDefaultCamera === true) {
1665
+ * setCamera(cam2);
1666
+ * isDefaultCamera = false;
1667
+ * } else {
1668
+ * setCamera(cam1);
1669
+ * isDefaultCamera = true;
1670
+ * }
1671
+ * }
1672
+ * </code>
1673
+ * </div>
1674
+ */
1675
+ function frustum(left?: number, right?: number, bottom?: number, top?: number, near?: number, far?: number): void;
1676
+
1677
+ /**
1678
+ * Rotates the camera left and right.Panning rotates the camera without changing its position. The rotation
1679
+ * happens in the camera’s "local" space.The parameter, `angle`, is the angle the camera should rotate. Passing a
1680
+ * positive angle, as in `myCamera.pan(0.001)`, rotates the camera to the
1681
+ * right. Passing a negative angle, as in `myCamera.pan(-0.001)`, rotates the
1682
+ * camera to the left.Note: Angles are interpreted based on the current
1683
+ * angleMode().
1684
+ *
1685
+ * @param amount to rotate in the current
1686
+ * <a href="#/p5/angleMode">angleMode()</a>.
1687
+ * @example <div>
1688
+ * <code>
1689
+ * let cam;
1690
+ * let delta = 0.001;
1691
+ *
1692
+ * function setup() {
1693
+ * createCanvas(100, 100, WEBGL);
1694
+ *
1695
+ * // Create a p5.Camera object.
1696
+ * cam = createCamera();
1697
+ *
1698
+ * // Set the camera
1699
+ * setCamera(cam);
1700
+ *
1701
+ * // Place the camera at the top-center.
1702
+ * cam.setPosition(0, -400, 800);
1703
+ *
1704
+ * // Point the camera at the origin.
1705
+ * cam.lookAt(0, 0, 0);
1706
+ *
1707
+ * describe(
1708
+ * 'A white cube on a gray background. The cube goes in and out of view as the camera pans left and right.'
1709
+ * );
1710
+ * }
1711
+ *
1712
+ * function draw() {
1713
+ * background(200);
1714
+ *
1715
+ * // Pan with the camera.
1716
+ * cam.pan(delta);
1717
+ *
1718
+ * // Switch directions every 120 frames.
1719
+ * if (frameCount % 120 === 0) {
1720
+ * delta *= -1;
1721
+ * }
1722
+ *
1723
+ * // Draw the box.
1724
+ * box();
1725
+ * }
1726
+ * </code>
1727
+ * </div>
1728
+ */
1729
+ function pan(amount: any, angle: number): void;
1730
+
1731
+ /**
1732
+ * Rotates the camera up and down.Tilting rotates the camera without changing its position. The rotation
1733
+ * happens in the camera’s "local" space.The parameter, `angle`, is the angle the camera should rotate. Passing a
1734
+ * positive angle, as in `myCamera.tilt(0.001)`, rotates the camera down.
1735
+ * Passing a negative angle, as in `myCamera.tilt(-0.001)`, rotates the camera
1736
+ * up.Note: Angles are interpreted based on the current
1737
+ * angleMode().
1738
+ *
1739
+ * @param amount to rotate in the current
1740
+ * <a href="#/p5/angleMode">angleMode()</a>.
1741
+ * @example <div>
1742
+ * <code>
1743
+ * let cam;
1744
+ * let delta = 0.001;
1745
+ *
1746
+ * function setup() {
1747
+ * createCanvas(100, 100, WEBGL);
1748
+ *
1749
+ * // Create a p5.Camera object.
1750
+ * cam = createCamera();
1751
+ *
1752
+ * // Set the camera
1753
+ * setCamera(cam);
1754
+ *
1755
+ * // Place the camera at the top-center.
1756
+ * cam.setPosition(0, -400, 800);
1757
+ *
1758
+ * // Point the camera at the origin.
1759
+ * cam.lookAt(0, 0, 0);
1760
+ *
1761
+ * describe(
1762
+ * 'A white cube on a gray background. The cube goes in and out of view as the camera tilts up and down.'
1763
+ * );
1764
+ * }
1765
+ *
1766
+ * function draw() {
1767
+ * background(200);
1768
+ *
1769
+ * // Pan with the camera.
1770
+ * cam.tilt(delta);
1771
+ *
1772
+ * // Switch directions every 120 frames.
1773
+ * if (frameCount % 120 === 0) {
1774
+ * delta *= -1;
1775
+ * }
1776
+ *
1777
+ * // Draw the box.
1778
+ * box();
1779
+ * }
1780
+ * </code>
1781
+ * </div>
1782
+ */
1783
+ function tilt(amount: any, angle: number): void;
1784
+
1785
+ /**
1786
+ * Points the camera at a location.`myCamera.lookAt()` changes the camera’s orientation without changing its
1787
+ * position.The parameters, `x`, `y`, and `z`, are the coordinates in "world" space
1788
+ * where the camera should point. For example, calling
1789
+ * `myCamera.lookAt(10, 20, 30)` points the camera at the coordinates
1790
+ * `(10, 20, 30)`.
1791
+ *
1792
+ * @for p5.Camera
1793
+ * @param x-coordinate of the position where the camera should look in "world" space.
1794
+ * @param y-coordinate of the position where the camera should look in "world" space.
1795
+ * @param z-coordinate of the position where the camera should look in "world" space.
1796
+ * @example <div>
1797
+ * <code>
1798
+ * // Double-click to look at a different cube.
1799
+ *
1800
+ * let cam;
1801
+ * let isLookingLeft = true;
1802
+ *
1803
+ * function setup() {
1804
+ * createCanvas(100, 100, WEBGL);
1805
+ *
1806
+ * // Create a p5.Camera object.
1807
+ * cam = createCamera();
1808
+ *
1809
+ * // Set the camera
1810
+ * setCamera(cam);
1811
+ *
1812
+ * // Place the camera at the top-center.
1813
+ * cam.setPosition(0, -400, 800);
1814
+ *
1815
+ * // Point the camera at the origin.
1816
+ * cam.lookAt(-30, 0, 0);
1817
+ *
1818
+ * describe(
1819
+ * 'A red cube and a blue cube on a gray background. The camera switches focus between the cubes when the user double-clicks.'
1820
+ * );
1821
+ * }
1822
+ *
1823
+ * function draw() {
1824
+ * background(200);
1825
+ *
1826
+ * // Draw the box on the left.
1827
+ * push();
1828
+ * // Translate the origin to the left.
1829
+ * translate(-30, 0, 0);
1830
+ * // Style the box.
1831
+ * fill(255, 0, 0);
1832
+ * // Draw the box.
1833
+ * box(20);
1834
+ * pop();
1835
+ *
1836
+ * // Draw the box on the right.
1837
+ * push();
1838
+ * // Translate the origin to the right.
1839
+ * translate(30, 0, 0);
1840
+ * // Style the box.
1841
+ * fill(0, 0, 255);
1842
+ * // Draw the box.
1843
+ * box(20);
1844
+ * pop();
1845
+ * }
1846
+ *
1847
+ * // Change the camera's focus when the user double-clicks.
1848
+ * function doubleClicked() {
1849
+ * if (isLookingLeft === true) {
1850
+ * cam.lookAt(30, 0, 0);
1851
+ * isLookingLeft = false;
1852
+ * } else {
1853
+ * cam.lookAt(-30, 0, 0);
1854
+ * isLookingLeft = true;
1855
+ * }
1856
+ * }
1857
+ * </code>
1858
+ * </div>
1859
+ */
1860
+ function lookAt(x: number, y: number, z: number): void;
1861
+
1862
+ /**
1863
+ * Sets the position and orientation of the camera.`myCamera.camera()` allows objects to be viewed from different angles. It
1864
+ * has nine parameters that are all optional.The first three parameters, `x`, `y`, and `z`, are the coordinates of the
1865
+ * camera’s position in "world" space. For example, calling
1866
+ * `myCamera.camera(0, 0, 0)` places the camera at the origin `(0, 0, 0)`. By
1867
+ * default, the camera is placed at `(0, 0, 800)`.The next three parameters, `centerX`, `centerY`, and `centerZ` are the
1868
+ * coordinates of the point where the camera faces in "world" space. For
1869
+ * example, calling `myCamera.camera(0, 0, 0, 10, 20, 30)` places the camera
1870
+ * at the origin `(0, 0, 0)` and points it at `(10, 20, 30)`. By default, the
1871
+ * camera points at the origin `(0, 0, 0)`.The last three parameters, `upX`, `upY`, and `upZ` are the components of
1872
+ * the "up" vector in "local" space. The "up" vector orients the camera’s
1873
+ * y-axis. For example, calling
1874
+ * `myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0)` places the camera at the
1875
+ * origin `(0, 0, 0)`, points it at `(10, 20, 30)`, and sets the "up" vector
1876
+ * to `(0, -1, 0)` which is like holding it upside-down. By default, the "up"
1877
+ * vector is `(0, 1, 0)`.
1878
+ *
1879
+ * @for p5.Camera
1880
+ * @param x-coordinate of the camera. Defaults to 0.
1881
+ * @param y-coordinate of the camera. Defaults to 0.
1882
+ * @param z-coordinate of the camera. Defaults to 800.
1883
+ * @param x-coordinate of the point the camera faces. Defaults to 0.
1884
+ * @param y-coordinate of the point the camera faces. Defaults to 0.
1885
+ * @param z-coordinate of the point the camera faces. Defaults to 0.
1886
+ * @param x-component of the camera’s "up" vector. Defaults to 0.
1887
+ * @param x-component of the camera’s "up" vector. Defaults to 1.
1888
+ * @param z-component of the camera’s "up" vector. Defaults to 0.
1889
+ * @example <div>
1890
+ * <code>
1891
+ * // Double-click to toggle between cameras.
1892
+ *
1893
+ * let cam1;
1894
+ * let cam2;
1895
+ * let isDefaultCamera = true;
1896
+ *
1897
+ * function setup() {
1898
+ * createCanvas(100, 100, WEBGL);
1899
+ *
1900
+ * // Create the first camera.
1901
+ * // Keep its default settings.
1902
+ * cam1 = createCamera();
1903
+ *
1904
+ * // Create the second camera.
1905
+ * cam2 = createCamera();
1906
+ *
1907
+ * // Place it at the top-right: (1200, -600, 100)
1908
+ * // Point it at the row of boxes: (-10, -10, 400)
1909
+ * // Set its "up" vector to the default: (0, 1, 0)
1910
+ * cam2.camera(1200, -600, 100, -10, -10, 400, 0, 1, 0);
1911
+ *
1912
+ * // Set the current camera to cam1.
1913
+ * setCamera(cam1);
1914
+ *
1915
+ * describe(
1916
+ * 'A row of white cubes against a gray background. The camera toggles between a frontal and an aerial view when the user double-clicks.'
1917
+ * );
1918
+ * }
1919
+ *
1920
+ * function draw() {
1921
+ * background(200);
1922
+ *
1923
+ * // Translate the origin toward the camera.
1924
+ * translate(-10, 10, 500);
1925
+ *
1926
+ * // Rotate the coordinate system.
1927
+ * rotateY(-0.1);
1928
+ * rotateX(-0.1);
1929
+ *
1930
+ * // Draw the row of boxes.
1931
+ * for (let i = 0; i < 6; i += 1) {
1932
+ * translate(0, 0, -30);
1933
+ * box(10);
1934
+ * }
1935
+ * }
1936
+ *
1937
+ * // Toggle the current camera when the user double-clicks.
1938
+ * function doubleClicked() {
1939
+ * if (isDefaultCamera === true) {
1940
+ * setCamera(cam2);
1941
+ * isDefaultCamera = false;
1942
+ * } else {
1943
+ * setCamera(cam1);
1944
+ * isDefaultCamera = true;
1945
+ * }
1946
+ * }
1947
+ * </code>
1948
+ * </div>
1949
+ *
1950
+ * <div>
1951
+ * <code>
1952
+ * // Double-click to toggle between cameras.
1953
+ *
1954
+ * let cam1;
1955
+ * let cam2;
1956
+ * let isDefaultCamera = true;
1957
+ *
1958
+ * function setup() {
1959
+ * createCanvas(100, 100, WEBGL);
1960
+ *
1961
+ * // Create the first camera.
1962
+ * // Keep its default settings.
1963
+ * cam1 = createCamera();
1964
+ *
1965
+ * // Create the second camera.
1966
+ * cam2 = createCamera();
1967
+ *
1968
+ * // Place it at the right: (1200, 0, 100)
1969
+ * // Point it at the row of boxes: (-10, -10, 400)
1970
+ * // Set its "up" vector to the default: (0, 1, 0)
1971
+ * cam2.camera(1200, 0, 100, -10, -10, 400, 0, 1, 0);
1972
+ *
1973
+ * // Set the current camera to cam1.
1974
+ * setCamera(cam1);
1975
+ *
1976
+ * describe(
1977
+ * 'A row of white cubes against a gray background. The camera toggles between a static frontal view and an orbiting view when the user double-clicks.'
1978
+ * );
1979
+ * }
1980
+ *
1981
+ * function draw() {
1982
+ * background(200);
1983
+ *
1984
+ * // Update cam2's position.
1985
+ * let x = 1200 * cos(frameCount * 0.01);
1986
+ * let y = -600 * sin(frameCount * 0.01);
1987
+ * cam2.camera(x, y, 100, -10, -10, 400, 0, 1, 0);
1988
+ *
1989
+ * // Translate the origin toward the camera.
1990
+ * translate(-10, 10, 500);
1991
+ *
1992
+ * // Rotate the coordinate system.
1993
+ * rotateY(-0.1);
1994
+ * rotateX(-0.1);
1995
+ *
1996
+ * // Draw the row of boxes.
1997
+ * for (let i = 0; i < 6; i += 1) {
1998
+ * translate(0, 0, -30);
1999
+ * box(10);
2000
+ * }
2001
+ * }
2002
+ *
2003
+ * // Toggle the current camera when the user double-clicks.
2004
+ * function doubleClicked() {
2005
+ * if (isDefaultCamera === true) {
2006
+ * setCamera(cam2);
2007
+ * isDefaultCamera = false;
2008
+ * } else {
2009
+ * setCamera(cam1);
2010
+ * isDefaultCamera = true;
2011
+ * }
2012
+ * }
2013
+ * </code>
2014
+ * </div>
2015
+ */
2016
+ function camera(eyeX: any, eyeY: any, eyeZ: any, centerX?: number, centerY?: number, centerZ?: number, upX?: number, upY?: number, upZ?: number, x?: number, y?: number, z?: number): void;
2017
+
2018
+ /**
2019
+ * Moves the camera along its "local" axes without changing its orientation.The parameters, `x`, `y`, and `z`, are the distances the camera should
2020
+ * move. For example, calling `myCamera.move(10, 20, 30)` moves the camera 10
2021
+ * pixels to the right, 20 pixels down, and 30 pixels backward in its "local"
2022
+ * space.
2023
+ *
2024
+ * @param distance to move along the camera’s "local" x-axis.
2025
+ * @param distance to move along the camera’s "local" y-axis.
2026
+ * @param distance to move along the camera’s "local" z-axis.
2027
+ * @example <div>
2028
+ * <code>
2029
+ * // Click the canvas to begin detecting key presses.
2030
+ *
2031
+ * let cam;
2032
+ *
2033
+ * function setup() {
2034
+ * createCanvas(100, 100, WEBGL);
2035
+ *
2036
+ * // Create the first camera.
2037
+ * // Keep its default settings.
2038
+ * cam = createCamera();
2039
+ *
2040
+ * // Place the camera at the top-right.
2041
+ * cam.setPosition(400, -400, 800);
2042
+ *
2043
+ * // Point it at the origin.
2044
+ * cam.lookAt(0, 0, 0);
2045
+ *
2046
+ * // Set the camera.
2047
+ * setCamera(cam);
2048
+ *
2049
+ * describe(
2050
+ * 'A white cube drawn against a gray background. The cube appears to move when the user presses certain keys.'
2051
+ * );
2052
+ * }
2053
+ *
2054
+ * function draw() {
2055
+ * background(200);
2056
+ *
2057
+ * // Move the camera along its "local" axes
2058
+ * // when the user presses certain keys.
2059
+ *
2060
+ * // Move horizontally.
2061
+ * if (keyIsDown(LEFT_ARROW)) {
2062
+ * cam.move(-1, 0, 0);
2063
+ * }
2064
+ * if (keyIsDown(RIGHT_ARROW)) {
2065
+ * cam.move(1, 0, 0);
2066
+ * }
2067
+ *
2068
+ * // Move vertically.
2069
+ * if (keyIsDown(UP_ARROW)) {
2070
+ * cam.move(0, -1, 0);
2071
+ * }
2072
+ * if (keyIsDown(DOWN_ARROW)) {
2073
+ * cam.move(0, 1, 0);
2074
+ * }
2075
+ *
2076
+ * // Move in/out of the screen.
2077
+ * if (keyIsDown('i')) {
2078
+ * cam.move(0, 0, -1);
2079
+ * }
2080
+ * if (keyIsDown('o')) {
2081
+ * cam.move(0, 0, 1);
2082
+ * }
2083
+ *
2084
+ * // Draw the box.
2085
+ * box();
2086
+ * }
2087
+ * </code>
2088
+ * </div>
2089
+ */
2090
+ function move(x: number, y: number, z: number): void;
2091
+
2092
+ /**
2093
+ * Sets the camera’s position in "world" space without changing its
2094
+ * orientation.The parameters, `x`, `y`, and `z`, are the coordinates where the camera
2095
+ * should be placed. For example, calling `myCamera.setPosition(10, 20, 30)`
2096
+ * places the camera at coordinates `(10, 20, 30)` in "world" space.
2097
+ *
2098
+ * @param x-coordinate in "world" space.
2099
+ * @param y-coordinate in "world" space.
2100
+ * @param z-coordinate in "world" space.
2101
+ * @example <div>
2102
+ * <code>
2103
+ * // Double-click to toggle between cameras.
2104
+ *
2105
+ * let cam1;
2106
+ * let cam2;
2107
+ * let isDefaultCamera = true;
2108
+ *
2109
+ * function setup() {
2110
+ * createCanvas(100, 100, WEBGL);
2111
+ *
2112
+ * // Create the first camera.
2113
+ * // Keep its default settings.
2114
+ * cam1 = createCamera();
2115
+ *
2116
+ * // Create the second camera.
2117
+ * cam2 = createCamera();
2118
+ *
2119
+ * // Place it closer to the origin.
2120
+ * cam2.setPosition(0, 0, 600);
2121
+ *
2122
+ * // Set the current camera to cam1.
2123
+ * setCamera(cam1);
2124
+ *
2125
+ * describe(
2126
+ * 'A row of white cubes against a gray background. The camera toggles the amount of zoom when the user double-clicks.'
2127
+ * );
2128
+ * }
2129
+ *
2130
+ * function draw() {
2131
+ * background(200);
2132
+ *
2133
+ * // Translate the origin toward the camera.
2134
+ * translate(-10, 10, 500);
2135
+ *
2136
+ * // Rotate the coordinate system.
2137
+ * rotateY(-0.1);
2138
+ * rotateX(-0.1);
2139
+ *
2140
+ * // Draw the row of boxes.
2141
+ * for (let i = 0; i < 6; i += 1) {
2142
+ * translate(0, 0, -30);
2143
+ * box(10);
2144
+ * }
2145
+ * }
2146
+ *
2147
+ * // Toggle the current camera when the user double-clicks.
2148
+ * function doubleClicked() {
2149
+ * if (isDefaultCamera === true) {
2150
+ * setCamera(cam2);
2151
+ * isDefaultCamera = false;
2152
+ * } else {
2153
+ * setCamera(cam1);
2154
+ * isDefaultCamera = true;
2155
+ * }
2156
+ * }
2157
+ * </code>
2158
+ * </div>
2159
+ *
2160
+ * <div>
2161
+ * <code>
2162
+ * // Double-click to toggle between cameras.
2163
+ *
2164
+ * let cam1;
2165
+ * let cam2;
2166
+ * let isDefaultCamera = true;
2167
+ *
2168
+ * function setup() {
2169
+ * createCanvas(100, 100, WEBGL);
2170
+ *
2171
+ * // Create the first camera.
2172
+ * // Keep its default settings.
2173
+ * cam1 = createCamera();
2174
+ *
2175
+ * // Create the second camera.
2176
+ * cam2 = createCamera();
2177
+ *
2178
+ * // Place it closer to the origin.
2179
+ * cam2.setPosition(0, 0, 600);
2180
+ *
2181
+ * // Set the current camera to cam1.
2182
+ * setCamera(cam1);
2183
+ *
2184
+ * describe(
2185
+ * 'A row of white cubes against a gray background. The camera toggles between a static view and a view that zooms in and out when the user double-clicks.'
2186
+ * );
2187
+ * }
2188
+ *
2189
+ * function draw() {
2190
+ * background(200);
2191
+ *
2192
+ * // Update cam2's z-coordinate.
2193
+ * let z = 100 * sin(frameCount * 0.01) + 700;
2194
+ * cam2.setPosition(0, 0, z);
2195
+ *
2196
+ * // Translate the origin toward the camera.
2197
+ * translate(-10, 10, 500);
2198
+ *
2199
+ * // Rotate the coordinate system.
2200
+ * rotateY(-0.1);
2201
+ * rotateX(-0.1);
2202
+ *
2203
+ * // Draw the row of boxes.
2204
+ * for (let i = 0; i < 6; i += 1) {
2205
+ * translate(0, 0, -30);
2206
+ * box(10);
2207
+ * }
2208
+ * }
2209
+ *
2210
+ * // Toggle the current camera when the user double-clicks.
2211
+ * function doubleClicked() {
2212
+ * if (isDefaultCamera === true) {
2213
+ * setCamera(cam2);
2214
+ * isDefaultCamera = false;
2215
+ * } else {
2216
+ * setCamera(cam1);
2217
+ * isDefaultCamera = true;
2218
+ * }
2219
+ * }
2220
+ * </code>
2221
+ * </div>
2222
+ */
2223
+ function setPosition(x: number, y: number, z: number): void;
2224
+
2225
+ /**
2226
+ * Sets the camera’s position, orientation, and projection by copying another
2227
+ * camera.The parameter, `cam`, is the `p5.Camera` object to copy. For example, calling
2228
+ * `cam2.set(cam1)` will set `cam2` using `cam1`’s configuration.
2229
+ *
2230
+ * @param camera to copy.
2231
+ * @example <div>
2232
+ * <code>
2233
+ * // Double-click to "reset" the camera zoom.
2234
+ *
2235
+ * let cam1;
2236
+ * let cam2;
2237
+ *
2238
+ * function setup() {
2239
+ * createCanvas(100, 100, WEBGL);
2240
+ *
2241
+ * // Create the first camera.
2242
+ * cam1 = createCamera();
2243
+ *
2244
+ * // Place the camera at the top-right.
2245
+ * cam1.setPosition(400, -400, 800);
2246
+ *
2247
+ * // Point it at the origin.
2248
+ * cam1.lookAt(0, 0, 0);
2249
+ *
2250
+ * // Create the second camera.
2251
+ * cam2 = createCamera();
2252
+ *
2253
+ * // Copy cam1's configuration.
2254
+ * cam2.set(cam1);
2255
+ *
2256
+ * // Set the camera.
2257
+ * setCamera(cam2);
2258
+ *
2259
+ * describe(
2260
+ * 'A white cube drawn against a gray background. The camera slowly moves forward. The camera resets when the user double-clicks.'
2261
+ * );
2262
+ * }
2263
+ *
2264
+ * function draw() {
2265
+ * background(200);
2266
+ *
2267
+ * // Update cam2's position.
2268
+ * cam2.move(0, 0, -1);
2269
+ *
2270
+ * // Draw the box.
2271
+ * box();
2272
+ * }
2273
+ *
2274
+ * // "Reset" the camera when the user double-clicks.
2275
+ * function doubleClicked() {
2276
+ * cam2.set(cam1);
2277
+ * }
2278
+ */
2279
+ function set(cam: p5.Camera): void;
2280
+
2281
+ /**
2282
+ * Sets the camera’s position and orientation to values that are in-between
2283
+ * those of two other cameras.`myCamera.slerp()` uses spherical linear interpolation to calculate a
2284
+ * position and orientation that’s in-between two other cameras. Doing so is
2285
+ * helpful for transitioning smoothly between two perspectives.The first two parameters, `cam0` and `cam1`, are the `p5.Camera` objects
2286
+ * that should be used to set the current camera.The third parameter, `amt`, is the amount to interpolate between `cam0` and
2287
+ * `cam1`. 0.0 keeps the camera’s position and orientation equal to `cam0`’s,
2288
+ * 0.5 sets them halfway between `cam0`’s and `cam1`’s , and 1.0 sets the
2289
+ * position and orientation equal to `cam1`’s.For example, calling `myCamera.slerp(cam0, cam1, 0.1)` sets cam’s position
2290
+ * and orientation very close to `cam0`’s. Calling
2291
+ * `myCamera.slerp(cam0, cam1, 0.9)` sets cam’s position and orientation very
2292
+ * close to `cam1`’s.Note: All of the cameras must use the same projection.
2293
+ *
2294
+ * @param first camera.
2295
+ * @param second camera.
2296
+ * @param amount of interpolation between 0.0 (`cam0`) and 1.0 (`cam1`).
2297
+ * @example <div>
2298
+ * <code>
2299
+ * let cam;
2300
+ * let cam0;
2301
+ * let cam1;
2302
+ *
2303
+ * function setup() {
2304
+ * createCanvas(100, 100, WEBGL);
2305
+ *
2306
+ * // Create the main camera.
2307
+ * // Keep its default settings.
2308
+ * cam = createCamera();
2309
+ *
2310
+ * // Create the first camera.
2311
+ * // Keep its default settings.
2312
+ * cam0 = createCamera();
2313
+ *
2314
+ * // Create the second camera.
2315
+ * cam1 = createCamera();
2316
+ *
2317
+ * // Place it at the top-right.
2318
+ * cam1.setPosition(400, -400, 800);
2319
+ *
2320
+ * // Point it at the origin.
2321
+ * cam1.lookAt(0, 0, 0);
2322
+ *
2323
+ * // Set the current camera to cam.
2324
+ * setCamera(cam);
2325
+ *
2326
+ * describe('A white cube drawn against a gray background. The camera slowly oscillates between a frontal view and an aerial view.');
2327
+ * }
2328
+ *
2329
+ * function draw() {
2330
+ * background(200);
2331
+ *
2332
+ * // Calculate the amount to interpolate between cam0 and cam1.
2333
+ * let amt = 0.5 * sin(frameCount * 0.01) + 0.5;
2334
+ *
2335
+ * // Update the main camera's position and orientation.
2336
+ * cam.slerp(cam0, cam1, amt);
2337
+ *
2338
+ * box();
2339
+ * }
2340
+ * </code>
2341
+ * </div>
2342
+ */
2343
+ function slerp(cam0: p5.Camera, cam1: p5.Camera, amt: number): void;
2344
+
2345
+ /**
2346
+ * Rotates the camera in a clockwise/counter-clockwise direction.Rolling rotates the camera without changing its orientation. The rotation
2347
+ * happens in the camera’s "local" space.The parameter, `angle`, is the angle the camera should rotate. Passing a
2348
+ * positive angle, as in `myCamera.roll(0.001)`, rotates the camera in counter-clockwise direction.
2349
+ * Passing a negative angle, as in `myCamera.roll(-0.001)`, rotates the
2350
+ * camera in clockwise direction.Note: Angles are interpreted based on the current
2351
+ * angleMode().
2352
+ *
2353
+ * @param amount to rotate camera in current
2354
+ * <a href="#/p5/angleMode">angleMode</a> units.
2355
+ * @example <div>
2356
+ * <code>
2357
+ * let cam;
2358
+ * let delta = 0.01;
2359
+ *
2360
+ * function setup() {
2361
+ * createCanvas(100, 100, WEBGL);
2362
+ * normalMaterial();
2363
+ * // Create a p5.Camera object.
2364
+ * cam = createCamera();
2365
+ *
2366
+ * // Set the camera
2367
+ * setCamera(cam);
2368
+ * }
2369
+ *
2370
+ * function draw() {
2371
+ * background(200);
2372
+ *
2373
+ * // Roll camera according to angle 'delta'
2374
+ * cam.roll(delta);
2375
+ *
2376
+ * translate(0, 0, 0);
2377
+ * box(20);
2378
+ * translate(0, 25, 0);
2379
+ * box(20);
2380
+ * translate(0, 26, 0);
2381
+ * box(20);
2382
+ * translate(0, 27, 0);
2383
+ * box(20);
2384
+ * translate(0, 28, 0);
2385
+ * box(20);
2386
+ * translate(0,29, 0);
2387
+ * box(20);
2388
+ * translate(0, 30, 0);
2389
+ * box(20);
2390
+ * }
2391
+ * </code>
2392
+ * </div>
2393
+ * @alt camera view rotates in counter clockwise direction with vertically stacked boxes in front of it.
2394
+ */
2395
+ function roll(angle: number): void;
2396
+
2397
+ /**
2398
+ * Sets the position and orientation of the current camera in a 3D sketch.`camera()` allows objects to be viewed from different angles. It has nine
2399
+ * parameters that are all optional.The first three parameters, `x`, `y`, and `z`, are the coordinates of the
2400
+ * camera’s position. For example, calling `camera(0, 0, 0)` places the camera
2401
+ * at the origin `(0, 0, 0)`. By default, the camera is placed at
2402
+ * `(0, 0, 800)`.The next three parameters, `centerX`, `centerY`, and `centerZ` are the
2403
+ * coordinates of the point where the camera faces. For example, calling
2404
+ * `camera(0, 0, 0, 10, 20, 30)` places the camera at the origin `(0, 0, 0)`
2405
+ * and points it at `(10, 20, 30)`. By default, the camera points at the
2406
+ * origin `(0, 0, 0)`.The last three parameters, `upX`, `upY`, and `upZ` are the components of
2407
+ * the "up" vector. The "up" vector orients the camera’s y-axis. For example,
2408
+ * calling `camera(0, 0, 0, 10, 20, 30, 0, -1, 0)` places the camera at the
2409
+ * origin `(0, 0, 0)`, points it at `(10, 20, 30)`, and sets the "up" vector
2410
+ * to `(0, -1, 0)` which is like holding it upside-down. By default, the "up"
2411
+ * vector is `(0, 1, 0)`.Note: `camera()` can only be used in WebGL mode.
2412
+ *
2413
+ * @for p5
2414
+ * @param x-coordinate of the camera. Defaults to 0.
2415
+ * @param y-coordinate of the camera. Defaults to 0.
2416
+ * @param z-coordinate of the camera. Defaults to 800.
2417
+ * @param x-coordinate of the point the camera faces. Defaults to 0.
2418
+ * @param y-coordinate of the point the camera faces. Defaults to 0.
2419
+ * @param z-coordinate of the point the camera faces. Defaults to 0.
2420
+ * @param x-component of the camera’s "up" vector. Defaults to 0.
2421
+ * @param y-component of the camera’s "up" vector. Defaults to 1.
2422
+ * @param z-component of the camera’s "up" vector. Defaults to 0.
2423
+ * @example <div>
2424
+ * <code>
2425
+ * function setup() {
2426
+ * createCanvas(100, 100, WEBGL);
2427
+ *
2428
+ * describe('A white cube on a gray background.');
2429
+ * }
2430
+ *
2431
+ * function draw() {
2432
+ * background(200);
2433
+ *
2434
+ * // Move the camera to the top-right.
2435
+ * camera(200, -400, 800);
2436
+ *
2437
+ * // Draw the box.
2438
+ * box();
2439
+ * }
2440
+ * </code>
2441
+ * </div>
2442
+ *
2443
+ * <div>
2444
+ * <code>
2445
+ * function setup() {
2446
+ * createCanvas(100, 100, WEBGL);
2447
+ *
2448
+ * describe('A white cube apperas to sway left and right on a gray background.');
2449
+ * }
2450
+ *
2451
+ * function draw() {
2452
+ * background(200);
2453
+ *
2454
+ * // Calculate the camera's x-coordinate.
2455
+ * let x = 400 * cos(frameCount * 0.01);
2456
+ *
2457
+ * // Orbit the camera around the box.
2458
+ * camera(x, -400, 800);
2459
+ *
2460
+ * // Draw the box.
2461
+ * box();
2462
+ * }
2463
+ * </code>
2464
+ * </div>
2465
+ *
2466
+ * <div>
2467
+ * <code>
2468
+ * // Adjust the range sliders to change the camera's position.
2469
+ *
2470
+ * let xSlider;
2471
+ * let ySlider;
2472
+ * let zSlider;
2473
+ *
2474
+ * function setup() {
2475
+ * createCanvas(100, 100, WEBGL);
2476
+ *
2477
+ * // Create slider objects to set the camera's coordinates.
2478
+ * xSlider = createSlider(-400, 400, 400);
2479
+ * xSlider.position(0, 100);
2480
+ * xSlider.size(100);
2481
+ * ySlider = createSlider(-400, 400, -200);
2482
+ * ySlider.position(0, 120);
2483
+ * ySlider.size(100);
2484
+ * zSlider = createSlider(0, 1600, 800);
2485
+ * zSlider.position(0, 140);
2486
+ * zSlider.size(100);
2487
+ *
2488
+ * describe(
2489
+ * 'A white cube drawn against a gray background. Three range sliders appear beneath the image. The camera position changes when the user moves the sliders.'
2490
+ * );
2491
+ * }
2492
+ *
2493
+ * function draw() {
2494
+ * background(200);
2495
+ *
2496
+ * // Get the camera's coordinates from the sliders.
2497
+ * let x = xSlider.value();
2498
+ * let y = ySlider.value();
2499
+ * let z = zSlider.value();
2500
+ *
2501
+ * // Move the camera.
2502
+ * camera(x, y, z);
2503
+ *
2504
+ * // Draw the box.
2505
+ * box();
2506
+ * }
2507
+ * </code>
2508
+ * </div>
2509
+ */
2510
+ function camera(x?: number, y?: number, z?: number, centerX?: number, centerY?: number, centerZ?: number, upX?: number, upY?: number, upZ?: number): void;
2511
+
2512
+ /**
2513
+ * Sets a perspective projection for the current camera in a 3D sketch.In a perspective projection, shapes that are further from the camera appear
2514
+ * smaller than shapes that are near the camera. This technique, called
2515
+ * foreshortening, creates realistic 3D scenes. It’s applied by default in
2516
+ * WebGL mode.`perspective()` changes the camera’s perspective by changing its viewing
2517
+ * frustum. The frustum is the volume of space that’s visible to the camera.
2518
+ * Its shape is a pyramid with its top cut off. The camera is placed where
2519
+ * the top of the pyramid should be and views everything between the frustum’s
2520
+ * top (near) plane and its bottom (far) plane.The first parameter, `fovy`, is the camera’s vertical field of view. It’s
2521
+ * an angle that describes how tall or narrow a view the camera has. For
2522
+ * example, calling `perspective(0.5)` sets the camera’s vertical field of
2523
+ * view to 0.5 radians. By default, `fovy` is calculated based on the sketch’s
2524
+ * height and the camera’s default z-coordinate, which is 800. The formula for
2525
+ * the default `fovy` is `2 * atan(height / 2 / 800)`.The second parameter, `aspect`, is the camera’s aspect ratio. It’s a number
2526
+ * that describes the ratio of the top plane’s width to its height. For
2527
+ * example, calling `perspective(0.5, 1.5)` sets the camera’s field of view to
2528
+ * 0.5 radians and aspect ratio to 1.5, which would make shapes appear thinner
2529
+ * on a square canvas. By default, aspect is set to `width / height`.The third parameter, `near`, is the distance from the camera to the near
2530
+ * plane. For example, calling `perspective(0.5, 1.5, 100)` sets the camera’s
2531
+ * field of view to 0.5 radians, its aspect ratio to 1.5, and places the near
2532
+ * plane 100 pixels from the camera. Any shapes drawn less than 100 pixels
2533
+ * from the camera won’t be visible. By default, near is set to `0.1 * 800`,
2534
+ * which is 1/10th the default distance between the camera and the origin.The fourth parameter, `far`, is the distance from the camera to the far
2535
+ * plane. For example, calling `perspective(0.5, 1.5, 100, 10000)` sets the
2536
+ * camera’s field of view to 0.5 radians, its aspect ratio to 1.5, places the
2537
+ * near plane 100 pixels from the camera, and places the far plane 10,000
2538
+ * pixels from the camera. Any shapes drawn more than 10,000 pixels from the
2539
+ * camera won’t be visible. By default, far is set to `10 * 800`, which is 10
2540
+ * times the default distance between the camera and the origin.Note: `perspective()` can only be used in WebGL mode.
2541
+ *
2542
+ * @for p5
2543
+ * @param camera frustum vertical field of view. Defaults to
2544
+ * `2 * atan(height / 2 / 800)`.
2545
+ * @param camera frustum aspect ratio. Defaults to
2546
+ * `width / height`.
2547
+ * @param distance from the camera to the near clipping plane.
2548
+ * Defaults to `0.1 * 800`.
2549
+ * @param distance from the camera to the far clipping plane.
2550
+ * Defaults to `10 * 800`.
2551
+ * @example <div>
2552
+ * <code>
2553
+ * // Double-click to squeeze the box.
2554
+ *
2555
+ * let isSqueezed = false;
2556
+ *
2557
+ * function setup() {
2558
+ * createCanvas(100, 100, WEBGL);
2559
+ *
2560
+ * describe('A white rectangular prism on a gray background. The box appears to become thinner when the user double-clicks.');
2561
+ * }
2562
+ *
2563
+ * function draw() {
2564
+ * background(200);
2565
+ *
2566
+ * // Place the camera at the top-right.
2567
+ * camera(400, -400, 800);
2568
+ *
2569
+ * if (isSqueezed === true) {
2570
+ * // Set fovy to 0.2.
2571
+ * // Set aspect to 1.5.
2572
+ * perspective(0.2, 1.5);
2573
+ * }
2574
+ *
2575
+ * // Draw the box.
2576
+ * box();
2577
+ * }
2578
+ *
2579
+ * // Change the camera's perspective when the user double-clicks.
2580
+ * function doubleClicked() {
2581
+ * isSqueezed = true;
2582
+ * }
2583
+ * </code>
2584
+ * </div>
2585
+ *
2586
+ * <div>
2587
+ * <code>
2588
+ * function setup() {
2589
+ * createCanvas(100, 100, WEBGL);
2590
+ *
2591
+ * describe('A white rectangular prism on a gray background. The prism moves away from the camera until it disappears.');
2592
+ * }
2593
+ *
2594
+ * function draw() {
2595
+ * background(200);
2596
+ *
2597
+ * // Place the camera at the top-right.
2598
+ * camera(400, -400, 800);
2599
+ *
2600
+ * // Set fovy to 0.2.
2601
+ * // Set aspect to 1.5.
2602
+ * // Set near to 600.
2603
+ * // Set far to 1200.
2604
+ * perspective(0.2, 1.5, 600, 1200);
2605
+ *
2606
+ * // Move the origin away from the camera.
2607
+ * let x = -frameCount;
2608
+ * let y = frameCount;
2609
+ * let z = -2 * frameCount;
2610
+ * translate(x, y, z);
2611
+ *
2612
+ * // Draw the box.
2613
+ * box();
2614
+ * }
2615
+ * </code>
2616
+ * </div>
2617
+ */
2618
+ function perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
2619
+
2620
+ /**
2621
+ * Enables or disables perspective for lines in 3D sketches.In WebGL mode, lines can be drawn with a thinner stroke when they’re
2622
+ * further from the camera. Doing so gives them a more realistic appearance.By default, lines are drawn differently based on the type of perspective
2623
+ * being used:`linePerspective()` can override the default line drawing mode.The parameter, `enable`, is optional. It’s a `Boolean` value that sets the
2624
+ * way lines are drawn. If `true` is passed, as in `linePerspective(true)`,
2625
+ * then lines will appear thinner when they are further from the camera. If
2626
+ * `false` is passed, as in `linePerspective(false)`, then lines will have
2627
+ * consistent stroke weights regardless of their distance from the camera. By
2628
+ * default, `linePerspective()` is enabled.Calling `linePerspective()` without passing an argument returns `true` if
2629
+ * it's enabled and `false` if not.Note: `linePerspective()` can only be used in WebGL mode.
2630
+ *
2631
+ * @for p5
2632
+ * @param whether to enable line perspective.
2633
+ * @example <div>
2634
+ * <code>
2635
+ * // Double-click the canvas to toggle the line perspective.
2636
+ *
2637
+ * function setup() {
2638
+ * createCanvas(100, 100, WEBGL);
2639
+ *
2640
+ * describe(
2641
+ * 'A white cube with black edges on a gray background. Its edges toggle between thick and thin when the user double-clicks.'
2642
+ * );
2643
+ * }
2644
+ *
2645
+ * function draw() {
2646
+ * background(200);
2647
+ *
2648
+ * // Translate the origin toward the camera.
2649
+ * translate(-10, 10, 600);
2650
+ *
2651
+ * // Rotate the coordinate system.
2652
+ * rotateY(-0.1);
2653
+ * rotateX(-0.1);
2654
+ *
2655
+ * // Draw the row of boxes.
2656
+ * for (let i = 0; i < 6; i += 1) {
2657
+ * translate(0, 0, -40);
2658
+ * box(10);
2659
+ * }
2660
+ * }
2661
+ *
2662
+ * // Toggle the line perspective when the user double-clicks.
2663
+ * function doubleClicked() {
2664
+ * let isEnabled = linePerspective();
2665
+ * linePerspective(!isEnabled);
2666
+ * }
2667
+ * </code>
2668
+ * </div>
2669
+ *
2670
+ * <div>
2671
+ * <code>
2672
+ * // Double-click the canvas to toggle the line perspective.
2673
+ *
2674
+ * function setup() {
2675
+ * createCanvas(100, 100, WEBGL);
2676
+ *
2677
+ * describe(
2678
+ * 'A row of cubes with black edges on a gray background. Their edges toggle between thick and thin when the user double-clicks.'
2679
+ * );
2680
+ * }
2681
+ *
2682
+ * function draw() {
2683
+ * background(200);
2684
+ *
2685
+ * // Use an orthographic projection.
2686
+ * ortho();
2687
+ *
2688
+ * // Translate the origin toward the camera.
2689
+ * translate(-10, 10, 600);
2690
+ *
2691
+ * // Rotate the coordinate system.
2692
+ * rotateY(-0.1);
2693
+ * rotateX(-0.1);
2694
+ *
2695
+ * // Draw the row of boxes.
2696
+ * for (let i = 0; i < 6; i += 1) {
2697
+ * translate(0, 0, -40);
2698
+ * box(10);
2699
+ * }
2700
+ * }
2701
+ *
2702
+ * // Toggle the line perspective when the user double-clicks.
2703
+ * function doubleClicked() {
2704
+ * let isEnabled = linePerspective();
2705
+ * linePerspective(!isEnabled);
2706
+ * }
2707
+ * </code>
2708
+ * </div>
2709
+ */
2710
+ function linePerspective(enable: boolean): void;
2711
+
2712
+ /**
2713
+ * @return whether line perspective is enabled.
2714
+ */
2715
+ function linePerspective(): boolean;
2716
+
2717
+ /**
2718
+ * Sets an orthographic projection for the current camera in a 3D sketch.In an orthographic projection, shapes with the same size always appear the
2719
+ * same size, regardless of whether they are near or far from the camera.`ortho()` changes the camera’s perspective by changing its viewing frustum
2720
+ * from a truncated pyramid to a rectangular prism. The camera is placed in
2721
+ * front of the frustum and views everything between the frustum’s near plane
2722
+ * and its far plane. `ortho()` has six optional parameters to define the
2723
+ * frustum.The first four parameters, `left`, `right`, `bottom`, and `top`, set the
2724
+ * coordinates of the frustum’s sides, bottom, and top. For example, calling
2725
+ * `ortho(-100, 100, 200, -200)` creates a frustum that’s 200 pixels wide and
2726
+ * 400 pixels tall. By default, these coordinates are set based on the
2727
+ * sketch’s width and height, as in
2728
+ * `ortho(-width / 2, width / 2, -height / 2, height / 2)`.The last two parameters, `near` and `far`, set the distance of the
2729
+ * frustum’s near and far plane from the camera. For example, calling
2730
+ * `ortho(-100, 100, 200, 200, 50, 1000)` creates a frustum that’s 200 pixels
2731
+ * wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000
2732
+ * pixels from the camera. By default, `near` and `far` are set to 0 and
2733
+ * `max(width, height) + 800`, respectively.Note: `ortho()` can only be used in WebGL mode.
2734
+ *
2735
+ * @for p5
2736
+ * @param x-coordinate of the frustum’s left plane. Defaults to `-width / 2`.
2737
+ * @param x-coordinate of the frustum’s right plane. Defaults to `width / 2`.
2738
+ * @param y-coordinate of the frustum’s bottom plane. Defaults to `height / 2`.
2739
+ * @param y-coordinate of the frustum’s top plane. Defaults to `-height / 2`.
2740
+ * @param z-coordinate of the frustum’s near plane. Defaults to 0.
2741
+ * @param z-coordinate of the frustum’s far plane. Defaults to `max(width, height) + 800`.
2742
+ * @example <div>
2743
+ * <code>
2744
+ * function setup() {
2745
+ * createCanvas(100, 100, WEBGL);
2746
+ *
2747
+ * describe('A row of tiny, white cubes on a gray background. All the cubes appear the same size.');
2748
+ * }
2749
+ *
2750
+ * function draw() {
2751
+ * background(200);
2752
+ *
2753
+ * // Apply an orthographic projection.
2754
+ * ortho();
2755
+ *
2756
+ * // Translate the origin toward the camera.
2757
+ * translate(-10, 10, 600);
2758
+ *
2759
+ * // Rotate the coordinate system.
2760
+ * rotateY(-0.1);
2761
+ * rotateX(-0.1);
2762
+ *
2763
+ * // Draw the row of boxes.
2764
+ * for (let i = 0; i < 6; i += 1) {
2765
+ * translate(0, 0, -40);
2766
+ * box(10);
2767
+ * }
2768
+ * }
2769
+ * </code>
2770
+ * </div>
2771
+ *
2772
+ * <div>
2773
+ * <code>
2774
+ * function setup() {
2775
+ * createCanvas(100, 100, WEBGL);
2776
+ *
2777
+ * describe('A white cube on a gray background.');
2778
+ * }
2779
+ *
2780
+ * function draw() {
2781
+ * background(200);
2782
+ *
2783
+ * // Apply an orthographic projection.
2784
+ * // Center the frustum.
2785
+ * // Set its width and height to 20.
2786
+ * // Place its near plane 300 pixels from the camera.
2787
+ * // Place its far plane 350 pixels from the camera.
2788
+ * ortho(-10, 10, -10, 10, 300, 350);
2789
+ *
2790
+ * // Translate the origin toward the camera.
2791
+ * translate(-10, 10, 600);
2792
+ *
2793
+ * // Rotate the coordinate system.
2794
+ * rotateY(-0.1);
2795
+ * rotateX(-0.1);
2796
+ *
2797
+ * // Draw the row of boxes.
2798
+ * for (let i = 0; i < 6; i += 1) {
2799
+ * translate(0, 0, -40);
2800
+ * box(10);
2801
+ * }
2802
+ * }
2803
+ * </code>
2804
+ * </div>
2805
+ */
2806
+ function ortho(left?: number, right?: number, bottom?: number, top?: number, near?: number, far?: number): void;
2807
+
2808
+ /**
2809
+ * Sets the frustum of the current camera in a 3D sketch.In a frustum projection, shapes that are further from the camera appear
2810
+ * smaller than shapes that are near the camera. This technique, called
2811
+ * foreshortening, creates realistic 3D scenes.`frustum()` changes the default camera’s perspective by changing its
2812
+ * viewing frustum. The frustum is the volume of space that’s visible to the
2813
+ * camera. The frustum’s shape is a pyramid with its top cut off. The camera
2814
+ * is placed where the top of the pyramid should be and points towards the
2815
+ * base of the pyramid. It views everything within the frustum.The first four parameters, `left`, `right`, `bottom`, and `top`, set the
2816
+ * coordinates of the frustum’s sides, bottom, and top. For example, calling
2817
+ * `frustum(-100, 100, 200, -200)` creates a frustum that’s 200 pixels wide
2818
+ * and 400 pixels tall. By default, these coordinates are set based on the
2819
+ * sketch’s width and height, as in
2820
+ * `ortho(-width / 20, width / 20, height / 20, -height / 20)`.The last two parameters, `near` and `far`, set the distance of the
2821
+ * frustum’s near and far plane from the camera. For example, calling
2822
+ * `ortho(-100, 100, 200, -200, 50, 1000)` creates a frustum that’s 200 pixels
2823
+ * wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000
2824
+ * pixels from the camera. By default, near is set to `0.1 * 800`, which is
2825
+ * 1/10th the default distance between the camera and the origin. `far` is set
2826
+ * to `10 * 800`, which is 10 times the default distance between the camera
2827
+ * and the origin.Note: `frustum()` can only be used in WebGL mode.
2828
+ *
2829
+ * @for p5
2830
+ * @param x-coordinate of the frustum’s left plane. Defaults to `-width / 20`.
2831
+ * @param x-coordinate of the frustum’s right plane. Defaults to `width / 20`.
2832
+ * @param y-coordinate of the frustum’s bottom plane. Defaults to `height / 20`.
2833
+ * @param y-coordinate of the frustum’s top plane. Defaults to `-height / 20`.
2834
+ * @param z-coordinate of the frustum’s near plane. Defaults to `0.1 * 800`.
2835
+ * @param z-coordinate of the frustum’s far plane. Defaults to `10 * 800`.
2836
+ * @example <div>
2837
+ * <code>
2838
+ * function setup() {
2839
+ * createCanvas(100, 100, WEBGL);
2840
+ *
2841
+ * describe('A row of white cubes on a gray background.');
2842
+ * }
2843
+ *
2844
+ * function draw() {
2845
+ * background(200);
2846
+ *
2847
+ * // Apply the default frustum projection.
2848
+ * frustum();
2849
+ *
2850
+ * // Translate the origin toward the camera.
2851
+ * translate(-10, 10, 600);
2852
+ *
2853
+ * // Rotate the coordinate system.
2854
+ * rotateY(-0.1);
2855
+ * rotateX(-0.1);
2856
+ *
2857
+ * // Draw the row of boxes.
2858
+ * for (let i = 0; i < 6; i += 1) {
2859
+ * translate(0, 0, -40);
2860
+ * box(10);
2861
+ * }
2862
+ * }
2863
+ * </code>
2864
+ * </div>
2865
+ *
2866
+ * <div>
2867
+ * <code>
2868
+ * function setup() {
2869
+ * createCanvas(100, 100, WEBGL);
2870
+ * describe('A white cube on a gray background.');
2871
+ * }
2872
+ *
2873
+ * function draw() {
2874
+ * background(200);
2875
+ *
2876
+ * // Adjust the frustum.
2877
+ * // Center it.
2878
+ * // Set its width and height to 20 pixels.
2879
+ * // Place its near plane 300 pixels from the camera.
2880
+ * // Place its far plane 350 pixels from the camera.
2881
+ * frustum(-10, 10, -10, 10, 300, 350);
2882
+ *
2883
+ * // Translate the origin toward the camera.
2884
+ * translate(-10, 10, 600);
2885
+ *
2886
+ * // Rotate the coordinate system.
2887
+ * rotateY(-0.1);
2888
+ * rotateX(-0.1);
2889
+ *
2890
+ * // Draw the row of boxes.
2891
+ * for (let i = 0; i < 6; i += 1) {
2892
+ * translate(0, 0, -40);
2893
+ * box(10);
2894
+ * }
2895
+ * }
2896
+ * </code>
2897
+ * </div>
2898
+ */
2899
+ function frustum(left?: number, right?: number, bottom?: number, top?: number, near?: number, far?: number): void;
2900
+
2901
+ /**
2902
+ * Creates a new p5.Camera object and sets it
2903
+ * as the current (active) camera.The new camera is initialized with a default position `(0, 0, 800)` and a
2904
+ * default perspective projection. Its properties can be controlled with
2905
+ * p5.Camera methods such as
2906
+ * `myCamera.lookAt(0, 0, 0)`.Note: Every 3D sketch starts with a default camera initialized.
2907
+ * This camera can be controlled with the functions
2908
+ * camera(),
2909
+ * perspective(),
2910
+ * ortho(), and
2911
+ * frustum() if it's the only camera in the scene.Note: `createCamera()` can only be used in WebGL mode.
2912
+ *
2913
+ * @return the new camera.
2914
+ * @for p5
2915
+ * @example <div>
2916
+ * <code>
2917
+ * // Double-click to toggle between cameras.
2918
+ *
2919
+ * let cam1;
2920
+ * let cam2;
2921
+ * let usingCam1 = true;
2922
+ *
2923
+ * function setup() {
2924
+ * createCanvas(100, 100, WEBGL);
2925
+ *
2926
+ * // Create the first camera.
2927
+ * // Keep its default settings.
2928
+ * cam1 = createCamera();
2929
+ *
2930
+ * // Create the second camera.
2931
+ * // Place it at the top-left.
2932
+ * // Point it at the origin.
2933
+ * cam2 = createCamera();
2934
+ * cam2.setPosition(400, -400, 800);
2935
+ * cam2.lookAt(0, 0, 0);
2936
+ *
2937
+ * // Set the current camera to cam1.
2938
+ * setCamera(cam1);
2939
+ *
2940
+ * describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.');
2941
+ * }
2942
+ *
2943
+ * function draw() {
2944
+ * background(200);
2945
+ *
2946
+ * // Draw the box.
2947
+ * box();
2948
+ * }
2949
+ *
2950
+ * // Toggle the current camera when the user double-clicks.
2951
+ * function doubleClicked() {
2952
+ * if (usingCam1 === true) {
2953
+ * setCamera(cam2);
2954
+ * usingCam1 = false;
2955
+ * } else {
2956
+ * setCamera(cam1);
2957
+ * usingCam1 = true;
2958
+ * }
2959
+ * }
2960
+ * </code>
2961
+ * </div>
2962
+ */
2963
+ function createCamera(): p5.Camera;
2964
+
2965
+ /**
2966
+ * Sets the current (active) camera of a 3D sketch.`setCamera()` allows for switching between multiple cameras created with
2967
+ * createCamera().Note: `setCamera()` can only be used in WebGL mode.
2968
+ *
2969
+ * @param camera that should be made active.
2970
+ * @for p5
2971
+ * @example <div>
2972
+ * <code>
2973
+ * // Double-click to toggle between cameras.
2974
+ *
2975
+ * let cam1;
2976
+ * let cam2;
2977
+ * let usingCam1 = true;
2978
+ *
2979
+ * function setup() {
2980
+ * createCanvas(100, 100, WEBGL);
2981
+ *
2982
+ * // Create the first camera.
2983
+ * // Keep its default settings.
2984
+ * cam1 = createCamera();
2985
+ *
2986
+ * // Create the second camera.
2987
+ * // Place it at the top-left.
2988
+ * // Point it at the origin.
2989
+ * cam2 = createCamera();
2990
+ * cam2.setPosition(400, -400, 800);
2991
+ * cam2.lookAt(0, 0, 0);
2992
+ *
2993
+ * // Set the current camera to cam1.
2994
+ * setCamera(cam1);
2995
+ *
2996
+ * describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.');
2997
+ * }
2998
+ *
2999
+ * function draw() {
3000
+ * background(200);
3001
+ *
3002
+ * // Draw the box.
3003
+ * box();
3004
+ * }
3005
+ *
3006
+ * // Toggle the current camera when the user double-clicks.
3007
+ * function doubleClicked() {
3008
+ * if (usingCam1 === true) {
3009
+ * setCamera(cam2);
3010
+ * usingCam1 = false;
3011
+ * } else {
3012
+ * setCamera(cam1);
3013
+ * usingCam1 = true;
3014
+ * }
3015
+ * }
3016
+ * </code>
3017
+ * </div>
3018
+ */
3019
+ function setCamera(cam: p5.Camera): void;
3020
+
3021
+ }
3022
+
3023
+ export default function p5_Camera(p5: any, fn: any): void;