A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: help: remove Plane from scene (papervision3d)

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    16

    help: remove Plane from scene (papervision3d)

    I am working with papervision3d to display photos from a gallery. With the code below, it is straight forward to load a single image at a time into the 3d renderer.

    The problem is: When a new photo is loaded, it only partially loads atop the previous photo. I need some way to remove the previous photo/plane.

    PHP Code:
    public function load_image():void {
            
                
        
    photo_loader = new Loader();
        
    photo_loader.load(new URLRequest(gallery_list[photo_num]));
    photo_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESSimage_loading);
    photo_loader.contentLoaderInfo.addEventListener(Event.COMPLETEimage_loaded);

    }
             
    public function 
    image_loaded(e:Event):void {
                
        
    mat = new BitmapFileMaterial(gallery_list[photo_num]);
        
    plane = new Plane(mat60045044);
        
    scene.addChild(plane);
        
    camera.zoom 100;
        
    renderer.renderScene(scenecameraviewport);
    }
             
    public function 
    image_loading(e:ProgressEvent):void {} 
    I've tried

    PHP Code:
    scene.removeChild(plane); 
    Thanks,

  2. #2
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    The scene.removeChild(plane); should work if it is placed in the correct spot. How does the rest of your code look?

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    16
    I've tried putting removeChild in various places. It seems to remove the Plane for good, so that I can't see any image at all.

    PHP Code:
    package Gallery{

        
    import flash.display.*;
        
    import flash.events.*;
        
    import flash.xml.*;
        
    import flash.text.*;
        
    import flash.net.*;

        
    import org.papervision3d.events.InteractiveScene3DEvent;
        
    import org.papervision3d.materials.BitmapColorMaterial;
        
    import org.papervision3d.cameras.*;
        
    import org.papervision3d.objects.primitives.*;
        
    import org.papervision3d.materials.*;
        
    import org.papervision3d.render.*;
        
    import org.papervision3d.view.*;
        
    import org.papervision3d.scenes.*;
        
        
        public class 
    Gallery extends MovieClip {
            
            private var 
    _stage:Stage;

            private var 
    xml_loader:URLLoader;
            private var 
    photo_loader:Loader;
            private var 
    photo_num:Number 0;
            private var 
    width_list:XMLList;
            private var 
    gallery_xml:XML;
            private var 
    gallery_list:XMLList;

            
            private var 
    viewport:Viewport3D = new Viewport3D(1000600truetrue);
            private var 
    renderer:BasicRenderEngine = new BasicRenderEngine();
            private var 
    scene:Scene3D = new Scene3D();
            private var 
    camera:Camera3D = new Camera3D();
            private var 
    mat:BitmapFileMaterial;
            private var 
    plane:Plane;
            

            public function 
    Gallery(mc:MovieClipstage:Stage):void
            
    {
                
                
    _stage stage;
                
                
    load_xml(null);
            
                
    _stage.addEventListener(MouseEvent.CLICKinc_photo);
                
                
    _stage.addEventListener(Event.ENTER_FRAMEOnEnterFrame);
                
                
    _stage.addChild(viewport);

            }
            
    //**********LOAD XML
            
    public function load_xml(e:Event):void
            
    {
                
    xml_loader = new URLLoader();
                
    xml_loader.addEventListener(Event.COMPLETEload_gallery);
                
    xml_loader.load(new URLRequest("Gallery/gallery.xml"));
            
            }
            
    //**********PARSE XML
            
    public function load_gallery(xml_event:Event):void {
                
                
    gallery_xml = new XML(xml_event.target.data);
                
    gallery_list gallery_xml.section.(@name == section).photo.attribute("url");
                
    width_list gallery_xml.section.(@name == section).photo.attribute("width");
                
                
    load_image();
            }
            
    //**********LOAD IMAGE
            
    public function load_image():void {
            
                
                
    photo_loader = new Loader();
                
    photo_loader.load(new URLRequest(gallery_list[photo_num]));
                
    photo_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESSimage_loading);
                
    photo_loader.contentLoaderInfo.addEventListener(Event.COMPLETEimage_loaded);

            }
             
    //**********SETUP PLANE & RENDER
            
    public function image_loaded(e:Event):void {
                
                
    mat = new BitmapFileMaterial(gallery_list[photo_num]);
                
    mat.smooth true;
                
    mat.interactive true;    
                
    plane = new Plane(matwidth_list[photo_num], 45044);
                
    scene.addChild(plane);
                
    camera.zoom 100;
                
    renderer.renderScene(scenecameraviewport);
            }
             
    //**********WHILE LOADING....
            
    public function image_loading(e:ProgressEvent):void {}
            
    //**********FRAME HEAD
            
    public function OnEnterFrame(stage_event:Event):void {}

    //**********INCREMENT PHOTO (PREV/NEXT)
            
    public function inc_photo(click_event:MouseEvent):void
            
    {
                
                if(
    mouseX _stage.stageWidth/2){photo_num += 1;}
                if(
    mouseX _stage.stageWidth/2){photo_num -= 1;}
                if(
    photo_num <= || photo_num >= gallery_list.length()){photo_num 0;} //reset to 0
                
    load_image();
                
            }    
        }


  4. #4
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    um... ok I may not be able to help after all. Sorry. The only other thing I can think of is you may need to add some code that puts the gallery images in to a sprite or movieClip that then gets added to the plane. That way you can remove the image holder, while still keeping your plane intact. Not sure it this would work. Good luck : )

  5. #5
    Junior Member
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by word2yerMom View Post
    um... ok I may not be able to help after all. Sorry. The only other thing I can think of is you may need to add some code that puts the gallery images in to a sprite or movieClip that then gets added to the plane. That way you can remove the image holder, while still keeping your plane intact. Not sure it this would work. Good luck : )
    This is actually what I had originally done. It worked fine once the image was loaded, but during the load (progressEvent) weird things happened with the images. I wasn't able to get the loading sequence I wanted.
    I thought that adding the image directly to a bitmapMaterial would make things easier, but I've had no luck. Thanks for your thoughts!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center