package { import flash.display.*; import flash.events.*; import flash.geom.*; import org.papervision3d.view.*; import org.papervision3d.lights.*; import org.papervision3d.materials.*; import org.papervision3d.materials.shadematerials.*; import org.papervision3d.materials.shaders.*; import org.papervision3d.objects.*; import org.papervision3d.objects.primitives.*; import org.papervision3d.cameras.*; [SWF(width = "720", height = "480", frameRate = "60", backgroundColor = "#FFFFFF")] public class Main extends BasicView { static private const CAMERA_POSITION :uint = 1000; [Embed(source="defalut.jpg")] private var ObjectBitmapImage:Class; [Embed(source="bump.jpg")] private var BumpImage:Class; [Embed(source = "pano.jpg")] private var EnvImage:Class; private var sphere:DisplayObject3D; public function Main() { super(0, 0, true, false, CameraType.TARGET); stage.quality = StageQuality.LOW; // Specify a point light source and its location var light:PointLight3D = PointLight3D(scene.addChild(new PointLight3D(true))); light.x = light.y = 700; // create bitmap material var bitmapMaterial:BitmapMaterial = new BitmapMaterial(new ObjectBitmapImage().bitmapData, false); // carete horizonal Emv Image var emvImage:Bitmap = new EnvImage(); var hOppositMatrix:Matrix = new Matrix(); hOppositMatrix.translate( - emvImage.width / 2, - emvImage.height / 2 ); hOppositMatrix.rotate(Math.PI); hOppositMatrix.translate( emvImage.width / 2, emvImage.height / 2 ); emvImage.transform.matrix = hOppositMatrix; var envImageBmpData:BitmapData = new BitmapData(emvImage.width, emvImage.height, false); envImageBmpData.draw(emvImage, hOppositMatrix); // create shader var shader:Shader = new EnvMapShader( light, envImageBmpData, envImageBmpData, 0xFFFFFF, new BumpImage().bitmapData); // create new shaded material by combining the bitmap material with shader var shadedMaterial:ShadedMaterial = new ShadedMaterial(bitmapMaterial, shader); sphere = Sphere(scene.addChild(new Sphere(shadedMaterial, 500, 20, 20))); var sm:BitmapMaterial = new BitmapMaterial(new EnvImage().bitmapData, false); sm.opposite = true; sm.oneSide = true; // キューブを作成 var panorama:DisplayObject3D = scene.addChild(new Sphere(sm, 15000, 20, 20)); startRendering(); } private var rot:Number = 0; override protected function onRenderTick(event:Event = null):void { sphere.yaw(1); rot += (mouseX / stage.stageWidth * 360 - rot) * .1; camera.x = CAMERA_POSITION * Math.sin(rot * Math.PI / 180); camera.z = CAMERA_POSITION * Math.cos(rot * Math.PI / 180); camera.y += (CAMERA_POSITION * mouseY / stage.stageHeight - CAMERA_POSITION / 2 - camera.y) * .1; super.onRenderTick(event); } } }