Camera free vs. target
By default, cameras point forward. If you give them a “target” to look at, they’ll stay focused on the target. In this example, you’ll see two cameras moving in the exact same circular pattern. The left camera keeps looking forward while the right camera keeps looking at the center

source
package { import flash.display.Sprite; import flash.events.Event; import flash.text.TextFormat; import gs.TweenMax; import org.papervision3d.cameras.Camera3D; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.Viewport3D; [SWF(width="800", height="300", backgroundColor="#000000", frameRate="60")] public class FreeCameraVSTargetCamera extends Sprite { private var leftViewport:Viewport3D; private var leftCamera:Camera3D; private var rightViewport:Viewport3D; private var rightCamera:Camera3D; private var scene:Scene3D; private var renderer:BasicRenderEngine; public function FreeCameraVSTargetCamera() { leftViewport = new Viewport3D(400, 300); leftCamera = new Camera3D(); leftCamera.y = 100; leftCamera.z = -2000; rightViewport = new Viewport3D(400, 300); rightCamera = new Camera3D(); rightCamera.target = DisplayObject3D.ZERO;//x:0, y:0, z:0 rightCamera.y = 100; rightCamera.z = -2000; addChild(leftViewport); rightViewport.x = 400; rightViewport.opaqueBackground = 0xffffff; addChild(rightViewport); scene= new Scene3D(); renderer = new BasicRenderEngine(); for(var i:int = 0; i < 5; i++) { for(var j:int = 0; j < 5; j++) { var randColor:Number = Math.random() * 0xffffff; var material:WireframeMaterial = new WireframeMaterial(randColor, 1, 2); var sphere:Sphere = new Sphere(material); sphere.x = 1000 * i - 2000; sphere.z = 1000 * j - 2000; scene.addChild(sphere); } } var floor:Plane = new Plane(new WireframeMaterial(0x00cc00, 1, 2), 5000, 5000, 10, 10); floor.pitch(90); floor.y = -100; scene.addChild(floor); //Set both cameras along the same circular motion var bezierThrough:Array = [{x:2000, z:0}, {x:0, z:2000}, {x:-2000, z:0}]; TweenMax.to(leftCamera, 10, {x:0, z:-2000, bezierThrough:bezierThrough, yoyo:true}); TweenMax.to(rightCamera, 10, {x:0, z:-2000, bezierThrough:bezierThrough, yoyo:true}); addEventListener(Event.ENTER_FRAME, enterFrameHandler); addText(); } private function addText():void { var leftHeaderText:headerContainer = new headerContainer(); leftHeaderText.header.text = "No target"; addChild(leftHeaderText); var rightHeaderText:headerContainer = new headerContainer(); rightHeaderText.x = 400; var textFormat:TextFormat = new TextFormat(); textFormat.color = 0x000000; rightHeaderText.header.defaultTextFormat = textFormat; rightHeaderText.header.text = "Target DisplayObject3D.ZERO"; addChild(rightHeaderText); } private function enterFrameHandler(event:Event):void { renderer.renderScene(scene, leftCamera, leftViewport); renderer.renderScene(scene, rightCamera, rightViewport); } } }
-
Gabriel.Wang(From China)
-
Gabriel.Wang(From China)
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
- Register Domain Name on Augmented Reality – Recursive Webcam
- Katie on Augmented Reality – Recursive Webcam
- software akuntansi terbaik on Back in the saddle
- loan rates on Augmented Reality – Recursive Webcam
- loan rates on Looking around the inside of a Sphere
- reverse phone lookup on Looking around the inside of a Sphere
- Oidhreachta on The Spotlight Effect (Dimming the unselected)
- Hosting company on archive
- aanbae on Back in the saddle
- Domain registration on Looking around the inside of a Sphere
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

