flash on 2010-7-26
♥0 |
Line 47 |
Modified 2010-07-26 17:48:48 |
MIT License
archived:2017-03-20 17:26:44
ActionScript3 source code
/**
* Copyright hig_an ( http://wonderfl.net/user/hig_an )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5lut
*/
package {
import flash.utils.Timer;
import org.papervision3d.core.math.Plane3D;
import org.papervision3d.materials.special.CompositeMaterial;
import org.papervision3d.view.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.objects.primitives.*;
import flash.events.*;
public class FlashTest extends BasicView {
private var rot:Number = 0;
private var timer:Timer
private var bars:Array = new Array();
public function FlashTest() {
var material:ColorMaterial = new ColorMaterial(0xFFCC00);
material.doubleSided = true;
for (var i:int = 0; i < 7; i++) {
var b:Bar = new Bar(i);
bars[i] = new Plane(material, 300, 100, 1, 1);
bars[i].x = b.x;
bars[i].y = b.y;
bars[i].rotationZ = b.rotationZ;
scene.addChild(bars[i]);
}
startRendering();
addEventListener(Event.ENTER_FRAME, loop);
camera.y = 0;
}
private function loop(e:Event):void {
rot += 0.5;
camera.z = 1000 * Math.sin(rot * Math.PI / 180);
camera.x = 1000 * Math.cos(rot * Math.PI / 180);
}
}
}
class Bar {
public var x:Number;
public var y:Number;
public var deg2:Array = new Array[0, 200, 400, 200, 0, -200, -400, -200];
public var rotationZ:int;
function Bar(n:int) {
var deg1:int = n * 90;
x = 200 * Math.sin(deg1 * Math.PI / 180);
y = deg2[n];
rotationZ = deg1;
}
}