Away3D [sphere]
////////////////////////////////////////////////////////////////////////////////
// Away3D [sphere]
//
// [Away3D] 球体 (1)
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1726
////////////////////////////////////////////////////////////////////////////////
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6Zsh
*/
////////////////////////////////////////////////////////////////////////////////
// Away3D [sphere]
//
// [Away3D] 球体 (1)
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1726
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.system.System;
import flash.events.Event;
import flash.geom.Vector3D;
import flash.display.BitmapData;
import flash.display.Bitmap;
import away3d.Away3D;
import away3d.containers.View3D;
import away3d.containers.Scene3D;
import away3d.cameras.Camera3D;
import away3d.primitives.WireframeSphere;
import away3d.debug.AwayStats;
[SWF(backgroundColor="#000000", width="465", height="465", frameRate="60")]
public class Main extends Sprite {
private var view:View3D;
private var scene:Scene3D;
private var camera:Camera3D;
private var sphere:WireframeSphere;
private static var radius:uint = 500;
private var angle:Number = 90;
private var degree:Number = 0;
private static var depression:uint = 30;
private static var radian:Number = Math.PI/180;
private static var center:Vector3D = new Vector3D();
private var stats:AwayStats;
//private var source:BitmapData = new BitmapData(465, 465, false, 0x000000);
public function Main() {
Wonderfl.disable_capture();
//addChild(new Bitmap(source));
//
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
System.pauseForGCIfCollectionImminent(1);
init();
stats = new AwayStats(view);
addChild(stats);
stats.x = 340;
}
private function init():void {
view = new View3D();
scene = view.scene;
camera = view.camera;
addChild(view);
setup();
initialize();
//
addEventListener(Event.ENTER_FRAME, render, false, 0, true);
}
private function setup():void {
view.backgroundColor = 0x000000;
view.antiAlias = 4;
//
camera.x = 0;
camera.y = 0;
camera.z = - radius;
}
private function initialize():void {
sphere = new WireframeSphere(160, 40, 20, 0xFFFFFF, 1.6);
scene.addChild(sphere);
}
private function render(evt:Event):void {
angle += 0.5;
degree += 1;
var dip:Number = depression*Math.sin(degree*radian);
camera.x = radius*Math.cos(angle*radian)*Math.cos(dip*radian);
camera.y = radius*Math.sin(dip*radian);
camera.z = radius*Math.sin(angle*radian)*Math.cos(dip*radian);
camera.lookAt(center);
view.render();
//view.renderer.queueSnapshot(source);
}
}
}