※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


forked from : mash's Alternativa3D demo [diff(8)]

FORKED
  1. // forked from BOX's forked from: Alternativa3D demo
  2. // forked from mash's Alternativa3D demo
  3. // Alternativa3D demo via
  4. // http://clockmaker.jp/blog/2008/10/alternativa3d_helloworld/
  5. package
  6. {
  7.     import alternativa.engine3d.controllers.*;
  8.     import alternativa.engine3d.core.*;
  9.     import alternativa.engine3d.display.*;
  10.     import alternativa.engine3d.materials.*;
  11.     import alternativa.engine3d.primitives.*;
  12.     import alternativa.types.*;
  13.     import alternativa.utils.*;
  14.     
  15.     import flash.net.*;
  16.     import flash.display.*;
  17.     import flash.events.*;
  18.     import flash.geom.*;
  19.     [SWF(width="720", height="480", frameRate="60")]
  20.     public class Main extends Sprite
  21.     {
  22.         private var scene:Scene3D;
  23.         private var view:View;
  24.         private var camera:Camera3D;
  25.         private var cameraController:CameraController;
  26.         private var wrap:Object3D;
  27.         
  28.         public function Main()
  29.         {
  30.             stage.scaleMode = StageScaleMode.NO_SCALE;
  31.             stage.align = StageAlign.TOP_LEFT;
  32.             
  33.             // Creating scene
  34.             scene = new Scene3D();
  35.             scene.root = new Object3D();
  36.             
  37.             wrap = scene.root.addChild(new Object3D());
  38.             //wrap.y = 500;
  39.             
  40.             // create box
  41.             var box:Box = Box(wrap.addChild(new Box()));
  42.             box.cloneMaterialToAllSurfaces(new DevMaterial());
  43.             box.x = 500 * Math.sin(0 * Math.PI / 180);
  44.             box.z = 500 * Math.cos(0 * Math.PI / 180);
  45.             
  46.             var cone:Cone = Cone(wrap.addChild(new Cone()));
  47.             cone.cloneMaterialToAllSurfaces(new DevMaterial());
  48.             cone.x = 500 * Math.sin(90 * Math.PI / 180);
  49.             cone.z = 500 * Math.cos(90 * Math.PI / 180);
  50.             cone.rotationX = -90 * Math.PI / 180;
  51.             
  52.             //var sphere:Sphere = Sphere(wrap.addChild(new Sphere(100, 6, 6)));
  53.             var sphere:GeoSphere = GeoSphere(wrap.addChild(new GeoSphere(1001)));
  54.             sphere.cloneMaterialToAllSurfaces(new DevMaterial());
  55.             sphere.x = 500 * Math.sin(180 * Math.PI / 180);
  56.             sphere.z = 500 * Math.cos(180 * Math.PI / 180);
  57.             
  58.              //var sphere2:Sphere = Sphere(wrap.addChild(new Sphere(100, 20, 20)));
  59.             var sphere2:GeoSphere = GeoSphere(wrap.addChild(new GeoSphere(1001)));
  60.             sphere2.cloneMaterialToAllSurfaces(new DevMaterial());
  61.             sphere2.x = 500 * Math.sin(180 * Math.PI / 180);
  62.             sphere2.z = 200 * Math.cos(180 * Math.PI / 180);
  63.           
  64.             
  65.             var plane:Plane = Plane(wrap.addChild(new Plane()));
  66.             //var geoPlane:GeoPlane = GeoPlane(wrap.addChild(new GeoPlane()));
  67.             plane.cloneMaterialToAllSurfaces(new DevMaterial());
  68.             plane.x = 500 * Math.sin(270 * Math.PI / 180);
  69.             plane.z = 500 * Math.cos(270 * Math.PI / 180);
  70.             
  71.             
  72.             // Adding camera and view
  73.             camera = new Camera3D();
  74.             camera.x = 0;
  75.             camera.y = 0;
  76.             camera.z = 1000;
  77.             scene.root.addChild(camera);
  78.             
  79.             view = new View();
  80.             addChild(view);
  81.             view.camera = camera;
  82.             // Connecting camera controller
  83.             cameraController = new CameraController(stage);
  84.             cameraController.camera = camera;
  85.             cameraController.setDefaultBindings();
  86.             cameraController.checkCollisions = false;
  87.             cameraController.collisionRadius = 0;
  88.             cameraController.lookAt(new Point3D());
  89.             cameraController.controlsEnabled = false;
  90.             
  91.             // FPS display launch
  92.             FPS.init(stage);
  93.             createLogo();
  94.             
  95.             stage.addEventListener(Event.RESIZE, onResize);
  96.             stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  97.             onResize(null);
  98.         }
  99.         
  100.         private function onResize(e:Event):void
  101.         {
  102.             view.width = stage.stageWidth;
  103.             view.height = stage.stageHeight;
  104.             
  105.             // BackGround Color
  106.             var bgMatrix:Matrix = new Matrix();
  107.             bgMatrix.rotate(90 * Math.PI / 180);
  108.             graphics.clear()
  109.             graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100100], [0255], bgMatrix);
  110.             graphics.drawRect(00, stage.stageWidth, stage.stageHeight);
  111.         }
  112.         
  113.         private function onEnterFrame(e:Event):void
  114.         {
  115.             // Scene calculating
  116.             scene.calculate();
  117.             
  118.             wrap.rotationY -= .015
  119.         }
  120.         
  121.         private function createLogo():void
  122.         {
  123.             var sp:Sprite = Sprite(addChild(new Sprite()));
  124.             //sp.addChild(new Logo())
  125.             
  126.             sp.buttonMode = true;
  127.             sp.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void
  128.             {
  129.                 navigateToURL( new URLRequest("http://alternativaplatform.com/en/"), "_blank");
  130.             })
  131.         }
  132.     }
  133. }
noswf
Get Adobe Flash Player