home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2005 May / PC för Alla 0505.iso / fullversioner / realsoft3d / data1.cab / Scripting / scripts / js / myclasses / toolbars / mytransform.js < prev    next >
Encoding:
Text File  |  2005-04-04  |  1.8 KB  |  78 lines

  1.  
  2. //
  3. // Description:
  4. //     Tool Bar example. This JavaScript program defines new class called
  5. //      myTransformTools. It creates a tool bar consisting 
  6. //      of two tool buttons: Move and Scale. 
  7. //
  8. // Super class:
  9. //      myclasses/toolbars/toolbar.js
  10. //
  11. // Constructor:
  12. //      toolbar = new myTransformTools(Integer Orientation);
  13. //
  14. // Methods:
  15. //      --
  16. //
  17.  
  18. include("myclasses/toolbars/mytoolbar.js"); // our super class
  19. include("real/layer/r3prilay.js");          // geometrics objects
  20.  
  21.  
  22. // --- Functionality for our tool buttons ---
  23.  
  24. function mytrMove(button, event, value)
  25. {
  26.     var m = new r3Matrix();
  27.  
  28.     m.identity();
  29.     m.translate(0.1, 0.0, 0.0);
  30.     button.layer.TRANSFORM(m);
  31.     return 1;
  32. }
  33.  
  34. function mytrScale(button, event, value)
  35. {
  36.     var m = new r3Matrix();
  37.  
  38.     m.identity();
  39.     m.scale(0.5, 0.5, 0.5);
  40.     button.layer.TRANSFORM(m);
  41.     return 1;
  42. }
  43.  
  44. function mytrRotate(button, event, value)
  45. {
  46.     m = new r3Matrix();
  47.     vAxis = new r3Vect(0, 0, 1);
  48.     
  49.     m.identity();
  50.     m.rotate(Math.PI/2, vAxis);
  51.     button.layer.TRANSFORM(m);
  52.     return 1;
  53. }
  54.  
  55. // --- Constructor for our transformation tool bar --- 
  56.  
  57. function myTransformTools(orientation)
  58. {
  59.     // Let the super class to do its job, as usual
  60.     if(arguments.length == 0)
  61.         return;
  62.     
  63.     // create JavaScript interface for accessing geometric objects layer
  64.     primLayer = new r3Primlayer();
  65.     primLayer.r3Attach(Get("CurrentProject.Geometrics"));
  66.  
  67.     // call super class constructor, as usual
  68.     this.base = myToolBar; 
  69.     this.base("Transformation Tools", orientation, primLayer);
  70.  
  71.     // Add tool buttons.
  72.     this.AddTool("Move", mytrMove);
  73.     this.AddTool("Scale", mytrScale);
  74.     this.AddTool("Rotate", mytrRotate);
  75. }
  76.  
  77. myTransformTools.prototype=new myToolBar;
  78.