HTML5 Canvas 3D WebGL (TM) js Library

lightAmbDiff Library Method

Short Description: Set ambient and diffuse color

Signature: t.lightAmbDiff (ambientColor,diffuseColor,a0,a1)
Group: Texture
Class: transition Class

Defines the ambient and diffuse reflection color and the background transparency. The diffuse color specifies the color of the light coming directly from the light source and reflected by the object. If the object direclty faces the light source, it receives the full diffuse color specified here. If it turns away or if it is shadowed, it gets less or even no diffuse light. The amibient color models the color of the light the object receives from other light sources or via multiple reflections. It always receives the ambient color specified here, regardless of the objects position.

If the ambient color white and diffuse color black are specified, the animated HTML element shows up as is, regardless of its position. If the two colors add up to white and if the light source is in front of the page (which is roughly the default), then the animated HTML element shows up as is but gets darker and more like the ambient color if it is rotated away.

If the sum of ambient and diffuse color is darker than white, then the animated HTML element becomes darker. If the sum of ambient and diffuse color is light than white (which is indeed mathematically possible), then the HTML element becomes lighter, however since a screen cannot show lighter colors than white, this does not really look good.

In most cases one specifies a gray scale for both colors. You can however specify any color, e.g. to model a colored light source.

If the method is not used, default values as specified in taccgl.Lighting Parameters are taken."Layout").rotateMiddle(0,1,0).dur(7).lightAmbDiff("black","white",0,0).start();

The methods color, lightAmbDiff, and lightBgAmbDiff are mutually exclusive, only one of them can be used for a single transition. lightAmbDiff sets the background color to white with the specified alpha value (0 means transparent ... 1 fully visible). If the second alpha value is given, an animation from the first to the second value is performed. Note that the background color is relevant, only if the HTML element is transparent. But if this is the case, it can be important to show some kind of background. Using lightAmbDiff you can only have white as background color. If you need another background color, you need to modify your HTML code to include the background or use lightBgAmbDiff.


taccgl.texClearAll(); var"para").rotateMiddle(0,1,0).dur(7); a.position(a.x,a.y-100,0);
taccgl.texClearAll(); var"para").rotateMiddle(0,1,0).dur(7); a.position(a.x,a.y-100,0);
taccgl.texClearAll(); var"para").rotateMiddle(0,1,0).dur(7); a.position(a.x,a.y-100,0);
taccgl.texClearAll(); var"para").rotateMiddle(0,1,0).dur(7); a.position(a.x,a.y-100,0);

WebGL™ is a trademark of the Khronos Group Inc.

Next Page:transition.lightBgAmbDiff - Set background color, ambient and diffuse factors
Previous Page: transition.material - Use Material for Transition