private function init3D():void {
scene = new Scene3D();
camera = new Camera3D();
view = new View3D();
view.scene = scene;
view.camera = camera;
resize();
window.addChild(view); }
private function initListen():void {
addEventListener(Event.ENTER_FRAME,enterFrame);
stage.addEventListener(Event.RESIZE,resize)}
protected function enterFrame(event:Event):void {
view.render(); }
protected function resize(event:Event=null):void {
view.width = stage.stageWidth;
view.height = stage.stageHeight;
//camera.position = new Vector3D(0,0,0);
}
private function initCore():void {
var mesh:Mesh = new Mesh(new SphereGeometry(2000,48,48))
mesh.material = new ColorMaterial(0x0099ff,1)
mesh.position= new Vector3D(0,0,0)
scene.addChild(mesh);}
]]>
</fx:Script>
<fx:Declarations>
<!—Place non-visual elements (e.g., services, value objects) here—>
</fx:Declarations>
Matse, Sr. Member Posted: 24 February 2012 11:31 AM Total Posts: 149
[ # 1 ]
“Not working” isn’t exactly what I’d call a good problem description
I don’t use Flex but unless that changed in the Beta, you don’t need to create a scene or camera : not sure if that’s the problem though.
private function init3D():void {
view = new View3D();
scene = view.scene;
camera = view.camera;
resize();
window.addChild(view); }
Lucid, Member Posted: 24 February 2012 11:46 AM Total Posts: 93
[ # 2 ]
Not Working = completely white.
Also, I’ve modified the code (using only the view3D). And it still does not work. (completely white).
So, this is about as basic as it gets folks. I’m using the latest Flex SDK (4.6.0), the latest version of Away3D (4.0.0 Beta) and the latest version of Flash Player (11.2).
private function init3D():void {
view = new View3D();
resize();
window.addChild(view); }
private function initListen():void {
addEventListener(Event.ENTER_FRAME,enterFrame);
stage.addEventListener(Event.RESIZE,resize)}
protected function enterFrame(event:Event):void {
view.render(); }
protected function resize(event:Event=null):void {
view.width = stage.stageWidth;
view.height = stage.stageHeight;
view.camera.position = new Vector3D(0,0,0); }
private function initCore():void {
var mesh:Mesh = new Mesh(new SphereGeometry(2000,48,48))
mesh.material = new ColorMaterial(0x0099ff,1)
mesh.position= new Vector3D(0,0,0)
view.scene.addChild(mesh); }
]]>
</fx:Script>
<fx:Declarations>
<!—Place non-visual elements (e.g., services, value objects) here—>
</fx:Declarations>
theMightyAtom, Sr. Member Posted: 24 February 2012 01:42 PM Total Posts: 669
[ # 3 ]
You are possibly obscuring the 3D scene with a white background on you “Window”. Remember, GPU 3D renders behind flashes displayList, regardless of where you attach your view.
Good Luck!
Lucid, Member Posted: 24 February 2012 01:55 PM Total Posts: 93
[ # 4 ]
I have now completely removed the SpriteVisualElement (‘window’) and have attached the View3D directly to the Stage - stage.addChild(view);
Still there is only white. I have also tried various combinations of:
1. setting mesh.bothsides = true
2. setting the Application background alpha to 0
private function init3D():void {
view = new View3D();
resize();
stage.addChild(view);
stage.addChild(new AwayStats(view))}
private function initListen():void {
addEventListener(Event.ENTER_FRAME,enterFrame);
stage.addEventListener(Event.RESIZE,resize)}
protected function enterFrame(event:Event):void {
view.render(); }
protected function resize(event:Event=null):void {
//view.x=stage.stageWidth/2;
//view.y=stage.stageHeight/2;
view.width = stage.stageWidth;
view.height = stage.stageHeight;
//view.camera.position = new Vector3D(0,0,0);
}
private function initCore():void {
var mesh:Mesh = new Mesh(new SphereGeometry(2000,48,48))
mesh.material = new ColorMaterial(0x0000ff,1)
//mesh.material.bothSides = true;
mesh.position= new Vector3D(0,0,0)
view.scene.addChild(mesh); }
kurono, Sr. Member Posted: 24 February 2012 04:20 PM Total Posts: 103
[ # 5 ]
Try this after initialization:
this.setStyle("backgroundAlpha", 0);
Hope it will resolve your problem
Another possibility is that your camera is inside your geometry or view’s clipping has too small range.
Lucid, Member Posted: 24 February 2012 05:42 PM Total Posts: 93
[ # 6 ]
Setting the background alpha to 0 does not fix the problem. The application only shows pure white.
Considering that I am running the latest versions of Flash Player, Away3D and the Flex SDK, I would say the inability to get a (basic) working setup under these circumstances is troubling to say the least.
kurono, Sr. Member Posted: 24 February 2012 06:00 PM Total Posts: 103
[ # 7 ]
To check is your View3D visible or not, change its background color or fill it with BitmapData
view.backgroundColor = 0xaabbcc;
or
view.backgroundImage = new myAsset().bitmapData;
Lucid, Member Posted: 24 February 2012 06:06 PM Total Posts: 93
[ # 8 ]
I added:
view.backgroundColor = 0x0000ff;
Still shows only white.
Matse, Sr. Member Posted: 24 February 2012 06:10 PM Total Posts: 149
[ # 9 ]
I took the time to test on my end : I get the white screen too, just the away stats showing up.
Then I tried putting the AS code in a Class extending Sprite and it worked right away, showing a blue sphere over a black background.
No idea what’s going on with the Flex version though as I never worked with Flex and only know some basics about it.
kurono, Sr. Member Posted: 24 February 2012 06:30 PM Total Posts: 103
[ # 10 ]
View3d extends Sprite. Sprite can’t be attached to Flex directly. Flex deals with UIComponent. So, I can share subroutine which can do it.
private function addFlexUIChild(addWhat:DisplayObject, addTo:UIComponent):UIComponent { var uic:UIComponent = new UIComponent(); addTo.addChild(uic); uic.addChild(addWhat); return uic; }
To add your view to the Flex container:
addFlexUIChild(view, someFlexControl);
where someFlexControl is, for example, is a Canvas
Lucid, Member Posted: 24 February 2012 06:55 PM Total Posts: 93
[ # 11 ]
@ Kurono
I solved the puzzle. It was actually very simple. I replaced the s:SpriteVisualElement with an mx:UIComponent and added the view to the UIComponent. Finally, setting the backgroundAlpha of the Flex Application to 0 allows the Stage3D to show.
kurono, Sr. Member Posted: 24 February 2012 07:38 PM Total Posts: 103
[ # 12 ]
So am I.
Stephen Hopkins, Sr. Member Posted: 24 February 2012 10:32 PM Total Posts: 110
[ # 13 ]
set the backgroundAlpha of your flex component to 0
Stephen Hopkins, Sr. Member Posted: 24 February 2012 10:33 PM Total Posts: 110
[ # 14 ]
Lucid - 24 February 2012 06:55 PM
@ Kurono
Finally, setting the backgroundAlpha of the Flex Application to 0 allows the Stage3D to show.
That is what you needed, SpriteVisualElements work fine.
frogman_pep, Newbie Posted: 27 February 2012 10:24 PM Total Posts: 19
[ # 15 ]
Lucid, I’ve been struggling to get this to work, could you post the complete working code?