<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:xx="com.fontvirus.*"
xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#020202, #646464]"
layout="absolute"
creationComplete="init()"
creationCompleteEffect="slowDisolve"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.net.navigateToURL;
import mx.controls.Alert;
import org.papervision3d.scenes.*;
import org.papervision3d.events.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*
import org.papervision3d.core.geom.*;
import org.papervision3d.core.proto.*;
import com.fontvirus.*;
private var cam :Camera3D;
private var scene :Scene3D;
private var rootNode :DisplayObject3D;
private var theKnot :DisplayObject3D;
private var skin :ShadedColorMaterial;
private var wireSkin :WireframeMaterial;
private var whichOne :Number;
private var posX :Number;
private var posY :Number;
private var rotX :Number;
private var rotY :Number;
private var startUp :Timer;
private var holdUp :Timer;
private var ready :Number=0;
private var whatSkin :String="shaded";
private var moveit :Boolean = true;
private var movehow :String = "mouse";
private var goFull :Boolean = false;
private function init():void{
holdUp = new Timer(3000, 1);
holdUp.addEventListener(TimerEvent.TIMER_COMPLETE, init3D);
holdUp.start();
startUp = new Timer(500, 0);
startUp.addEventListener(TimerEvent.TIMER, cycle);
startUp.start();
}
private function init3D(e:Event):void{
startUp.stop();
startUp.removeEventListener(TimerEvent.TIMER_COMPLETE, showAlert);
cam = new Camera3D( new DisplayObject3D() );
cam.zoom = 3;
cam.focus = 1000;
scene = new Scene3D( paperSpace.canvas );
rootNode = scene.addChild(new DisplayObject3D("rootNode"));
rootNode.container = paperSpace.canvas;
skin = new ShadedColorMaterial(0x00FF00, 1);
theKnot = rootNode.addChild(new Knot(skin),"theKnot") as Knot;
stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenRedraw);
btnFS.addEventListener(MouseEvent.CLICK, changeFullScreenStatus);
addEventListener( MouseEvent.MOUSE_MOVE , handleMouseMove);
addEventListener( Event.ENTER_FRAME , loop3D );
}
public function loop3D( event:Event ):void
{
lblDebug.text = "< fontvir.us (memory usage: "+flash.system.System.totalMemory.toString()+" bytes) >";
rootNode = scene.getChildByName("rootNode") as DisplayObject3D;
if(moveit){
if(movehow=="mouse"){
posX = (mouseX / width) - 1;
posY = (mouseY / height) - 1;
rootNode.rotationX += 5 * posY;
rootNode.rotationY += 5 * posX;
} else if(movehow=="drag"){
rotY = rootNode.rotationY - 210 * mouseX/(paperSpace.stage.width*0.5);
rotY = Math.max(-100, Math.min(rotY, 100));
rootNode.rotationY -= rotY*0.12;
rotX = 90 * mouseY/(paperSpace.stage.height*0.5);
rootNode.rotationX -= (rootNode.rotationX + rotX)*0.12;
}
}
var filter:Array = new Array();
if(hasHighlight.selected == true){
filter.push(new GlowFilter(highlight.selectedColor, 0.95, 90, 90, 2, 1, true, false));
}
if(hasGlow.selected == true){
filter.push(new GlowFilter(glow.selectedColor, 1, 90, 90, 1, 1, false, false));
}
if(hasBorder.selected == true){
filter.push(new GlowFilter(theBorder.selectedColor, 10, 10, 1, 60, 1, false, false));
}
if(hasDrop.selected == true) {
filter.push(new DropShadowFilter(shadowDist.value, shadowAngle.value, 0x000000, shadowLevel.value, 15, 10, 0.5, 1, false, false));
}
if(hasBlur.selected == true){
filter.push(new BlurFilter(blurLevelx.value, blurLevely.value, 1));
}
rootNode.container.filters = filter;
scene.renderCamera( cam );
}
public function cycle(e:TimerEvent):void
{
if(ready==0){
nav.selectedIndex=3;
ready++;
} else if(ready==1){
nav.selectedIndex=2;
ready++;
} else if(ready==2){
nav.selectedIndex=1;
ready++;
} else if(ready==3){
nav.selectedIndex=0;
ready++;
} else if(ready==4){
startUp.stop();
var modelsArray:Array = new Array();
modelsArray.push("knot");
modelsArray.push("knotted");
modelsArray.push("knotty");
modelsArray.push("knothing");
modelsArray.push("knotAgain");
whichModel.dataProvider = modelsArray;
btnFONTV.addEventListener(MouseEvent.CLICK, go0);
btnFONTV.buttonMode = true;
btnFLEX3.addEventListener(MouseEvent.CLICK, go1);
btnFLEX3.buttonMode = true;
btnPV3D.addEventListener(MouseEvent.CLICK, go2);
btnPV3D.buttonMode = true;
btnAS3G.addEventListener(MouseEvent.CLICK, go3);
btnAS3G.buttonMode = true;
}
}
public function handleMouseMove(event:MouseEvent):void
{
if(moveit && movehow=="mouse"){
cam.y = Math.max( paperSpace.mouseY*5 , -500 );
}
}
public function changeColor():void
{
rootNode = scene.getChildByName("rootNode") as DisplayObject3D;
theKnot = rootNode.getChildByName("theKnot") as DisplayObject3D;
if(whatSkin=="shaded"){
skin = new ShadedColorMaterial(base.selectedColor, 1);
theKnot.material = skin;
} else if(whatSkin=="wireframe"){
wireSkin = new WireframeMaterial(wirecolor.selectedColor, 0.95);
theKnot.material = wireSkin;
}
}
public function switchModels():void
{
rootNode = scene.getChildByName("rootNode") as DisplayObject3D;
theKnot = rootNode.getChildByName("theKnot") as DisplayObject3D;
if(whichModel.selectedIndex==0){
rootNode.removeChild(theKnot);
theKnot = rootNode.addChild(new Knot(skin),"theKnot") as Knot;
} else if(whichModel.selectedIndex==1){
rootNode.removeChild(theKnot);
theKnot = rootNode.addChild(new Knotted(skin),"theKnot") as Knotted;
} else if(whichModel.selectedIndex==2){
rootNode.removeChild(theKnot);
theKnot = rootNode.addChild(new Knotty(skin),"theKnot") as Knotty;
} else if(whichModel.selectedIndex==3){
rootNode.removeChild(theKnot);
theKnot = rootNode.addChild(new Knothing(skin),"theKnot") as Knothing;
} else if(whichModel.selectedIndex==4){
rootNode.removeChild(theKnot);
theKnot = rootNode.addChild(new KnotAgain(skin),"theKnot") as KnotAgain;
}
}
public function changeSkin():void
{
rootNode = scene.getChildByName("rootNode") as DisplayObject3D;
theKnot = rootNode.getChildByName("theKnot") as DisplayObject3D;
if(whatSkin=="shaded"){
if(hasWire.selected==true){
hasShading.selected = false;
base.enabled = false;
hasHighlight.selected = false;
hasGlow.selected = false;
hasBorder.selected = false;
wirecolor.enabled = true;
lightx.enabled = false;
lighty.enabled = false;
lightz.enabled = false;
wireSkin = new WireframeMaterial(wirecolor.selectedColor, 0.95);
theKnot.material = wireSkin;
whatSkin="wireframe";
} else {
hasShading.selected = true;
}
} else if(whatSkin=="wireframe"){
if(hasShading.selected==true){
hasWire.selected = false;
wirecolor.enabled = false;
base.enabled = true;
lightx.enabled = true;
lighty.enabled = true;
lightz.enabled = true;
skin = new ShadedColorMaterial(base.selectedColor, 1);
theKnot.material = skin;
whatSkin="shaded";
} else {
hasWire.selected = true;
}
}
}
public function moveLights():void
{
skin.light.x = lightx.value;
skin.light.y = lighty.value;
skin.light.z = lightz.value;
}
public function enableHighlight():void
{
if(hasHighlight.selected==true){
highlight.enabled = true;
} else {
highlight.enabled = false;
}
}
public function enableGlow():void
{
if(hasGlow.selected==true){
glow.enabled = true;
} else {
glow.enabled = false;
}
}
public function enableBorder():void
{
if(hasBorder.selected==true){
theBorder.enabled = true;
} else {
theBorder.enabled = false;
}
}
public function enableDrop():void
{
if(hasDrop.selected==true){
shadowAngle.enabled = true;
shadowDist.enabled = true;
shadowLevel.enabled = true;
} else {
shadowAngle.enabled = false;
shadowDist.enabled = false;
shadowLevel.enabled = false;
}
}
public function enableBlur():void
{
if(hasBlur.selected==true){
blurLevelx.enabled = true;
blurLevely.enabled = true;
} else {
blurLevelx.enabled = false;
blurLevely.enabled = false;
}
}
public function how2move():void
{
if(movehow=="mouse"){
if(hasControls.selected==true){
moveit = false;
hasMouse.selected=false;
hasControls.selected=true;
hasDrag.selected=false;
camX.enabled=true;
camY.enabled=true;
camZ.enabled=true;
adjustCam();
movehow="controls"
} else if(hasDrag.selected==true){
moveit = false;
hasMouse.selected=false;
hasControls.selected=false;
hasDrag.selected=true;
paperSpace.addEventListener(MouseEvent.MOUSE_DOWN, setMouseDown);
paperSpace.addEventListener(MouseEvent.MOUSE_UP, setMouseUp);
movehow="drag";
} else {
hasMouse.selected=true;
}
} else if(movehow=="controls"){
if(hasMouse.selected==true){
moveit = true;
hasMouse.selected=true;
hasControls.selected=false;
hasDrag.selected=false;
camX.enabled=false;
camY.enabled=false;
camZ.enabled=false;
cam.zoom = 3;
movehow="mouse";
} else if(hasDrag.selected==true){
moveit = false;
hasMouse.selected=false;
hasControls.selected=false;
hasDrag.selected=true;
paperSpace.addEventListener(MouseEvent.MOUSE_DOWN, setMouseDown);
paperSpace.addEventListener(MouseEvent.MOUSE_UP, setMouseUp);
movehow="drag";
} else {
hasControls.selected=true;
}
} else if(movehow=="drag"){
if(hasMouse.selected==true){
moveit = true;
hasMouse.selected=true;
hasControls.selected=false;
hasDrag.selected=false;
camX.enabled=false;
camY.enabled=false;
camZ.enabled=false;
cam.zoom = 3;
movehow="mouse";
paperSpace.removeEventListener(MouseEvent.MOUSE_DOWN, setMouseDown);
paperSpace.removeEventListener(MouseEvent.MOUSE_UP, setMouseUp);
} else if(hasControls.selected==true){
moveit = false;
hasMouse.selected=false;
hasControls.selected=true;
hasDrag.selected=false;
camX.enabled=true;
camY.enabled=true;
camZ.enabled=true;
adjustCam();
movehow="controls";
paperSpace.removeEventListener(MouseEvent.MOUSE_DOWN, setMouseDown);
paperSpace.removeEventListener(MouseEvent.MOUSE_UP, setMouseUp);
} else {
hasDrag.selected=true;
}
}
}
public function setMouseDown(e:MouseEvent):void
{
moveit=true;
}
public function setMouseUp(e:MouseEvent):void
{
moveit=false;
}
public function adjustCam():void
{
rootNode = scene.getChildByName("rootNode") as DisplayObject3D;
rootNode.rotationX = camX.value;
rootNode.rotationY = camY.value;
cam.zoom = camZ.value;
}
public function showAlert(e:TimerEvent):void
{
Alert.show("http://the.fontvir.us/","xero.owns.us", 1, this);
}
private function fullScreenRedraw(event:FullScreenEvent):void
{
if (event.fullScreen == false)
disableFullScreen()
}
private function changeFullScreenStatus(e:MouseEvent):void
{
if(goFull)
disableFullScreen()
else
enableFullScreen()
}
private function disableFullScreen():void
{
goFull = false;
btnFS.stage.displayState = StageDisplayState.NORMAL;
}
private function enableFullScreen():void
{
goFull = true;
btnFS.stage.displayState = StageDisplayState.FULL_SCREEN;
}
public function go0(e:MouseEvent):void
{
var url:String = "http://the.fontvir.us/b10g/";
var req:URLRequest = new URLRequest(url);
navigateToURL(req);
}
public function go1(e:MouseEvent):void
{
var url:String = "http://labs.adobe.com/technologies/flex/";
var req:URLRequest = new URLRequest(url);
navigateToURL(req);
}
public function go2(e:MouseEvent):void
{
var url:String = "http://blog.papervision3d.org/";
var req:URLRequest = new URLRequest(url);
navigateToURL(req);
}
public function go3(e:MouseEvent):void
{
var url:String = "http://seraf.mediabox.fr/showcase/as3-geom-class-exporter-for-3ds-max-english/";
var req:URLRequest = new URLRequest(url);
navigateToURL(req);
}
]]>
</mx:Script>
<mx:Style>
Alert {
corner-radius: 0;
header-height: 27;
header-colors: #999999, #000000;
background-color: #000000;
color: #ffffff;
border-thickness: 4;
border-color: #000000;
panel-border-style: roundCorners;
shadow-distance: 9;
shadow-direction: right;
buttonStyleName: Button;
}
Button {
borderThickness: 2.5;
cornerRadius: 6;
fillColors: #333333, #999999;
borderColor: #999999;
themeColor: #000000;
textRollOverColor: #ffffff;
textSelectedColor: #ffffff;
color: #ffffff;
}
ComboBox {
corner-radius: 0;
color: #ffffff;
borderColor: #000000;
fillAlphas: 0.84, 0.4, 0.75, 0.65;
fillColors: #000000, #666666, #333333, #cccccc;
selectionColor: #006600;
textSelectedColor: #ffffff;
rollOverColor: #00ff00;
textRollOverColor: #000000;
themeColor: #000000;
alternatingItemColors: #000000, #000000;
}
CheckBox {
fillColors: #333333, #666666, #333333, #cccccc;
borderColor: #000000;
color: #ffffff;
textSelectedColor: #ffffff;
textRollOverColor: #ffffff;
themeColor: #00ff00;
}
VSlider, HSlider {
labelOffset: 0;
thumbOffset: -2;
dataTipOffset: 0;
tickLength: 2;
tickOffset: -9;
tickThickness: 1;
showTrackHighlight: true;
invertThumbDirection: false;
trackColors: #000000, #333333;
themeColor: #00cc00;
fillColors: #999999, #333333, #009900, #333333;
}
TextInput {
background-color: #000000;
border-color:#ffffff;
border-cap-color:#ffffff;
highlight-color:#ffffff;
theme-color:#000000;
color:#ffffff;
}
ColorPicker {
closeDuration: 250;
horizontalGap: 0;
paddingTop: 0;
paddingBottom: 0;
paddingLeft: 0;
paddingRight: 0;
previewHeight: 23;
previewWidth: 31;
swatchBorderColor: #000000;
swatchGridBackgroundColor: #000000;
swatchHeight: 13;
swatchHighlightColor: #cccccc;
swatchHighlightSize: 3;
swatchWidth: 13;
verticalGap: 0;
}
Canvas {
borderStyle: none;
borderAlpha: 0;
cornerRadius: 0;
headerHeight: 10;
backgroundAlpha: 0;
highlightAlphas: 0, 0;
paddingLeft: 4;
paddingRight: 0;
paddingTop: 4;
paddingBottom: 4;
}
Accordion {
borderStyle: none;
fillColors: #333333, #666666, #cccccc, #666666;
selectedFillColors: #333333, #666666;
themeColor: #00cc00;
backgroundColor: #666666;
borderColor: #000000;
textRollOverColor: #ffffff;
textSelectedColor: #ffffff;
headerStyleName: ;
}
.AccordionHeader {
letterSpacing: 3;
color: #ffffff;
textAlign: center;
fontWeight: bold;
}
</mx:Style>
<mx:Fade duration="5555" id="slowDisolve" alphaFrom="0.0" alphaTo="1.0"/>
<xx:Canvas3D id="paperSpace" backgroundAlpha="0" top="0" bottom="0" left="1" right="127"/>
<mx:Image source="@Embed(source='assets/fps.swf')" top="0" left="0" width="640"/>
<mx:Image source="@Embed(source='assets/btnFS.swf')" id="btnFS" left="4" bottom="4" height="32" width="50"/>
<mx:Accordion showEffect="{slowDisolve}" id="nav" paddingLeft="2" paddingRight="2" width="131" right="0" top="0" bottom="0">
<mx:Canvas label="theKnot" width="133" height="100%">
<mx:Label text="3D model" color="#FFFFFF" horizontalCenter="-24" top="20"/>
<mx:ComboBox width="99" id="whichModel" change="switchModels()" horizontalCenter="-4" top="36"></mx:ComboBox>
<mx:Label color="#FFFFFF"/>
<mx:Image source="@Embed(source='assets/flex.png')" id="btnFLEX3" height="80" horizontalCenter="0" bottom="140"/>
<mx:Image source="@Embed(source='assets/pv3d.png')" id="btnPV3D" horizontalCenter="0" bottom="69"/>
<mx:Image source="@Embed(source='assets/as3geom.png')" id="btnAS3G" horizontalCenter="0" bottom="21"/>
<mx:Image source="@Embed(source='assets/fontv.png')" id="btnFONTV" horizontalCenter="0" bottom="228"/>
</mx:Canvas>
<mx:Canvas label="skin" width="100%" height="100%">
<mx:CheckBox label="wireframe" id="hasWire" horizontalCenter="-14" top="10" click="changeSkin()"/>
<mx:ColorPicker id="wirecolor" selectedColor="#00FF00" horizontalCenter="-34" top="34" enabled="false" change="changeColor()"/>
<mx:CheckBox label="shaded" selected="true" id="hasShading" top="74" horizontalCenter="-21" click="changeSkin()"/>
<mx:ColorPicker id="base" selectedColor="0x00FF00" change="changeColor()" horizontalCenter="-34" top="98"/>
<mx:Label text="lighting" color="#FFFFFF" horizontalCenter="-36" top="125"/>
<mx:Label text="x" color="#FFFFFF" horizontalCenter="-48" top="143"/>
<mx:HSlider value="0" minimum="0" maximum="300" liveDragging="true" width="97" id="lightx" horizontalCenter="8" top="142" change="moveLights()"/>
<mx:Label text="y" color="#FFFFFF" horizontalCenter="-48" top="165"/>
<mx:HSlider value="0" minimum="0" maximum="300" liveDragging="true" width="97" id="lighty" horizontalCenter="8" top="164" change="moveLights()"/>
<mx:Label text="z" color="#FFFFFF" horizontalCenter="-48" top="186"/>
<mx:HSlider value="100" minimum="0" maximum="300" liveDragging="true" width="97" id="lightz" horizontalCenter="8" top="182" change="moveLights()"/>
<mx:CheckBox label="highlight" id="hasHighlight" change="enableHighlight()" selected="true" horizontalCenter="-17" top="205"/>
<mx:ColorPicker id="highlight" selectedColor="0x003300" horizontalCenter="-34" top="228"/>
<mx:CheckBox label="glow" id="hasGlow" change="enableGlow()" selected="false" horizontalCenter="-29" top="268"/>
<mx:ColorPicker id="glow" selectedColor="0xCCCC00" enabled="false" horizontalCenter="-34" top="291"/>
<mx:CheckBox label="border" id="hasBorder" change="enableBorder()" selected="false" horizontalCenter="-23" top="334"/>
<mx:ColorPicker id="theBorder" selectedColor="0xFFFFFF" enabled="false" horizontalCenter="-34" top="357"/>
</mx:Canvas>
<mx:Canvas label="effectz" width="100%" height="100%">
<mx:CheckBox id="hasDrop" label="shadow" horizontalCenter="-21" height="22" change="enableDrop()" top="12"/>
<mx:Label text="darkness" color="#FFFFFF" horizontalCenter="-26" height="18" top="42"/>
<mx:HSlider liveDragging="true" value="0.25" minimum="0" maximum="1" width="107" id="shadowLevel" horizontalCenter="0" height="17" top="55"/>
<mx:Label text="angle" color="#FFFFFF" horizontalCenter="-36" height="18" top="75"/>
<mx:HSlider liveDragging="true" value="45" minimum="0" maximum="360" width="107" id="shadowAngle" horizontalCenter="0" height="17" top="91"/>
<mx:Label text="depth" color="#FFFFFF" horizontalCenter="-34" height="18" top="113"/>
<mx:HSlider liveDragging="true" value="80" minimum="5" maximum="400" width="107" id="shadowDist" horizontalCenter="0" height="17" top="133"/>
<mx:Label text="blur x" color="#FFFFFF" height="18" horizontalCenter="-27" top="186"/>
<mx:VSlider liveDragging="true" value="2.6" maximum="10" minimum="0" id="blurLevelx" horizontalCenter="-29" height="160" top="206"/>
<mx:Label text="blur y" color="#FFFFFF" horizontalCenter="25" top="186"/>
<mx:VSlider liveDragging="true" value="2.6" maximum="10" minimum="0" id="blurLevely" horizontalCenter="23" height="160" top="206"/>
<mx:CheckBox label="blur" id="hasBlur" selected="true" change="enableBlur()" horizontalCenter="-31" top="160"/>
</mx:Canvas>
<mx:Canvas label="movement" width="100%" height="100%">
<mx:CheckBox label="use mouse" selected="true" horizontalCenter="-10" top="20" id="hasMouse" change="how2move()"/>
<mx:CheckBox label="use controls" id="hasControls" change="how2move()" horizontalCenter="-8" top="50"/>
<mx:HSlider enabled="false" liveDragging="true" value="150" minimum="0" maximum="360" width="102" id="camX" change="adjustCam()" horizontalCenter="2" top="80"/>
<mx:HSlider enabled="false" liveDragging="true" value="210" minimum="0" maximum="360" width="102" id="camY" change="adjustCam()" horizontalCenter="2" top="107"/>
<mx:HSlider enabled="false" liveDragging="true" value="2" minimum="1" maximum="4" width="102" id="camZ" change="adjustCam()" horizontalCenter="2" top="134"/>
<mx:Label text="x" color="#FFFFFF" horizontalCenter="-48" top="82"/>
<mx:Label text="y" color="#FFFFFF" horizontalCenter="-48" top="112"/>
<mx:Label text="z" color="#FFFFFF" horizontalCenter="-48" top="137"/>
<mx:CheckBox x="10" y="163" label="drag mode" id="hasDrag" change="how2move()"/>
</mx:Canvas>
</mx:Accordion>
<mx:Label text="< fontvirus (memory usage: 0 bytes) >" id="lblDebug" color="#FFFFFF" textAlign="right" bottom="0" horizontalCenter="-33"/>
</mx:Application>