Nesting(둥지) 부모Object 하나 혹은 다수의 Object 추가하는 기술입니다. 이점으로는 계층적 구조를 유지하여 부모에 상대적인 변화를 보여준다. 예를 들면 부모의 좌표계를 변경하면 자식의 좌표 또한  상대적으로 변화 합니다.


[ 참조 ]

Scene3D (scene) DisplayObject3D (sphere) DisplayObjectContainer3D 상속받아, DisplayObjectContainer3D addChild() 메소드를 사용할 있게 됩니다.
 

 DisplayObjectContainer3D

DisplayObject3D

DisplayObjectContainer3D

SceneObject3D

  Scene3D


 

[예제 3개의 Sphere() 상대적으로 돌아가는 화면 태양-지구-? ]

: 지구는 태양을 중심으로 돌고 달은 지구를 중심으로 돌고 있는 형태입니다.

(자세한 값을 확인하고 싶은 경우 sceneX, sceneY, sceneZ 값을 확인하면 좋습니다.)

=> 결론 상대적으로 움직이는 이득을 있습니다. 여러 곳에 쓰일 있겠죠.. ^^



//Main.mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Application

       creationComplete="init()"

       frameRate="40"

       xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

       <mx:Script>

             <![CDATA[

                    import sample.NestingExample;

                    import mx.core.UIComponent;

                   

                    private function init():void{

                           var bs:NestingExample = new NestingExample();

                          

                           var ui:UIComponent = new UIComponent();

                           ui.addChild(bs);

                          

                           this.addChild(ui);

                    }

                   

             ]]>

       </mx:Script>

</mx:Application>


//NestingExample.as

package sample

{

       import flash.events.Event;

      

       import org.papervision3d.objects.primitives.Sphere;

       import org.papervision3d.view.BasicView;

 

       public class NestingExample extends BasicView

       {

             private var _sunSphere:Sphere;

             private var _earthSphere:Sphere;

             private var _moonSphere:Sphere;

            

             public function NestingExample()

             {

                    init();

                    startRendering();

             }

            

             private function init():void{

                                       

                    _sunSphere = new Sphere(null,200,16,12);

                    _earthSphere = new Sphere(null,100,12,8);

                    _moonSphere = new Sphere(null,50,8,4);

                    _earthSphere.x = 400;

                    _earthSphere.y = -50;

                    _moonSphere.x = 200;

                    _moonSphere.y = 50;

                                                           

                    scene.addChild(_sunSphere);

                    _sunSphere.addChild(_earthSphere);

                    _earthSphere.addChild(_moonSphere);

                   

             }

            

             override protected function onRenderTick(event:Event=null):void{

                    _sunSphere.localRotationY+=1;

                    _earthSphere.localRotationY+=2;

                                       

                    super.onRenderTick();

             }

       }

}

+ Recent posts