Papervision Help!

Hello, I’m Ricardo Catarino (Portuguese), and i need some help on papervision for my School Final Project.:link:

So, I m doing a website, and the navigation is the 3D object thet i import from swift3D to Papervision, in other words, i have a fantasy world(sphere Mesh), then 3 planes on it. And on those 3 planes, i want to insert the button. Then the Buttons will Load a external SWF or a movieclip.

Can anyone help???
By the Way i will leave the code down there.:mario:

The code works, but when i insert a button on the movie clip, he does’t load it. Bah…:crying:

Thx

//!============================================================================
//!                              ERMain.as
//!
//!                 Copyright 2007 (c) Electric Rain, Inc.
//!============================================================================
//!
//! Permission is hereby granted, free of charge, to any person obtaining a
//! copy of this software and associated documentation files (the "Software"),
//! to deal in the Software without restriction, including without limitation the
//! rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
//! sell copies of the Software, and to permit persons to whom the Software is
//! furnished to do so, subject to the following conditions:
//!
//! The above copyright notice and this permission notice shall be included in
//! all copies or substantial portions of the Software.
//!
//! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
//! DEALINGS IN THE SOFTWARE.
//!
//!============================================================================

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.utils.Dictionary;

    import org.papervision3d.cameras.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.materials.MovieAssetMaterial;
    import org.papervision3d.objects.*;
    import org.papervision3d.scenes.*;
    import org.papervision3d.core.*;
    import org.papervision3d.core.proto.*;
    import org.papervision3d.events.FileLoadEvent;


    public class ERMain extends Sprite
    {
        // Member variables
        public  var mCamera                        :Camera3D;
        public  var mCollada                    :Collada;
        public var  mSceneCenter                :Number3D;

        private var mContainer                    :Sprite;
        private var movieAssetMaterial          :MovieAssetMaterial;

        private var mRadius                        :Number;
        private var mRootNode                    :DisplayObject3D;
        private var mRotationAnchor                :Number3D;

        private var mScene                        :Scene3D;

        private var mTarget                        :DisplayObject3D;

        private var mWheelZoomAmount            :Number                = 1.10;

        // Constructor for the ERMain class
        public function ERMain()
        {
            stage.quality = "HIGH";
            stage.scaleMode = "noScale";

            // 3D redraw mechanism as the 3D scene is manipulated
            this.addEventListener( Event.ENTER_FRAME, EROnEnterFrame );

            // Set the event handlers for the mouse to the stage so we will
            // handle all mouse events not just those that click on a display
            // object in this class.  These event handlers handle the interactive
            // rotation and mouse wheel zooming.
            stage.addEventListener(MouseEvent.MOUSE_DOWN, ERMouseDownHandler);
            stage.addEventListener(MouseEvent.MOUSE_UP, ERMouseUpHandler);
            stage.addEventListener(MouseEvent.MOUSE_WHEEL, ERMouseWheelHandler);

            mRotationAnchor = new Number3D;

            // Perform the 3D initialization.
            ERInitialize();
        }


        // This method creates and initializes the 3D scene.
        private function ERInitialize():void
        {
            // Create canvas movieclip and center it
            this.mContainer = new Sprite();
            addChild( this.mContainer );
            this.mContainer.x = 275;
            this.mContainer.y = 200;

            // Create Scene
            this.mScene = new Scene3D( this.mContainer );
            mTarget = new DisplayObject3D ( );


            // Create Camera.  Camera is based on selected Swift 3D
            // camera at the time of export.
            mCamera = new Camera3D();
            mCamera.x = 0;
            mCamera.y = 0;
            mCamera.z = -2.38918;

            mTarget.x = 0;
            mTarget.y = 0;
            mTarget.z = -2.38918;

            mCamera.zoom = 121.41;
            mCamera.focus = 50;
            mCamera.target = mTarget;

            // Establish the scene center to ensure all rotations
            // occur about that center.
            mSceneCenter = new Number3D;
            mSceneCenter.x = 0.253414;
            mSceneCenter.y = -0.194503;
            mSceneCenter.z = 0.0642688;

            // Below is the solid color material list.  Papervision3D Version 1.5 does not import solid
            // colors so we place them here to ensure that they will be displayed.

            var lMaterialsList:MaterialsList = new MaterialsList();
            lMaterialsList.addMaterial ( new MovieAssetMaterial("Symbol1", false), "color1");
            lMaterialsList.addMaterial ( new MovieAssetMaterial("Symbol1", false), "color2");
            lMaterialsList.addMaterial ( new MovieAssetMaterial("Symbol1", false), "color3");


            mCollada = new Collada("fworld.dae", lMaterialsList, 0.01);
            mCollada.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, EROnFileLoaded);

            mRootNode = mScene.addChild( mCollada, "mRootNode" );
        }

        // The next three functions will turn all of the materials to double sided.
        private function EROnFileLoaded( event :Event ):void
        {
            var lMaterialsList:MaterialsList = mCollada.getMaterialsList ( );
            if ( lMaterialsList )
            {
                for each ( var lMaterial:MaterialObject3D in lMaterialsList.materialsByName )
                    lMaterial.doubleSided = true;
            }

            var lChildren:Dictionary = Dictionary (mCollada.children);
            ERProcessChildrenMaterials ( lChildren );
        }

        private function ERProcessChildrenMaterials ( aChildren:Dictionary ):void
        {
            if ( aChildren )
            {
                for each ( var lChild:DisplayObject3D in aChildren )
                    ERProcessChildMaterials ( lChild );
            }

            var lChildren:Dictionary = Dictionary (mCollada.children);
        }

        private function ERProcessChildMaterials( aChild:DisplayObject3D ):void
        {
            if ( aChild )
            {
                if ( aChild.materials )
                {
                    for each ( var lMaterial:MaterialObject3D in aChild.materials.materialsByName )
                        lMaterial.doubleSided = true;
                }

                var lChildren:Dictionary = Dictionary (aChild.children);
                ERProcessChildrenMaterials ( lChildren );
            }
        }

        // Rendering method to display changes as the scene is manipulated.
        private function EROnEnterFrame( event :Event ):void
        {
            this.mScene.renderCamera( mCamera );
        }

        // When the mouse is pressed anywhere on the stage, set up for
        // rotational manipulation and add the mouse move event handler. 
        // The rotational system is just like Swift 3D's trackballs.  When
        // the mouse is within the ball, the scene tracks like it is inside
        // a ball and when the mouse is outside the ball, it spins around the
        // axis perpendicular to the screen.
        private function ERMouseDownHandler(event:MouseEvent):void
        {
            if ( mScene.container.x < mScene.container.y )
                mRadius = mScene.container.x;
            else
                mRadius = mScene.container.y;

            mRotationAnchor.x = mScene.container.mouseX;
            mRotationAnchor.y = mScene.container.mouseY;

            var lValue:Number = (mRadius * mRadius) - (mRotationAnchor.x * mRotationAnchor.x) - (mRotationAnchor.y * mRotationAnchor.y);
            if ( lValue < 0 )
                mRotationAnchor.z = 0;
            else
                mRotationAnchor.z = Math.sqrt( lValue );

            stage.addEventListener(MouseEvent.MOUSE_MOVE, ERMouseMoveHandler);
        }

        // This mouse move handler calculates the incremental rotation between the mouse
        // down or last mouse move event and the current mouse move event.  It then rotates
        // the Papervision3D scene appropriate to that incremental rotation.
        private function ERMouseMoveHandler(event:MouseEvent):void
        {
            var lCurrentPosition:Number3D = new Number3D;
            var lLastPosition:Number3D = new Number3D;
            var lAxis:Number3D = new Number3D;
            var lCosAngle:Number;
            var lAngle:Number;
            var lTranslationMatrix:Matrix3D;
            var lRotationMatrix:Matrix3D;

            lCurrentPosition.x = mScene.container.mouseX;
            lCurrentPosition.y = mScene.container.mouseY;

            var lValue:Number = (mRadius * mRadius) - (lCurrentPosition.x * lCurrentPosition.x) - (lCurrentPosition.y * lCurrentPosition.y);
            if ( lValue < 0 )
                lCurrentPosition.z = 0;
            else
                lCurrentPosition.z = Math.sqrt( lValue );

            lLastPosition = mRotationAnchor;
            mRotationAnchor = new Number3D ( lCurrentPosition.x, lCurrentPosition.y, lCurrentPosition.z );

            lLastPosition.normalize ( );
            if ( lLastPosition.z == 0 )
                lCurrentPosition.z = 0;
            lCurrentPosition.normalize ( );
            if ( lCurrentPosition.z == 0 )
                lLastPosition.z = 0;
            lAxis = Number3D.cross ( lLastPosition, lCurrentPosition );
            lAxis.normalize ( );
            lCosAngle = Number3D.dot ( lLastPosition, lCurrentPosition );
            lAngle = Math.acos( lCosAngle );

            ERRotateScene ( lAxis, lAngle );

            event.updateAfterEvent();
        }

        // The mouse up handler terminates the interactive rotation mode by 
        // removing the mouse move handler.
        private function ERMouseUpHandler(event:MouseEvent):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, ERMouseMoveHandler);
        }

        // The mouse wheel handler zooms in or out of the scene depending on
        // the mouse wheel spin direction (positive or negative values).
        private function ERMouseWheelHandler(event:MouseEvent):void
        {
            if ( event.delta > 0 )
                mCamera.zoom *= mWheelZoomAmount;
            else
                mCamera.zoom /= mWheelZoomAmount;
        }

        public function ERZoomInScene( aZoomAmount:Number ):void
        {
            mCamera.zoom *= aZoomAmount;
        }

        public function ERZoomOutScene( aZoomAmount:Number ):void
        {
            mCamera.zoom /= aZoomAmount;
        }

        // The ERRotateScene method is used by both the interactive rotation code
        // and the button based rotation code.
        public function ERRotateScene ( aAxis:Number3D, aAngle:Number ):void
        {
            var lTranslationMatrix:Matrix3D;
            var lRotationMatrix:Matrix3D;
            var lAxis:Number3D = aAxis.clone ( );

            lTranslationMatrix = Matrix3D.translationMatrix( -mSceneCenter.x, -mSceneCenter.y, mSceneCenter.z );
            this.mCollada.transform = Matrix3D.multiply( lTranslationMatrix, this.mCollada.transform );

            lAxis.x = - lAxis.x;
            Matrix3D.rotateAxis (  mCamera.transform, lAxis );
            lRotationMatrix = Matrix3D.rotationMatrix( lAxis.x, lAxis.y, lAxis.z, aAngle );
            this.mCollada.transform = Matrix3D.multiply( lRotationMatrix, this.mCollada.transform );

            lTranslationMatrix = Matrix3D.translationMatrix( mSceneCenter.x, mSceneCenter.y, -mSceneCenter.z );
            this.mCollada.transform = Matrix3D.multiply( lTranslationMatrix, this.mCollada.transform );
        };
    }
}