开发者

How do I 'addChild' an DisplayObject3d from another class? (Papervision3d)

Im kind of new in the whole papervision scene. For a school assignment I'm making a panorama version of my own room using a cube with 6 pictures in it. It created the panorama, it works great.

But now I want to add clickable objects in it. One of the requirements is that my code is OOP focused. So that's what I am trying right now.

Currently I got two classes - Main.as (Here i make the panorama cube as the room) - photoWall.as (Here I want to create my first clickable object)

Now my problem is: I want to addChild a clickable object from photoWall.as to my panorama room. 开发者_运维技巧But he doesn't show it? I think it has something to do with the scenes. I use a new scene in Main.as and in photoWall.as. No errors or warnings are reported

This is the piece in photoWall.as were I want to addChild my object (photoList):

    private function portret():void
{
    //defining my material for the clickable portret
    var material : BitmapFileMaterial = new BitmapFileMaterial('images/room.jpg');
    var material_list : MaterialsList = new MaterialsList( { front: material, back: material } );

    // I don't know if this is nessecary? that's my problem
    scene = new Scene3D();

    material.interactive = true;

    // make the clickable object as a cube
    var photoList : DisplayObject3D = new Cube(material_list, 1400, 1400, 1750, 1, 4, 4, 4);

    // positioning
    photoList.x = -1400;
    photoList.y = -280;
    photoList.z = 5000;

    //mouse event 
    photoList.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, onPress);

    // this is my problem! I cannot see 'photoList' within my scene!!!
    scene.addChild(photoList);

    // trace works, so the function must be loaded.
    trace('function loaded'); 
}

Hope you guys can help me out here. Would really be great!

Thanks,

Sandor


you have to render before you can se anything.

missing: viewport.startRender()


No I already rendered everything in another class. I figured it out, the answer is: I have to make this class a displayobject3d. that's it. everything you addchild on the stage now is a displayobject3d.

for details or code..just ask.

view the result of my little project here :

http://www.sandorkerst.com/papervision/bin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜