dehash »  AS3 Papervision3D GreatWhite example code «

Some AS3 code examples that use Papervision3D GreatWhite from SVN. Made with FlashDevelop and Flex3 SDK but as they are pure AS3 examples they should work mostly the same in Flash 9 too. Some examples are clean and basic but others are less so and some are just ideas for things to explore later when more examples are added. Will try to put build/revision number in each post but note when using SVN it is inevitable that if some time has passed parts of these they may not work without tweaking in later builds. The source code text is released as open source under the BSD License which is a very open license with few restrictions. Any external media used however (bitmaps, flv, sound etc) is not covered by this license. If you notice mistakes please email dehash_at_gmail_dot_com.

 

Title: VectorVisionClock

VectorVision Demo - Simple Clock - revision 856

Actionscript:
  1. /**
  2. * v0.1 code by dehash.com 2008
  3. * Released as open source under the BSD License
  4. * http://www.opensource.org/licenses/bsd-license.php
  5. */
  6. package com.dehash.pv3d.examples.vectortext {
  7. import org.papervision3d.view.BasicView;
  8. import org.papervision3d.materials.special.Letter3DMaterial;
  9. import org.papervision3d.typography.Font3D;
  10. import org.papervision3d.typography.Text3D;
  11. import org.papervision3d.typography.fonts.HelveticaRoman;
  12. import flash.events.Event;
  13.  
  14. [SWF(width = "800", height = "600", backgroundColor = "0xAD5E40")]
  15.  
  16. public class VectorVisionClock extends BasicView {
  17. private var text3D:Text3D;
  18.  
  19. public function VectorVisionClock(viewportWidth:Number = 800, viewportHeight:Number = 600,
  20. scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="CAMERA3D"){
  21. super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
  22.  
  23. text3D = new Text3D(buildTime(), new HelveticaRoman(), new Letter3DMaterial(0xF7EE97));
  24. text3D.scale = 4;
  25. camera.target = text3D;
  26. scene.addChild(text3D);
  27. startRendering();
  28. }
  29.  
  30. protected override function onRenderTick(event:Event = null):void {
  31. text3D.text = buildTime();
  32. // hover
  33. camera.x -= (camera.x - Math.sin(mouseX*0.01)*1000) /8;
  34. camera.z -= (camera.z - Math.cos(mouseX*0.01)*1000) /8;
  35. camera.y -= (camera.y - viewport.containerSprite.mouseY * 5) / 8;
  36. // render
  37. renderer.renderScene(scene, camera, viewport);
  38. }
  39.  
  40. private function buildTime():String {
  41. var d:Date = new Date();
  42. var hours:String = String(d.getHours());
  43. var minutes:String = String(d.getMinutes());
  44. var seconds:String = String(d.getSeconds());
  45. hours = (hours.length <2)? "0" + hours : hours;
  46. minutes = (minutes.length <2)? "0" + minutes : minutes;
  47. seconds = (seconds.length <2)? "0" + seconds : seconds;
  48. return String(hours+":"+minutes+":"+seconds);
  49. }
  50. }
  51. }