Skip to content
Open
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
25 changes: 21 additions & 4 deletions src/webgl/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,16 @@ p5.prototype.directionalLight = function (v1, v2, v3, x, y, z) {
this._assert3d('directionalLight');
p5._validateParameters('directionalLight', arguments);

//@TODO: check parameters number
const args = arguments.length;
if (args !== 2 && args !== 4 && args !== 6) {
p5._friendlyError(
'directionalLight() expects 2, 4, or 6 arguments, but received ' + args + '. ' +
'Accepted forms: (color, direction), (v1, v2, v3, direction), (color, x, y, z), or (v1, v2, v3, x, y, z).',
'directionalLight'
);
return this;
}

let color;
if (v1 instanceof p5.Color) {
color = v1;
Expand Down Expand Up @@ -917,7 +926,16 @@ p5.prototype.pointLight = function (v1, v2, v3, x, y, z) {
this._assert3d('pointLight');
p5._validateParameters('pointLight', arguments);

//@TODO: check parameters number
const args = arguments.length;
if (args !== 2 && args !== 4 && args !== 6) {
p5._friendlyError(
'pointLight() expects 2, 4, or 6 arguments, but received ' + args + '. ' +
'Accepted forms: (color, position), (v1, v2, v3, position), (color, x, y, z), or (v1, v2, v3, x, y, z).',
'pointLight'
);
return this;
}

let color;
if (v1 instanceof p5.Color) {
color = v1;
Expand Down Expand Up @@ -1637,8 +1655,7 @@ p5.prototype.spotLight = function (

default:
console.warn(
`Sorry, input for spotlight() is not in prescribed format. Too ${
length < 3 ? 'few' : 'many'
`Sorry, input for spotlight() is not in prescribed format. Too ${length < 3 ? 'few' : 'many'
} arguments were provided`
);
return this;
Expand Down