Skip to content

Instantly share code, notes, and snippets.

@richardolsson
Created August 7, 2012 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardolsson/3284386 to your computer and use it in GitHub Desktop.
Save richardolsson/3284386 to your computer and use it in GitHub Desktop.
Simple example of how to use new Away3D stereoscopic rendering
// 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();
}
}
}
Copy link

ghost commented Jun 19, 2013

I messed around in away3d with the stereo lens from your code. It's pretty cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment