开发者

how I can get mouse z coordinates on flex papervision3d?

开发者 https://www.devze.com 2023-02-17 14:40 出处:网络
I am working on panoramic scene . And I want to move a plane with cursor. When I move mouse, plane must be mouse coordinates. And I want to take plane 3D coordinates (x,y,z) expecially z-coordinate.I

I am working on panoramic scene . And I want to move a plane with cursor. When I move mouse, plane must be mouse coordinates. And I want to take plane 3D coordinates (x,y,z) expecially z-coordinate. I try below code. But it doesnt work correctly. Mouse and plane are not be same coordinates on screen. How I can do?

public class RayTracer
{
    public static function getIntersection(viewport:Viewport3D, camera:CameraObject3D, normal:Array):Number3D
    {
        var plane3D:Plane3D=new Plane3D(); 
        plane3D.setNormalAndPoint(new Number3D(0, 1, 0), new Number3D(0, 0, 0));
        var cameraPosition:Number3D=new Number3D(camera.x, camera.y, camera.z);
        var ray:Number3D=camera.unproject(viewport.containerSprite.mouseX, viewport.conta开发者_如何学JAVAinerSprite.mouseY);
        ray=Number3D.add(ray, cameraPosition);
        var intersect:Number3D=plane3D.getIntersectionLineNumbers(cameraPosition, ray);
        return intersect;
    }
}


As far as I know there is no Z coordinate of the Mouse even in PV3d.


No i will try. I am trying to Mouse3d object and run below code:

private function onEnterFrame(param1:Event=null):void{
renderer.renderScene(scene, camera, viewport);
var mouse3D:Mouse3D;
viewport.interactive=true;
Mouse3D.enabled=true;
mouse3D=viewport.interactiveSceneManager.mouse3D;
trace(mouse3D.x, mouse3D.y, mouse3D.z)

}

But mouse3D coordinates always (0,0,0). I dont know why.

0

精彩评论

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