Black screen Broomstick

84 views
Skip to first unread message

kyma

unread,
Apr 7, 2011, 7:25:57 AM4/7/11
to Away3D.dev
I've been having fun playing with the broomstick examples. When I
tried to begin a project from scratch though, I'm juts getting a black
screen. I can't see any objects. I have checked, and they are
definitely being added to the display list, but I can't see them. Is
there anything I need to set up in my camera/scene, or can anyone
offer any tips for debugging this, because I'm currently a bit stuck

John Brookes

unread,
Apr 7, 2011, 7:44:15 AM4/7/11
to away3...@googlegroups.com
Unless this is some guessing game.

Tip 1
post the code

kyma

unread,
Apr 7, 2011, 8:32:20 AM4/7/11
to Away3D.dev
:-) Yep sorry, that was a desperate plea for help and not very useful.
My view component:

package com.netaporter.napLive.views
{

import away3d.cameras.Camera3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.core.render.DefaultRenderer;
import away3d.materials.ColorMaterial;
import away3d.materials.WireframeMaterial;
import away3d.primitives.Sphere;

import flash.events.Event;

import mx.core.UIComponent;

public class AwayView extends UIComponent
{
public var view:View3D
public var _scene:Scene3D = new Scene3D();
private var _camera:Camera3D = new Camera3D();

protected var viewWidth:Number;
protected var viewHeight:Number;

public function AwayView()
{
view = new View3D(_scene,_camera);
super();
}

public function setDimensions(_width:Number,_height:Number):void {
viewWidth = _width;
viewHeight = _height;
update();
}

public function set camera(cam:Camera3D):void {
this.view.camera = cam;
}

public function get camera():Camera3D {
return this.view.camera;
}

override protected function createChildren():void
{
super.createChildren();
this.addChild( view );
view.addEventListener(Event.ADDED_TO_STAGE, update);
}

override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
update();
}

private function update(e:* = null):void
{
if(view.stage){
view.x = viewWidth/2;
view.y = viewHeight/2;
view.render();
view.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
}

private function enterFrameHandler(e:Event):void {
view.render();

kyma

unread,
Apr 7, 2011, 8:39:57 AM4/7/11
to Away3D.dev
Then I'm trying to set up a background. For the moment, just adding a
sphere as a test. Passing my view component to this controller:

package com.netaporter.napLive.control
{
import away3d.materials.ColorMaterial;
import away3d.primitives.Sphere;

import com.netaporter.napLive.displayObjects.NapBackground;
import com.netaporter.napLive.views.NapliveView;

import flash.events.EventDispatcher;

public class BackgroundControl extends ANapLiveControl
{
private var bg:NapBackground;
public function BackgroundControl(_viewCom:NapliveView,
_dispatcher:EventDispatcher)
{
super(_viewCom, _dispatcher);
}

override protected function initDisplayObjects():void {
bg = new NapBackground();
var test:Sphere= new Sphere(new ColorMaterial(0xffffff,1));
this.view.mainContainer.addChild(test);

kyma

unread,
Apr 7, 2011, 8:43:11 AM4/7/11
to Away3D.dev
The I've got a similar controller for the camera, that just moves it
to -500 z and tells it to look at the centre.

John Brookes

unread,
Apr 7, 2011, 9:02:07 AM4/7/11
to away3...@googlegroups.com
And they say mvc makes things simpler :/

Pass.

Michael Iv

unread,
Apr 7, 2011, 9:05:00 AM4/7/11
to away3...@googlegroups.com
I am not sure MVC is always a good choice for this kind of apps
.BTW , John have you solved the problem with rotations?

On Thu, Apr 7, 2011 at 4:02 PM, John Brookes <jbp...@googlemail.com> wrote:
And they say mvc makes things simpler :/

Pass.



--
Michael Ivanov ,Programmer
Neurotech Solutions Ltd.
Flex|Air |3D|Unity|
www.neurotechresearch.com
http://blog.alladvanced.net
Tel:054-4962254
mic...@neurotech.co.il
te...@neurotech.co.il

John Brookes

unread,
Apr 7, 2011, 9:17:07 AM4/7/11
to away3...@googlegroups.com
@Michael
Facial twitch appears again starts rocking back and forward.
No :(
Sort of hidden it away before I go insane.
But feel free to make me go DOH.

Michael Iv

unread,
Apr 7, 2011, 9:19:09 AM4/7/11
to away3...@googlegroups.com
If you can send me the code in private i can take a look at the evening . :)

John Brookes

unread,
Apr 7, 2011, 9:23:52 AM4/7/11
to away3...@googlegroups.com
Kyma not sure what your doing but check that the render actually fires.
just trace in the enterframe.

Also I've no idea what the sphere is being added to
this.view.mainContainer.addChild(test);

view.scene.addChild(test)?

or what NapBackground is.

Sorry, other than that not a clue.

kyma

unread,
Apr 7, 2011, 11:08:14 AM4/7/11
to Away3D.dev
I solved this by removing all the flex bits. It's probably something
in my implementation but I couldn't get anything to work in a Flex
UIComponent. I can work around it for now, but I'd be interested to
know if anyone else has had Broomstick working in Flex components, or
whether this is a bug.
Like I say, it's most likely something stupid I was doing. Thanks a
lot for your suggestions everyone. Incidentally, aside from the last
few hours' frustrations, I don't think I've ever had so much fun at
work. Everything looks so smooth and runs so quickly. Incredible
work devs :-)

Li

unread,
Apr 7, 2011, 11:20:07 AM4/7/11
to away3...@googlegroups.com, kyma
I think the Adobe PB3D examples use Flex.

Justin Patrin

unread,
Apr 18, 2011, 7:09:09 PM4/18/11
to away3...@googlegroups.com
Actually this is because the 3D stuff happens in a layer beneath the flex components. You just need to set your Application's backgroundAlpha to 0.

Yeah, it took me forever to figure that out too.

--
Justin Patrin
Developer Extraordinaire

Stephen Hopkins

unread,
May 15, 2011, 5:17:20 AM5/15/11
to Away3D.dev
wow, spent like 4 hours trying to figure this out until now. Thanks
justin. Is this a bug with flex?

richardolsson

unread,
May 15, 2011, 5:53:31 AM5/15/11
to Away3D.dev
Molehill by design renders the 3D behind everything (except
StageVideo, which is even further down the stack.) Flex by design
works only with the display list, so if Flex draws a background it's
gonna be over StageVideo and Stage3D (Molehill.) Hence, you need to
prevent Flex from drawing a background.

The View3D is a display object, but it can't actually be used to move
the view around in the display list. The main reason that it's a
display object is actually legacy reasons.

Bottom line is, Molehill will always render 3D behind the display
list, so don't try to draw a background gradient or anything like that
in the display list, as it will always obscur your 3D canvas.


Cheers
/R
Reply all
Reply to author
Forward
0 new messages