Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating loadModel function #7691

Merged
merged 2 commits into from
Apr 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ function loadingDisplaying(p5, fn){
*
* <div>
* <code>
* function setup() {
* async function setup() {
* // Call handleImage() once the image loads.
* loadImage('assets/laDefense.jpg', handleImage);
* await loadImage('assets/laDefense.jpg', handleImage);
*
* describe('Image of the underside of a white umbrella and a gridded ceiling.');
* }
Expand All @@ -82,10 +82,10 @@ function loadingDisplaying(p5, fn){
*
* <div>
* <code>
* function setup() {
* async function setup() {
* // Call handleImage() once the image loads or
* // call handleError() if an error occurs.
* loadImage('assets/laDefense.jpg', handleImage, handleError);
* await loadImage('assets/laDefense.jpg', handleImage, handleError);
* }
*
* // Display the image.
Expand Down Expand Up @@ -995,7 +995,7 @@ function loadingDisplaying(p5, fn){
*
* async function setup() {
* // Load the image.
* img = await loadImage('assets/laDefense50.jpg');
* img = await loadImage('assets/laDefense50.png');
*
* createCanvas(100, 100);
*
Expand Down
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