Spiral Typography 3D
@OKASUKE
* 2010/04/08 Spiral Typography
* マウスで動かすと線が入ります。
* カメラ自動回転でもやっぱ線がはいる。。。
* 処理的にあんまやっちゃいけない感じかな。
*
/**
* Copyright OKASUKE ( http://wonderfl.net/user/OKASUKE )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sLmJ
*/
/* @OKASUKE
* 2010/04/08 Spiral Typography
* マウスで動かすと線が入ります。
* カメラ自動回転でもやっぱ線がはいる。。。
* 処理的にあんまやっちゃいけない感じかな。
*
*/
package
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.utils.getTimer;
import org.papervision3d.view.*;
import org.papervision3d.core.effects.view.ReflectionView;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.materials.WireframeMaterial
import org.papervision3d.materials.special.Letter3DMaterial
import org.papervision3d.typography.fonts.HelveticaBold;
import org.papervision3d.typography.Font3D;
import org.papervision3d.typography.Letter3D;
import org.papervision3d.typography.Text3D;
import net.hires.debug.Stats;
public class Test3Dwon extends ReflectionView {
private var _word:Text3D;
private var _textVec:Vector.<Text3D> = new Vector.<Text3D>;
private var _num:uint = 0;
private var _nextDate:Text3D;
private var onTimer:Timer = new Timer(1000, 1);
private var _count:uint = 0;
private var _floor:Plane = new Plane(new WireframeMaterial(0x999999, 0.5), 3000, 3000, 12, 12);
public function Test3Dwon():void {
stage.quality = "medium";
surfaceHeight = -1800;
viewportReflection.filters = [new BlurFilter(4, 4, 1)];
viewportReflection.alpha = 0.7;
for (var i:int = 0 ; i < 50; i++) {
Text(i, Math.random() * 0xFF00FF);
}
var material:Letter3DMaterial = new Letter3DMaterial(0xFFFFFF);
material.doubleSided = true;
var font:HelveticaBold = new HelveticaBold();
_nextDate = new Text3D("0", font, material);
_nextDate.x = _textVec[0].x;
_nextDate.y = _textVec[0].y;
_nextDate.z = _textVec[0].z;
//scene.addChild(_nextDate);
_floor.rotationX = 90;
_floor.y = -900
_floor.z = 1200
scene.addChild(_floor);
addEventListener(Event.ENTER_FRAME, loop);
//onTimer.addEventListener(TimerEvent.TIMER, stoptime);
addChild(new Stats());
}
//1秒おきに動かしてみる用。
private function stoptime(e:TimerEvent):void {
removeEventListener(TimerEvent.TIMER, stoptime);
/*_count += 1
_nextDate.text = _count.toString();
for (var i:uint = 0; i < _textVec.length; i++) {
if (i == _textVec.length - 1) {
_textVec[i].x = _nextDate.x
_textVec[i].y = _nextDate.y
_textVec[i].z = _nextDate.z
} else {
_num = i + 1;
_textVec[i].x = _textVec[_num].x;
_textVec[i].y = _textVec[_num].y;
_textVec[i].z = _textVec[_num].z;
}
}*/
}
private function loop(e:Event):void {
camera.x = 600 * Math.sin(getTimer() / 1000);
camera.z = -2100 * Math.cos(getTimer() / 1000);
camera.y = 600 * Math.sin(getTimer() / 1000);
//マウスで動かすか。
//camera.x += (1200 * Math.sin(mouseX / stage.stageWidth * Math.PI * 2) - camera.x) * 0.01;
//camera.y += (1200 * mouseY / stage.stageHeight - camera.y) * 0.01;
//camera.z += (1500 * Math.cos(mouseX / stage.stageWidth * Math.PI * 2) - camera.z) * 0.01;
//onTimer.start();
for (var i:uint = 0; i < _textVec.length; i++) {
if (i == _textVec.length - 1) {
_num = 0; //仮
} else {
_num = i + 1;
}
_textVec[i].x = _textVec[_num].x;
_textVec[i].y = _textVec[_num].y;
_textVec[i].z = _textVec[_num].z;
}
singleRender();
}
private function Text(n:int, col:uint):void {
var material:Letter3DMaterial = new Letter3DMaterial(col);
material.doubleSided = true;
var font:HelveticaBold = new HelveticaBold();
_word = new Text3D(n.toString() , font, material);
_word.alpha = Math.random();
_textVec.push(_word);
scene.addChild(_word);
var rot:Number = (n / 100) * 360 * 12;
_word.x = 20 * n * Math.cos(rot * Math.PI/180);
_word.y = 20 * n * Math.sin(rot * Math.PI/180);
_word.z = n * 50 + 100;
}
}
}