I have a cube Primitive with two collada children inside it. the camera is set inside the cube looking out a "window" in the material. I have the ground Plane Viewport Layer, a skydome Viewport Layer and spaceship Viewport Layer. When i set the layer Index and everything looks great (no more z-fighting) except that my objects that are supposed to be inside the cube are no longer there.
I need to rotate the cube with the objects moving with the cube inside (joystick, horizontal indicator) so i need them to be children of the cube parent.
Any ideas on how to get around this obstacle?
Ive tried adding each object (cube, joystick and horizontal indicator) to the same viewport layer with no success. I also tried adding the cube with it's children to an empty DO3D with no success.
Thank you so much in advance, jason.
snippet of my code to see how my objects are setup...
private var cube: Cube;
private var joystick: DisplayObject3D;
private var sphere: DisplayObject3D;
//Cube Primitive
cube = new Cube(cubeMat, 1024, 675, 768, 3, 3, 3);
scene.addChild(cube);
cube.y = 4000;
cube.z = -2000;
//Joystick Collada instantiate
joystick = new Collada("assets/joystick.dae");
joystick.scale = 0.8;
joystick.z = 200;
joystick.x = 250;
joystick.y = 300;
cube.addChild(joystick);
//Sphere Collada instantiate
sphere = new Collada("assets/sphere.dae");
sphere.scale = 0.45;
sphere.z = 300;
sphere.x = 0;
sphere.y = 40;
cube.addChild(sphere);
// Instantiate Viewport Layers
var groundLayer:ViewportLayer = new ViewportLayer(viewport,null);
var skidLayer:ViewportLayer = new ViewportLayer(viewport,null);
var skyLayer:ViewportLayer = new ViewportLayer(viewport,null);
var shipLayer:ViewportLayer = new ViewportLayer(viewport,null);
// add layers to parent
viewport.containerSprite.addLayer(groundLayer);
viewport.containerSprite.addLayer(skidLayer);
viewport.containerSprite.addLayer(skyLayer);
viewport.containerSprite.addLayer(shipLayer);
// set the sorting of all childlayers to sort by index
viewport.containerSprite.sortMode = ViewportLayerSortMode.INDEX_SORT;
// set the sort index of the new layer
groundLayer.layerIndex = 1;
skidLayer.layerIndex = 2;
skyLayer.layerIndex = 3;
shipLayer.layerIndex = 4;
// add our objects to the new layers
groundLayer.addDisplayObject3D(floor);
skidLayer.addDisplayObject3D(skidStrip);
skyLayer.addDisplayObject3D(skyDome);
shipLayer.addDisplayObject3D(cube);