Away3D Orthographic Lens & MouseClick

I’m having some issues getting mouse clicks, or any mouse events interacting with away3d scenes when using Orthographic lens, OrthographicOffCenterLens in this case, but the same issues apply to a standard OrthographicLens.

I have applied the typo fix to the OrthographicOffCenterLens.hx code from OrthographicLens (https://github.com/away3d/away3d-core-fp11/pull/692/commits/a493d43fcfe512e83618425c14a4b1fdeb4168ea), which hasn’t seemed to have been applied yet…

// Replace the following
//if (v == null) v = new Vector3D();
//v.x = nX;
//v.y = -nY;
//v.z = sZ;
//v.w = 1;

// With the following	
if (v == null) v = new Vector3D();
var translation:Vector3D = Matrix3DUtils.CALCULATION_VECTOR3D;
matrix.copyColumnTo(3, translation);
v.x = nX + translation.x;
v.y = -nY + translation.y;
v.z = sZ;
v.w = 1;

The mouse events do fire, but not correctly, the translation from the stage mouse position to 3D mesh positions seems way off, so rollover or click events etc. don’t fire over the mesh, but from an arbitrary position on screen.

I have tried both Ortho lens options and both exhibit the same behavior, to the extent that makes me question if anybody has them working.

Is this a known bug or have I missed something.

Thanks

1 Like

Do you have a way of testing a basic test like this with the AS3 version of Away3D? It would be really interesting to know if this is a bug caused by the Haxe port.

There is a hit testing algorithm that we don’t have in our version, which used PixelBender in the AS3 version, but I think that was for speed only, so I don’t think it would affect this :slight_smile:

Thanks for the suggestion to test.

Yes it is significantly improved, although still offset in the x which may be related to using a OrthographicOffCenterLens, but the rollover and click are working, albeit by clicking to the right of the mesh by a consistent amount.

It does suggest the hit test algorithm is the culprit.

Would you mind sharing your test code in ActionScript? This is really helpful for trying to validate the accuracy of the Haxe translation

I have uploaded a haxedevelop simple project to GitHub, with simple 3D AWD file and swapping between Orthographic and Perspective Lens…

1 Like

Thank you!

I’m seeing the following behavior:

Flash

When the project starts, it is orthographic. Mouse interaction occurs for each object.

Clicking the perspective button changes to a perspective view. Mouse interaction continues for each object.

Neko

When the project starts, it is orthographic. Mouse interaction rotates the view… it does not interact with the objects, except when the view is rotated 180 degrees, when interaction does start to occur with objects, though clicking empty areas still rotates the view.

When changing to perspective view, interaction appears to work the same as the Flash target.

I have not tested HTML5, yet. Also, are you running on a retina-style display? What is your primary test target for this project?

Thanks

Yes it’s been tested on a Retina display on an iPhone X so far.

The primary target is HTML5

The behavior described for Orthographic lens on HTML5 is as described for Neko, mouse movement works to rotate the view, but hit interaction with meshes isn’t correct.

It seems the translation from mouse screen position to 3D space is off, which is particularly problematic when the camera is top down.

Today I encountered this problem on Away3d-as3, and this patch effectively solves this problem.

1 Like