My application has a View3d (viewport) that is included in a user interface with lots of other non 3d related graphical stuff. In away3d version 3.6 I put the view3d onto a sprite that I was able to move around and make visible and invisible as needed. However when I try to do the same thing with the version 4 View3D object the viewport is always hidden below the sprite that it was added to. I’ve attached the following sample program that illustrates the problem.
Interestingly enough the x/y position of the View3D gets moved properly but the visible property is ignored and any background fill color in the sprite completely covers over the View3D. This is not at all what I would expect and if this is the way it has to be - my application is screwed!
Please let me know if I am doing something stupid or is this the way the View3d object is designed because of it’s interaction with stage3d?
The code that illustrates the problem is below. The View3D is addChild’ed to the vctr sprite object which I make visible/invisible and move around. The compiled swf is attached.
thanks in advance,
...bob…
package
{
import away3d.containers.View3D;
import away3d.materials.ColorMaterial;
import away3d.primitives.Cube;
import away3d.primitives.Plane;
import away3d.primitives.Sphere;
import away3d.containers.ObjectContainer3D;
import away3d.cameras.Camera3D;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
[SWF (width="500", height="500")]
public class foobar extends Sprite
{
private var _view : View3D;
private var _ctr : ObjectContainer3D;
private var vctr:Sprite;
public function foobar()
{
stage.frameRate = 30;
_view = new View3D();
_view.width = 200;
_view.height = 200;
_view.x = 25;
_view.y = 25;
_view.camera = new Camera3D();
vctr = new Sprite();
vctr.x = 0;
vctr.y = 0;
vctr.graphics.beginFill(0xffff00);
vctr.graphics.drawRect(0,0,500,500);
vctr.graphics.endFill();
this.addChild(vctr);
vctr.addChild(_view);
var t:TextField = new TextField();
t.text = "Look at this!";
t.x = 50;
t.y = 250;
vctr.addChild(t);
this.addEventListener(Event.ENTER_FRAME, _handleEnterFrame);
_ctr = new ObjectContainer3D();
_view.scene.addChild(_ctr);
var material : ColorMaterial = new ColorMaterial(0xff0000);
_ctr.addChild(new Plane(material)).x = -200;
_ctr.addChild(new Cube(material, 100, 100, 100, 11, 7, 25, false));
_ctr.addChild(new Sphere(material)).x = 200;
}
private var tick:int = 0;
private function _handleEnterFrame(ev : Event) : void
{
_ctr.rotationY += 1;
_view.render();
tick++;
if ((tick0) == 0) {
vctr.visible = !vctr.visible;
vctr.x += 10;
};
}
}
}