Created
August 7, 2012 10:31
-
-
Save richardolsson/3284386 to your computer and use it in GitHub Desktop.
Simple example of how to use new Away3D stereoscopic rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example uses the stereoscopic rendering feature of Away3D that | |
// has not yet been merged into any of the main branches. At the time | |
// of writing this, the below code requires the "stereofeature" branch | |
// of Away3D. | |
// | |
// The running demo can be found here: | |
// https://dl.dropbox.com/u/1560087/away3d/stereo/Basic_Stereo.html | |
// | |
// Note that this feature may or may not make it into main Away3D. | |
// | |
package | |
{ | |
import away3d.debug.Debug; | |
import away3d.entities.Mesh; | |
import away3d.materials.ColorMaterial; | |
import away3d.primitives.CubeGeometry; | |
import away3d.stereo.StereoCamera3D; | |
import away3d.stereo.StereoView3D; | |
import away3d.stereo.methods.AnaglyphStereoRenderMethod; | |
import away3d.stereo.methods.InterleavedStereoRenderMethod; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
public class Basic_Stereo extends Sprite | |
{ | |
private var _view : StereoView3D; | |
private var _camera : StereoCamera3D; | |
private var _cube : Mesh; | |
public function Basic_Stereo() | |
{ | |
super(); | |
_camera = new StereoCamera3D(); | |
_camera.stereoOffset = 50; | |
_view = new StereoView3D(); | |
_view.antiAlias = 4; | |
_view.camera = _camera; | |
_view.stereoEnabled = true; | |
_view.stereoRenderMethod = new AnaglyphStereoRenderMethod(); | |
//_view.stereoRenderMethod = new InterleavedStereoRenderMethod(); | |
addChild(_view); | |
_cube = new Mesh(new CubeGeometry(), new ColorMaterial(0xffcc00)); | |
_cube.scale(5); | |
_view.scene.addChild(_cube); | |
addEventListener(Event.ENTER_FRAME, onEnterFrame); | |
} | |
private function onEnterFrame(ev : Event) : void | |
{ | |
_cube.rotationY += 2; | |
_view.render(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I messed around in away3d with the stereo lens from your code. It's pretty cool.