Skip to content

Commit

Permalink
transform working but transform axes exaggerates
Browse files Browse the repository at this point in the history
  • Loading branch information
arjxn-py committed Oct 24, 2024
1 parent 232e2dc commit 8cc8601
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion packages/base/src/3dview/mainview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,15 @@ export class MainView extends React.Component<IProps, IStates> {

this._scene.add(this._clippingPlaneMesh);
this._scene.add(this._meshGroup);

// if (this._selectedMeshes.length === 1) {
// const selectedMesh = this._selectedMeshes[0];

// const bbox = new THREE.Box3().setFromObject(selectedMesh);
// const center = new THREE.Vector3();
// bbox.getCenter(center);
// }

if (this._loadingTimeout) {
clearTimeout(this._loadingTimeout);
this._loadingTimeout = null;
Expand Down Expand Up @@ -980,7 +989,15 @@ export class MainView extends React.Component<IProps, IStates> {
return mesh;
}

private _previousSelection: { [key: string]: ISelection } | null = null;
private _updateSelected(selection: { [key: string]: ISelection }) {
const selectionChanged = JSON.stringify(selection) !== JSON.stringify(this._previousSelection);

if (!selectionChanged) {
return;
}
this._previousSelection = { ...selection };

// Reset original color and remove bounding boxes for old selection
for (const selectedMesh of this._selectedMeshes) {
let originalColor = selectedMesh.userData.originalColor;
Expand Down Expand Up @@ -1069,13 +1086,41 @@ export class MainView extends React.Component<IProps, IStates> {
this._meshGroup?.add(boundingBox);

const matchingChild = this._meshGroup?.children.find(child => child.name.startsWith(selectedMesh.name));
console.log(matchingChild);

if (matchingChild) {
this._transformControls.attach(matchingChild as BasicMesh);

// --------- To set center from matchingchild ---------------

// const bbox = new THREE.Box3().setFromObject(matchingChild);
// const size = new THREE.Vector3();
// bbox.getSize(size);
// boundingBox.scale.copy(size);

// const center = new THREE.Vector3();
// bbox.getCenter(center);

// ----------------------------------------------------------

this._transformControls.position.copy(center);
console.log(matchingChild.position);

console.log(this._transformControls.position);


this._transformControls.visible = true;
this._transformControls.enabled = true;
}
// if (this._selectedMeshes.length === 1) {
// const selectedMesh = this._selectedMeshes[0];

// const bbox = new THREE.Box3().setFromObject(selectedMesh);
// const center = new THREE.Vector3();
// bbox.getCenter(center);
// console.log(center);

// // this._transformControls.position.copy(center);
// }
}
}
}
Expand Down

0 comments on commit 8cc8601

Please sign in to comment.