Mouse3D moving light
Mouse3D is bound to the interactiveSceneManager of your viewport. So to get the 3d “renderHitData” of where your mouse is, you need to:
Mouse3D.enabled = true; viewport.interactive = true; mouse3D = viewport.interactiveSceneManager.mouse3D;
Then you can get 3d data from your mouse3D object like you would any other DisplayObject3D. Just remember the mouse will need to be over an object with a “material.interactive = true” to get any data back.
package { import flash.events.Event; import flash.ui.Mouse; import org.papervision3d.core.utils.Mouse3D; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.shadematerials.PhongMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.view.BasicView; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class Mouse3DExample extends BasicView { private var mouse3D:Mouse3D; private var pivotPoint:DisplayObject3D; private var light:PointLight3D; public function Mouse3DExample() { var headerText:headerContainer = new headerContainer(); headerText.header.text = "Mouse over the sphere to move the light"; addChild(headerText); viewport.interactive = true; Mouse3D.enabled = true; mouse3D = viewport.interactiveSceneManager.mouse3D; light = new PointLight3D(true); pivotPoint = new DisplayObject3D(); var material:PhongMaterial = new PhongMaterial(light, 0xcc0000, 0x000000, 10); material.interactive = true; var sphere:Sphere = new Sphere(material, 500, 30, 30); sphere.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, objectOverHandler); sphere.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, objectOutHandler); var smallSphere1:Sphere = new Sphere(new PhongMaterial(light, 0x00cc00, 0x000000, 10), 100, 10, 10); var smallSphere2:Sphere = new Sphere(new PhongMaterial(light, 0x0000cc, 0x000000, 10), 100, 10, 10); smallSphere1.x = -500; smallSphere1.y = 500; smallSphere2.x = 400; smallSphere2.y = -600; pivotPoint.addChild(smallSphere1); pivotPoint.addChild(smallSphere2); scene.addChild(sphere); scene.addChild(pivotPoint); scene.addChild(light); addEventListener(Event.ENTER_FRAME, enterFrameHandler); } private function objectOverHandler(event:InteractiveScene3DEvent):void { Mouse.hide(); } private function objectOutHandler(event:InteractiveScene3DEvent):void { Mouse.show(); } private function enterFrameHandler(event:Event):void { pivotPoint.yaw(1); pivotPoint.pitch(.5); light.copyTransform(mouse3D); light.moveBackward(100); singleRender(); } } }
-
Gabriel.Wang(From China)
-
John Lindquist
-
JB
-
John Lindquist
-
JB
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
- Ocatarinabelachichix on about
- Rajiv on faq
- Rajiv on 3ds max texture baking for Papervision3D
- Anupam Biswas on Maya Texture Baking
- Anupam Biswas on Maya Texture Baking
- Arindam Mojumder on requests
- Arindam Mojumder on requests
- Arindam Mojumder on Full Screen Cube
- Arindam Mojumder on faq
- Mimosa123321 on requests
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


