@@ -159,17 +159,14 @@ function BezierCurve(cp, u1, u2){
159159 * in a Bézier curve.
160160 * @param {number } u Point on the curve to evaluate (generally within the range
161161 * given in the constructor).
162- * @param {Array<number> } output Array where the result of
163- * the evaluation will be stored. A number of elements equal to the
164- * length of a control point, as specified in the constructor, will be
165- * written to the array, starting with the first element.
166- * @return {number } Number of values written to the
167- * output array, which is the length of control points associated with the
168- * evaluator.
162+ * @return An array of the result of
163+ * the evaluation. Its length will be equal to the
164+ * length of a control point, as specified in the constructor.
169165 */
170- BezierCurve . prototype . evaluate = function ( u , output ) {
166+ BezierCurve . prototype . evaluate = function ( u ) {
167+ var output = [ ] ;
171168 this . evaluator . evaluate ( ( u - this . uoffset ) * this . umul , output ) ;
172- return this . k ;
169+ return output ;
173170}
174171/**
175172 * A parametric evaluator for Bézier surfaces.<p>
@@ -231,18 +228,15 @@ function BezierSurface(cp, u1, u2, v1, v2){
231228 * @param {number } u U-coordinate of the surface to evaluate (generally within the range
232229 * given in the constructor).
233230 * @param {number } v V-coordinate of the surface to evaluate.
234- * @param {Array<number> } output Array where the result of
235- * the evaluation will be stored. A number of elements equal to the
236- * length of a control point, as specified in the constructor, will be
237- * written to the array, starting with the first element.
238- * @return {number } Number of values written to the
239- * output array, which is the length of control points associated with the
240- * evaluator.
231+ * @return An array of the result of
232+ * the evaluation. Its length will be equal to the
233+ * length of a control point, as specified in the constructor.
241234 */
242235 BezierSurface . prototype . evaluate = function ( u , v , output ) {
236+ var output = [ ] ;
243237 this . evaluator . evaluate ( ( u - this . uoffset ) * this . umul ,
244238 ( v - this . voffset ) * this . vmul , output ) ;
245- return this . k ;
239+ return output ;
246240}
247241
248242/**
@@ -265,11 +259,8 @@ function CurveEval(){
265259* named "evaluate". It takes the following parameters in this order:<ul>
266260* <li><code>u</code> - Horizontal-axis coordinate, generally from 0 to 1.
267261* <li><code>v</code> - Vertical-axis coordinate, generally from 0 to 1.
268- * <li><code>output</code> - Array to store the result of the evaluation. It is
269- * expected to write 3 values to the array starting with the first element.
270262* </ul>
271- * The evaluator function returns the number of values it wrote to the "output"
272- * array.
263+ * The evaluator function returns an array of the result of the evaluation.
273264* @return {CurveEval } This object.
274265*/
275266CurveEval . prototype . vertex = function ( evaluator ) {
@@ -385,26 +376,23 @@ CurveEval.prototype.evaluate=function(mesh,u){
385376 var normal = null ;
386377 var texcoord = null ;
387378 if ( this . colorCurve ) {
388- color = [ ] ;
389- this . colorCurve . evaluate ( u , color ) ;
379+ color = this . colorCurve . evaluate ( u ) ;
390380 }
391381 if ( this . texCoordCurve ) {
392- texcoord = [ 0 , 0 ] ;
393- this . texCoordCurve . evaluate ( u , color ) ;
382+ texcoord = this . texCoordCurve . evaluate ( u ) ;
383+ if ( texcoord . length == 1 ) texcoord . push ( 0 ) ;
394384 }
395385 if ( this . normalCurve ) {
396- normal = [ ] ;
397- this . normalCurve . evaluate ( u , color ) ;
386+ normal = this . normalCurve . evaluate ( u ) ;
398387 }
399388 if ( this . vertexCurve ) {
400- var vertex = [ ] ;
401389 var oldColor = ( color ) ? mesh . color . slice ( 0 , 3 ) : null ;
402390 var oldNormal = ( normal ) ? mesh . normal . slice ( 0 , 3 ) : null ;
403391 var oldTexCoord = ( texcoord ) ? mesh . texCoord . slice ( 0 , 3 ) : null ;
404392 if ( color ) mesh . color3 ( color [ 0 ] , color [ 1 ] , color [ 2 ] ) ;
405393 if ( normal ) mesh . normal3 ( normal [ 0 ] , normal [ 1 ] , normal [ 2 ] ) ;
406394 if ( texcoord ) mesh . texCoord3 ( texcoord [ 0 ] , texcoord [ 1 ] , texcoord [ 2 ] ) ;
407- this . vertexCurve . evaluate ( u , vertex ) ;
395+ var vertex = this . vertexCurve . evaluate ( u ) ;
408396 mesh . vertex3 ( vertex [ 0 ] , vertex [ 1 ] , vertex [ 2 ] ) ;
409397 if ( oldColor ) mesh . color3 ( oldColor [ 0 ] , oldColor [ 1 ] , oldColor [ 2 ] ) ;
410398 if ( oldNormal ) mesh . normal3 ( oldNormal [ 0 ] , oldNormal [ 1 ] , oldNormal [ 2 ] ) ;
@@ -486,11 +474,8 @@ SurfaceEval.prototype.setAutoNormal=function(value){
486474* named "evaluate". It takes the following parameters in this order:<ul>
487475* <li><code>u</code> - Horizontal-axis coordinate, generally from 0 to 1.
488476* <li><code>v</code> - Vertical-axis coordinate, generally from 0 to 1.
489- * <li><code>output</code> - Array to store the result of the evaluation. It is
490- * expected to write 3 values to the array starting with the first element.
491477* </ul>
492- * The evaluator function returns the number of values it wrote to the "output"
493- * array.
478+ * The evaluator function returns an array of the result of the evaluation.
494479* @return {SurfaceEval } This object.
495480*/
496481SurfaceEval . prototype . vertex = function ( evaluator ) {
@@ -615,32 +600,28 @@ SurfaceEval.prototype.evaluate=function(mesh,u,v){
615600 var normal = null ;
616601 var texcoord = null ;
617602 if ( this . colorSurface ) {
618- color = [ ] ;
619- this . colorSurface . evaluate ( u , v , color ) ;
603+ color = this . colorSurface . evaluate ( u , v ) ;
620604 }
621605 if ( this . texCoordSurface ) {
622- texcoord = [ 0 , 0 ] ;
623- this . texCoordSurface . evaluate ( u , v , texcoord ) ;
606+ texcoord = this . texCoordSurface . evaluate ( u , v ) ;
607+ if ( texcoord . length == 1 ) texcoord . push ( 0 ) ;
624608 }
625609 if ( this . normalSurface && ! this . autoNormal ) {
626- normal = [ ] ;
627- this . normalSurface . evaluate ( u , v , normal ) ;
610+ normal = this . normalSurface . evaluate ( u , v ) ;
628611 }
629612 if ( this . vertexSurface ) {
630- var vertex = [ ] ;
613+ var vertex ;
631614 var oldColor = ( color ) ? mesh . color . slice ( 0 , 3 ) : null ;
632615 var oldNormal = ( normal || this . autoNormal ) ? mesh . normal . slice ( 0 , 3 ) : null ;
633616 var oldTexCoord = ( texcoord ) ? mesh . texCoord . slice ( 0 , 3 ) : null ;
634617 if ( color ) mesh . color3 ( color [ 0 ] , color [ 1 ] , color [ 2 ] ) ;
635- this . vertexSurface . evaluate ( u , v , vertex ) ;
618+ vertex = this . vertexSurface . evaluate ( u , v ) ;
636619 if ( this . autoNormal ) {
637620 var du = 0.001
638621 var dv = 0.001
639- var vv = [ ] ;
640- var vu = [ ] ;
641622 // Find the derivatives of u and v
642- this . vertexSurface . evaluate ( u + du , v , vu ) ;
643- this . vertexSurface . evaluate ( u , v + dv , vv ) ;
623+ var vu = this . vertexSurface . evaluate ( u + du , v ) ;
624+ var vv = this . vertexSurface . evaluate ( u , v + dv ) ;
644625 GLMath . vec3subInPlace ( vv , vertex ) ;
645626 GLMath . vec3subInPlace ( vu , vertex ) ;
646627 // Divide by the deltas of u and v
0 commit comments