※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!
wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)
forked from: Alternativa3D demo forked from: forked from: Alternativa3D demo
- // forked from BOX's forked from: Alternativa3D demo
- // forked from mash's Alternativa3D demo
- // Alternativa3D demo via
- // http://clockmaker.jp/blog/2008/10/alternativa3d_helloworld/
- package
- {
- import alternativa.engine3d.controllers.*;
- import alternativa.engine3d.core.*;
- import alternativa.engine3d.display.*;
- import alternativa.engine3d.materials.*;
- import alternativa.engine3d.primitives.*;
- import alternativa.types.*;
- import alternativa.utils.*;
- import flash.net.*;
- import flash.display.*;
- import flash.events.*;
- import flash.geom.*;
- [SWF(width="720", height="480", frameRate="60")]
- public class Main extends Sprite
- {
- private var scene:Scene3D;
- private var view:View;
- private var camera:Camera3D;
- private var cameraController:CameraController;
- private var wrap:Object3D;
- public function Main()
- {
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- // Creating scene
- scene = new Scene3D();
- scene.root = new Object3D();
- wrap = scene.root.addChild(new Object3D());
- //wrap.y = 500;
- // create box
- var box:Box = Box(wrap.addChild(new Box()));
- box.cloneMaterialToAllSurfaces(new DevMaterial());
- box.x = 500 * Math.sin(0 * Math.PI / 180);
- box.z = 500 * Math.cos(0 * Math.PI / 180);
- var cone:Cone = Cone(wrap.addChild(new Cone()));
- cone.cloneMaterialToAllSurfaces(new DevMaterial());
- cone.x = 500 * Math.sin(90 * Math.PI / 180);
- cone.z = 500 * Math.cos(90 * Math.PI / 180);
- cone.rotationX = -90 * Math.PI / 180;
- //var sphere:Sphere = Sphere(wrap.addChild(new Sphere(100, 6, 6)));
- var sphere:GeoSphere = GeoSphere(wrap.addChild(new GeoSphere(100, 1)));
- sphere.cloneMaterialToAllSurfaces(new DevMaterial());
- sphere.x = 500 * Math.sin(180 * Math.PI / 180);
- sphere.z = 500 * Math.cos(180 * Math.PI / 180);
- //var sphere2:Sphere = Sphere(wrap.addChild(new Sphere(100, 20, 20)));
- var sphere2:GeoSphere = GeoSphere(wrap.addChild(new GeoSphere(100, 1)));
- sphere2.cloneMaterialToAllSurfaces(new DevMaterial());
- sphere2.x = 500 * Math.sin(180 * Math.PI / 180);
- sphere2.z = 200 * Math.cos(180 * Math.PI / 180);
- var plane:Plane = Plane(wrap.addChild(new Plane()));
- //var geoPlane:GeoPlane = GeoPlane(wrap.addChild(new GeoPlane()));
- plane.cloneMaterialToAllSurfaces(new DevMaterial());
- plane.x = 500 * Math.sin(270 * Math.PI / 180);
- plane.z = 500 * Math.cos(270 * Math.PI / 180);
- // Adding camera and view
- camera = new Camera3D();
- camera.x = 0;
- camera.y = 0;
- camera.z = 1000;
- scene.root.addChild(camera);
- view = new View();
- addChild(view);
- view.camera = camera;
- // Connecting camera controller
- cameraController = new CameraController(stage);
- cameraController.camera = camera;
- cameraController.setDefaultBindings();
- cameraController.checkCollisions = false;
- cameraController.collisionRadius = 0;
- cameraController.lookAt(new Point3D());
- cameraController.controlsEnabled = false;
- // FPS display launch
- FPS.init(stage);
- createLogo();
- stage.addEventListener(Event.RESIZE, onResize);
- stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
- onResize(null);
- }
- private function onResize(e:Event):void
- {
- view.width = stage.stageWidth;
- view.height = stage.stageHeight;
- // BackGround Color
- var bgMatrix:Matrix = new Matrix();
- bgMatrix.rotate(90 * Math.PI / 180);
- graphics.clear()
- graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100, 100], [0, 255], bgMatrix);
- graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
- }
- private function onEnterFrame(e:Event):void
- {
- // Scene calculating
- scene.calculate();
- wrap.rotationY -= .015
- }
- private function createLogo():void
- {
- var sp:Sprite = Sprite(addChild(new Sprite()));
- //sp.addChild(new Logo())
- sp.buttonMode = true;
- sp.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void
- {
- navigateToURL( new URLRequest("http://alternativaplatform.com/en/"), "_blank");
- })
- }
- }
- }
notice: 

