@@ -1032,11 +1032,14 @@ export class MainView extends React.Component<IProps, IStates> {
1032
1032
selectedMesh . material . color = originalColor ;
1033
1033
}
1034
1034
1035
- const groupBoundingBox = this . _meshGroup ?. getObjectByName (
1035
+ const parentGroup = this . _meshGroup ?. getObjectByName (
1036
+ selectedMesh . name
1037
+ ) ?. parent ;
1038
+ const boundingBox = parentGroup ?. getObjectByName (
1036
1039
SELECTION_BOUNDING_BOX
1037
- ) ;
1038
- if ( groupBoundingBox ) {
1039
- this . _meshGroup ?. remove ( groupBoundingBox ) ;
1040
+ ) as THREE . Mesh ;
1041
+ if ( boundingBox ) {
1042
+ boundingBox . visible = false ;
1040
1043
}
1041
1044
1042
1045
const material = selectedMesh . material as THREE . Material & {
@@ -1058,6 +1061,10 @@ export class MainView extends React.Component<IProps, IStates> {
1058
1061
continue ;
1059
1062
}
1060
1063
1064
+ if ( ! selectedMesh . visible ) {
1065
+ continue ;
1066
+ }
1067
+
1061
1068
if ( selectedMesh . name . startsWith ( 'edge' ) ) {
1062
1069
// Highlight edges using the old method
1063
1070
if ( ! selectedMesh . userData . originalColor ) {
@@ -1080,29 +1087,16 @@ export class MainView extends React.Component<IProps, IStates> {
1080
1087
// Highlight non-edges using a bounding box
1081
1088
this . _selectedMeshes . push ( selectedMesh ) ;
1082
1089
1083
- // Create and add bounding box
1084
- const geometry = new THREE . BoxGeometry ( 1 , 1 , 1 ) ;
1085
- const material = new THREE . LineBasicMaterial ( {
1086
- color : BOUNDING_BOX_COLOR ,
1087
- depthTest : false
1088
- } ) ;
1089
- const boundingBox = new THREE . LineSegments (
1090
- new THREE . EdgesGeometry ( geometry ) ,
1091
- material
1092
- ) ;
1093
- boundingBox . name = SELECTION_BOUNDING_BOX ;
1094
-
1095
- // Set the bounding box size and position
1096
- const bbox = new THREE . Box3 ( ) . setFromObject ( selectedMesh ) ;
1097
- const size = new THREE . Vector3 ( ) ;
1098
- bbox . getSize ( size ) ;
1099
- boundingBox . scale . copy ( size ) ;
1090
+ const parentGroup = this . _meshGroup ?. getObjectByName (
1091
+ selectedMesh . name
1092
+ ) ?. parent ;
1093
+ const boundingBox = parentGroup ?. getObjectByName (
1094
+ SELECTION_BOUNDING_BOX
1095
+ ) as THREE . Mesh ;
1100
1096
1101
- const center = new THREE . Vector3 ( ) ;
1102
- bbox . getCenter ( center ) ;
1103
- boundingBox . position . copy ( center ) ;
1104
-
1105
- this . _meshGroup ?. add ( boundingBox ) ;
1097
+ if ( boundingBox ) {
1098
+ boundingBox . visible = true ;
1099
+ }
1106
1100
}
1107
1101
}
1108
1102
}
0 commit comments