Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RaycastPicker bug #700

Open
matrix3d opened this issue Jun 3, 2014 · 2 comments
Open

RaycastPicker bug #700

matrix3d opened this issue Jun 3, 2014 · 2 comments

Comments

@matrix3d
Copy link

matrix3d commented Jun 3, 2014

why can not pick?

the center of point is x=8 z=8

package mytest 
{
    import away3d.containers.View3D;
    import away3d.core.base.Geometry;
    import away3d.core.base.SubGeometry;
    import away3d.core.pick.PickingColliderType;
    import away3d.core.pick.PickingCollisionVO;
    import away3d.core.pick.RaycastPicker;
    import away3d.entities.Mesh;
    import away3d.events.MouseEvent3D;
    import away3d.materials.ColorMaterial;
    import away3d.materials.MaterialBase;
    import flash.events.Event;
    import flash.geom.Vector3D;
    /**
     * ...
     * @author lizhi
     */
    public class TestMouse extends View3D
    {
        
        public function TestMouse() 
        {
            addMesh(Vector.([8, -13.898313811479861 , 7, 8, -13.176487753206212, 8, 7, -13.679803966417216, 8]));
            addMesh(Vector.([8, -13.176487753206212, 8, 8, -11.964657473672023, 9, 7, -12.450258983111945, 9]));
            addMesh(Vector.([7 ,-12.450258983111945 ,9 ,7, -13.679803966417216 ,8 ,8, -13.176487753206212 ,8]));
            addMesh(Vector.([9 ,-12.955115272308943, 7, 9, -11.638058724648703 ,8, 8, -13.176487753206212, 8]));
            addMesh(Vector.([8, -13.176487753206212 ,8 ,8 ,-13.898313811479861, 7 ,9 ,-12.955115272308943, 7]));
            addMesh(Vector.([8, -11.964657473672023, 9, 8, -13.176487753206212 ,8, 9 ,-11.638058724648703, 8]));
            
            var raycastPicker:RaycastPicker = new RaycastPicker(true);
            var vo:PickingCollisionVO=raycastPicker.getSceneCollision(new Vector3D(8,1000 , 8),new Vector3D(0,-1,0), scene)
            trace(vo?vo.localPosition:null);
            camera.x = 0;
            camera.z = 0;
            camera.y = 10;
            camera.lookAt(new Vector3D);
        }
        private function addMesh(vs:Vector.):void {
            var g:Geometry = new Geometry();
            var subg:SubGeometry = new SubGeometry();
            subg.updateIndexData(Vector.([0,1,2]));
            subg.updateVertexData(vs);
            g.addSubGeometry(subg);
            
            var t:MaterialBase = new ColorMaterial(0xffffff * Math.random());
            t.bothSides = true;
            
            var m:Mesh = new Mesh(g, t);
            m.mouseEnabled = true;
            m.pickingCollider = PickingColliderType.AS3_BEST_HIT;
            scene.addChild(m);
            m.addEventListener(MouseEvent3D.MOUSE_OVER, m_mouseOver);
            m.addEventListener(MouseEvent3D.MOUSE_OUT, m_mouseOut);
            addEventListener(Event.ENTER_FRAME, enterFrame);
        }
        
        private function m_mouseOut(e:MouseEvent3D):void 
        {
            var m:Mesh = e.currentTarget as Mesh;
            m.showBounds = false;
        }
        
        private function m_mouseOver(e:MouseEvent3D):void 
        {
            var m:Mesh = e.currentTarget as Mesh;
            m.showBounds = true;
        }
        
        private function enterFrame(e:Event):void 
        {
            render();
        }
        
    }

}
@gonchar
Copy link
Member

gonchar commented Jun 5, 2014

thank you for the issue, I will check it soon

@matrix3d
Copy link
Author

matrix3d commented Jun 6, 2014

@gonchar thanks there have 5 mesh,if you marge it to one mesh.the vo also null.
var vo:PickingCollisionVO=raycastPicker.getSceneCollision(new Vector3D(8,1000 , 8),new Vector3D(0,-1,0), scene)

but if set vector3d (8.0001,1000,8.0001)
the vo not null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants