space clock
ローレンツアトラクターをうまいこと使いたかったんですが、
いまいち上手く使えず振り回されました。
なんか飛んでくるのは秒数です。
/**
* Copyright applicott ( http://wonderfl.net/user/applicott )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/g2MR
*/
package
{
import flash.display.Graphics;
import caurina.transitions.Tweener;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.filters.GlowFilter;
import flash.sampler.getSampleCount;
import frocessing.color.ColorHSV;
import org.papervision3d.cameras.CameraType;
import org.papervision3d.cameras.SpringCamera3D;
import org.papervision3d.core.effects.BitmapLayerEffect;
import org.papervision3d.core.math.Number3D;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.special.Letter3DMaterial;
import org.papervision3d.materials.special.ParticleMaterial;
import org.papervision3d.objects.primitives.PaperPlane;
import org.papervision3d.objects.special.ParticleField;
import org.papervision3d.typography.Text3D;
import org.papervision3d.typography.fonts.HelveticaBold;
import org.papervision3d.view.BasicView;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.view.layer.BitmapEffectLayer;
[SWF(backgroundColor=0x0)]
public class pv3 extends BasicView
{
Wonderfl.capture_delay(3);
//あとらくたーーの設定
private const A:Number = 10.0, B:Number = 25.0, C:Number = 8.0/3.0, D:Number = 0.01;
//円
private const length:int = 1000;
//向かう座標
private var xx:Number=1, yy:Number=1, zz:Number=1;
private var vec:Vector.<Text3D>=new Vector.<Text3D>;
private var str:String;
private var t:Number=0;
private var pp:PaperPlane;
private var s:Number=0;
private var dd:Number=0;
private var mat:Letter3DMaterial = new Letter3DMaterial(0xFFFFFF);
private var font:HelveticaBold = new HelveticaBold();
private var theta:Number;
private var hi:Text3D;
private var d:Date;
private var hsv:ColorHSV;
public function pv3()
{
Wonderfl.capture_delay(6);
super(465, 465, true, false, CameraType.TARGET);
//まずは宇宙
scene.addChild(new ParticleField(new ParticleMaterial(0xffffff, 0.8, 0), 9200, 2, 5000, 5000, 2300));
//frocessing
hsv = new ColorHSV(0, 1, 1);
d=new Date();
hi=new Text3D(d.getFullYear() + "/" + to2time(d.getMonth()+1) + "/" + to2time(d.getDate()) +" "+ to2time(d.getHours()) + ":" + to2time(d.getMinutes()),font,mat);
scene.addChild(hi);
mat.doubleSided = true;
//飛行機作り
var wmat:WireframeMaterial=new WireframeMaterial(0x0000ff);
wmat.doubleSided=true;
pp=new PaperPlane(wmat);
scene.addChild(pp);
pp.useOwnContainer=true;
pp.alpha=0;
//スプリンカメラの設定
camera.target=hi;
// camera.target=pp;
// SpringCamera3D(camera).mass = 30;
// SpringCamera3D(camera).damping = 1;
// SpringCamera3D(camera).stiffness = 0;
// SpringCamera3D(camera).positionOffset = new Number3D(0,100,0);
// SpringCamera3D(camera).lookOffset = new Number3D(0,100,0);
startRendering();
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
public function onEnterFrame(e:Event):void{
t+=0.3+Math.random()*0.2;
d = new Date();
//from
var preX:Number = pp.x;
var preY:Number = pp.y;
var preZ:Number = pp.z;
//進む距離
var dx:Number, dy:Number, dz:Number;
dx = A*(yy-xx)+1;
dy = xx * (B - zz) - yy+1;
dz = xx * yy - C * zz+1;
xx += D*dx;
yy += D*dy;
zz += D*dz;
hsv.h+=0.1;
trace(xx,yy,zz,A,C,B);
//飛行機
var angle:Number = (t / 100) * 360 * Math.PI / 180;
// pp.x = Math.cos(angle) * length;
// pp.z = Math.sin(angle) * length;
// pp.y = 0.3 * Math.cos(angle) * length + 300;
pp.x = xx*50;
pp.z = zz*50;
pp.y = yy*50;
pp.rotationY=-toDegree(pp.x,pp.z);
camera.x=xx*50-500;
camera.y=yy*50-5;
//camera.z=zz*50-5;
// camera.rotationY=-toDegree(camera.x,camera.z);
// camera.rotationX=-toDegree(camera.z,camera.y);
// camera.rotationZ=-toDegree(camera.x,camera.y);
//時間
if(s!=d.getSeconds()){
s= d.getSeconds();
var str:String=to2time(d.getSeconds());
var tmat:Letter3DMaterial = new Letter3DMaterial(hsv.toRGB().value);
tmat.doubleSided=true;
var text:Text3D=new Text3D(str,font,tmat);
text.x = xx*50;
text.z = zz*50;
text.y = yy*50;
//text.rotationY=-toDegree(text.x,text.z);
vec.push(text);
scene.addChild(text);
Tweener.addTween(text, { rotationZ:360, time:1, scaleY:2 } );
Tweener.addTween(text, {x:camera.x,y:camera.y, z:camera.z-200, time:1,delay:0 } );
}
//日付
if(d.getSeconds()%60==0){
//SpringCamera3D(camera).stiffness = Math.random()*3+1;
var h:String=d.getFullYear() + "/" + to2time(d.getMonth()+1) + "/" + to2time(d.getDate()) +" "+ to2time(d.getHours()) + ":" + to2time(d.getMinutes());
hi.text=h;
hi.x = xx;
hi.z = zz+500;
hi.y =yy+500;
hi.rotationY=0//toDegree(hi.x,hi.z);
}
//時間削除
if(vec.length>2) {
var c:Text3D = vec[0];
vec.splice(0, 1);
scene.removeChild(c);
}
}
private function to2time(i:Number):String {
if(i<10) return "0"+i.toString();
else return i.toString();
}
private function toDegree( x:Number , y:Number ):int {
var i:Number = 0;
if ( ( x == 0 ) && ( y == 0 ) ) return 0;
i = Math.acos( x / Math.sqrt( x * x + y * y ) );
i = ( i / Math.PI ) * 180;
if ( y < 0 ) i = 360 - i;
return i;
}
}
}