Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. class MyCylinder extends CGFobject
  2. {
  3. constructor(scene, base, top, height, slices, stacks)
  4. {
  5. super(scene);
  6.  
  7. this.scene = scene;
  8. this.slices = slices;
  9. this.stacks = stacks;
  10. this.height = height;
  11. this.rtop = top;
  12. this.rbase = base;
  13.  
  14. this.baselessCylinder = new MyBaselessCylinder(scene, base, top, height, slices, stacks);
  15.  
  16. this.top = new MyCircle(scene, slices);
  17.  
  18. this.bottom = new MyCircle(scene, slices);
  19.  
  20. this.display();
  21. };
  22.  
  23. display()
  24. {
  25. this.baselessCylinder.display();
  26.  
  27. this.scene.pushMatrix();
  28. this.scene.translate(0, 0, this.height);
  29. if(this.top !=null){
  30. this.scene.pushMatrix();
  31. this.scene.scale(this.rtop,this.rtop,1);
  32. this.top.display();
  33. this.scene.popMatrix();
  34. }
  35. this.scene.popMatrix();
  36.  
  37. this.scene.pushMatrix();
  38. this.scene.rotate(Math.PI, 0, 1, 0);
  39. this.scene.scale(-1, -1, 1);
  40. if(this.bottom !=null){
  41. this.scene.pushMatrix();
  42. this.scene.scale(this.rbase,this.rbase,1);
  43. this.bottom.display();
  44. this.scene.popMatrix();
  45. }
  46. this.scene.popMatrix();
  47. };
  48. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement