From 36efd95efd48b6711a75b734b8587fa529e6ac63 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 7 Jan 2018 14:37:26 -0800 Subject: [PATCH] fix light references and z coord for manual test --- src/webgl/light.js | 72 ++++++++++--------- .../webgl/lights/pointLight/sketch.js | 2 +- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/webgl/light.js b/src/webgl/light.js index 118b03613a..c03f0c89de 100644 --- a/src/webgl/light.js +++ b/src/webgl/light.js @@ -32,13 +32,14 @@ var p5 = require('../core/core'); * background(0); * ambientLight(150); * ambientMaterial(250); - * sphere(50); + * noStroke(); + * sphere(25); * } * * * * @alt - * nothing displayed + * evenly distributed light across a sphere * */ @@ -98,6 +99,28 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) { * @param {Number} v3 blue or brightness value * @param {p5.Vector} position the direction of the light * @chainable + * @example + *
+ * + * function setup() { + * createCanvas(100, 100, WEBGL); + * } + * function draw() { + * background(0); + * //move your mouse to change light direction + * var dirX = (mouseX / width - 0.5) * 2; + * var dirY = (mouseY / height - 0.5) * 2; + * directionalLight(250, 250, 250, -dirX, -dirY, 0.25); + * ambientMaterial(250); + * noStroke(); + * sphere(25); + * } + * + *
+ * + * @alt + * light source on canvas changeable with mouse position + * */ /** @@ -126,28 +149,6 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) { * @param {Number} y * @param {Number} z * @chainable - * - * @example - *
- * - * function setup() { - * createCanvas(100, 100, WEBGL); - * } - * function draw() { - * background(0); - * //move your mouse to change light direction - * var dirX = (mouseX / width - 0.5) * 2; - * var dirY = (mouseY / height - 0.5) * 2; - * directionalLight(250, 250, 250, -dirX, -dirY, 0.25); - * ambientMaterial(250); - * sphere(50); - * } - * - *
- * - * @alt - * light source on canvas changeable with mouse position - * */ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) { var shader = this._renderer._useLightShader(); @@ -213,18 +214,19 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) { * function draw() { * background(0); * //move your mouse to change light position - * var locY = (mouseY / height - 0.5) * -2; - * var locX = (mouseX / width - 0.5) * 2; - * //to set the light position, - * //think of the world's coordinate as: - * // -1,1 -------- 1,1 - * // | | - * // | | - * // | | - * // -1,-1---------1,-1 - * pointLight(250, 250, 250, locX, locY, 0); + * var locX = mouseX - width / 2; + * var locY = mouseY - height / 2; + * // to set the light position, + * // think of the world's coordinate as: + * // -width/2,-height/2 -------- width/2,-height/2 + * // | | + * // | 0,0 | + * // | | + * // -width/2,height/2--------width/2,height/2 + * pointLight(250, 250, 250, locX, locY, 50); * ambientMaterial(250); - * sphere(50); + * noStroke(); + * sphere(25); * } * * diff --git a/test/manual-test-examples/webgl/lights/pointLight/sketch.js b/test/manual-test-examples/webgl/lights/pointLight/sketch.js index 2c1415bc37..b7aa4b0908 100644 --- a/test/manual-test-examples/webgl/lights/pointLight/sketch.js +++ b/test/manual-test-examples/webgl/lights/pointLight/sketch.js @@ -6,7 +6,7 @@ function draw(){ background(0); ambientLight(50); - pointLight(250, 250, 250, mouseX - width / 2, mouseY - height / 2, 0); + pointLight(250, 250, 250, mouseX - width / 2, mouseY - height / 2, 100); ambientMaterial(250); sphere(50, 64);