#VRML V2.0 utf8 PROTO RevolveZ [ field SFInt32 spineSides 3 field MFVec2f crossSection [ ] field SFBool ccw TRUE field SFBool convex TRUE field SFFloat creaseAngle 0 field SFBool solid TRUE field SFBool offset FALSE ] { DEF EX Extrusion { crossSection [] spine [] beginCap FALSE endCap FALSE ccw IS ccw convex IS convex creaseAngle IS creaseAngle solid IS solid } Script { field SFInt32 s IS spineSides field MFVec2f c IS crossSection field SFNode e USE EX field SFInt32 l 0 field SFInt32 i 0 field SFInt32 m 0 field SFInt32 os 0 field SFFloat ps 0 field SFFloat p 0 field SFFloat r 0 #radius field MFVec3f st [] # spine temp field SFBool ofs IS offset url [ "javascript: function initialize() { //find biggest x in crossSection l = c.length; for ( i = 0; i < l; i++ ) { if ( c[i].x > c[m].x ) { m = i; } } r = c[m].x; //move crossSection to Center for ( i = 0; i < l; i++ ) { c[i].x = c[i].x - r; } if ( ofs ){ os = 1; }; //compute the spine ps = Math.PI / s; for (i = 0; i < s; i++) { p = ps * (i * 2 + os); st[i] = new SFVec3f( r * Math.cos(p), r * Math.sin(p),0); } st[s] = st[0]; e.set_crossSection = c; e.set_spine = st; } " ] } }