Dancing Spheres
This was supposed to be something completely different
package { import flash.events.Event; import org.papervision3d.core.effects.BitmapColorEffect; import org.papervision3d.core.math.Number3D; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.shadematerials.FlatShadeMaterial; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.view.BasicView; import org.papervision3d.view.layer.BitmapEffectLayer; import org.papervision3d.view.layer.ViewportLayer; [SWF(width="800", height="600", backgroundColor="#000000", frameRate="60")] public class DancingSpheres extends BasicView { private const LENGTH:Number = 2000; private var yellowSphere:Sphere; public function DancingSpheres() { super(800, 600); camera.fov = 140; var light:PointLight3D = new PointLight3D(); light.x = -1000, light.y = 1000; var yellowMaterial:FlatShadeMaterial = new FlatShadeMaterial(light, 0xcccc00); yellowSphere = new Sphere(yellowMaterial, 120); var redMaterial:FlatShadeMaterial = new FlatShadeMaterial(light, 0xcc0000); var redSphere:Sphere = new Sphere(redMaterial, 120); redSphere.x = -400; yellowSphere.addChild(redSphere); var bitmapEffectLayer:BitmapEffectLayer = new BitmapEffectLayer(viewport, 800, 600); bitmapEffectLayer.addDisplayObject3D(yellowSphere); bitmapEffectLayer.addDisplayObject3D(redSphere); bitmapEffectLayer.addEffect(new BitmapColorEffect()); viewport.containerSprite.addLayer(bitmapEffectLayer); scene.addChild(yellowSphere); startRendering(); } override protected function onRenderTick(event:Event=null):void { var ray:Number3D = camera.unproject(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY); ray.normalize(); ray.multiplyEq(LENGTH); ray = Number3D.add(ray, new Number3D(camera.x, camera.y, camera.z)); var velocityX:Number = (ray.x - yellowSphere.x) * .1; var velocityY:Number = (ray.y - yellowSphere.y) * .1; var velocityZ:Number = (ray.z - yellowSphere.z) * .1; yellowSphere.x += velocityX; yellowSphere.y += velocityY; yellowSphere.z += velocityZ; if(velocityX > 20) velocityX = 20; if(velocityX < -20) velocityX = -20; yellowSphere.roll(velocityX); renderer.renderScene(scene, camera, viewport); } } }
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- Moving to johnlindquist.com
- AsyncCommand with Robotlegs, Signals, Flight, MinimalComps
- Search Widget – Robotlegs, Signals, Flight, Minimal Comps, Yahoo Astra
- FDT Super Awesome March Deal
- haXe Tutorial
- AS3 Signals Tutorial
- Preferred Video Tutorial Resolution?
- TweenMax – Tweening a timeline (Advanced Tweening)
- Robotlegs + Flight + Union Platform
- Back in the saddle
- Eclipse Theme Designer Preview
- RobotLegs Hello World Video Tutorial
- 10 Things Every Senior Flash Developer Should Know
- Efflex – 3D Effects for Flex
- MorphController – Mighty Morphing Papervision3D
Recent Comments
- list of lpn courses on SpringCamera3D and Driving a Car
- rn to bsn in montgomery al on archive
- PowerPoint Recovery on Eclipse Theme Designer Preview
- cheat mw3 on Test if a plane is within the view of the camera (aka testing if culled)
- Goa Hotels on Looking around the inside of a Sphere
- cheat gratuit on Looking around the inside of a Sphere
- Application Development on Robotlegs + Flight + Union Platform
- nexium on Moving Faces
- buy nexium on Holy Sphere
- buy aldara online on Tweening a “moveForward()” behavior
Categories
Archives
Preferred Video Tutorial Resolution
- 1024x768 (53%, 85 Votes)
- 1280x1024 (15%, 24 Votes)
- 1920x1080 (15%, 24 Votes)
- 800x600 (13%, 20 Votes)
- 480x320 (4%, 6 Votes)
- 640x480 (0%, 2 Votes)
Total Voters: 160


