Skip to content

Commit 022183a

Browse files
committed
modify docs and a demo; fix issues with glutil-eval.js
1 parent 6cf9703 commit 022183a

File tree

4 files changed

+167
-142
lines changed

4 files changed

+167
-142
lines changed

demos/surfaces.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<a href="javascript:link1()">Superellipsoid</a>,
1515
<a href="javascript:link2()">Klein bottle</a>,
1616
<a href="javascript:link3()">M&ouml;bius strip</a>,
17+
<a href="javascript:link3a()">M&ouml;bius-like strip</a>,
1718
<a href="javascript:link4()">Surface of revolution for f(x) = sin x</a>,
1819
<a href="javascript:link5()">Surface of revolution for f(x) = x<sup>2</sup></a>,
1920
<a href="javascript:link6()">Supertoroid</a>
@@ -123,7 +124,25 @@
123124
}
124125
}
125126

126-
var MoebiusStrip=function(maj, a, b){
127+
var MoebiusStrip=function(radius,width){
128+
this.radius=radius==null ? 1 : radius;
129+
this.width=width==null ? 0.5 : width;
130+
this.evaluate=function(u,v){
131+
u=-this.width+(this.width*2)*u;
132+
v*=GLMath.PiTimes2;
133+
var x, y, z;
134+
var sinv=Math.sin(v);
135+
var cosv=Math.cos(v);
136+
var sinv2=Math.sin(v/2);
137+
var tmp=u*Math.cos(v/2)+this.radius;
138+
x=cosv*tmp;
139+
y=sinv*tmp;
140+
z=sinv2*u;
141+
return [x,y,z]
142+
}
143+
}
144+
145+
var MoebiusLikeStrip=function(maj, a, b){
127146
this.maj=maj==null ? 1.25 : maj
128147
this.a=a==null ? 0.125 : a
129148
this.b=b==null ? 0.5 : b
@@ -192,6 +211,11 @@
192211
scene.addShape(shape=scene.makeShape(makeMesh(new MoebiusStrip())).setMaterial(material));
193212
}
194213

214+
215+
function link3a(){
216+
scene.removeShape(shape);
217+
scene.addShape(shape=scene.makeShape(makeMesh(new MoebiusLikeStrip())).setMaterial(material));
218+
}
195219
function link4(){
196220
scene.removeShape(shape);
197221
scene.addShape(shape=scene.makeShape(makeMesh(new RevolutionSurface(function(x){

glutil-eval.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ at: http://upokecenter.dreamhosters.com/articles/donate-now-2/
88
*/
99
(function(global){
1010
/** @private */
11+
function BernsteinEval(order){
12+
this.order=order;
13+
this.n=this.order-1;
14+
}
15+
/** @private */
1116
BernsteinEval._binomial=[ [1],
1217
[1,1],
1318
[1,2,1],
@@ -42,11 +47,6 @@ BernsteinEval._factorial=function(n) {
4247
return result;
4348
}
4449
/** @private */
45-
function BernsteinEval(order){
46-
this.order=order;
47-
this.n=this.order-1;
48-
}
49-
/** @private */
5050
BernsteinEval.prototype.getFactor=function(t, i){
5151
var bino;
5252
if(i==0){
@@ -253,7 +253,7 @@ function BezierSurface(cp, u1, u2, v1, v2){
253253
* @class
254254
* @alias CurveEval
255255
*/
256-
function CurveEval(){
256+
var CurveEval=function(){
257257
this.colorCurve=null;
258258
this.normalCurve=null;
259259
this.texCoordCurve=null;
@@ -455,7 +455,7 @@ CurveEval.prototype.evalCurve=function(mesh,mode,n,u1,u2){
455455
* @class
456456
* @alias glutil.SurfaceEval
457457
*/
458-
this.SurfaceEval=function(){
458+
var SurfaceEval=function(){
459459
this.colorSurface=null;
460460
this.normalSurface=null;
461461
this.texCoordSurface=null;
@@ -743,4 +743,6 @@ SurfaceEval.prototype.evalSurface=function(mesh,mode,un,vn,u1,u2,v1,v2){
743743
}
744744
return this;
745745
}
746+
global.SurfaceEval=SurfaceEval;
747+
global.CurveEval=CurveEval;
746748
})(this);

0 commit comments

Comments
 (0)