JDK-8118078 : Picking is broken in SubScene
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2013-06-24
  • Updated: 2015-06-17
  • Resolved: 2013-07-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Relates :  
Description
I was going to add picking support in 3DViewer and run into this issue. For some reason targets of any mouse events in 3DViewer ContentModel subscene is SubScene, not the mesh inside.

I was unable to reproduce it with a simple app in reasonable time so please debug 3DViewer directly.

In order to debug just add the following lines to Jfx3dViewerApp.start() method:

        scene.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<Event>() {

            @Override
            public void handle(Event t) {
                System.out.println("t = " + t);
            }
        });

and observe that whenever you click anything inside 3D view subscene, you get only SubScene as the target:

t = MouseEvent [source = javafx.scene.Scene@2b5997ae, target = SubScene@45f5f40f, eventType = MOUSE_CLICKED, consumed = false, x = 397.0, y = 303.0, z = 0.0, button = PRIMARY, pickResult = PickResult [node = SubScene@45f5f40f, point = Point3D [x = 397.0, y = 268.0, z = 0.0], distance = 1.0]

3DViewer is available in rt/apps/experiments/3DViewer

You can drag the attached simple maya file onto the 3DViewer to load it and use for testing. However it seems to be reproducible no matter which file is loaded.

I also identified that if camera is changed to new PerspectiveCamera(false) in ContentModel.java:67, although it is hard to position camera properly, picking seems to work ok.
Comments
Unit Test: javafx/scene/Mouse3DTest/BoxShouldBePickedInsideSubScene
17-07-2013

Fixed by changeset 8bf5f6080484. Alexander, it should now work without the workaround.
17-07-2013

Disregard my previous comments. Picking in SubScene really is broken. There is a missing pickRay normalization so the distances are computed wrong.
16-07-2013

Well, maybe picking uses wrong coordinate system for the clipping. Discussing this in RT-31502.
16-07-2013

Pavel, thank you for the workaround! It worked for 3DViewer.
11-07-2013

Actually, picking works fine, rendering is broken (RT-30189). The cube should not be rendered at all, because it is too close to camera (in my case distance is ~0.016 whereas near clip is 0.1). The workaround is to set SubScene's camera's near clip to something closer to zero.
09-07-2013

I've also verified that if exactly same content and camera are set for external Scene, not a Subscene, then picking works ok.
24-06-2013