Greetings to the Away3D team, let me just start by thanking you all
for the amazing work you guys are doing! I'm very much enjoying myself
experimenting with your framework.

However I have run into a problem with the way the Mouse3DManager
currently handles the getObjectHitData function.

It currently uses the the mouse position on the stage, divided by the
stage size, which is all well and good, if you have a view that is
exacly the size of your stage.stagewidth/height. I'm afraid this is
not always the case.

For example in my current project in which the swf is 800 x 600 pixels
in size, a bar of 200 x 600 on the left side is the GUI, so my view is
positioned at x=200 and y=100 with a size of 600x600. With these
settings mouse events are nowhere near accurate.

To compensate for this problem I have changed the getObjectHitData
function to use the mouse position relative to the position of the
view and use the size of the view rather then the stage. The function
now reads as follows:

private function getObjectHitData() : void
                {
                        var collector : EntityCollector = _view.entityCollector;

                        _previousActiveObject = _activeObject;
                        _previousActiveRenderable = _activeRenderable;

                        // todo: would it be faster to run a custom 
ray-intersect collector
instead of using entity collector's data?
                        // todo: shouldn't render it every time, only when 
invalidated (on
move or view render)
                        if (collector.numMouseEnableds > 0) {
                                var viewMouseX:Number = _stage.mouseX - 
this._view.x;
                                var viewMouseY:Number = _stage.mouseY - 
this._view.y;

                                
_hitTestRenderer.update(viewMouseX/this._view.width, viewMouseY/
this._view.height, collector);

                                _activeRenderable = 
_hitTestRenderer.hitRenderable;
                                _activeObject = (_activeRenderable &&
_activeRenderable.mouseEnabled)? _activeRenderable.sourceEntity :
null;
                        }
                        else {
                                _activeObject = null;
                        }
                }

With this function the mouseEvent3D's are accurate regardless of the
views size and position. If there was a reason for the way it was done
before please let me know, otherwise I hope this gets implemented in
the future as I had to spend a lot of time figuring this out and hope
to prevent others from having to do the same thing.

Reply via email to