<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:xx="com.fontvirus.*"
backgroundGradientColors="[#000000, #4A4A4A]"
backgroundGradientAlphas="[1.0, 1.0]"
pageTitle=" ://fonts.xero.style/pv3d-2.0-test "
applicationComplete="init3D()"
layout="absolute" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.ui.*;
import mx.events.*;
import org.papervision3d.view.*;
import org.papervision3d.scenes.*;
import org.papervision3d.render.*;
import org.papervision3d.lights.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.shadematerials.*;
import com.mrdoob.*;
import com.fontvirus.*;
private var fps :FlexFPS;
private var fs :FlexFS;
private var scene :Scene3D;
private var view :Viewport3D;
private var cam :Camera3D;
private var renderer :BasicRenderEngine;
private var thelight :PointLight3D;
private var shadedObject :DisplayObject3D;
public function init3D():void
{
fps = new FlexFPS(0x333333, 0x000000, 0xffffff);
addChild(fps);
fs = new FlexFS(0x000000, 0xcccccc, "bottomLeft", this.width, this.height);
addChild(fs);
scene = new Scene3D();
cam = new Camera3D(null, 11, 100);
renderer = new BasicRenderEngine();
view = new Viewport3D(640, 480, true, false, true, true);
paperCanvas.addChild(view);
thelight = new PointLight3D(true);
thelight.x = paperCanvas.width * 0.5;
thelight.y = paperCanvas.width * 0.5;
thelight.moveForward(500);
shadedObject = new MrDoobPlanet(new FlatShadeMaterial(thelight, 0x006600, 0x000000));
scene.addChild(shadedObject, "shadedObject");
addEventListener(Event.ENTER_FRAME, loop3D);
addEventListener(ResizeEvent.RESIZE, setup);
}
private function loop3D(e:Event):void
{
fps.update("ploys: " + view.lastRenderList.length);
if(spinit.selected){
shadedObject.rotationY+=theSpeed.value;
}
cam.x += ((mouseX-paperCanvas.width*.5) - cam.x);
cam.y += ((mouseY-paperCanvas.height*.5) - cam.y);
view.filters = [new DropShadowFilter(50, 45, 0x000000, .35, 18, 18, 1, 1)];
renderer.renderScene(scene, cam, view);
}
private function changeModel():void
{
scene.removeChildByName("shadedObject");
if(whichModel.selectedItem=="MrDoobPlanet"){
shadedObject = new MrDoobPlanet();
} else if(whichModel.selectedItem=="MrDoobSphere"){
shadedObject = new MrDoobSphere();
} else if(whichModel.selectedItem=="InvaderAlpha"){
shadedObject = new InvaderAlpha();
shadedObject.moveDown(150);
} else if(whichModel.selectedItem=="InvaderBeta"){
shadedObject = new InvaderBeta();
shadedObject.moveDown(150);
} else if(whichModel.selectedItem=="InvaderGamma"){
shadedObject = new InvaderGamma();
shadedObject.moveDown(150);
shadedObject.scale = .75;
} else if(whichModel.selectedItem=="TorusKnot"){
shadedObject = new TorusKnot();
} else if(whichModel.selectedItem=="TorusKnotTwist"){
shadedObject = new TorusKnotTwist();
} else if(whichModel.selectedItem=="TorusKnotSpiral"){
shadedObject = new TorusKnotSpiral();
}
changeShading();
scene.addChild(shadedObject, "shadedObject");
}
private function changeShading():void
{
if(whichEffect.selectedItem=="cell"){
shadedObject.material = new CellMaterial(thelight, difColor.selectedColor, ambColor.selectedColor, int(specularLevel.selectedItem));
specularLevel.enabled = true;
lbl.enabled = true;
} else if(whichEffect.selectedItem=="flat") {
shadedObject.material = new FlatShadeMaterial(thelight, difColor.selectedColor, ambColor.selectedColor);
specularLevel.enabled = false;
lbl.enabled = false;
} else if(whichEffect.selectedItem=="gouraud") {
shadedObject.material = new GouraudMaterial(thelight, difColor.selectedColor, ambColor.selectedColor);
specularLevel.enabled = false;
lbl.enabled = false;
} else if(whichEffect.selectedItem=="phong") {
shadedObject.material = new PhongMaterial(thelight, difColor.selectedColor, ambColor.selectedColor, int(specularLevel.selectedItem));
specularLevel.enabled = true;
lbl.enabled = true;
}
}
private function adjustCam():void
{
cam.zoom=theZoom.value;
}
private function setup(e:ResizeEvent):void
{
fs.setup(this.width, this.height);
}
]]>
</mx:Script>
<mx:Style>
Panel {
shadowDistance: 6;
shadowDirection: right;
backgroundColor:#000000;
color:#FFFFFF;
cornerRadius:0;
headerHeight:22;
headerColors:#000000, #666666;
width:227;
backgroundAlpha:1.0;
borderStyle:solid;
}
.header {
letterSpacing: 5;
color: #ffffff;
fontWeight: normal;
}
ComboBox {
color: #ffffff;
borderColor: #ffffff;
fillColors: #000000, #666666, #333333, #000000;
selectionColor: #006600;
textSelectedColor: #ffffff;
rollOverColor: #333333;
textRollOverColor: #ffffff;
themeColor: #00ff00;
alternatingItemColors: #000000, #000000;
dropDownStyleName: "dropMenu";
}
.dropMenu {
cornerRadius: 14;
borderThickness: 6;
borderColor: #000000;
color: #ffffff;
textAlign: center;
}
</mx:Style>
<xx:Canvas3D id="paperCanvas" top="0" bottom="0" left="0" right="0" backgroundAlpha="0"/>
<mx:Panel title="papervision3D 2.0a - demo" right="10" bottom="10" height="214" layout="absolute" width="233">
<mx:Label x="10" y="35" text="3D model"/>
<mx:ComboBox x="77" y="33" width="144" id="whichModel" dataProvider="{['MrDoobPlanet','MrDoobSphere','InvaderAlpha','InvaderBeta','InvaderGamma','TorusKnot','TorusKnotTwist','TorusKnotSpiral']}" change="changeModel()"/>
<mx:Label x="12" y="64" text="shading effect"/>
<mx:ComboBox x="106" y="62" width="115" id="whichEffect" change="changeShading()" dataProvider="{['flat','cell','gouraud','phong']}"/>
<mx:Label x="30" y="94" text="diffuse"/>
<mx:ColorPicker x="79" y="92" id="difColor" selectedColor="0x006600" change="changeShading()"/>
<mx:Label x="121" y="94" text="ambiant"/>
<mx:ColorPicker x="180" y="92" id="ambColor" selectedColor="0x000000" change="changeShading()"/>
<mx:Label x="13" y="147" text="zoom"/>
<mx:HSlider x="57" y="144" width="166" id="theZoom" minimum="5" maximum="25" value="11" liveDragging="true" change="adjustCam()"/>
<mx:CheckBox x="68" y="165" label="auto roation" id="spinit" selected="true"/>
<mx:Label x="13" y="187" text="speed"/>
<mx:HSlider x="60" y="185" width="163" id="theSpeed" minimum="-5" value="0.69" maximum="5" liveDragging="true"/>
<mx:ComboBox x="133" y="122" width="58" dataProvider="{['0','20','50','100','150']}" selectedIndex="2" id="specularLevel" change="changeShading()" enabled="false"/>
<mx:Label x="41" y="124" text="specular level" enabled="false" id="lbl"/>
</mx:Panel>
</mx:Application>