p5 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessibility/color_namer.js +5 -5
- package/dist/accessibility/describe.js +10 -0
- package/dist/accessibility/index.js +5 -5
- package/dist/accessibility/outputs.js +21 -0
- package/dist/app.js +5 -5
- package/dist/color/color_conversion.js +5 -5
- package/dist/color/creating_reading.js +1 -1
- package/dist/color/index.js +2 -2
- package/dist/color/p5.Color.js +1 -1
- package/dist/color/setting.js +2 -2
- package/dist/{constants-C-g_eAdC.js → constants-tYr0tCl8.js} +19 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +6 -5
- package/dist/core/friendly_errors/fes_core.js +1 -1
- package/dist/core/friendly_errors/index.js +1 -1
- package/dist/core/friendly_errors/param_validator.js +41 -75
- package/dist/core/friendly_errors/sketch_reader.js +5 -5
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/friendly_errors/validate_params.js +5 -5
- package/dist/core/helpers.js +1 -1
- package/dist/core/init.js +5 -5
- package/dist/core/legacy.js +5 -5
- package/dist/core/main.js +5 -5
- package/dist/core/p5.Graphics.js +4 -4
- package/dist/core/p5.Renderer.js +3 -3
- package/dist/core/p5.Renderer2D.js +5 -5
- package/dist/core/rendering.js +4 -4
- package/dist/{creating_reading-D4AAKRbx.js → creating_reading-Cr8L2Jnm.js} +2 -2
- package/dist/dom/dom.js +10 -10
- package/dist/dom/index.js +2 -2
- package/dist/dom/p5.Element.js +2 -2
- package/dist/dom/p5.MediaElement.js +2 -2
- package/dist/events/acceleration.js +24 -24
- package/dist/events/keyboard.js +1 -2
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +4 -4
- package/dist/image/image.js +4 -4
- package/dist/image/index.js +4 -4
- package/dist/image/loading_displaying.js +4 -4
- package/dist/image/p5.Image.js +3 -3
- package/dist/image/pixels.js +1 -0
- package/dist/io/files.js +4 -4
- package/dist/io/index.js +4 -4
- package/dist/io/p5.TableRow.js +2 -2
- package/dist/{main-s72KWcUy.js → main-CAxvgiOV.js} +12 -9
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/index.js +1 -1
- package/dist/math/math.js +1 -1
- package/dist/math/p5.Matrix.js +1 -1
- package/dist/math/p5.Vector.js +1 -1
- package/dist/math/trigonometry.js +1 -1
- package/dist/{p5.Renderer-CwAYZOC2.js → p5.Renderer-Swjl9HQO.js} +5 -5
- package/dist/{rendering--aAe5aq3.js → rendering-B5TRR7aY.js} +101 -66
- package/dist/shape/2d_primitives.js +1 -1
- package/dist/shape/attributes.js +1 -1
- package/dist/shape/custom_shapes.js +2 -2
- package/dist/shape/index.js +2 -2
- package/dist/type/index.js +3 -3
- package/dist/type/p5.Font.js +3 -5
- package/dist/type/textCore.js +4 -4
- package/dist/webgl/3d_primitives.js +4 -4
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShapeBuilder.js +1 -1
- package/dist/webgl/index.js +4 -4
- package/dist/webgl/interaction.js +1 -1
- package/dist/webgl/light.js +4 -4
- package/dist/webgl/loading.js +4 -4
- package/dist/webgl/material.js +4 -4
- package/dist/webgl/p5.Camera.js +4 -4
- package/dist/webgl/p5.Framebuffer.js +4 -4
- package/dist/webgl/p5.Geometry.js +1 -1
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +4 -4
- package/dist/webgl/p5.Shader.js +4 -4
- package/dist/webgl/p5.Texture.js +4 -4
- package/dist/webgl/text.js +32 -34
- package/lib/p5.esm.js +273 -225
- package/lib/p5.js +273 -225
- package/lib/p5.min.js +1 -1
- package/package.json +1 -2
- package/types/accessibility/color_namer.d.ts +8 -0
- package/types/accessibility/describe.d.ts +184 -0
- package/types/accessibility/gridOutput.d.ts +8 -0
- package/types/accessibility/outputs.d.ts +235 -0
- package/types/accessibility/textOutput.d.ts +8 -0
- package/types/color/color_conversion.d.ts +47 -0
- package/types/color/creating_reading.d.ts +1348 -0
- package/types/color/p5.Color.d.ts +1070 -0
- package/types/color/setting.d.ts +2085 -0
- package/types/core/constants.d.ts +341 -0
- package/types/core/environment.d.ts +668 -0
- package/types/core/friendly_errors/fes_core.d.ts +8 -0
- package/types/core/friendly_errors/file_errors.d.ts +8 -0
- package/types/core/friendly_errors/param_validator.d.ts +30 -0
- package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
- package/types/core/friendly_errors/stacktrace.d.ts +11 -0
- package/types/core/friendly_errors/validate_params.d.ts +8 -0
- package/types/core/helpers.d.ts +8 -0
- package/types/core/legacy.d.ts +8 -0
- package/types/core/main.d.ts +5996 -0
- package/types/core/p5.Graphics.d.ts +484 -0
- package/types/core/p5.Renderer.d.ts +14 -0
- package/types/core/reference.d.ts +8 -0
- package/types/core/rendering.d.ts +481 -0
- package/types/core/structure.d.ts +492 -0
- package/types/core/transform.d.ts +1638 -0
- package/types/data/local_storage.d.ts +323 -0
- package/types/dom/dom.d.ts +1295 -0
- package/types/dom/p5.Element.d.ts +2011 -0
- package/types/dom/p5.File.d.ts +13 -0
- package/types/dom/p5.MediaElement.d.ts +1249 -0
- package/types/events/acceleration.d.ts +193 -0
- package/types/events/keyboard.d.ts +499 -0
- package/types/events/pointer.d.ts +782 -0
- package/types/global.d.ts +5542 -0
- package/types/image/filterRenderer2D.d.ts +54 -0
- package/types/image/image.d.ts +326 -0
- package/types/image/loading_displaying.d.ts +580 -0
- package/types/image/p5.Image.d.ts +5882 -0
- package/types/image/pixels.d.ts +832 -0
- package/types/io/files.d.ts +1447 -0
- package/types/io/p5.Table.d.ts +1247 -0
- package/types/io/p5.TableRow.d.ts +343 -0
- package/types/io/p5.XML.d.ts +1188 -0
- package/types/math/Matrices/Matrix.d.ts +1029 -0
- package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
- package/types/math/calculation.d.ts +923 -0
- package/types/math/math.d.ts +90 -0
- package/types/math/noise.d.ts +311 -0
- package/types/math/p5.Matrix.d.ts +8 -0
- package/types/math/p5.Vector.d.ts +3416 -0
- package/types/math/random.d.ts +267 -0
- package/types/math/trigonometry.d.ts +663 -0
- package/types/p5.d.ts +6663 -0
- package/types/shape/2d_primitives.d.ts +1033 -0
- package/types/shape/attributes.d.ts +466 -0
- package/types/shape/curves.d.ts +740 -0
- package/types/shape/custom_shapes.d.ts +888 -0
- package/types/shape/vertex.d.ts +1141 -0
- package/types/type/p5.Font.d.ts +575 -0
- package/types/type/textCore.d.ts +1198 -0
- package/types/utilities/conversion.d.ts +894 -0
- package/types/utilities/time_date.d.ts +295 -0
- package/types/utilities/utility_functions.d.ts +587 -0
- package/types/webgl/3d_primitives.d.ts +1432 -0
- package/types/webgl/ShaderGenerator.d.ts +8 -0
- package/types/webgl/interaction.d.ts +371 -0
- package/types/webgl/light.d.ts +1184 -0
- package/types/webgl/loading.d.ts +481 -0
- package/types/webgl/material.d.ts +2656 -0
- package/types/webgl/p5.Camera.d.ts +3023 -0
- package/types/webgl/p5.DataArray.d.ts +61 -0
- package/types/webgl/p5.Framebuffer.d.ts +760 -0
- package/types/webgl/p5.Geometry.d.ts +1191 -0
- package/types/webgl/p5.Quat.d.ts +45 -0
- package/types/webgl/p5.RendererGL.d.ts +234 -0
- package/types/webgl/p5.Shader.d.ts +660 -0
- package/types/webgl/p5.Texture.d.ts +61 -0
- package/types/webgl/text.d.ts +74 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
/**
|
|
7
|
+
* Loads a 3D model to create a
|
|
8
|
+
* p5.Geometry object.`loadModel()` can load 3D models from OBJ and STL files. Once the model is
|
|
9
|
+
* loaded, it can be displayed with the
|
|
10
|
+
* model() function, as in `model(shape)`.There are three ways to call `loadModel()` with optional parameters to help
|
|
11
|
+
* process the model.The first parameter, `path`, is a `String` with the path to the file. Paths
|
|
12
|
+
* to local files should be relative, as in `loadModel('assets/model.obj')`.
|
|
13
|
+
* URLs such as `'https://example.com/model.obj'` may be blocked due to browser
|
|
14
|
+
* security. The `path` parameter can also be defined as a
|
|
15
|
+
* object for more advanced usage.
|
|
16
|
+
* Note: When loading a `.obj` file that references materials stored in
|
|
17
|
+
* `.mtl` files, p5.js will attempt to load and apply those materials.
|
|
18
|
+
* To ensure that the `.obj` file reads the `.mtl` file correctly include the
|
|
19
|
+
* `.mtl` file alongside it.The first way to call `loadModel()` has three optional parameters after the
|
|
20
|
+
* file path. The first optional parameter, `successCallback`, is a function
|
|
21
|
+
* to call once the model loads. For example,
|
|
22
|
+
* `loadModel('assets/model.obj', handleModel)` will call the `handleModel()`
|
|
23
|
+
* function once the model loads. The second optional parameter,
|
|
24
|
+
* `failureCallback`, is a function to call if the model fails to load. For
|
|
25
|
+
* example, `loadModel('assets/model.obj', handleModel, handleFailure)` will
|
|
26
|
+
* call the `handleFailure()` function if an error occurs while loading. The
|
|
27
|
+
* third optional parameter, `fileType`, is the model’s file extension as a
|
|
28
|
+
* string. For example,
|
|
29
|
+
* `loadModel('assets/model', handleModel, handleFailure, '.obj')` will try to
|
|
30
|
+
* load the file model as a `.obj` file.The second way to call `loadModel()` has four optional parameters after the
|
|
31
|
+
* file path. The first optional parameter is a `Boolean` value. If `true` is
|
|
32
|
+
* passed, as in `loadModel('assets/model.obj', true)`, then the model will be
|
|
33
|
+
* resized to ensure it fits the canvas. The next three parameters are
|
|
34
|
+
* `successCallback`, `failureCallback`, and `fileType` as described above.The third way to call `loadModel()` has one optional parameter after the
|
|
35
|
+
* file path. The optional parameter, `options`, is an `Object` with options,
|
|
36
|
+
* as in `loadModel('assets/model.obj', options)`. The `options` object can
|
|
37
|
+
* have the following properties:`let options = {
|
|
38
|
+
* // Enables standardized size scaling during loading if set to true.
|
|
39
|
+
* normalize: true,
|
|
40
|
+
*
|
|
41
|
+
* // Function to call once the model loads.
|
|
42
|
+
* successCallback: handleModel,
|
|
43
|
+
*
|
|
44
|
+
* // Function to call if an error occurs while loading.
|
|
45
|
+
* failureCallback: handleError,
|
|
46
|
+
*
|
|
47
|
+
* // Model's file extension.
|
|
48
|
+
* fileType: '.stl',
|
|
49
|
+
*
|
|
50
|
+
* // Flips the U texture coordinates of the model.
|
|
51
|
+
* flipU: false,
|
|
52
|
+
*
|
|
53
|
+
* // Flips the V texture coordinates of the model.
|
|
54
|
+
* flipV: false
|
|
55
|
+
* };
|
|
56
|
+
*
|
|
57
|
+
* // Pass the options object to loadModel().
|
|
58
|
+
* loadModel('assets/model.obj', options);`This function returns a `Promise` and should be used in an `async` setup with
|
|
59
|
+
* `await`. See the examples for the usage syntax.Note: There’s no support for colored STL files. STL files with color will
|
|
60
|
+
* be rendered without color.
|
|
61
|
+
*
|
|
62
|
+
* @param path of the model to be loaded.
|
|
63
|
+
* @param model’s file extension. Either `'.obj'` or `'.stl'`.
|
|
64
|
+
* @param if `true`, scale the model to fit the canvas.
|
|
65
|
+
* @param function to call once the model is loaded. Will be passed
|
|
66
|
+
* the <a href="#/p5.Geometry">p5.Geometry</a> object.
|
|
67
|
+
* @param function to call if the model fails to load. Will be passed an `Error` event object.
|
|
68
|
+
* @return the <a href="#/p5.Geometry">p5.Geometry</a> object
|
|
69
|
+
* @example <div>
|
|
70
|
+
* <code>
|
|
71
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
72
|
+
*
|
|
73
|
+
* let shape;
|
|
74
|
+
*
|
|
75
|
+
* // Load the file and create a p5.Geometry object.
|
|
76
|
+
* async function setup() {
|
|
77
|
+
* shape = await loadModel('assets/teapot.obj');
|
|
78
|
+
*
|
|
79
|
+
* createCanvas(100, 100, WEBGL);
|
|
80
|
+
*
|
|
81
|
+
* describe('A white teapot drawn against a gray background.');
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* function draw() {
|
|
85
|
+
* background(200);
|
|
86
|
+
*
|
|
87
|
+
* // Enable orbiting with the mouse.
|
|
88
|
+
* orbitControl();
|
|
89
|
+
*
|
|
90
|
+
* // Draw the shape.
|
|
91
|
+
* model(shape);
|
|
92
|
+
* }
|
|
93
|
+
* </code>
|
|
94
|
+
* </div>
|
|
95
|
+
*
|
|
96
|
+
* <div>
|
|
97
|
+
* <code>
|
|
98
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
99
|
+
*
|
|
100
|
+
* let shape;
|
|
101
|
+
*
|
|
102
|
+
* // Load the file and create a p5.Geometry object.
|
|
103
|
+
* // Normalize the geometry's size to fit the canvas.
|
|
104
|
+
* async function setup() {
|
|
105
|
+
* shape = await loadModel('assets/teapot.obj', true);
|
|
106
|
+
*
|
|
107
|
+
* createCanvas(100, 100, WEBGL);
|
|
108
|
+
*
|
|
109
|
+
* describe('A white teapot drawn against a gray background.');
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* function draw() {
|
|
113
|
+
* background(200);
|
|
114
|
+
*
|
|
115
|
+
* // Enable orbiting with the mouse.
|
|
116
|
+
* orbitControl();
|
|
117
|
+
*
|
|
118
|
+
* // Draw the shape.
|
|
119
|
+
* model(shape);
|
|
120
|
+
* }
|
|
121
|
+
* </code>
|
|
122
|
+
* </div>
|
|
123
|
+
*
|
|
124
|
+
* <div>
|
|
125
|
+
* <code>
|
|
126
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
127
|
+
*
|
|
128
|
+
* let shape;
|
|
129
|
+
*
|
|
130
|
+
* // Load the file and create a p5.Geometry object.
|
|
131
|
+
* async function setup() {
|
|
132
|
+
* await loadModel('assets/teapot.obj', true, handleModel);
|
|
133
|
+
*
|
|
134
|
+
* createCanvas(100, 100, WEBGL);
|
|
135
|
+
*
|
|
136
|
+
* describe('A white teapot drawn against a gray background.');
|
|
137
|
+
* }
|
|
138
|
+
*
|
|
139
|
+
* function draw() {
|
|
140
|
+
* background(200);
|
|
141
|
+
*
|
|
142
|
+
* // Enable orbiting with the mouse.
|
|
143
|
+
* orbitControl();
|
|
144
|
+
*
|
|
145
|
+
* // Draw the shape.
|
|
146
|
+
* model(shape);
|
|
147
|
+
* }
|
|
148
|
+
*
|
|
149
|
+
* // Set the shape variable and log the geometry's
|
|
150
|
+
* // ID to the console.
|
|
151
|
+
* function handleModel(data) {
|
|
152
|
+
* shape = data;
|
|
153
|
+
* console.log(shape.gid);
|
|
154
|
+
* }
|
|
155
|
+
* </code>
|
|
156
|
+
* </div>
|
|
157
|
+
*
|
|
158
|
+
* <div class='notest'>
|
|
159
|
+
* <code>
|
|
160
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
161
|
+
*
|
|
162
|
+
* let shape;
|
|
163
|
+
*
|
|
164
|
+
* // Load the file and create a p5.Geometry object.
|
|
165
|
+
* async function setup() {
|
|
166
|
+
* await loadModel('assets/teapot.obj', true, handleModel, handleError);
|
|
167
|
+
*
|
|
168
|
+
* createCanvas(100, 100, WEBGL);
|
|
169
|
+
*
|
|
170
|
+
* describe('A white teapot drawn against a gray background.');
|
|
171
|
+
* }
|
|
172
|
+
*
|
|
173
|
+
* function draw() {
|
|
174
|
+
* background(200);
|
|
175
|
+
*
|
|
176
|
+
* // Enable orbiting with the mouse.
|
|
177
|
+
* orbitControl();
|
|
178
|
+
*
|
|
179
|
+
* // Draw the shape.
|
|
180
|
+
* model(shape);
|
|
181
|
+
* }
|
|
182
|
+
*
|
|
183
|
+
* // Set the shape variable and print the geometry's
|
|
184
|
+
* // ID to the console.
|
|
185
|
+
* function handleModel(data) {
|
|
186
|
+
* shape = data;
|
|
187
|
+
* console.log(shape.gid);
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* // Print an error message if the file doesn't load.
|
|
191
|
+
* function handleError(error) {
|
|
192
|
+
* console.error('Oops!', error);
|
|
193
|
+
* }
|
|
194
|
+
* </code>
|
|
195
|
+
* </div>
|
|
196
|
+
*
|
|
197
|
+
* <div>
|
|
198
|
+
* <code>
|
|
199
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
200
|
+
*
|
|
201
|
+
* let shape;
|
|
202
|
+
*
|
|
203
|
+
* // Load the file and create a p5.Geometry object.
|
|
204
|
+
* async function setup() {
|
|
205
|
+
* await loadModel('assets/teapot.obj', '.obj', true, handleModel, handleError);
|
|
206
|
+
*
|
|
207
|
+
* createCanvas(100, 100, WEBGL);
|
|
208
|
+
*
|
|
209
|
+
* describe('A white teapot drawn against a gray background.');
|
|
210
|
+
* }
|
|
211
|
+
*
|
|
212
|
+
* function draw() {
|
|
213
|
+
* background(200);
|
|
214
|
+
*
|
|
215
|
+
* // Enable orbiting with the mouse.
|
|
216
|
+
* orbitControl();
|
|
217
|
+
*
|
|
218
|
+
* // Draw the shape.
|
|
219
|
+
* model(shape);
|
|
220
|
+
* }
|
|
221
|
+
*
|
|
222
|
+
* // Set the shape variable and print the geometry's
|
|
223
|
+
* // ID to the console.
|
|
224
|
+
* function handleModel(data) {
|
|
225
|
+
* shape = data;
|
|
226
|
+
* console.log(shape.gid);
|
|
227
|
+
* }
|
|
228
|
+
*
|
|
229
|
+
* // Print an error message if the file doesn't load.
|
|
230
|
+
* function handleError(error) {
|
|
231
|
+
* console.error('Oops!', error);
|
|
232
|
+
* }
|
|
233
|
+
* </code>
|
|
234
|
+
* </div>
|
|
235
|
+
*
|
|
236
|
+
* <div>
|
|
237
|
+
* <code>
|
|
238
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
239
|
+
*
|
|
240
|
+
* let shape;
|
|
241
|
+
* let options = {
|
|
242
|
+
* fileType: '.obj',
|
|
243
|
+
* normalize: true,
|
|
244
|
+
* successCallback: handleModel,
|
|
245
|
+
* failureCallback: handleError
|
|
246
|
+
* };
|
|
247
|
+
*
|
|
248
|
+
* // Load the file and create a p5.Geometry object.
|
|
249
|
+
* async function setup() {
|
|
250
|
+
* await loadModel('assets/teapot.obj', options);
|
|
251
|
+
*
|
|
252
|
+
* createCanvas(100, 100, WEBGL);
|
|
253
|
+
*
|
|
254
|
+
* describe('A white teapot drawn against a gray background.');
|
|
255
|
+
* }
|
|
256
|
+
*
|
|
257
|
+
* function draw() {
|
|
258
|
+
* background(200);
|
|
259
|
+
*
|
|
260
|
+
* // Enable orbiting with the mouse.
|
|
261
|
+
* orbitControl();
|
|
262
|
+
*
|
|
263
|
+
* // Draw the shape.
|
|
264
|
+
* model(shape);
|
|
265
|
+
* }
|
|
266
|
+
*
|
|
267
|
+
* // Set the shape variable and print the geometry's
|
|
268
|
+
* // ID to the console.
|
|
269
|
+
* function handleModel(data) {
|
|
270
|
+
* shape = data;
|
|
271
|
+
* console.log(shape.gid);
|
|
272
|
+
* }
|
|
273
|
+
*
|
|
274
|
+
* // Print an error message if the file doesn't load.
|
|
275
|
+
* function handleError(error) {
|
|
276
|
+
* console.error('Oops!', error);
|
|
277
|
+
* }
|
|
278
|
+
* </code>
|
|
279
|
+
* </div>
|
|
280
|
+
*/
|
|
281
|
+
function loadModel(path: string | Request, fileType?: string, normalize: boolean, successCallback?: any, failureCallback?: any): Promise<p5.Geometry>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @return new <a href="#/p5.Geometry">p5.Geometry</a> object.
|
|
285
|
+
*/
|
|
286
|
+
function loadModel(path: string | Request, fileType?: string, successCallback?: any, failureCallback?: any): Promise<p5.Geometry>;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param loading options.
|
|
290
|
+
* @return new <a href="#/p5.Geometry">p5.Geometry</a> object.
|
|
291
|
+
*/
|
|
292
|
+
function loadModel(path: string | Request, options?: object): Promise<p5.Geometry>;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Draws a p5.Geometry object to the canvas.The parameter, `model`, is the
|
|
296
|
+
* p5.Geometry object to draw.
|
|
297
|
+
* p5.Geometry objects can be built with
|
|
298
|
+
* buildGeometry(), or
|
|
299
|
+
* beginGeometry() and
|
|
300
|
+
* endGeometry(). They can also be loaded from
|
|
301
|
+
* a file with loadGeometry().Note: `model()` can only be used in WebGL mode.
|
|
302
|
+
*
|
|
303
|
+
* @param 3D shape to be drawn.
|
|
304
|
+
* @example <div>
|
|
305
|
+
* <code>
|
|
306
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
307
|
+
*
|
|
308
|
+
* let shape;
|
|
309
|
+
*
|
|
310
|
+
* function setup() {
|
|
311
|
+
* createCanvas(100, 100, WEBGL);
|
|
312
|
+
*
|
|
313
|
+
* // Create the p5.Geometry object.
|
|
314
|
+
* shape = buildGeometry(createShape);
|
|
315
|
+
*
|
|
316
|
+
* describe('A white cone drawn on a gray background.');
|
|
317
|
+
* }
|
|
318
|
+
*
|
|
319
|
+
* function draw() {
|
|
320
|
+
* background(200);
|
|
321
|
+
*
|
|
322
|
+
* // Enable orbiting with the mouse.
|
|
323
|
+
* orbitControl();
|
|
324
|
+
*
|
|
325
|
+
* // Draw the p5.Geometry object.
|
|
326
|
+
* model(shape);
|
|
327
|
+
* }
|
|
328
|
+
*
|
|
329
|
+
* // Create p5.Geometry object from a single cone.
|
|
330
|
+
* function createShape() {
|
|
331
|
+
* cone();
|
|
332
|
+
* }
|
|
333
|
+
* </code>
|
|
334
|
+
* </div>
|
|
335
|
+
*
|
|
336
|
+
* <div>
|
|
337
|
+
* <code>
|
|
338
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
339
|
+
*
|
|
340
|
+
* let shape;
|
|
341
|
+
*
|
|
342
|
+
* function setup() {
|
|
343
|
+
* createCanvas(100, 100, WEBGL);
|
|
344
|
+
*
|
|
345
|
+
* // Create the p5.Geometry object.
|
|
346
|
+
* shape = buildGeometry(createArrow);
|
|
347
|
+
*
|
|
348
|
+
* describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.');
|
|
349
|
+
* }
|
|
350
|
+
*
|
|
351
|
+
* function draw() {
|
|
352
|
+
* background(50);
|
|
353
|
+
*
|
|
354
|
+
* // Enable orbiting with the mouse.
|
|
355
|
+
* orbitControl();
|
|
356
|
+
*
|
|
357
|
+
* // Turn on the lights.
|
|
358
|
+
* lights();
|
|
359
|
+
*
|
|
360
|
+
* // Style the arrows.
|
|
361
|
+
* noStroke();
|
|
362
|
+
*
|
|
363
|
+
* // Draw the p5.Geometry object.
|
|
364
|
+
* model(shape);
|
|
365
|
+
*
|
|
366
|
+
* // Translate and rotate the coordinate system.
|
|
367
|
+
* translate(30, 0, 0);
|
|
368
|
+
* rotateZ(frameCount * 0.01);
|
|
369
|
+
*
|
|
370
|
+
* // Draw the p5.Geometry object again.
|
|
371
|
+
* model(shape);
|
|
372
|
+
* }
|
|
373
|
+
*
|
|
374
|
+
* function createArrow() {
|
|
375
|
+
* // Add shapes to the p5.Geometry object.
|
|
376
|
+
* push();
|
|
377
|
+
* rotateX(PI);
|
|
378
|
+
* cone(10);
|
|
379
|
+
* translate(0, -10, 0);
|
|
380
|
+
* cylinder(3, 20);
|
|
381
|
+
* pop();
|
|
382
|
+
* }
|
|
383
|
+
* </code>
|
|
384
|
+
* </div>
|
|
385
|
+
*
|
|
386
|
+
* <div>
|
|
387
|
+
* <code>
|
|
388
|
+
* // Click and drag the mouse to view the scene from different angles.
|
|
389
|
+
*
|
|
390
|
+
* let shape;
|
|
391
|
+
*
|
|
392
|
+
* async function setup() {
|
|
393
|
+
* shape = await loadModel('assets/octahedron.obj');
|
|
394
|
+
*
|
|
395
|
+
* createCanvas(100, 100, WEBGL);
|
|
396
|
+
*
|
|
397
|
+
* describe('A white octahedron drawn against a gray background.');
|
|
398
|
+
* }
|
|
399
|
+
*
|
|
400
|
+
* function draw() {
|
|
401
|
+
* background(200);
|
|
402
|
+
*
|
|
403
|
+
* // Enable orbiting with the mouse.
|
|
404
|
+
* orbitControl();
|
|
405
|
+
*
|
|
406
|
+
* // Draw the shape.
|
|
407
|
+
* model(shape);
|
|
408
|
+
* }
|
|
409
|
+
* </code>
|
|
410
|
+
* </div>
|
|
411
|
+
*/
|
|
412
|
+
function model(model: p5.Geometry): void;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Load a 3d model from an OBJ or STL string.OBJ and STL files lack a built-in sense of scale, causing models exported from different programs to vary in size.
|
|
416
|
+
* If your model doesn't display correctly, consider using `loadModel()` with `normalize` set to `true` to standardize its size.
|
|
417
|
+
* Further adjustments can be made using the `scale()` function.Also, the support for colored STL files is not present. STL files with color will be
|
|
418
|
+
* rendered without color properties.
|
|
419
|
+
*
|
|
420
|
+
* @param String of the object to be loaded
|
|
421
|
+
* @param The file extension of the model
|
|
422
|
+
* (<code>.stl</code>, <code>.obj</code>).
|
|
423
|
+
* @param If true, scale the model to a
|
|
424
|
+
* standardized size when loading
|
|
425
|
+
* @param Function to be called
|
|
426
|
+
* once the model is loaded. Will be passed
|
|
427
|
+
* the 3D model object.
|
|
428
|
+
* @param called with event error if
|
|
429
|
+
* the model fails to load.
|
|
430
|
+
* @return the <a href="#/p5.Geometry">p5.Geometry</a> object
|
|
431
|
+
* @example <div>
|
|
432
|
+
* <code>
|
|
433
|
+
* const octahedron_model = `
|
|
434
|
+
* v 0.000000E+00 0.000000E+00 40.0000
|
|
435
|
+
* v 22.5000 22.5000 0.000000E+00
|
|
436
|
+
* v 22.5000 -22.5000 0.000000E+00
|
|
437
|
+
* v -22.5000 -22.5000 0.000000E+00
|
|
438
|
+
* v -22.5000 22.5000 0.000000E+00
|
|
439
|
+
* v 0.000000E+00 0.000000E+00 -40.0000
|
|
440
|
+
* f 1 2 3
|
|
441
|
+
* f 1 3 4
|
|
442
|
+
* f 1 4 5
|
|
443
|
+
* f 1 5 2
|
|
444
|
+
* f 6 5 4
|
|
445
|
+
* f 6 4 3
|
|
446
|
+
* f 6 3 2
|
|
447
|
+
* f 6 2 5
|
|
448
|
+
* `;
|
|
449
|
+
* //draw a spinning octahedron
|
|
450
|
+
* let octahedron;
|
|
451
|
+
*
|
|
452
|
+
* function setup() {
|
|
453
|
+
* createCanvas(100, 100, WEBGL);
|
|
454
|
+
* octahedron = createModel(octahedron_model, '.obj');
|
|
455
|
+
* describe('Vertically rotating 3D octahedron.');
|
|
456
|
+
* }
|
|
457
|
+
*
|
|
458
|
+
* function draw() {
|
|
459
|
+
* background(200);
|
|
460
|
+
* rotateX(frameCount * 0.01);
|
|
461
|
+
* rotateY(frameCount * 0.01);
|
|
462
|
+
* model(octahedron);
|
|
463
|
+
* }
|
|
464
|
+
* </code>
|
|
465
|
+
* </div>
|
|
466
|
+
*/
|
|
467
|
+
function createModel(modelString: string, fileType?: string, normalize: boolean, successCallback?: any, failureCallback?: any): p5.Geometry;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @return the <a href="#/p5.Geometry">p5.Geometry</a> object
|
|
471
|
+
*/
|
|
472
|
+
function createModel(modelString: string, fileType?: string, successCallback?: any, failureCallback?: any): p5.Geometry;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @return the <a href="#/p5.Geometry">p5.Geometry</a> object
|
|
476
|
+
*/
|
|
477
|
+
function createModel(modelString: string, fileType?: string, options?: object): p5.Geometry;
|
|
478
|
+
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export default function loading(p5: any, fn: any): void;
|