Papervisionの勉強(パーティクルの作成)
/**
* Copyright matsu4512 ( http://wonderfl.net/user/matsu4512 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zGki
*/
package {
import com.adobe.viewsource.ViewSource;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import org.papervision3d.materials.special.ParticleMaterial;
import org.papervision3d.objects.special.ParticleField;
import org.papervision3d.view.BasicView;
[SWF(backgroundColor=0x000000, width = 800, height=800)]
public class Papervision9 extends Sprite
{
public function Papervision9()
{
//初期設定
var world:BasicView = new BasicView();
world.startRendering();
addChild(world);
//生成するパーティクルの設定。色とアルファ値
var particleMat:ParticleMaterial = new ParticleMaterial(0xFFFFFF, 1);
//大きさ2000の立方体の中に大きさ4のパーティクルを500個生成
var particles:ParticleField = new ParticleField(particleMat, 500, 4, 2000, 2000, 2000);
world.scene.addChild(particles);
addEventListener(Event.ENTER_FRAME, function():void{
particles.rotationY -= (stage.mouseX - stage.stageWidth/2)/100;
particles.rotationX -= (stage.mouseY - stage.stageHeight/2)/100;
});
}
}
}