Skip to content

Commit ced906c

Browse files
committed
add docs
1 parent 79602f2 commit ced906c

File tree

1 file changed

+89
-14
lines changed

1 file changed

+89
-14
lines changed

glutil-eval.js

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ var BezierSurface=function(cp, u1, u2, v1, v2){
154154
* first and last control points match the curve's end points.<p>
155155
* @param {boolean} [bits] Bits for defining input
156156
* and controlling output. Zero or more of BSplineCurve.WEIGHTED_BIT,
157-
* BSplineCurve.HOMOGENEOUS_BIT.
157+
* BSplineCurve.HOMOGENEOUS_BIT,
158158
* and BSplineCurve.DIVIDE_BIT. If null or omitted, no bits are set.
159159
*/
160160
var BSplineCurve=function(controlPoints, knots, bits){
@@ -353,7 +353,7 @@ BSplineCurve.prototype.evaluate=function(u){
353353
* @param {Array<number>} knotsV Knot vector of the curve, along the V-axis.
354354
* @param {boolean} [bits] Bits for defining input
355355
* and controlling output. Zero or more of BSplineCurve.WEIGHTED_BIT,
356-
* BSplineCurve.HOMOGENEOUS_BIT.
356+
* BSplineCurve.HOMOGENEOUS_BIT,
357357
* and BSplineCurve.DIVIDE_BIT. If null or omitted, no bits are set.
358358
*/
359359
var BSplineSurface=function(controlPoints, knotsU, knotsV, bits){
@@ -387,28 +387,79 @@ var BSplineSurface=function(controlPoints, knotsU, knotsV, bits){
387387
this.bufferV=[];
388388
this.controlPoints=controlPoints;
389389
}
390-
391-
BSplineCurve.clamped=function(controlPoints,degree,flags){
390+
/**
391+
* Creates a B-spline curve with uniform knots, except that
392+
* the curve will start and end at the first and last control points.
393+
* @param {Array<Array<number>>} controlPoints Array of
394+
* control points as specified in the {@link glutil.BSplineCurve} constructor.
395+
* @param {number|undefined} degree Degree of the B-Spline
396+
* curve. For example, 3 means a degree-3 (cubic) curve.
397+
* If null or omitted, the default is 3.
398+
* @param {number} [bits] Bits as specified in the {@link glutil.BSplineCurve} constructor.
399+
* @return {BSplineCurve}
400+
*/
401+
BSplineCurve.clamped=function(controlPoints,degree,bits){
392402
return new BSplineCurve(controlPoints,
393-
BSplineCurve.clampedKnots(controlPoints.length,degree),flags)
403+
BSplineCurve.clampedKnots(controlPoints.length,degree),bits)
394404
}
395-
BSplineCurve.uniform=function(controlPoints,degree,flags){
405+
/**
406+
* Creates a B-spline curve with uniform knots.
407+
* @param {Array<Array<number>>} controlPoints Array of
408+
* control points as specified in the {@link glutil.BSplineCurve} constructor.
409+
* @param {number|undefined} degree Degree of the B-Spline
410+
* curve. For example, 3 means a degree-3 (cubic) curve.
411+
* If null or omitted, the default is 3.
412+
* @param {number} [bits] Bits as specified in the {@link glutil.BSplineCurve} constructor.
413+
* @return {BSplineCurve}
414+
*/
415+
BSplineCurve.uniform=function(controlPoints,degree,bits){
396416
return new BSplineCurve(controlPoints,
397-
BSplineCurve.uniformKnots(controlPoints.length,degree),flags)
417+
BSplineCurve.uniformKnots(controlPoints.length,degree),bits)
398418
}
399-
BSplineSurface.clamped=function(controlPoints,degreeU,degreeV,flags){
419+
/**
420+
* Creates a B-spline surface with uniform knots, except that
421+
* the surface's edges lie on the edges of the control point array.
422+
* @param {Array<Array<Array<number>>>} controlPoints Array of
423+
* control point arrays as specified in the {@link glutil.BSplineSurface} constructor.
424+
* @param {number|undefined} degreeU Degree of the B-Spline
425+
* surface along the U-axis. For example, 3 means a degree-3 (cubic) curve.
426+
* If null or omitted, the default is 3.
427+
* @param {number|undefined} degreeV Degree of the B-Spline
428+
* surface along the V-axis
429+
* If null or omitted, the default is 3.
430+
* @param {number} [bits] Bits as specified in the {@link glutil.BSplineSurface} constructor.
431+
* @return {BSplineSurface}
432+
*/
433+
BSplineSurface.clamped=function(controlPoints,degreeU,degreeV,bits){
400434
return new BSplineSurface(controlPoints,
401435
BSplineCurve.clampedKnots(controlPoints[0].length,degreeU),
402-
BSplineCurve.clampedKnots(controlPoints.length,degreeV),flags)
436+
BSplineCurve.clampedKnots(controlPoints.length,degreeV),bits)
403437
}
404-
BSplineSurface.uniform=function(controlPoints,degreeU,degreeV,flags){
438+
/**
439+
* Creates a B-spline surface with uniform knots.
440+
* @param {Array<Array<Array<number>>>} controlPoints Array of
441+
* control point arrays as specified in the {@link glutil.BSplineSurface} constructor.
442+
* @param {number|undefined} degreeU Degree of the B-Spline
443+
* surface along the U-axis. For example, 3 means a degree-3 (cubic) curve.
444+
* If null or omitted, the default is 3.
445+
* @param {number|undefined} degreeV Degree of the B-Spline
446+
* surface along the V-axis
447+
* If null or omitted, the default is 3.
448+
* @param {number} [bits] Bits as specified in the {@link glutil.BSplineSurface} constructor.
449+
* @return {BSplineSurface}
450+
*/
451+
BSplineSurface.uniform=function(controlPoints,degreeU,degreeV,bits){
405452
return new BSplineSurface(controlPoints,
406453
BSplineCurve.uniformKnots(controlPoints[0].length,degreeU),
407-
BSplineCurve.uniformKnots(controlPoints.length,degreeV),flags)
454+
BSplineCurve.uniformKnots(controlPoints.length,degreeV),bits)
408455
}
456+
/**
457+
* Not documented yet.
458+
*/
409459
BSplineCurve.uniformKnots=function(controlPoints,degree){
410460
if(typeof controlPoints=="object")
411461
controlPoints=controlPoints.length;
462+
if(degree==null)degree=3
412463
if(controlPoints<degree+1)
413464
throw new Error("too few control points for degree "+degree+" curve")
414465
var order=degree+1;
@@ -418,9 +469,13 @@ BSplineCurve.uniformKnots=function(controlPoints,degree){
418469
}
419470
return ret;
420471
}
472+
/**
473+
* Not documented yet.
474+
*/
421475
BSplineCurve.clampedKnots=function(controlPoints,degree){
422476
if(typeof controlPoints=="object")
423477
controlPoints=controlPoints.length;
478+
if(degree==null)degree=3
424479
if(controlPoints<degree+1)
425480
throw new Error("too few control points for degree "+degree+" curve")
426481
var order=degree+1;
@@ -586,6 +641,8 @@ CurveEval.prototype.texCoord=function(evaluator){
586641
}
587642
/**
588643
* Specifies a B&eacute;zier curve used for generating vertex positions.
644+
* @deprecated Use the <code>vertex()</code> method instead with a
645+
* BezierCurve object.
589646
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierCurve},
590647
* where each point is a 3-element array giving the x, y, and z coordinates of a vertex
591648
* position.
@@ -601,6 +658,8 @@ CurveEval.prototype.vertexBezier=function(controlPoints,u1,u2){
601658
}
602659
/**
603660
* Specifies a B&eacute;zier curve used for generating normals.
661+
* @deprecated Use the <code>normal()</code> method instead with a
662+
* BezierCurve object.
604663
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierCurve},
605664
* where each point is a 3-element array giving the x, y, and z coordinates of a normal.
606665
* @param {number} [u1] Starting point; see {@link BezierCurve}.
@@ -615,6 +674,8 @@ CurveEval.prototype.normalBezier=function(controlPoints,u1,u2){
615674
}
616675
/**
617676
* Specifies a B&eacute;zier curve used for generating texture coordinates.
677+
* @deprecated Use the <code>texCoord()</code> method instead with a
678+
* BezierCurve object.
618679
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierCurve},
619680
* where each point is a 1- or 2-element array giving the u and v texture coordinates.
620681
* @param {number} [u1] Starting point; see {@link BezierCurve}.
@@ -629,6 +690,8 @@ CurveEval.prototype.texCoordBezier=function(controlPoints,u1,u2){
629690
}
630691
/**
631692
* Specifies a B&eacute;zier curve used for generating color values.
693+
* @deprecated Use the <code>colorBezier()</code> method instead with a
694+
* BezierCurve object.
632695
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierCurve},
633696
* where each point is a 3-element array giving the red, green, and blue
634697
* values of a color.
@@ -717,12 +780,12 @@ CurveEval.prototype.evalCurve=function(mesh,mode,n,u1,u2){
717780
u2=1.0;
718781
}
719782
if(mode==null)mode=Mesh.LINES;
720-
var uv=(u2-u1)/n;
721783
if(mode==Mesh.POINTS)
722784
mesh.mode(Mesh.POINTS)
723785
else if(mode==Mesh.LINES)
724786
mesh.mode(Mesh.LINE_STRIP)
725787
else return this;
788+
var uv=(u2-u1)/n;
726789
for(var i=0; i<=n; i++){
727790
this.evalOne(mesh, u1+i*uv);
728791
}
@@ -859,6 +922,8 @@ SurfaceEval.prototype.texCoord=function(evaluator){
859922
}
860923
/**
861924
* Specifies a B&eacute;zier surface used for generating vertex positions.
925+
* @deprecated Use the <code>vertex()</code> method instead with a
926+
* BezierCurve object.
862927
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierSurface},
863928
* where each point is a 3-element array giving the x, y, and z coordinates of a vertex
864929
* position.
@@ -876,6 +941,8 @@ SurfaceEval.prototype.vertexBezier=function(controlPoints,u1,u2,v1,v2){
876941
}
877942
/**
878943
* Specifies a B&eacute;zier surface used for generating normals.
944+
* @deprecated Use the <code>normal()</code> method instead with a
945+
* BezierCurve object.
879946
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierSurface},
880947
* where each point is a 3-element array giving the x, y, and z coordinates of a normal.
881948
* @param {number} [u1] Starting point along the U axis; see {@link BezierSurface}.
@@ -892,6 +959,8 @@ SurfaceEval.prototype.normalBezier=function(controlPoints,u1,u2,v1,v2){
892959
}
893960
/**
894961
* Specifies a B&eacute;zier surface used for generating texture coordinates.
962+
* @deprecated Use the <code>texCoord()</code> method instead with a
963+
* BezierCurve object.
895964
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierSurface},
896965
* where each point is a 1- or 2-element array giving the u and v texture coordinates.
897966
* @param {number} [u1] Starting point along the U axis; see {@link BezierSurface}.
@@ -908,6 +977,8 @@ SurfaceEval.prototype.texCoordBezier=function(controlPoints,u1,u2,v1,v2){
908977
}
909978
/**
910979
* Specifies a B&eacute;zier surface used for generating color values.
980+
* @deprecated Use the <code>color()</code> method instead with a
981+
* BezierCurve object.
911982
* @param {Array<Array<number>>} controlPoints Control points as specified in {@link BezierSurface},
912983
* where each point is a 3-element array giving the red, green, and blue
913984
* values of a color.
@@ -946,9 +1017,13 @@ SurfaceEval.prototype.evalOne=function(mesh,u,v){
9461017
this._restoreValues(mesh,values,0);
9471018
return this;
9481019
}
949-
/** @private */
1020+
/** @private
1021+
@const
1022+
*/
9501023
var _OLD_VALUES_SIZE = 8;
951-
/** @private */
1024+
/** @private
1025+
@const
1026+
*/
9521027
var _RECORDED_VALUES_SIZE = 11;
9531028
/** @private */
9541029
SurfaceEval.prototype._recordAndPlayBack=function(mesh,u,v,buffer,index){

0 commit comments

Comments
 (0)