In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

# Orbitals - Beta

```3D座標への変換の方法は知っていたんですが、深さで円を描く順番を変えるのには少し手間がかかりました。
まだ試しに作ってみた作品なので、完成したらwonderflに載せるつもりです。```
by GreekFellows 20 Apr 2012

## Tags

Embed
```/**
* Copyright GreekFellows ( http://wonderfl.net/user/GreekFellows )
*/

package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix3D;
import flash.geom.Vector3D;

/**
* ...
* @author Greek Fellows
*/
public class Main extends Sprite
{
private var sprite:Sprite;
private var core:Sprite;
private var array:Array;
private var colors:Array;
private var zsorted:Array;

public function Main():void
{
this.array = [];
this.colors = [];
this.zsorted = [];

init();

this.sprite=new Sprite();
this.sprite.x=465/2;
this.sprite.y=465/2;
this.sprite.z=0;

this.core=new Sprite();
this.core.x=0;
this.core.y=0;
this.core.z=0;

}

private function init():void {
// change array here
this.array = [new Vector3D(100, 100, 100), new Vector3D(-100, 100, 100), new Vector3D(-100, -100, 100), new Vector3D(100, -100, 100), new Vector3D(100, 100, -100), new Vector3D(-100, 100, -100), new Vector3D(-100, -100, -100), new Vector3D(100, -100, -100)];

for (var a:int = 0; a < array.length; a++) {
var vector:Vector3D = this.array[a];
this.array[a] = { vector:vector, color:Math.floor(Math.random() * 0xffffff / 5) * 5, radius:Math.random() * 45 + 5 };
}
}

private function graph(vector:Vector3D,transformVector:Boolean=true):Vector3D {
var mat:Matrix3D = this.core.transform.matrix3D.clone();

var xy:Vector3D = vector;
if (transformVector) xy = mat.transformVector(vector);
xy.w = (750 + xy.z) / 750;
xy.project();

return xy;
}

private    function spin(e:Event):void {
this.core.transform.matrix3D.appendRotation((mouseY - 200) / 50, Vector3D.X_AXIS);
this.core.transform.matrix3D.appendRotation((mouseX - 300) / 50, Vector3D.Y_AXIS);

this.sprite.graphics.clear();

sortbyZ();

for (var b:int = 0; b < this.zsorted.length; b++) {
this.sprite.graphics.beginFill(this.zsorted[b].color, 1);
this.sprite.graphics.endFill();
}
}

private function sortbyZ():void {
this.zsorted = [];
var mat:Matrix3D = this.core.transform.matrix3D.clone();

for (var c:int = 0; c < this.array.length; c++) {