webcaetano / papervision3d

Automatically exported from code.google.com/p/papervision3d
0 stars 0 forks source link

Interactvity on DAE loaded objects #241

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. No matter you set material interactive to any node in the DAE tree list
object noone got interactivity. Interactivity is based on geometry and in
DAE there is lot of empty nodes that form the tree not containing the geometry.
2. There is no one working example out there.
3. Didn't figure out the need of material.interactive setting manually at
all. When you set listener to object to InteractiveEvent material
interactivity should be set by itself.

IDEA:

    override public function addEventListener(type:String, listener:Function,
useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean =
false):void 
        {

                    var inter:Boolean= (InteractiveScene3DEvent.OBJECT_OVER==type)
|| (InteractiveScene3DEvent.OBJECT_OVER==type) ||
(InteractiveScene3DEvent.OBJECT_PRESS==type) ||
(InteractiveScene3DEvent.OBJECT_RELEASE==type) ||
(InteractiveScene3DEvent.OBJECT_RELEASE_OUTSIDE==type);

                    if(!inter)
                        super.addEventListener(type, listener, useCapture, priority,
useWeakReference);
                    else
                       if (!this.geometry || !this.geometry.faces.length)
                        addEventListenerToGeomChildren(this, type, listener, useCapture,
priority, useWeakReference);
                       else
                       super.addEventListener(type, listener, useCapture, priority,
useWeakReference);

            //
        }

        /**
         * passing interactivity to children with geometry
         * @param   do3d
         * @param   type
         * @param   listener
         * @param   useCapture
         * @param   priority
         * @param   useWeakReference
         */
        private function
addEventListenerToGeomChildren(do3d:DisplayObject3D,type:String,
listener:Function, useCapture:Boolean = false, priority:int = 0,
useWeakReference:Boolean = false)
        {
            var child:DisplayObject3D;
            var faces:Array
            var childrenOfChildren:Dictionary;
            var i:int;
            var len:int;
            var children:Dictionary = do3d.children as Dictionary;

            for each(child in children)
                {

addEventListenerToGeomChildren(child,type,listener,useCapture,priority,useWeakRe
ference);

                }

                        if(!child)
                        if (do3d.geometry && do3d.geometry.faces.length)
                        {
                            /*for (var i:int = 0; i < do3d.geometry.faces.length; i++)
                             (do3d.geometry.faces[i] as Triangle3D).material.interactive = true;*/
                            do3d.material.interactive = true;
                            do3d.addEventListener(type, listener, useCapture, priority,
useWeakReference);
                        }
                        /*else
                        throw new Error("No child with geometry found on which interactivity
would be based");
                */

        }

Original issue reported on code.google.com by winxa...@gmail.com on 21 Nov 2009 at 12:00