Adding new Stage3DProxy

73 Views Asked by At

I'm attempting to add a new view to Away3d, and I can't get it to show up.

Previously if I had a View3d, and then created a Stage3dProxy afterwards to create a new view, it worked fine - but when attempting to switch back it caused too many problems.

I decided to initialise the Stage3dProxy at the start, assign the initial view and then add the new view. It seems to be rendering, it's just hidden and I can't work out how to show it.

Here's my code to get the new view:

        public function loadVR(){

        vrMode = true;
        stage3DProxy.clear();
        view.width = stage.stageWidth/2;
        view.layeredView = true;
        stage3DProxy.context3D.setDepthTest( false, Context3DCompareMode.ALWAYS);
        initializeVR();
    }


    private function initializeVR():void
    {
        trace('PanoVR.initialize()');
        initialized = true;
        Model.state.autoPlay = false;

        rightEye = new View3D();
        rightEye.width = stage.stageWidth/2;
        rightEye.height = stage.stageHeight;
        rightEye.x = stage.stageWidth/2;
        rightEye.y = 0;
        rightEye.backgroundColor = 0xFF9900;

        rightEye.stage3DProxy = stage3DProxy;
        rightEye.shareContext = true;


        rightEye.layeredView = true;


        rightEye.camera = new Camera3D();
        //rightEye.camera.lens = new VRLens(zoom,0.25,0.5);
        rightEye.camera.lens = new PerspectiveLens(zoom);
        rightEye.camera.lens.far = cameraViewDistance;
        rightEye.camera.lens.near = 100;
        rightEye.z = 0;
        cameraControllerR = new HoverController(rightEye.camera, null, pan, 0, 0.1);

        rightEye.scene = scene;
        addChild( rightEye );
        rightEye.render();

        rightEye.visible = true;
        stage3DProxy.context3D.setDepthTest(true,Context3DCompareMode.LESS);

    //  view.width = stage.stageWidth/3;

        stage3DProxy.present();

        panoTilesLoaded();

    }

Any clues on how to get the new view to show?

1

There are 1 best solutions below

0
beek On

I had to initialise the first view using Stage3dProxy, and change the enter frame listener to Stage3dProxy.