@@ -9,13 +9,14 @@ import SfmDataEntity 1.0
99 * Support for SfMData files in Qt3D.
1010 * Create this component dynamically to test for SfmDataEntity plugin availability.
1111 */
12+
1213SfmDataEntity {
1314 id: root
1415
1516 property bool cameraPickingEnabled: true
1617 property bool syncPickedViewId: false
1718
18- // filter out non-reconstructed cameras
19+ // Filter out non-reconstructed cameras
1920 skipHidden: true
2021
2122 signal cameraSelected (var viewId)
@@ -32,7 +33,7 @@ SfmDataEntity {
3233
3334 function spawnCameraSelectors () {
3435 var validCameras = 0 ;
35- // spawn camera selector for each camera
36+ // Spawn camera selector for each camera
3637 for (var i = 0 ; i < root .cameras .length ; ++ i)
3738 {
3839 var cam = root .cameras [i];
@@ -41,6 +42,7 @@ SfmDataEntity {
4142 if (viewId === undefined )
4243 continue ;
4344 camSelectionComponent .createObject (cam, {" viewId" : viewId});
45+ dummyCamSelectionComponent .createObject (cam, {" viewId" : viewId});
4446 validCameras++ ;
4547 }
4648 return validCameras;
@@ -80,11 +82,11 @@ SfmDataEntity {
8082 id: activePalette
8183 }
8284
83- // Camera selection picking and display
85+ // Camera selection display only
8486 Component {
85- id: camSelectionComponent
87+ id: dummyCamSelectionComponent
8688 Entity {
87- id: camSelector
89+ id: dummyCamSelector
8890 property string viewId
8991 property color customColor: Qt .hsva ((parseInt (viewId) / 255.0 ) % 1.0 , 0.3 , 1.0 , 1.0 )
9092 property real extent: cameraPickingEnabled ? 0.2 : 0
@@ -102,8 +104,33 @@ SfmDataEntity {
102104 },
103105 PhongMaterial{
104106 id: mat
105- ambient: _reconstruction && (viewId === _reconstruction .selectedViewId || (viewId === _reconstruction .pickedViewId && syncPickedViewId)) ? activePalette .highlight : customColor // "#CCC"
106- diffuse: cameraPicker .containsMouse ? Qt .lighter (activePalette .highlight , 1.2 ) : ambient
107+ ambient: _reconstruction && (viewId === _reconstruction .selectedViewId ||
108+ (viewId === _reconstruction .pickedViewId && syncPickedViewId)) ?
109+ activePalette .highlight : customColor // "#CCC"
110+ }
111+ ]
112+ }
113+ }
114+
115+ // Camera selection picking only
116+ Component {
117+ id: camSelectionComponent
118+ Entity {
119+ id: camSelector
120+ property string viewId
121+ property color customColor: Qt .hsva ((parseInt (viewId) / 255.0 ) % 1.0 , 0.3 , 1.0 , 1.0 )
122+ property real extent: cameraPickingEnabled ? 0.5 : 0
123+
124+ components: [
125+ // Use cuboid to represent the camera
126+ Transform {
127+ translation: Qt .vector3d (0 , 0 , 0.5 * cameraBack .zExtent )
128+ },
129+ CuboidMesh {
130+ id: cameraBack
131+ xExtent: parent .extent
132+ yExtent: xExtent
133+ zExtent: xExtent
107134 },
108135 ObjectPicker {
109136 id: cameraPicker
@@ -113,11 +140,10 @@ SfmDataEntity {
113140 pick .accepted = (pick .buttons & Qt .LeftButton ) && cameraPickingEnabled
114141 }
115142 onReleased : function (pick ) {
116- const delta = Qt .point (Math .abs (pos .x - pick .position .x ), Math .abs (pos .y - pick .position .y ));
117- // only trigger picking when mouse has not moved between press and release
118- if (delta .x + delta .y < 4 )
119- {
120- _reconstruction .selectedViewId = camSelector .viewId ;
143+ const delta = Qt .point (Math .abs (pos .x - pick .position .x ), Math .abs (pos .y - pick .position .y ))
144+ // Only trigger picking when mouse has not moved between press and release
145+ if (delta .x + delta .y < 4 ) {
146+ _reconstruction .selectedViewId = camSelector .viewId
121147 }
122148 }
123149 }
0 commit comments