竜巻
/**
* Copyright set0 ( http://wonderfl.net/user/set0 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/4A8r
*/
package
{
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.utils.*;
import flash.geom.*;
import org.papervision3d.core.effects.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.view.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.core.effects.utils.*;
[SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
public class Tornado extends BasicView
{
public var n:Number = 0;
public var layer:BitmapEffectLayer = new BitmapEffectLayer(viewport, 465, 465);
public var pixels:Pixels = new Pixels(layer);
public var pixel_list:Array = [];
public var color_list:Array = [0xffff9900, 0xffff9900, 0xffff9900, 0xffff9900, 0xffff9900, 0xffff9900, 0xffff9900, 0xffff0000];
public var material:WireframeMaterial = new WireframeMaterial(0x66ff66);
public var plane:Plane = new Plane(material, 2400, 2400, 20, 20);
private const MAX_PIXEL:Number = 2000;
private const MIN_R:Number = 50;
private const T_RAD:Number = Math.PI / 180;
public function Tornado()
{
var tmp_color:uint;
plane.useOwnContainer = true;
plane.filters = [new GlowFilter(0xffffff, 0.6, 8, 8, 2)];
scene.addChild(plane);
plane.rotationX = 90;
plane.x = 0;
plane.y = 0;
layer.addEffect(new BitmapLayerEffect(new BlurFilter(4, 4, 2), false));
viewport.containerSprite.addLayer(layer);
scene.addChild(pixels);
for (var i:int = 0; i < MAX_PIXEL; i++) {
var rot:Number = (i / (i % 100 + 1)) * 360 * 4;
var pointX:Number = Math.sin(rot * T_RAD) * MIN_R;
var pointZ:Number = Math.cos(rot * T_RAD) * MIN_R;
var pointY:Number = 0;
pixel_list[i] = new Pixel3D(color_list[i % color_list.length], pointX, pointY, pointZ);
pixels.addPixel3D(pixel_list[i]);
}
camera.y = 1000;
camera.z = 800;
startRendering();
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e:Event):void
{
for (var i:int = 0; i < n; i++) {
var rot:Number = (i / (i % 50 + pixel_list[i].y / 100)) * 360 * 4;
pixel_list[i].x = (MIN_R + pixel_list[i].y/20 + Math.random() * 10) * Math.sin(rot * T_RAD) + Math.cos(pixel_list[i].y * T_RAD) * 15;
pixel_list[i].z = (MIN_R + pixel_list[i].y/20 + Math.random() * 10) * Math.cos(rot * T_RAD) + Math.cos(pixel_list[i].y * T_RAD) * 15;
if(pixel_list[i].y < 1300) {
pixel_list[i].y += 5;
} else {
pixel_list[i].y = 0;
pixel_list[i].x = Math.sin(rot * T_RAD) * MIN_R;
pixel_list[i].z = Math.cos(rot * T_RAD) * MIN_R;
}
}
pixels.x = 600 * Math.sin(getTimer() / 6000);
pixels.z = 600 * Math.cos(getTimer() / 6000);
if (n >= MAX_PIXEL) {
n = MAX_PIXEL;
} else {
n+=10;
}
}
}
}