Study/Actionscript 3.0
PV3D Practice_Object
chacolina
2009. 3. 9. 20:08
3. 양면에 다른 이미지를 붙이고 클릭했을 때 뒤로 flip되도록 하기
package
{
import flash.display.Shape;
import gs.TweenMax;
import gs.easing.*;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[ SWF( width="640", height="480", frameRate="36", backgroundColor="0xEEEEEE")]
public class DTest3 extends BasicView
{
private var plane1:Plane = new Plane;
private var plane2:Plane = new Plane;
private var planeContainer:DisplayObject3D= new DisplayObject3D;
//private var tween1:TweenMax;
//private var tween2:TweenMax;
//private var tween3:TweenMax;
public function DTest3(viewportWidth:Number=640, viewportHeight:Number=480, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
{
super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
viewport.interactive= true;
camera.z =-300;
startRendering();
this.createObject();
}
private function createObject():void
{
var material1:BitmapFileMaterial= new BitmapFileMaterial("./img/img4.jpg");
var material2:BitmapFileMaterial= new BitmapFileMaterial("./img/img2.jpg");
material1.interactive= true;
material2.interactive= true;
material1.precise= true;
material2.precise= true;
this.plane1= new Plane (material1, 300, 200);
this.plane2= new Plane (material2, 300, 200 );
this.plane2.rotationY =180;
this.planeContainer= new DisplayObject3D();
scene.addChild(planeContainer);
this.planeContainer.addChild(plane1);
this.planeContainer.addChild(plane2);
this.plane1.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onClick);
this.plane2.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onClick);
}
//private function onEnter(e:Event):void
//{
// planeContainer.rotationY +=5;
//}
private function onClick(e:InteractiveScene3DEvent):void
{
//this.planeContainer= new DisplayObject3D();
if(e.target == plane1)
{
TweenMax.to(planeContainer, 1, {scaleX:1.2, scaleY:1.2, rotationY:180, ease:Circ.easeOut});
}else{
TweenMax.to(planeContainer, 1, {scaleX:1, scaleY:1, rotationY:0, ease:Circ.easeOut});
}
}
}
}
2. 양면에 다른 이미지를 붙이고 자동 rotation
/*
package
{
import flash.events.Event;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[ SWF( width="640", height="480", frameRate="36", backgroundColor="0xEEEEEE")]
public class DTest3 extends BasicView
{
private var plane1:Plane = new Plane;
private var plane2:Plane = new Plane;
private var planeContainer:DisplayObject3D= new DisplayObject3D;
public function DTest3(viewportWidth:Number=640, viewportHeight:Number=480, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
{
super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
// viewport.interactive= true;
this.createObject();
startRendering();
this.addEventListener(Event.ENTER_FRAME, onEnter);
}
private function createObject():void
{
var material1:BitmapFileMaterial= new BitmapFileMaterial("./img/img4.jpg");
var material2:BitmapFileMaterial= new BitmapFileMaterial("./img/img2.jpg");
material1.interactive= true
material2.interactive= true
this.plane1= new Plane (material1, 600, 400 );
this.plane2= new Plane (material2, 600, 400 );
this.plane2.rotationY =180;
this.planeContainer= new DisplayObject3D();
scene.addChild(planeContainer)
planeContainer.addChild(plane1);
planeContainer.addChild(plane2);
}
private function onEnter(e:Event):void
{
planeContainer.rotationY +=5;
}
}
}
*/
1. 단면에 이미지를 붙이기
/*
package
{
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[ SWF( width="640", height="480", frameRate="36", backgroundColor="0xEEEEEE")]
public class DTest3 extends BasicView
{
private var plane:Plane = new Plane;
public function DTest3(viewportWidth:Number=640, viewportHeight:Number=480, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
{
super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
// viewport.interactive= true;
this.createObject();
startRendering();
}
private function createObject():void
{
var material:BitmapFileMaterial= new BitmapFileMaterial;
// material.interactive= true
this.plane= new Plane (material, 300, 200 );
scene.addChild(plane);
}
}
}
*/
package
{
import flash.display.Shape;
import gs.TweenMax;
import gs.easing.*;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[ SWF( width="640", height="480", frameRate="36", backgroundColor="0xEEEEEE")]
public class DTest3 extends BasicView
{
private var plane1:Plane = new Plane;
private var plane2:Plane = new Plane;
private var planeContainer:DisplayObject3D= new DisplayObject3D;
//private var tween1:TweenMax;
//private var tween2:TweenMax;
//private var tween3:TweenMax;
public function DTest3(viewportWidth:Number=640, viewportHeight:Number=480, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
{
super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
viewport.interactive= true;
camera.z =-300;
startRendering();
this.createObject();
}
private function createObject():void
{
var material1:BitmapFileMaterial= new BitmapFileMaterial("./img/img4.jpg");
var material2:BitmapFileMaterial= new BitmapFileMaterial("./img/img2.jpg");
material1.interactive= true;
material2.interactive= true;
material1.precise= true;
material2.precise= true;
this.plane1= new Plane (material1, 300, 200);
this.plane2= new Plane (material2, 300, 200 );
this.plane2.rotationY =180;
this.planeContainer= new DisplayObject3D();
scene.addChild(planeContainer);
this.planeContainer.addChild(plane1);
this.planeContainer.addChild(plane2);
this.plane1.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onClick);
this.plane2.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onClick);
}
//private function onEnter(e:Event):void
//{
// planeContainer.rotationY +=5;
//}
private function onClick(e:InteractiveScene3DEvent):void
{
//this.planeContainer= new DisplayObject3D();
if(e.target == plane1)
{
TweenMax.to(planeContainer, 1, {scaleX:1.2, scaleY:1.2, rotationY:180, ease:Circ.easeOut});
}else{
TweenMax.to(planeContainer, 1, {scaleX:1, scaleY:1, rotationY:0, ease:Circ.easeOut});
}
}
}
}
2. 양면에 다른 이미지를 붙이고 자동 rotation
/*
package
{
import flash.events.Event;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[ SWF( width="640", height="480", frameRate="36", backgroundColor="0xEEEEEE")]
public class DTest3 extends BasicView
{
private var plane1:Plane = new Plane;
private var plane2:Plane = new Plane;
private var planeContainer:DisplayObject3D= new DisplayObject3D;
public function DTest3(viewportWidth:Number=640, viewportHeight:Number=480, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
{
super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
// viewport.interactive= true;
this.createObject();
startRendering();
this.addEventListener(Event.ENTER_FRAME, onEnter);
}
private function createObject():void
{
var material1:BitmapFileMaterial= new BitmapFileMaterial("./img/img4.jpg");
var material2:BitmapFileMaterial= new BitmapFileMaterial("./img/img2.jpg");
material1.interactive= true
material2.interactive= true
this.plane1= new Plane (material1, 600, 400 );
this.plane2= new Plane (material2, 600, 400 );
this.plane2.rotationY =180;
this.planeContainer= new DisplayObject3D();
scene.addChild(planeContainer)
planeContainer.addChild(plane1);
planeContainer.addChild(plane2);
}
private function onEnter(e:Event):void
{
planeContainer.rotationY +=5;
}
}
}
*/
1. 단면에 이미지를 붙이기
/*
package
{
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[ SWF( width="640", height="480", frameRate="36", backgroundColor="0xEEEEEE")]
public class DTest3 extends BasicView
{
private var plane:Plane = new Plane;
public function DTest3(viewportWidth:Number=640, viewportHeight:Number=480, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
{
super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
// viewport.interactive= true;
this.createObject();
startRendering();
}
private function createObject():void
{
var material:BitmapFileMaterial= new BitmapFileMaterial;
// material.interactive= true
this.plane= new Plane (material, 300, 200 );
scene.addChild(plane);
}
}
}
*/