Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify light direction and color #2

Closed
2 tasks done
rcmaniac25 opened this issue Apr 26, 2014 · 3 comments
Closed
2 tasks done

Add ability to specify light direction and color #2

rcmaniac25 opened this issue Apr 26, 2014 · 3 comments

Comments

@rcmaniac25
Copy link
Contributor

  • Ability to specify direction - options.lightPosition
  • Ability to specify light color - options.lightColor
@jdan
Copy link
Owner

jdan commented Apr 26, 2014

Good idea.

isomer.js specifies the direction like so:

/**
 * Light source as defined as the angle from
 * the object to the source.
 *
 * We'll define somewhat arbitrarily for now.
 */
this.lightAngle = new Isomer.Vector(2, -1, 3).normalize();

So you could technically write iso.lightAngle = ... but it should accept from options.

As for color, I currently compute that in Isomer.prototype._addPath:

/**
 * Brightness is between -1 and 1 and is computed based
 * on the dot product between the light source vector and normal.
 */
var brightness = Vector.dotProduct(normal, this.lightAngle);

var color = baseColor.lighten(brightness * this.colorDifference);

I guess lighten sort of assumes the color is pure white. But for colored light I would have to add the two colors somehow. I'll look into it, thanks :)

@jdan
Copy link
Owner

jdan commented Apr 27, 2014

Let me know if we need to make any improvements to this. Might be due for a vocabulary check...

@jdan jdan closed this as completed Apr 27, 2014
@rcmaniac25
Copy link
Contributor Author

Sure thing. Vocabulary is fine for now. Some of the terms aren't really needed unless you start to expand into lots of options for drawing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants