728x90
카메라와 큐브밑에 바닥을 추가해봤습니다.
점점 더 3d적으로 보이네요 ㅎ
package { import flash.display.MovieClip; import flash.events.Event; import flash.utils.getTimer; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.view.BasicView; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.materials.BitmapMaterial; import flash.display.BitmapData; import flash.display.Bitmap; import org.papervision3d.view.Viewport3D; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.materials.*; import flash.display.Shape; public class main extends BasicView { private var viewport_:Viewport3D; private var cube : Cube; private var earth:Plane; public function main() { init(); } private function init() { viewport_ = new Viewport3D(); viewport_.autoScaleToStage = true; viewport_.interactive = true; addChild(viewport_); var bitmap1:BitmapData = new img1() as BitmapData; var bitmap2:BitmapData = new img2() as BitmapData; var bitmap3:BitmapData = new img3() as BitmapData; var bitmap4:BitmapData = new img4() as BitmapData; var bitmap5:BitmapData = new img5() as BitmapData; var bitmap6:BitmapData = new img6() as BitmapData; //var bit:Bitmap = new img1() as Bitmap; var image1:BitmapMaterial = new BitmapMaterial(bitmap1); var image2:BitmapMaterial = new BitmapMaterial(bitmap2); var image3:BitmapMaterial = new BitmapMaterial(bitmap3); var image4:BitmapMaterial = new BitmapMaterial(bitmap4); var image5:BitmapMaterial = new BitmapMaterial(bitmap5); var image6:BitmapMaterial = new BitmapMaterial(bitmap6); var material:MaterialsList = new MaterialsList(); image1.smooth = true; image2.smooth = true; image3.smooth = true; image4.smooth = true; image5.smooth = true; image6.smooth = true; image1.interactive = true; image2.interactive = true; image3.interactive = true; image4.interactive = true; image5.interactive = true; image6.interactive = true; image1.doubleSided = true; image2.doubleSided = true; image3.doubleSided = true; image4.doubleSided = true; image5.doubleSided = true; image6.doubleSided = true; var materialsList:MaterialsList = new MaterialsList(); materialsList.addMaterial(image1 , "front"); materialsList.addMaterial(image2 , "back"); materialsList.addMaterial(image3 , "left"); materialsList.addMaterial(image4 , "right"); materialsList.addMaterial(image5 , "top"); materialsList.addMaterial(image6 , "bottom"); cube = new Cube(materialsList,120,120,120,10,10,10); earth = new Plane(new WireframeMaterial(0xFF0000, 0.5), 500, 500, 10, 10); camera.y=600; cube.y = 200; earth.rotationX = 90; earth.rotationY = 20; earth.y = -70; scene.addChild(cube); scene.addChild(earth); addEventListener(Event.ENTER_FRAME, render); } public function render(e:Event) { var xDist:Number = mouseX - stage.stageWidth * 0.5; var yDist:Number = mouseY - stage.stageHeight * 0.5; cube.rotationY += xDist*0.02; cube.rotationX += yDist*0.02; cube.y = Math.sin(getTimer() / 300) * -25 + 200; camera.x = 500 * Math.sin(getTimer() / 4000); camera.z = 500 * Math.cos(getTimer() / 4000); renderer.renderScene(scene, camera, viewport); } } }
반응형
'배워보자!! > papervision3D' 카테고리의 다른 글
[papervision3d] 플래시3D 마우스에 반응하는 큐브 (0) | 2015.04.23 |
---|---|
[papervision3d] 플래시3D 큐브에 이미지 넣기! (0) | 2015.04.16 |
[papervision3D] 페이퍼비전 3D 큐브(cube) 만들기! (0) | 2015.04.15 |
[papervision3D] 페이퍼비전 3D Plane 만들기! (2) | 2015.04.15 |
댓글