Skip to content

Commit d0f0381

Browse files
committed
edit docs; rename variable in shader code
1 parent 65a789b commit d0f0381

File tree

5 files changed

+24
-27
lines changed

5 files changed

+24
-27
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ Version 0.2:
9191

9292
- First Code Project release
9393

94-
9594
Source Code
9695
---------
9796
Source code is available in the [project page](https://github.com/peteroupc/html3dutil).

glmath.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,7 @@ return r;
424424
},
425425
/**
426426
* Inverts the rotation given in this quaternion without normalizing it;
427-
* returns a new quaternion. The conjugate represents the same
428-
* rotation as the original.
427+
* returns a new quaternion.
429428
* @param {Array<number>} quat A quaternion, containing four elements.
430429
* @return {Array<number>}
431430
*/
@@ -434,8 +433,7 @@ quatConjugate:function(quat){
434433
},
435434
/**
436435
* Inverts the rotation given in this quaternion, then normalizes the result;
437-
* returns a new quaternion. The inverse represents the same
438-
* rotation as the original.
436+
* returns a new quaternion.
439437
* @param {Array<number>} quat A quaternion, containing four elements.
440438
* @return {Array<number>}
441439
*/
@@ -605,15 +603,15 @@ quatFromTaitBryan:function(pitchDegrees,yawDegrees,rollDegrees, mode){
605603
if(mode==GLMath.PitchYawRoll || mode==GLMath.PitchRollYaw){
606604
var t7 = [rx*yx, ry * yx, rx * yy, ry * yy];
607605
if(mode==GLMath.PitchYawRoll)t7[0]=-t7[0];
608-
t8 = [((t7[3] * px) + (t7[0] * py)), ((t7[1] * py) + (t7[2] * px)), ((t7[2] * py) - (t7[1] * px)), ((t7[3] * py) - (t7[0] * px))];
606+
t8 = [t7[3] * px + t7[0] * py, t7[1] * py + t7[2] * px, t7[2] * py - t7[1] * px, t7[3] * py - t7[0] * px];
609607
} else if(mode==GLMath.YawPitchRoll || mode==GLMath.YawRollPitch){
610608
var t7 = [ry * px, rx * px, rx * py, ry * py];
611609
if(mode==GLMath.YawRollPitch)t7[1]=-t7[1];
612-
t8 = [((t7[0] * yy) - (t7[2] * yx)), ((t7[3] * yx) + (t7[1] * yy)), ((t7[2] * yy) + (t7[0] * yx)), ((t7[3] * yy) - (t7[1] * yx))];
610+
t8 = [t7[0] * yy - t7[2] * yx, t7[3] * yx + t7[1] * yy, t7[2] * yy + t7[0] * yx, t7[3] * yy - t7[1] * yx];
613611
} else {
614612
var t7 = [yy * px, yx * py, yx * px, yy * py];
615613
if(mode==GLMath.RollPitchYaw)t7[2]=-t7[2];
616-
t8 = [((t7[0] * ry) + (t7[1] * rx)), ((t7[1] * ry) - (t7[0] * rx)), ((t7[3] * rx) + (t7[2] * ry)), ((t7[3] * ry) - (t7[2] * rx))];
614+
t8 = [t7[0] * ry + t7[1] * rx, t7[1] * ry - t7[0] * rx, t7[3] * rx + t7[2] * ry, t7[3] * ry - t7[2] * rx];
617615
}
618616
return t8;
619617
},

glutil-shaderprog.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ var shader=ShaderProgram.fragmentShaderHeader() +
579579
"#define SET_LIGHTPOWER(i) "+
580580
" lightPower[i]=calcLightPower(lights[i],viewWorldPositionVar)\n" +
581581
"#define ADD_DIFFUSE(i) "+
582-
" phong+=vec3(lights[i].diffuse)*max(dot(transformedNormalVar," +
582+
" lightedColor+=vec3(lights[i].diffuse)*max(dot(transformedNormalVar," +
583583
" lightPower[i].xyz),0.0)*lightPower[i].w*materialDiffuse;\n" +
584584
"vec4 lightPower["+Lights.MAX_LIGHTS+"];\n";
585585
for(var i=0;i<Lights.MAX_LIGHTS;i++){
@@ -588,7 +588,7 @@ for(var i=0;i<Lights.MAX_LIGHTS;i++){
588588
shader+=""+
589589
"if(baseColor.a==0.0)discard;\n" +
590590
"vec3 materialAmbient=mix(ma,baseColor.rgb,sign(useColorAttr+useTexture)); /* ambient*/\n" +
591-
"vec3 phong=sceneAmbient*materialAmbient; /* ambient*/\n" +
591+
"vec3 lightedColor=sceneAmbient*materialAmbient; /* ambient*/\n" +
592592
" // diffuse\n"+
593593
" vec3 materialDiffuse=vec3(md)*baseColor.rgb;\n";
594594
for(var i=0;i<Lights.MAX_LIGHTS;i++){
@@ -609,14 +609,14 @@ shader+=" spectmp = dot(transformedNormalVar, lightPower["+i+"].xyz) >= 0.0;\n"
609609
" specular=max(specular,0.0);\n" +
610610
" specular=pow(specular,mshin);\n"+
611611
" specular=specular*lightPower["+i+"].w;\n" +
612-
" phong+=ms*specular*lightSpecular;\n" +
612+
" lightedColor+=ms*specular*lightSpecular;\n" +
613613
" }\n";
614614
}
615615
shader+="}\n";
616616
shader+="#endif\n";
617617
shader+=" // emission\n"+
618-
" phong+=me;\n" +
619-
" baseColor=vec4(phong,baseColor.a);\n" +
618+
" lightedColor+=me;\n" +
619+
" baseColor=vec4(lightedColor,baseColor.a);\n" +
620620
"#endif\n" +
621621
" gl_FragColor=baseColor;\n" +
622622
"}";

glutil.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,12 @@ function Material(ambient, diffuse, specular,shininess,emission) {
653653
this.shininess=(shininess==null) ? 0 : Math.min(Math.max(0,shininess),128);
654654
/** Ambient reflection of this material.<p>
655655
* Ambient reflection indicates how much an object reflects
656-
* ambient colors, those that color pixels the same way regardless
656+
* ambient colors, those that color pixels the same way regardless
657657
* of direction or distance.
658658
* Because every part of an object will be shaded the same way by ambient
659659
* light, an object with just ambient reflection will not look much like a 3D object.<p>
660660
* This value is a 3-element array giving the red, green, and blue
661-
* components of the ambient reflection; the final ambient color depends
661+
* components of the ambient reflection; the final ambient color depends
662662
* on the ambient color of the scene.
663663
* (0,0,0) means no ambient reflection,
664664
* and (1,1,1) means total ambient reflection.<p>
@@ -669,13 +669,13 @@ function Material(ambient, diffuse, specular,shininess,emission) {
669669
*/
670670
this.ambient=ambient ? ambient.slice(0,3) : [0.2,0.2,0.2];
671671
/**
672-
* Diffuse reflection of this material. Diffuse reflection is the color that a material
673-
* reflects equally in all directions. Because different parts of an object are shaded
672+
* Diffuse reflection of this material. Diffuse reflection is the color that a material
673+
* reflects equally in all directions. Because different parts of an object are shaded
674674
* differently depending
675675
* on how directly they face diffuse lights, diffuse reflection can contribute
676676
* much of the 3D effect of that object.<p>
677677
* This value is a 4-element array giving the red, green, blue, and
678-
* alpha components of the diffuse reflection; the final diffuse color depends
678+
* alpha components of the diffuse reflection; the final diffuse color depends
679679
* on the reflected colors of lights that shine on the material.
680680
* (0,0,0,1) means no diffuse reflection,
681681
* and (1,1,1,1) means total diffuse reflection.<p>
@@ -694,7 +694,7 @@ function Material(ambient, diffuse, specular,shininess,emission) {
694694
* specular light doesn't scatter very much to other parts of an object.
695695
* Specular reflection can make an object shiny.
696696
* This value is a 3-element array giving the red, green, and blue
697-
* components of the ambient reflection; the final specular color depends
697+
* components of the ambient reflection; the final specular color depends
698698
* on the specular color of lights that shine on the material.
699699
* (0,0,0) means no specular reflection,
700700
* and (1,1,1) means total specular reflection.<p>
@@ -708,7 +708,7 @@ function Material(ambient, diffuse, specular,shininess,emission) {
708708
* default shader if [Scene3D.disableLighting()]{@link glutil.Scene3D#disableLighting}
709709
* is called, disabling lighting calculations).<p>
710710
* This value is a 3-element array giving the red, green, and blue
711-
* components.
711+
* components.
712712
* For each of the three color components, positive values add to that component,
713713
* while negative values subtract from it. (0,0,0) means no additive color.
714714
*/
@@ -881,7 +881,7 @@ Texture.prototype.loadImage=function(){
881881
});
882882
}
883883
/**
884-
* Disposes the texture image in this object.
884+
* Disposes the texture data in this object.
885885
*/
886886
Texture.prototype.dispose=function(){
887887
if(this.loadedTexture==null){
@@ -1642,8 +1642,8 @@ Scene3D.prototype.setViewMatrix=function(matrix){
16421642
* the point in world space that the camera is looking at. May be null or omitted,
16431643
* in which case the default is the coordinates (0,0,0).
16441644
* @param {Array<number>} [up] A 3-element vector specifying
1645-
* the direction from the center of the camera to its top. This parameter may
1646-
* be null or omitted, in which case the default is the vector (0, 1, 0),
1645+
* the direction from the center of the camera to its top. This parameter may
1646+
* be null or omitted, in which case the default is the vector (0, 1, 0),
16471647
* the vector that results when the camera is held upright. This
16481648
* vector must not point in the same or opposite direction as
16491649
* the camera's view direction. (For best results, rotate the vector (0, 1, 0)

glutil_min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)