Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable toggling transform controls #578

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

arjxn-py
Copy link
Member

@arjxn-py arjxn-py commented Nov 11, 2024

toggle-transform.mov

Icon is a draft
In the direction of #573

@arjxn-py arjxn-py added the enhancement New Feature or improvement label Nov 11, 2024
Copy link
Contributor

github-actions bot commented Nov 11, 2024

Preview PR at appsharing.space

Copy link
Contributor

github-actions bot commented Nov 11, 2024

Integration tests report: appsharing.space

@trungleduc
Copy link
Member

Thanks!

this.setState(
old => ({ ...old, transform: transformEnabled }),
() => {
this._updateSelected({});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? Shouldn't we just set the transformControls object's visible attribute here instead? Or the enabled property

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i tried that but just setting those was preventing transformControls from disabling or enabling right on clicking the toggle button, which is why I also had to trigger this part of code:

this._transformControls.attach(matchingChild as BasicMesh);
const obj = this._model.sharedModel.getObjectByName(selectedMeshName);
const positionArray = obj?.parameters?.Placement?.Position;
if (positionArray && positionArray.length === 3) {
const positionVector = new THREE.Vector3(
positionArray[0],
positionArray[1],
positionArray[2]
);
this._transformControls.position.copy(positionVector);
}
this._transformControls.visible = true;
this._transformControls.enabled = true;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, though calling _updateSelected({}) means unselecting anything that was previously selected.

I'm a bit confused you need this code to be triggered again. This code should already have been triggered upon the latest selection.

Copy link
Member Author

@arjxn-py arjxn-py Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should already have been triggered upon the latest selection.

i am needed to reselect the object manually after toggling the transform controls from the button

though calling _updateSelected({}) means unselecting anything that was previously selected.

yes this is not ideal and should be done better, happy to start iterating & hear thoughts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am needed to reselect the object manually

Do you know why you need that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am needed to reselect the object manually

Do you know why you need that?

It was most probably needed because of missing attach & detach calls.
Is it better after f0b2c6d? if not what should be the right method to get the selected object?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not look correct to me this._pick() will run the raycast picking, so it's entirely dependent on your current mouse position. This means your code does not work (won't attach to the correct object) if the mouse is mal-positioned.

I'm still not sure why you need to attach/detach here?

It should already have been attached here on the latest selection. So AFAIU your code here should only do enabled = false/true and visible = false/true.

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just have a comment/question

@trungleduc
Copy link
Member

trungleduc commented Nov 13, 2024

Could you append a div containing the helper text to switch between rotation and translation mode into the main view div element? You could use the absolute position to place it in the bottom right of the viewport. Like this one

hint

@arjxn-py
Copy link
Member Author

Could you append a div containing the helper text to switch between rotation and translation mode into the main view div element? You could use the absolute position to place it in the bottom right of the viewport. Like this one

Yes, that looks great. Thank You 🚀 i'll be on it

@trungleduc
Copy link
Member

This element can also be used for the clipping plane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New Feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants