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
33 changes: 19 additions & 14 deletions src/webgl/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,22 +1233,25 @@ p5.prototype.lightFalloff = function (

if (constantAttenuation < 0) {
constantAttenuation = 0;
console.warn(
'Value of constant argument in lightFalloff() should be never be negative. Set to 0.'
p5._friendlyError(
'Value of constant argument in lightFalloff() should be never be negative. Set to 0.',
'lightFalloff'
);
}

if (linearAttenuation < 0) {
linearAttenuation = 0;
console.warn(
'Value of linear argument in lightFalloff() should be never be negative. Set to 0.'
p5._friendlyError(
'Value of linear argument in lightFalloff() should be never be negative. Set to 0.',
'lightFalloff'
);
}

if (quadraticAttenuation < 0) {
quadraticAttenuation = 0;
console.warn(
'Value of quadratic argument in lightFalloff() should be never be negative. Set to 0.'
p5._friendlyError(
'Value of quadratic argument in lightFalloff() should be never be negative. Set to 0.',
'lightFalloff'
);
}

Expand All @@ -1257,8 +1260,9 @@ p5.prototype.lightFalloff = function (
(linearAttenuation === 0 && quadraticAttenuation === 0)
) {
constantAttenuation = 1;
console.warn(
'Either one of the three arguments in lightFalloff() should be greater than zero. Set constant argument to 1.'
p5._friendlyError(
'Either one of the three arguments in lightFalloff() should be greater than zero. Set constant argument to 1.',
'lightFalloff'
);
}

Expand Down Expand Up @@ -1636,10 +1640,10 @@ p5.prototype.spotLight = function (
break;

default:
console.warn(
`Sorry, input for spotlight() is not in prescribed format. Too ${
length < 3 ? 'few' : 'many'
} arguments were provided`
p5._friendlyError(
`Sorry, input for spotlight() is not in prescribed format. Too ${length < 3 ? 'few' : 'many'
} arguments were provided.`,
'spotLight'
);
return this;
}
Expand Down Expand Up @@ -1668,8 +1672,9 @@ p5.prototype.spotLight = function (

if (concentration !== undefined && concentration < 1) {
concentration = 1;
console.warn(
'Value of concentration needs to be greater than 1. Setting it to 1'
p5._friendlyError(
'Value of concentration needs to be greater than 1. Setting it to 1.',
'spotLight'
);
} else if (concentration === undefined) {
concentration = 100;
Expand Down
25 changes: 14 additions & 11 deletions src/webgl/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ p5.prototype.shader = function (s) {
* </code>
* </div>
*/
p5.prototype.baseMaterialShader = function() {
p5.prototype.baseMaterialShader = function () {
this._assert3d('baseMaterialShader');
return this._renderer.baseMaterialShader();
};
Expand Down Expand Up @@ -1284,7 +1284,7 @@ p5.prototype.baseMaterialShader = function() {
* </code>
* </div>
*/
p5.prototype.baseNormalShader = function() {
p5.prototype.baseNormalShader = function () {
this._assert3d('baseNormalShader');
return this._renderer.baseNormalShader();
};
Expand Down Expand Up @@ -1347,7 +1347,7 @@ p5.prototype.baseNormalShader = function() {
* </code>
* </div>
*/
p5.prototype.baseColorShader = function() {
p5.prototype.baseColorShader = function () {
this._assert3d('baseColorShader');
return this._renderer.baseColorShader();
};
Expand Down Expand Up @@ -1620,7 +1620,7 @@ p5.prototype.baseColorShader = function() {
* </code>
* </div>
*/
p5.prototype.baseStrokeShader = function() {
p5.prototype.baseStrokeShader = function () {
this._assert3d('baseStrokeShader');
return this._renderer.baseStrokeShader();
};
Expand Down Expand Up @@ -2071,8 +2071,9 @@ p5.prototype.texture = function (tex) {
*/
p5.prototype.textureMode = function (mode) {
if (mode !== constants.IMAGE && mode !== constants.NORMAL) {
console.warn(
`You tried to set ${mode} textureMode only supports IMAGE & NORMAL `
p5._friendlyError(
`You tried to set ${mode} textureMode only supports IMAGE & NORMAL.`,
'textureMode'
);
} else {
this._renderer.textureMode = mode;
Expand Down Expand Up @@ -3191,7 +3192,7 @@ p5.prototype.metalness = function (metallic) {
* transparency internally, e.g. via vertex colors
* @return {Number[]} Normalized numbers array
*/
p5.RendererGL.prototype._applyColorBlend = function(colors, hasTransparency) {
p5.RendererGL.prototype._applyColorBlend = function (colors, hasTransparency) {
const gl = this.GL;

const isTexture = this.drawMode === constants.TEXTURE;
Expand Down Expand Up @@ -3278,8 +3279,9 @@ p5.RendererGL.prototype._applyBlendMode = function () {
);
gl.blendFuncSeparate(gl.ONE, gl.ONE, gl.ONE, gl.ONE);
} else {
console.warn(
'blendMode(DARKEST) does not work in your browser in WEBGL mode.'
p5._friendlyError(
'blendMode(DARKEST) does not work in your browser in WEBGL mode.',
'blendMode'
);
}
break;
Expand All @@ -3291,8 +3293,9 @@ p5.RendererGL.prototype._applyBlendMode = function () {
);
gl.blendFuncSeparate(gl.ONE, gl.ONE, gl.ONE, gl.ONE);
} else {
console.warn(
'blendMode(LIGHTEST) does not work in your browser in WEBGL mode.'
p5._friendlyError(
'blendMode(LIGHTEST) does not work in your browser in WEBGL mode.',
'blendMode'
);
}
break;
Expand Down