Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
udating-loadModel signature and async/await
  • Loading branch information
perminder-17 authored Mar 31, 2025
commit 7dcafb7249b7a07dbff695f5516f8f6d0b472207
26 changes: 13 additions & 13 deletions src/webgl/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ function loading(p5, fn){
*
* @method loadModel
* @param {String|Request} path path of the model to be loaded.
* @param {String} [fileType] model’s file extension. Either `'.obj'` or `'.stl'`.
* @param {Boolean} normalize if `true`, scale the model to fit the canvas.
* @param {function(p5.Geometry)} [successCallback] function to call once the model is loaded. Will be passed
* the <a href="#/p5.Geometry">p5.Geometry</a> object.
* @param {function(Event)} [failureCallback] function to call if the model fails to load. Will be passed an `Error` event object.
* @param {String} [fileType] model’s file extension. Either `'.obj'` or `'.stl'`.
* @return {Promise<p5.Geometry>} the <a href="#/p5.Geometry">p5.Geometry</a> object
*
* @example
Expand Down Expand Up @@ -168,8 +168,8 @@ function loading(p5, fn){
* let shape;
*
* // Load the file and create a p5.Geometry object.
* function setup() {
* loadModel('assets/teapot.obj', true, handleModel);
* async function setup() {
* await loadModel('assets/teapot.obj', true, handleModel);
*
* createCanvas(100, 100, WEBGL);
*
Expand Down Expand Up @@ -202,8 +202,8 @@ function loading(p5, fn){
* let shape;
*
* // Load the file and create a p5.Geometry object.
* function setup() {
* loadModel('assets/wrong.obj', true, handleModel, handleError);
* async function setup() {
* await loadModel('assets/teapot.obj', true, handleModel, handleError);
*
* createCanvas(100, 100, WEBGL);
*
Expand Down Expand Up @@ -241,8 +241,8 @@ function loading(p5, fn){
* let shape;
*
* // Load the file and create a p5.Geometry object.
* function setup() {
* loadModel('assets/teapot.obj', true, handleModel, handleError, '.obj');
* async function setup() {
* await loadModel('assets/teapot.obj', '.obj', true, handleModel, handleError);
*
* createCanvas(100, 100, WEBGL);
*
Expand Down Expand Up @@ -279,15 +279,15 @@ function loading(p5, fn){
*
* let shape;
* let options = {
* fileType: '.obj',
* normalize: true,
* successCallback: handleModel,
* failureCallback: handleError,
* fileType: '.obj'
* failureCallback: handleError
* };
*
* // Load the file and create a p5.Geometry object.
* function setup() {
* loadModel('assets/teapot.obj', options);
* async function setup() {
* await loadModel('assets/teapot.obj', options);
*
* createCanvas(100, 100, WEBGL);
*
Expand Down Expand Up @@ -321,18 +321,18 @@ function loading(p5, fn){
/**
* @method loadModel
* @param {String|Request} path
* @param {String} [fileType]
* @param {function(p5.Geometry)} [successCallback]
* @param {function(Event)} [failureCallback]
* @param {String} [fileType]
* @return {Promise<p5.Geometry>} new <a href="#/p5.Geometry">p5.Geometry</a> object.
*/
/**
* @method loadModel
* @param {String|Request} path
* @param {Object} [options] loading options.
* @param {String} [options.fileType]
* @param {function(p5.Geometry)} [options.successCallback]
* @param {function(Event)} [options.failureCallback]
* @param {String} [options.fileType]
* @param {Boolean} [options.normalize]
* @param {Boolean} [options.flipU]
* @param {Boolean} [options.flipV]
Expand Down