Skip to content
Open
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
6 changes: 6 additions & 0 deletions docs/parameterData.json
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,12 @@
"function(p5.Geometry)?",
"function(Event)?"
],
[
"String|Request",
"Boolean?",
"function(p5.Geometry)?",
"function(Event)?"
],
[
"String|Request",
"String?",
Expand Down
8 changes: 8 additions & 0 deletions src/webgl/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<p5.Geometry>} new <a href="#/p5.Geometry">p5.Geometry</a> object.
*/
/**
* @method loadModel
* @param {String|Request} path
Expand Down
20 changes: 20 additions & 0 deletions test/unit/core/param_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down