(p5, fn)
| 18 | } |
| 19 | |
| 20 | function loading(p5, fn){ |
| 21 | /** |
| 22 | * Loads a 3D model to create a |
| 23 | * <a href="#/p5.Geometry">p5.Geometry</a> object. |
| 24 | * |
| 25 | * `loadModel()` can load 3D models from OBJ and STL files. Once the model is |
| 26 | * loaded, it can be displayed with the |
| 27 | * <a href="#/p5/model">model()</a> function, as in `model(shape)`. |
| 28 | * |
| 29 | * There are three ways to call `loadModel()` with optional parameters to help |
| 30 | * process the model. |
| 31 | * |
| 32 | * The first parameter, `path`, is a `String` with the path to the file. Paths |
| 33 | * to local files should be relative, as in `loadModel('assets/model.obj')`. |
| 34 | * URLs such as `'https://example.com/model.obj'` may be blocked due to browser |
| 35 | * security. The `path` parameter can also be defined as a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) |
| 36 | * object for more advanced usage. |
| 37 | * Note: When loading a `.obj` file that references materials stored in |
| 38 | * `.mtl` files, p5.js will attempt to load and apply those materials. |
| 39 | * To ensure that the `.obj` file reads the `.mtl` file correctly include the |
| 40 | * `.mtl` file alongside it. |
| 41 | * |
| 42 | * The first way to call `loadModel()` has three optional parameters after the |
| 43 | * file path. The first optional parameter, `successCallback`, is a function |
| 44 | * to call once the model loads. For example, |
| 45 | * `loadModel('assets/model.obj', handleModel)` will call the `handleModel()` |
| 46 | * function once the model loads. The second optional parameter, |
| 47 | * `failureCallback`, is a function to call if the model fails to load. For |
| 48 | * example, `loadModel('assets/model.obj', handleModel, handleFailure)` will |
| 49 | * call the `handleFailure()` function if an error occurs while loading. The |
| 50 | * third optional parameter, `fileType`, is the model’s file extension as a |
| 51 | * string. For example, |
| 52 | * `loadModel('assets/model', handleModel, handleFailure, '.obj')` will try to |
| 53 | * load the file model as a `.obj` file. |
| 54 | * |
| 55 | * The second way to call `loadModel()` has four optional parameters after the |
| 56 | * file path. The first optional parameter is a `Boolean` value. If `true` is |
| 57 | * passed, as in `loadModel('assets/model.obj', true)`, then the model will be |
| 58 | * resized to ensure it fits the canvas. The next three parameters are |
| 59 | * `successCallback`, `failureCallback`, and `fileType` as described above. |
| 60 | * |
| 61 | * The third way to call `loadModel()` has one optional parameter after the |
| 62 | * file path. The optional parameter, `options`, is an `Object` with options, |
| 63 | * as in `loadModel('assets/model.obj', options)`. The `options` object can |
| 64 | * have the following properties: |
| 65 | * |
| 66 | * ```js |
| 67 | * let options = { |
| 68 | * // Enables standardized size scaling during loading if set to true. |
| 69 | * normalize: true, |
| 70 | * |
| 71 | * // Function to call once the model loads. |
| 72 | * successCallback: handleModel, |
| 73 | * |
| 74 | * // Function to call if an error occurs while loading. |
| 75 | * failureCallback: handleError, |
| 76 | * |
| 77 | * // Model's file extension. |
no test coverage detected