home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / org / papervision3d / objects / DisplayObject3D.as
Encoding:
Text File  |  2010-06-23  |  33.2 KB  |  1,075 lines

  1. package org.papervision3d.objects
  2. {
  3.    import org.papervision3d.Papervision3D;
  4.    import org.papervision3d.core.data.UserData;
  5.    import org.papervision3d.core.geom.renderables.Triangle3D;
  6.    import org.papervision3d.core.log.PaperLogger;
  7.    import org.papervision3d.core.material.AbstractLightShadeMaterial;
  8.    import org.papervision3d.core.math.Matrix3D;
  9.    import org.papervision3d.core.math.Number3D;
  10.    import org.papervision3d.core.math.Quaternion;
  11.    import org.papervision3d.core.proto.CameraObject3D;
  12.    import org.papervision3d.core.proto.DisplayObjectContainer3D;
  13.    import org.papervision3d.core.proto.GeometryObject3D;
  14.    import org.papervision3d.core.proto.MaterialObject3D;
  15.    import org.papervision3d.core.proto.SceneObject3D;
  16.    import org.papervision3d.core.render.data.RenderSessionData;
  17.    import org.papervision3d.materials.shaders.ShadedMaterial;
  18.    import org.papervision3d.materials.utils.MaterialsList;
  19.    import org.papervision3d.view.Viewport3D;
  20.    import org.papervision3d.view.layer.ViewportLayer;
  21.    
  22.    public class DisplayObject3D extends DisplayObjectContainer3D
  23.    {
  24.       public static var faceLevelMode:Boolean;
  25.       
  26.       public static const MESH_SORT_CENTER:uint = 1;
  27.       
  28.       public static const MESH_SORT_FAR:uint = 2;
  29.       
  30.       public static const MESH_SORT_CLOSE:uint = 3;
  31.       
  32.       public static var sortedArray:Array = new Array();
  33.       
  34.       private static const FORWARD:Number3D = new Number3D(0,0,1);
  35.       
  36.       private static const BACKWARD:Number3D = new Number3D(0,0,-1);
  37.       
  38.       private static const LEFT:Number3D = new Number3D(-1,0,0);
  39.       
  40.       private static const RIGHT:Number3D = new Number3D(1,0,0);
  41.       
  42.       private static const UP:Number3D = new Number3D(0,1,0);
  43.       
  44.       private static const DOWN:Number3D = new Number3D(0,-1,0);
  45.       
  46.       private static var _tempMatrix:Matrix3D = Matrix3D.IDENTITY;
  47.       
  48.       private static var _tempQuat:Quaternion = new Quaternion();
  49.       
  50.       private static var _newID:int = 0;
  51.       
  52.       private static var toDEGREES:Number = 180 / Math.PI;
  53.       
  54.       private static var toRADIANS:Number = Math.PI / 180;
  55.       
  56.       private static var entry_count:uint = 0;
  57.       
  58.       public var extra:Object;
  59.       
  60.       public var frustumTestMethod:int = 0;
  61.       
  62.       private var _rot:Quaternion = new Quaternion();
  63.       
  64.       public var id:int;
  65.       
  66.       private var _rotationY:Number;
  67.       
  68.       private var _rotationZ:Number;
  69.       
  70.       public var cullTest:Number = 0;
  71.       
  72.       private var _lookatTarget:Number3D = Number3D.ZERO;
  73.       
  74.       public var materials:MaterialsList;
  75.       
  76.       public var meshSort:uint = 1;
  77.       
  78.       private var _rotationX:Number;
  79.       
  80.       private var _qYaw:Quaternion = new Quaternion();
  81.       
  82.       private var _xAxis:Number3D = Number3D.ZERO;
  83.       
  84.       private var _zAxis:Number3D = Number3D.ZERO;
  85.       
  86.       private var _scaleDirty:Boolean = false;
  87.       
  88.       private var _autoCalcScreenCoords:Boolean = false;
  89.       
  90.       private var _tempScale:Number3D;
  91.       
  92.       private var _numClones:uint = 0;
  93.       
  94.       public var alpha:Number = 1;
  95.       
  96.       public var useClipping:Boolean = true;
  97.       
  98.       public var screen:Number3D = new Number3D();
  99.       
  100.       private var _scaleX:Number;
  101.       
  102.       private var _scaleY:Number;
  103.       
  104.       private var _scaleZ:Number;
  105.       
  106.       public var geometry:GeometryObject3D;
  107.       
  108.       private var _qPitch:Quaternion = new Quaternion();
  109.       
  110.       public var visible:Boolean;
  111.       
  112.       protected var _userData:UserData;
  113.       
  114.       public var screenZ:Number;
  115.       
  116.       public var container:ViewportLayer;
  117.       
  118.       protected var _useOwnContainer:Boolean = false;
  119.       
  120.       public var transform:Matrix3D;
  121.       
  122.       private var _material:MaterialObject3D;
  123.       
  124.       private var _position:Number3D = Number3D.ZERO;
  125.       
  126.       public var name:String;
  127.       
  128.       protected var _scene:SceneObject3D = null;
  129.       
  130.       private var _qRoll:Quaternion = new Quaternion();
  131.       
  132.       private var _localRotationZ:Number = 0;
  133.       
  134.       public var culled:Boolean;
  135.       
  136.       public var world:Matrix3D;
  137.       
  138.       public var blendMode:String = "normal";
  139.       
  140.       private var _localRotationX:Number = 0;
  141.       
  142.       private var _localRotationY:Number = 0;
  143.       
  144.       public var view:Matrix3D;
  145.       
  146.       public var parent:DisplayObjectContainer3D;
  147.       
  148.       public var faces:Array = new Array();
  149.       
  150.       private var _yAxis:Number3D = Number3D.ZERO;
  151.       
  152.       public var flipLightDirection:Boolean = false;
  153.       
  154.       private var _rotation:Number3D = Number3D.ZERO;
  155.       
  156.       protected var _transformDirty:Boolean = false;
  157.       
  158.       protected var _sorted:Array;
  159.       
  160.       private var _rotationDirty:Boolean = false;
  161.       
  162.       public var parentContainer:DisplayObject3D;
  163.       
  164.       public var testQuad:Boolean = true;
  165.       
  166.       public var filters:Array = [];
  167.       
  168.       public function DisplayObject3D(param1:String = null, param2:GeometryObject3D = null)
  169.       {
  170.          super();
  171.          if(param1 != null)
  172.          {
  173.             PaperLogger.info("DisplayObject3D: " + param1);
  174.          }
  175.          this.culled = false;
  176.          this.transform = Matrix3D.IDENTITY;
  177.          this.world = Matrix3D.IDENTITY;
  178.          this.view = Matrix3D.IDENTITY;
  179.          this.x = 0;
  180.          this.y = 0;
  181.          this.z = 0;
  182.          this.rotationX = 0;
  183.          this.rotationY = 0;
  184.          this.rotationZ = 0;
  185.          this._localRotationX = this._localRotationY = this._localRotationZ = 0;
  186.          var _loc3_:Number = Papervision3D.usePERCENT ? 100 : 1;
  187.          this.scaleX = _loc3_;
  188.          this.scaleY = _loc3_;
  189.          this.scaleZ = _loc3_;
  190.          this._tempScale = new Number3D();
  191.          this.visible = true;
  192.          this.id = _newID++;
  193.          this.name = param1 || String(this.id);
  194.          this._numClones = 0;
  195.          if(param2)
  196.          {
  197.             this.addGeometry(param2);
  198.          }
  199.       }
  200.       
  201.       public static function get ZERO() : DisplayObject3D
  202.       {
  203.          return new DisplayObject3D();
  204.       }
  205.       
  206.       public function set localRotationX(param1:Number) : void
  207.       {
  208.          param1 = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  209.          if(this._transformDirty)
  210.          {
  211.             this.updateTransform();
  212.          }
  213.          this._qPitch.setFromAxisAngle(this.transform.n11,this.transform.n21,this.transform.n31,this._localRotationX - param1);
  214.          this.transform.calculateMultiply3x3(this._qPitch.matrix,this.transform);
  215.          this._localRotationX = param1;
  216.          this._rotationDirty = true;
  217.       }
  218.       
  219.       public function set y(param1:Number) : void
  220.       {
  221.          this.transform.n24 = param1;
  222.       }
  223.       
  224.       public function set z(param1:Number) : void
  225.       {
  226.          this.transform.n34 = param1;
  227.       }
  228.       
  229.       override public function addChild(param1:DisplayObject3D, param2:String = null) : DisplayObject3D
  230.       {
  231.          param1 = super.addChild(param1,param2);
  232.          if(param1.scene == null)
  233.          {
  234.             param1.scene = this.scene;
  235.          }
  236.          if(this.useOwnContainer)
  237.          {
  238.             param1.parentContainer = this;
  239.          }
  240.          return param1;
  241.       }
  242.       
  243.       public function setChildMaterialByName(param1:String, param2:MaterialObject3D) : void
  244.       {
  245.          this.setChildMaterial(getChildByName(param1,true),param2);
  246.       }
  247.       
  248.       public function moveDown(param1:Number) : void
  249.       {
  250.          this.translate(param1,DOWN);
  251.       }
  252.       
  253.       public function project(param1:DisplayObject3D, param2:RenderSessionData) : Number
  254.       {
  255.          var _loc5_:DisplayObject3D = null;
  256.          if(this._transformDirty)
  257.          {
  258.             this.updateTransform();
  259.          }
  260.          this.world.calculateMultiply(param1.world,this.transform);
  261.          if(param2.camera.culler)
  262.          {
  263.             if(this === param2.camera)
  264.             {
  265.                this.culled = true;
  266.             }
  267.             else
  268.             {
  269.                this.culled = param2.camera.culler.testObject(this) < 0;
  270.             }
  271.             if(this.culled)
  272.             {
  273.                ++param2.renderStatistics.culledObjects;
  274.                return 0;
  275.             }
  276.          }
  277.          else
  278.          {
  279.             this.culled = false;
  280.          }
  281.          if(param1 !== param2.camera)
  282.          {
  283.             if(param2.camera.useProjectionMatrix)
  284.             {
  285.                this.view.calculateMultiply4x4(param1.view,this.transform);
  286.             }
  287.             else
  288.             {
  289.                this.view.calculateMultiply(param1.view,this.transform);
  290.             }
  291.          }
  292.          else if(param2.camera.useProjectionMatrix)
  293.          {
  294.             this.view.calculateMultiply4x4(param2.camera.eye,this.transform);
  295.          }
  296.          else
  297.          {
  298.             this.view.calculateMultiply(param2.camera.eye,this.transform);
  299.          }
  300.          if(this._autoCalcScreenCoords)
  301.          {
  302.             this.calculateScreenCoords(param2.camera);
  303.          }
  304.          var _loc3_:Number = 0;
  305.          var _loc4_:Number = 0;
  306.          for each(_loc5_ in this._childrenByName)
  307.          {
  308.             if(_loc5_.visible)
  309.             {
  310.                _loc3_ += _loc5_.project(this,param2);
  311.                _loc4_++;
  312.             }
  313.          }
  314.          return this.screenZ = _loc3_ / _loc4_;
  315.       }
  316.       
  317.       public function set scene(param1:SceneObject3D) : void
  318.       {
  319.          var _loc2_:DisplayObject3D = null;
  320.          this._scene = param1;
  321.          for each(_loc2_ in this._childrenByName)
  322.          {
  323.             if(_loc2_.scene == null)
  324.             {
  325.                _loc2_.scene = this._scene;
  326.             }
  327.          }
  328.       }
  329.       
  330.       public function setChildMaterial(param1:DisplayObject3D, param2:MaterialObject3D, param3:MaterialObject3D = null) : void
  331.       {
  332.          var _loc4_:Triangle3D = null;
  333.          if(!param1)
  334.          {
  335.             return;
  336.          }
  337.          if(!param3 || param1.material === param3)
  338.          {
  339.             param1.material = param2;
  340.          }
  341.          if(Boolean(param1.geometry) && Boolean(param1.geometry.faces))
  342.          {
  343.             for each(_loc4_ in param1.geometry.faces)
  344.             {
  345.                if(!param3 || _loc4_.material === param3)
  346.                {
  347.                   _loc4_.material = param2;
  348.                }
  349.             }
  350.          }
  351.       }
  352.       
  353.       public function get userData() : UserData
  354.       {
  355.          return this._userData;
  356.       }
  357.       
  358.       public function get material() : MaterialObject3D
  359.       {
  360.          return this._material;
  361.       }
  362.       
  363.       public function set userData(param1:UserData) : void
  364.       {
  365.          this._userData = param1;
  366.       }
  367.       
  368.       public function set rotationX(param1:Number) : void
  369.       {
  370.          this._rotationX = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  371.          this._transformDirty = true;
  372.       }
  373.       
  374.       public function calculateScreenCoords(param1:CameraObject3D) : void
  375.       {
  376.          var _loc2_:Number = NaN;
  377.          var _loc3_:Number = NaN;
  378.          var _loc4_:Number = NaN;
  379.          var _loc5_:Number = NaN;
  380.          var _loc6_:Number = NaN;
  381.          var _loc7_:Number = NaN;
  382.          var _loc8_:Number = NaN;
  383.          if(param1.useProjectionMatrix)
  384.          {
  385.             _loc2_ = 0;
  386.             _loc3_ = 0;
  387.             _loc4_ = 0;
  388.             _loc5_ = _loc2_ * this.view.n41 + _loc3_ * this.view.n42 + _loc4_ * this.view.n43 + this.view.n44;
  389.             _loc6_ = param1.viewport.width / 2;
  390.             _loc7_ = param1.viewport.height / 2;
  391.             this.screen.x = (_loc2_ * this.view.n11 + _loc3_ * this.view.n12 + _loc4_ * this.view.n13 + this.view.n14) / _loc5_;
  392.             this.screen.y = (_loc2_ * this.view.n21 + _loc3_ * this.view.n22 + _loc4_ * this.view.n23 + this.view.n24) / _loc5_;
  393.             this.screen.z = _loc2_ * this.view.n31 + _loc3_ * this.view.n32 + _loc4_ * this.view.n33 + this.view.n34;
  394.             this.screen.x *= _loc6_;
  395.             this.screen.y *= _loc7_;
  396.          }
  397.          else
  398.          {
  399.             _loc8_ = param1.focus * param1.zoom / (param1.focus + this.view.n34);
  400.             this.screen.x = this.view.n14 * _loc8_;
  401.             this.screen.y = this.view.n24 * _loc8_;
  402.             this.screen.z = this.view.n34;
  403.          }
  404.       }
  405.       
  406.       public function lookAt(param1:DisplayObject3D, param2:Number3D = null) : void
  407.       {
  408.          var _loc3_:DisplayObject3D = null;
  409.          var _loc4_:Matrix3D = null;
  410.          if(this is CameraObject3D)
  411.          {
  412.             this._position.reset(this.x,this.y,this.z);
  413.          }
  414.          else
  415.          {
  416.             _loc3_ = this.parent as DisplayObject3D;
  417.             if(_loc3_)
  418.             {
  419.                this.world.calculateMultiply(_loc3_.world,this.transform);
  420.             }
  421.             else
  422.             {
  423.                this.world.copy(this.transform);
  424.             }
  425.             this._position.reset(this.world.n14,this.world.n24,this.world.n34);
  426.          }
  427.          if(param1 is CameraObject3D)
  428.          {
  429.             this._lookatTarget.reset(param1.x,param1.y,param1.z);
  430.          }
  431.          else
  432.          {
  433.             _loc3_ = param1.parent as DisplayObject3D;
  434.             if(_loc3_)
  435.             {
  436.                param1.world.calculateMultiply(_loc3_.world,param1.transform);
  437.             }
  438.             else
  439.             {
  440.                param1.world.copy(param1.transform);
  441.             }
  442.             this._lookatTarget.reset(param1.world.n14,param1.world.n24,param1.world.n34);
  443.          }
  444.          this._zAxis.copyFrom(this._lookatTarget);
  445.          this._zAxis.minusEq(this._position);
  446.          this._zAxis.normalize();
  447.          if(this._zAxis.modulo > 0.1)
  448.          {
  449.             this._xAxis = Number3D.cross(this._zAxis,param2 || UP,this._xAxis);
  450.             this._xAxis.normalize();
  451.             this._yAxis = Number3D.cross(this._zAxis,this._xAxis,this._yAxis);
  452.             this._yAxis.normalize();
  453.             _loc4_ = this.transform;
  454.             _loc4_.n11 = this._xAxis.x * this._scaleX;
  455.             _loc4_.n21 = this._xAxis.y * this._scaleX;
  456.             _loc4_.n31 = this._xAxis.z * this._scaleX;
  457.             _loc4_.n12 = -this._yAxis.x * this._scaleY;
  458.             _loc4_.n22 = -this._yAxis.y * this._scaleY;
  459.             _loc4_.n32 = -this._yAxis.z * this._scaleY;
  460.             _loc4_.n13 = this._zAxis.x * this._scaleZ;
  461.             _loc4_.n23 = this._zAxis.y * this._scaleZ;
  462.             _loc4_.n33 = this._zAxis.z * this._scaleZ;
  463.             this._localRotationX = this._localRotationY = this._localRotationZ = 0;
  464.             this._transformDirty = false;
  465.             this._rotationDirty = true;
  466.          }
  467.          else
  468.          {
  469.             PaperLogger.error("lookAt error");
  470.          }
  471.       }
  472.       
  473.       public function set rotationZ(param1:Number) : void
  474.       {
  475.          this._rotationZ = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  476.          this._transformDirty = true;
  477.       }
  478.       
  479.       public function pitch(param1:Number) : void
  480.       {
  481.          param1 = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  482.          if(this._transformDirty)
  483.          {
  484.             this.updateTransform();
  485.          }
  486.          this._qPitch.setFromAxisAngle(this.transform.n11,this.transform.n21,this.transform.n31,param1);
  487.          this.transform.calculateMultiply3x3(this._qPitch.matrix,this.transform);
  488.          this._localRotationX += param1;
  489.          this._rotationDirty = true;
  490.       }
  491.       
  492.       public function set rotationY(param1:Number) : void
  493.       {
  494.          this._rotationY = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  495.          this._transformDirty = true;
  496.       }
  497.       
  498.       public function get position() : Number3D
  499.       {
  500.          this._position.reset(this.x,this.y,this.z);
  501.          return this._position;
  502.       }
  503.       
  504.       public function get sceneX() : Number
  505.       {
  506.          return this.world.n14;
  507.       }
  508.       
  509.       public function get scaleX() : Number
  510.       {
  511.          if(Papervision3D.usePERCENT)
  512.          {
  513.             return this._scaleX * 100;
  514.          }
  515.          return this._scaleX;
  516.       }
  517.       
  518.       public function get scaleY() : Number
  519.       {
  520.          if(Papervision3D.usePERCENT)
  521.          {
  522.             return this._scaleY * 100;
  523.          }
  524.          return this._scaleY;
  525.       }
  526.       
  527.       public function get scaleZ() : Number
  528.       {
  529.          if(Papervision3D.usePERCENT)
  530.          {
  531.             return this._scaleZ * 100;
  532.          }
  533.          return this._scaleZ;
  534.       }
  535.       
  536.       public function get scale() : Number
  537.       {
  538.          if(this._scaleX == this._scaleY && this._scaleX == this._scaleZ)
  539.          {
  540.             if(Papervision3D.usePERCENT)
  541.             {
  542.                return this._scaleX * 100;
  543.             }
  544.             return this._scaleX;
  545.          }
  546.          return NaN;
  547.       }
  548.       
  549.       public function set position(param1:Number3D) : void
  550.       {
  551.          this.x = param1.x;
  552.          this.y = param1.y;
  553.          this.z = param1.z;
  554.       }
  555.       
  556.       public function moveUp(param1:Number) : void
  557.       {
  558.          this.translate(param1,UP);
  559.       }
  560.       
  561.       public function get sceneZ() : Number
  562.       {
  563.          return this.world.n34;
  564.       }
  565.       
  566.       public function get sceneY() : Number
  567.       {
  568.          return this.world.n24;
  569.       }
  570.       
  571.       public function distanceTo(param1:DisplayObject3D) : Number
  572.       {
  573.          var _loc2_:Number = this.x - param1.x;
  574.          var _loc3_:Number = this.y - param1.y;
  575.          var _loc4_:Number = this.z - param1.z;
  576.          return Math.sqrt(_loc2_ * _loc2_ + _loc3_ * _loc3_ + _loc4_ * _loc4_);
  577.       }
  578.       
  579.       public function addGeometry(param1:GeometryObject3D = null) : void
  580.       {
  581.          if(param1)
  582.          {
  583.             this.geometry = param1;
  584.          }
  585.       }
  586.       
  587.       protected function setParentContainer(param1:DisplayObject3D, param2:Boolean = true) : void
  588.       {
  589.          var _loc3_:DisplayObject3D = null;
  590.          if(param2 && param1 != this)
  591.          {
  592.             this.parentContainer = param1;
  593.          }
  594.          for each(_loc3_ in children)
  595.          {
  596.             _loc3_.setParentContainer(param1,param2);
  597.          }
  598.       }
  599.       
  600.       private function updateMaterials(param1:DisplayObject3D, param2:MaterialObject3D, param3:MaterialObject3D) : void
  601.       {
  602.          var _loc4_:DisplayObject3D = null;
  603.          var _loc5_:Triangle3D = null;
  604.          param2.unregisterObject(param1);
  605.          if(param3 is AbstractLightShadeMaterial || param3 is ShadedMaterial)
  606.          {
  607.             param3.registerObject(param1);
  608.          }
  609.          if(param1.material === param2)
  610.          {
  611.             param1.material = param3;
  612.          }
  613.          if(param1.geometry && param1.geometry.faces && Boolean(param1.geometry.faces.length))
  614.          {
  615.             for each(_loc5_ in param1.geometry.faces)
  616.             {
  617.                if(_loc5_.material === param2)
  618.                {
  619.                   _loc5_.material = param3;
  620.                }
  621.             }
  622.          }
  623.          for each(_loc4_ in param1.children)
  624.          {
  625.             this.updateMaterials(_loc4_,param2,param3);
  626.          }
  627.       }
  628.       
  629.       public function clone() : DisplayObject3D
  630.       {
  631.          var _loc3_:DisplayObject3D = null;
  632.          var _loc1_:String = this.name + "_" + this._numClones++;
  633.          var _loc2_:DisplayObject3D = new DisplayObject3D(_loc1_);
  634.          if(this.material)
  635.          {
  636.             _loc2_.material = this.material;
  637.          }
  638.          if(this.materials)
  639.          {
  640.             _loc2_.materials = this.materials.clone();
  641.          }
  642.          if(this.geometry)
  643.          {
  644.             _loc2_.geometry = this.geometry.clone(_loc2_);
  645.             _loc2_.geometry.ready = true;
  646.          }
  647.          _loc2_.copyTransform(this);
  648.          for each(_loc3_ in this.children)
  649.          {
  650.             _loc2_.addChild(_loc3_.clone());
  651.          }
  652.          return _loc2_;
  653.       }
  654.       
  655.       public function set material(param1:MaterialObject3D) : void
  656.       {
  657.          if(this._material)
  658.          {
  659.             this._material.unregisterObject(this);
  660.          }
  661.          this._material = param1;
  662.          if(this._material)
  663.          {
  664.             this._material.registerObject(this);
  665.          }
  666.       }
  667.       
  668.       private function updateRotation() : void
  669.       {
  670.          this._tempScale.x = Papervision3D.usePERCENT ? this._scaleX * 100 : this._scaleX;
  671.          this._tempScale.y = Papervision3D.usePERCENT ? this._scaleY * 100 : this._scaleY;
  672.          this._tempScale.z = Papervision3D.usePERCENT ? this._scaleZ * 100 : this._scaleZ;
  673.          this._rotation = Matrix3D.matrix2euler(this.transform,this._rotation,this._tempScale);
  674.          this._rotationX = this._rotation.x * toRADIANS;
  675.          this._rotationY = this._rotation.y * toRADIANS;
  676.          this._rotationZ = this._rotation.z * toRADIANS;
  677.          this._rotationDirty = false;
  678.       }
  679.       
  680.       public function hitTestObject(param1:DisplayObject3D, param2:Number = 1) : Boolean
  681.       {
  682.          var _loc3_:Number = this.x - param1.x;
  683.          var _loc4_:Number = this.y - param1.y;
  684.          var _loc5_:Number = this.z - param1.z;
  685.          var _loc6_:Number = _loc3_ * _loc3_ + _loc4_ * _loc4_ + _loc5_ * _loc5_;
  686.          var _loc7_:Number = !!this.geometry ? this.geometry.boundingSphere.maxDistance : 0;
  687.          var _loc8_:Number = !!param1.geometry ? param1.geometry.boundingSphere.maxDistance : 0;
  688.          _loc7_ *= param2;
  689.          return _loc7_ + _loc8_ > _loc6_;
  690.       }
  691.       
  692.       public function translate(param1:Number, param2:Number3D) : void
  693.       {
  694.          var _loc3_:Number3D = param2.clone();
  695.          if(this._transformDirty)
  696.          {
  697.             this.updateTransform();
  698.          }
  699.          Matrix3D.rotateAxis(this.transform,_loc3_);
  700.          this.x += param1 * _loc3_.x;
  701.          this.y += param1 * _loc3_.y;
  702.          this.z += param1 * _loc3_.z;
  703.       }
  704.       
  705.       public function get localRotationZ() : Number
  706.       {
  707.          return Papervision3D.useDEGREES ? this._localRotationZ * toDEGREES : this._localRotationZ;
  708.       }
  709.       
  710.       public function get localRotationY() : Number
  711.       {
  712.          return Papervision3D.useDEGREES ? this._localRotationY * toDEGREES : this._localRotationY;
  713.       }
  714.       
  715.       public function get z() : Number
  716.       {
  717.          return this.transform.n34;
  718.       }
  719.       
  720.       public function get localRotationX() : Number
  721.       {
  722.          return Papervision3D.useDEGREES ? this._localRotationX * toDEGREES : this._localRotationX;
  723.       }
  724.       
  725.       public function get x() : Number
  726.       {
  727.          return this.transform.n14;
  728.       }
  729.       
  730.       public function get y() : Number
  731.       {
  732.          return this.transform.n24;
  733.       }
  734.       
  735.       public function moveLeft(param1:Number) : void
  736.       {
  737.          this.translate(param1,LEFT);
  738.       }
  739.       
  740.       public function replaceMaterialByName(param1:MaterialObject3D, param2:String) : void
  741.       {
  742.          if(!this.materials)
  743.          {
  744.             return;
  745.          }
  746.          var _loc3_:MaterialObject3D = this.materials.getMaterialByName(param2);
  747.          if(!_loc3_)
  748.          {
  749.             return;
  750.          }
  751.          if(this.material === _loc3_)
  752.          {
  753.             this.material = param1;
  754.          }
  755.          _loc3_ = this.materials.removeMaterial(_loc3_);
  756.          param1 = this.materials.addMaterial(param1,param2);
  757.          this.updateMaterials(this,_loc3_,param1);
  758.       }
  759.       
  760.       public function get scene() : SceneObject3D
  761.       {
  762.          return this._scene;
  763.       }
  764.       
  765.       public function set useOwnContainer(param1:Boolean) : void
  766.       {
  767.          this._useOwnContainer = param1;
  768.          this.setParentContainer(this,true);
  769.       }
  770.       
  771.       public function getMaterialByName(param1:String) : MaterialObject3D
  772.       {
  773.          var _loc3_:DisplayObject3D = null;
  774.          var _loc2_:MaterialObject3D = !!this.materials ? this.materials.getMaterialByName(param1) : null;
  775.          if(_loc2_)
  776.          {
  777.             return _loc2_;
  778.          }
  779.          for each(_loc3_ in this._childrenByName)
  780.          {
  781.             _loc2_ = _loc3_.getMaterialByName(param1);
  782.             if(_loc2_)
  783.             {
  784.                return _loc2_;
  785.             }
  786.          }
  787.          return null;
  788.       }
  789.       
  790.       public function copyTransform(param1:*) : void
  791.       {
  792.          var _loc4_:DisplayObject3D = null;
  793.          if(param1 is DisplayObject3D)
  794.          {
  795.             _loc4_ = DisplayObject3D(param1);
  796.             if(_loc4_._transformDirty)
  797.             {
  798.                _loc4_.updateTransform();
  799.             }
  800.          }
  801.          var _loc2_:Matrix3D = this.transform;
  802.          var _loc3_:Matrix3D = param1 is DisplayObject3D ? param1.transform : param1;
  803.          _loc2_.n11 = _loc3_.n11;
  804.          _loc2_.n12 = _loc3_.n12;
  805.          _loc2_.n13 = _loc3_.n13;
  806.          _loc2_.n14 = _loc3_.n14;
  807.          _loc2_.n21 = _loc3_.n21;
  808.          _loc2_.n22 = _loc3_.n22;
  809.          _loc2_.n23 = _loc3_.n23;
  810.          _loc2_.n24 = _loc3_.n24;
  811.          _loc2_.n31 = _loc3_.n31;
  812.          _loc2_.n32 = _loc3_.n32;
  813.          _loc2_.n33 = _loc3_.n33;
  814.          _loc2_.n34 = _loc3_.n34;
  815.          this._transformDirty = false;
  816.          this._rotationDirty = true;
  817.       }
  818.       
  819.       public function get rotationY() : Number
  820.       {
  821.          if(this._rotationDirty)
  822.          {
  823.             this.updateRotation();
  824.          }
  825.          return Papervision3D.useDEGREES ? this._rotationY * toDEGREES : this._rotationY;
  826.       }
  827.       
  828.       public function get rotationZ() : Number
  829.       {
  830.          if(this._rotationDirty)
  831.          {
  832.             this.updateRotation();
  833.          }
  834.          return Papervision3D.useDEGREES ? this._rotationZ * toDEGREES : this._rotationZ;
  835.       }
  836.       
  837.       public function set scaleY(param1:Number) : void
  838.       {
  839.          if(this._rotationDirty)
  840.          {
  841.             this.updateRotation();
  842.          }
  843.          if(Papervision3D.usePERCENT)
  844.          {
  845.             this._scaleY = param1 / 100;
  846.          }
  847.          else
  848.          {
  849.             this._scaleY = param1;
  850.          }
  851.          this._transformDirty = true;
  852.       }
  853.       
  854.       public function roll(param1:Number) : void
  855.       {
  856.          param1 = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  857.          if(this._transformDirty)
  858.          {
  859.             this.updateTransform();
  860.          }
  861.          this._qRoll.setFromAxisAngle(this.transform.n13,this.transform.n23,this.transform.n33,param1);
  862.          this.transform.calculateMultiply3x3(this._qRoll.matrix,this.transform);
  863.          this._localRotationZ += param1;
  864.          this._rotationDirty = true;
  865.       }
  866.       
  867.       public function set scaleZ(param1:Number) : void
  868.       {
  869.          if(this._rotationDirty)
  870.          {
  871.             this.updateRotation();
  872.          }
  873.          if(Papervision3D.usePERCENT)
  874.          {
  875.             this._scaleZ = param1 / 100;
  876.          }
  877.          else
  878.          {
  879.             this._scaleZ = param1;
  880.          }
  881.          this._transformDirty = true;
  882.       }
  883.       
  884.       public function get rotationX() : Number
  885.       {
  886.          if(this._rotationDirty)
  887.          {
  888.             this.updateRotation();
  889.          }
  890.          return Papervision3D.useDEGREES ? this._rotationX * toDEGREES : this._rotationX;
  891.       }
  892.       
  893.       public function set scale(param1:Number) : void
  894.       {
  895.          if(this._rotationDirty)
  896.          {
  897.             this.updateRotation();
  898.          }
  899.          if(Papervision3D.usePERCENT)
  900.          {
  901.             param1 /= 100;
  902.          }
  903.          this._scaleX = this._scaleY = this._scaleZ = param1;
  904.          this._transformDirty = true;
  905.       }
  906.       
  907.       public function get autoCalcScreenCoords() : Boolean
  908.       {
  909.          return this._autoCalcScreenCoords;
  910.       }
  911.       
  912.       public function yaw(param1:Number) : void
  913.       {
  914.          param1 = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  915.          if(this._transformDirty)
  916.          {
  917.             this.updateTransform();
  918.          }
  919.          this._qYaw.setFromAxisAngle(this.transform.n12,this.transform.n22,this.transform.n32,param1);
  920.          this.transform.calculateMultiply3x3(this._qYaw.matrix,this.transform);
  921.          this._localRotationY += param1;
  922.          this._rotationDirty = true;
  923.       }
  924.       
  925.       public function set scaleX(param1:Number) : void
  926.       {
  927.          if(this._rotationDirty)
  928.          {
  929.             this.updateRotation();
  930.          }
  931.          if(Papervision3D.usePERCENT)
  932.          {
  933.             this._scaleX = param1 / 100;
  934.          }
  935.          else
  936.          {
  937.             this._scaleX = param1;
  938.          }
  939.          this._transformDirty = true;
  940.       }
  941.       
  942.       public function createViewportLayer(param1:Viewport3D, param2:Boolean = true) : ViewportLayer
  943.       {
  944.          var _loc3_:ViewportLayer = param1.getChildLayer(this,true);
  945.          if(param2)
  946.          {
  947.             this.addChildrenToLayer(this,_loc3_);
  948.          }
  949.          return _loc3_;
  950.       }
  951.       
  952.       override public function toString() : String
  953.       {
  954.          return this.name + ": x:" + Math.round(this.x) + " y:" + Math.round(this.y) + " z:" + Math.round(this.z);
  955.       }
  956.       
  957.       public function moveForward(param1:Number) : void
  958.       {
  959.          this.translate(param1,FORWARD);
  960.       }
  961.       
  962.       public function addChildrenToLayer(param1:DisplayObject3D, param2:ViewportLayer) : void
  963.       {
  964.          var _loc3_:DisplayObject3D = null;
  965.          for each(_loc3_ in param1.children)
  966.          {
  967.             param2.addDisplayObject3D(_loc3_);
  968.             _loc3_.addChildrenToLayer(_loc3_,param2);
  969.          }
  970.       }
  971.       
  972.       public function copyPosition(param1:*) : void
  973.       {
  974.          var _loc2_:Matrix3D = this.transform;
  975.          var _loc3_:Matrix3D = param1 is DisplayObject3D ? param1.transform : param1;
  976.          _loc2_.n14 = _loc3_.n14;
  977.          _loc2_.n24 = _loc3_.n24;
  978.          _loc2_.n34 = _loc3_.n34;
  979.       }
  980.       
  981.       public function get useOwnContainer() : Boolean
  982.       {
  983.          return this._useOwnContainer;
  984.       }
  985.       
  986.       public function updateTransform() : void
  987.       {
  988.          this._rot.setFromEuler(this._rotationY,this._rotationZ,this._rotationX);
  989.          this.transform.copy3x3(this._rot.matrix);
  990.          _tempMatrix.reset();
  991.          _tempMatrix.n11 = this._scaleX;
  992.          _tempMatrix.n22 = this._scaleY;
  993.          _tempMatrix.n33 = this._scaleZ;
  994.          this.transform.calculateMultiply(this.transform,_tempMatrix);
  995.          this._transformDirty = false;
  996.       }
  997.       
  998.       public function hitTestPoint(param1:Number, param2:Number, param3:Number) : Boolean
  999.       {
  1000.          var _loc4_:Number = this.x - param1;
  1001.          var _loc5_:Number = this.y - param2;
  1002.          var _loc6_:Number = this.z - param3;
  1003.          var _loc7_:Number = _loc4_ * _loc4_ + _loc5_ * _loc5_ + _loc6_ * _loc6_;
  1004.          var _loc8_:Number = !!this.geometry ? this.geometry.boundingSphere.maxDistance : 0;
  1005.          return _loc8_ > _loc7_;
  1006.       }
  1007.       
  1008.       public function moveBackward(param1:Number) : void
  1009.       {
  1010.          this.translate(param1,BACKWARD);
  1011.       }
  1012.       
  1013.       public function set localRotationY(param1:Number) : void
  1014.       {
  1015.          param1 = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  1016.          if(this._transformDirty)
  1017.          {
  1018.             this.updateTransform();
  1019.          }
  1020.          this._qYaw.setFromAxisAngle(this.transform.n12,this.transform.n22,this.transform.n32,this._localRotationY - param1);
  1021.          this.transform.calculateMultiply3x3(this._qYaw.matrix,this.transform);
  1022.          this._localRotationY = param1;
  1023.          this._rotationDirty = true;
  1024.       }
  1025.       
  1026.       public function set localRotationZ(param1:Number) : void
  1027.       {
  1028.          param1 = Papervision3D.useDEGREES ? param1 * toRADIANS : param1;
  1029.          if(this._transformDirty)
  1030.          {
  1031.             this.updateTransform();
  1032.          }
  1033.          this._qRoll.setFromAxisAngle(this.transform.n13,this.transform.n23,this.transform.n33,this._localRotationZ - param1);
  1034.          this.transform.calculateMultiply3x3(this._qRoll.matrix,this.transform);
  1035.          this._localRotationZ = param1;
  1036.          this._rotationDirty = true;
  1037.       }
  1038.       
  1039.       public function moveRight(param1:Number) : void
  1040.       {
  1041.          this.translate(param1,RIGHT);
  1042.       }
  1043.       
  1044.       public function set x(param1:Number) : void
  1045.       {
  1046.          this.transform.n14 = param1;
  1047.       }
  1048.       
  1049.       public function materialsList() : String
  1050.       {
  1051.          var _loc2_:String = null;
  1052.          var _loc3_:DisplayObject3D = null;
  1053.          var _loc1_:String = "";
  1054.          for(_loc2_ in this.materials)
  1055.          {
  1056.             _loc1_ += _loc2_ + "\n";
  1057.          }
  1058.          for each(_loc3_ in this._childrenByName)
  1059.          {
  1060.             for(_loc2_ in _loc3_.materials.materialsByName)
  1061.             {
  1062.                _loc1_ += "+ " + _loc2_ + "\n";
  1063.             }
  1064.          }
  1065.          return _loc1_;
  1066.       }
  1067.       
  1068.       public function set autoCalcScreenCoords(param1:Boolean) : void
  1069.       {
  1070.          this._autoCalcScreenCoords = param1;
  1071.       }
  1072.    }
  1073. }
  1074.  
  1075.