diff --git a/docs/parameterData.json b/docs/parameterData.json index 81a8b6b4d0..2594301de4 100644 --- a/docs/parameterData.json +++ b/docs/parameterData.json @@ -962,6 +962,12 @@ "function(p5.Geometry)?", "function(Event)?" ], + [ + "String|Request", + "Boolean?", + "function(p5.Geometry)?", + "function(Event)?" + ], [ "String|Request", "String?", diff --git a/src/webgl/loading.js b/src/webgl/loading.js index 51bb504cc4..6b3207ef88 100755 --- a/src/webgl/loading.js +++ b/src/webgl/loading.js @@ -530,6 +530,14 @@ function loading(p5, fn) { * console.error('Oops!', error); * } */ + /** + * @method loadModel + * @param {String|Request} path + * @param {Boolean} [normalize] + * @param {function(p5.Geometry)} [successCallback] + * @param {function(Event)} [failureCallback] + * @return {Promise} new p5.Geometry object. + */ /** * @method loadModel * @param {String|Request} path diff --git a/test/unit/core/param_errors.js b/test/unit/core/param_errors.js index 7a01c3a165..4f26f5b923 100644 --- a/test/unit/core/param_errors.js +++ b/test/unit/core/param_errors.js @@ -380,6 +380,26 @@ suite('Validate Params', function () { }); }); + suite('validateParams: loadModel normalize overload', function () { + const onLoad = () => {}; + test('loadModel(): accepts normalize as the second argument', function () { + const result = mockP5Prototype._validate('p5.loadModel', ['model.obj', true]); + assert.isTrue(result.success); + }); + test('loadModel(): accepts normalize followed by a callback', function () { + const result = mockP5Prototype._validate('p5.loadModel', ['model.obj', true, onLoad]); + assert.isTrue(result.success); + }); + test('loadModel(): still accepts a file type and normalize', function () { + const result = mockP5Prototype._validate('p5.loadModel', ['model', '.obj', true]); + assert.isTrue(result.success); + }); + test('loadModel(): still rejects a number as the second argument', function () { + const result = mockP5Prototype._validate('p5.loadModel', ['model.obj', 5]); + assert.isFalse(result.success); + }); + }); + suite('validateParams: variadic min/max', function () { ['min', 'max'].forEach(fn => { test(`${fn}(): works with two numbers`, function () {