Gems
@author ish-xxxx
package {
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.objects.primitives.Cylinder;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.lights.PointLight3D;
import net.hires.debug.Stats;
import caurina.transitions.properties.CurveModifiers;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.ColorTransform;
/**
* @author ish-xxxx
*/
[SWF(frameRate="45")]
public class App2 extends Sprite {
private var v:Viewport3D, r:BasicRenderEngine, s:Scene3D, world:DisplayObject3D, camera:Camera3D, l:PointLight3D;
private var container:Sprite, b:Bitmap, bm:BitmapData;
private var _len:uint = 50;
private var count:uint = 0;
private var t:ColorTransform = new ColorTransform( 1, 1, 1, 0.9 );
public function App2() {
CurveModifiers.init();
container = addChild( new Sprite ) as Sprite;
l = new PointLight3D;
v = container.addChild( new Viewport3D( 0, 0, true, true ) ) as Viewport3D;
r = new BasicRenderEngine;
s = new Scene3D;
world = s.addChild( new DisplayObject3D ) as DisplayObject3D;
camera = new Camera3D;
var __len:uint = _len;
while ( __len-- ) {
var p:Particle = world.addChild( new Particle( l ) ) as Particle;
p.name = "p" + String( __len );
p.visible = false;
}
addEventListener( Event.ENTER_FRAME, render );
addChild( new Stats );
}
private function render( ev:Event ) : void {
var _count:uint = ++count % _len;
var p:Particle = world.getChildByName( "p" + String( _count ), true ) as Particle;
if ( p._running != true ) {
p.init();
p.run();
}
world.rotationX += ( ( mouseY - 225 ) - world.rotationX ) / 16;
world.rotationY += ( ( mouseX - 225 ) - world.rotationY ) / 16;
r.renderScene( s, camera, v );
}
}
}
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.objects.primitives.Arrow;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.objects.primitives.Cylinder;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.lights.PointLight3D;
import caurina.transitions.*;
internal class Particle extends DisplayObject3D {
private var s:Sphere, m:FlatShadeMaterial;
private var _radius:Number = Math.random() * 60;
private var _segW:Number = 4;
private var _segH:Number = 4;
private var _tx:Number;
private var _ty:Number;
private var _tz:Number;
private var _btx:Number;
private var _bty:Number;
private var _btz:Number;
private var _offset:Number = 1000;
internal var _running:Boolean = false;
public function Particle( _light:PointLight3D ) {
m = new FlatShadeMaterial( _light, Math.random() * 0xFFFFFF, 0x121212 );
s = addChild( new Sphere( m, _radius, _segW, _segH ) ) as Sphere;
init();
}
internal function init() : void {
s.scale = 1;
s.x = 0;
s.y = 0;
s.z = 0;
_tx = Math.random() * _offset - Math.random() * _offset;
_ty = Math.random() * _offset - Math.random() * _offset;
_tz = Math.random() * _offset - Math.random() * _offset;
_btx = Math.random() * _offset - Math.random() * _offset;
_bty = Math.random() * _offset - Math.random() * _offset;
_btz = Math.random() * _offset - Math.random() * _offset;
}
internal function run() : void {
visible = true;
_running = true;
Tweener.addTween( s, { x: _tx, y: _ty, z: _tz, rotationX: Math.random() * 360, rotationY: Math.random() * 360 , scale: 0 , _bezier: [ { x: _btx, y: _bty, y: _btz } ], time: 1, transition: Equations.easeOutQuad ,onComplete: comp } );
}
private function comp() : void {
_running = false;
}
}