package { import flash.display.*; import flash.events.*; import flash.geom.*; import org.papervision3d.view.*; import org.papervision3d.lights.*; import org.papervision3d.materials.*; import org.papervision3d.materials.shadematerials.*; import org.papervision3d.materials.shaders.*; import org.papervision3d.objects.*; import org.papervision3d.objects.primitives.*; import org.papervision3d.cameras.*; import org.papervision3d.core.utils.*; import org.papervision3d.core.utils.virtualmouse.*; import be.nascom.flash.graphics.Rippler; [SWF(width = "720", height = "480", frameRate = "30", backgroundColor = "0")] public class Main extends BasicView { /** * Variables */ static private const CAMERA_POSITION :uint = 1000; private var vMouse :VirtualMouse; private var earth :MovieClip; private var sphere :Sphere; /** * Constructor */ public function Main() { // init super(0, 0, true, true, CameraType.TARGET); stage.quality = StageQuality.HIGH; // interactive vMouse = viewport.interactiveSceneManager.virtualMouse; Mouse3D.enabled = true; // object earth = new MovieClip(); earth.base = earth.addChild(new Ripple); // material var material:MovieMaterial = new MovieMaterial(earth, false, true, false, new Rectangle(0, 0, 1000, 500)); material.smooth = false; material.interactive = true; material.allowAutoResize = false; // 3d sphere = Sphere(scene.addChild(new Sphere(material, 500, 10, 10))); // render startRendering(); } /** * render * @param event */ override protected function onRenderTick(event:Event = null):void { // ripple effect if (InteractiveSceneManager.MOUSE_IS_DOWN) earth.base.draw(new Point(vMouse.x, vMouse.y)); // rotation sphere.yaw(1); super.onRenderTick(event); } } } import be.nascom.flash.graphics.Rippler; import flash.events.*; import flash.geom.*; import flash.display.*; /** * Ripple Sprite */ class Ripple extends Sprite { // Embed an image (Flex Builder only, use library in Flash Authoring) [Embed(source = "defalut.jpg")] // Varialbles private var _sourceImage : Class; private var _target : Bitmap; public var _rippler : Rippler; public function Ripple() { // create a Bitmap displayobject and add it to the stage _target = new Bitmap(new _sourceImage().bitmapData); addChild(_target); // create the Rippler instance to affect the Bitmap object _rippler = new Rippler(_target, 100, 3); } // creates a ripple at mouse coordinates on mouse movement public function draw(mousePoint:Point) : void { // the ripple point of impact is size 20 and has alpha 1 _rippler.drawRipple(mousePoint.x, mousePoint.y, 20, 1); } }