Skip to content

Commit 7b46065

Browse files
Apply the transform control on the parent when clicking on an edge (#732)
* Apply the transform control on the parent when clicking on an edge. * Update _updateTransformControls as suggested by Martin. * Update _updateTransformControls with restoring the part dealing with detaching transformControls.
1 parent 5a9a0a0 commit 7b46065

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

packages/base/src/3dview/mainview.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,12 +1308,39 @@ export class MainView extends React.Component<IProps, IStates> {
13081308
private _updateTransformControls(selection: string[]) {
13091309
if (selection.length === 1 && !this._explodedView.enabled) {
13101310
const selectedMeshName = selection[0];
1311-
const matchingChild = this._meshGroup?.children.find(child =>
1311+
1312+
if (selectedMeshName.startsWith('edge')) {
1313+
const selectedMesh = this._meshGroup?.getObjectByName(
1314+
selectedMeshName
1315+
) as BasicMesh;
1316+
1317+
if (selectedMesh.parent?.name) {
1318+
const parentName = selectedMesh.parent.name;
1319+
1320+
// Not using getObjectByName, we want the full group
1321+
// TODO Improve this detection of the full group. startsWith looks brittle
1322+
const parent = this._meshGroup?.children.find(child =>
1323+
child.name.startsWith(parentName)
1324+
);
1325+
1326+
if (parent) {
1327+
this._transformControls.attach(parent as BasicMesh);
1328+
1329+
this._transformControls.visible = this.state.transform;
1330+
this._transformControls.enabled = this.state.transform;
1331+
}
1332+
}
1333+
return;
1334+
}
1335+
1336+
// Not using getObjectByName, we want the full group
1337+
// TODO Improve this detection of the full group. startsWith looks brittle
1338+
const selectedMesh = this._meshGroup?.children.find(child =>
13121339
child.name.startsWith(selectedMeshName)
13131340
);
13141341

1315-
if (matchingChild) {
1316-
this._transformControls.attach(matchingChild as BasicMesh);
1342+
if (selectedMesh) {
1343+
this._transformControls.attach(selectedMesh as BasicMesh);
13171344

13181345
this._transformControls.visible = this.state.transform;
13191346
this._transformControls.enabled = this.state.transform;

0 commit comments

Comments
 (0)