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

TransformControls: Derive from Controls. #29146

Merged
merged 5 commits into from
Sep 12, 2024
Merged

TransformControls: Derive from Controls. #29146

merged 5 commits into from
Sep 12, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Aug 15, 2024

Related issue: #29085

Description

Same as #29085.

This is a breaking change though. TransformControls was derived from Object3D so far which had pros and cons. You could add the controls directly to the scene to render the gizmo (the visual helpers) but the Object3D methods attach() and detach() were overwritten with control specific methods.

The new approach is conceptually cleaner and more consistent compared to all other controls. But since TransformControls is no 3D object anymore, developers must add the gizmo differently now. So instead of:

scene.add( controls );

It is now:

scene.add( controls.getGizmo() );

@@ -89,7 +88,9 @@
scene.add( mesh );

control.attach( mesh );
scene.add( control );

const gizmo = control.getGizmo();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mrdoob Are you okay with getGizmo()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@arodic How does this change look to you?

Copy link
Owner

Choose a reason for hiding this comment

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

getGizmo() is okay 👌

Copy link
Owner

Choose a reason for hiding this comment

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

Actually, getHelper() would follow the current naming:
https://github.com/mrdoob/three.js/tree/dev/examples/jsm/helpers

@Mugen87 Mugen87 added this to the r168 milestone Aug 18, 2024
Copy link
Contributor

@puxiao puxiao left a comment

Choose a reason for hiding this comment

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

TransformControls.html

You forgot to delete these:

- <h3>[property:Object3D object]</h3>
- <p>
-	The 3D object being controlled.
- </p>

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Aug 20, 2024

@puxiao Actually I had to restore some deleted docs. The camera property actually represents the camera whereas the object reference represents the object that is controlled by TransformControls.

The thing is TransformControls does not transform the camera so it makes sense when object points to the controlled 3D object and the scene's camera is saved in a separate reference.

@puxiao
Copy link
Contributor

puxiao commented Aug 20, 2024

Rome wasn't built in a day.

By the way, you forgot to delete these:

docs/examples/en/controls/DragControls.html

    <h2>Methods</h2>

    <p>See the base [page:Controls] class for common methods.</p>

-    <h3>[method:undefined connect] ()</h3>
-    <p>
-        Adds the event listeners of the controls.
-    </p>

-    <h3>[method:undefined disconnect] ()</h3>
-    <p>
-        Removes the event listeners of the controls.
-    </p>

-    <h3>[method:undefined dispose] ()</h3>
-    <p>
-        Should be called if the controls is no longer required.
-    </p>

    <h2>Source</h2>

@puxiao
Copy link
Contributor

puxiao commented Aug 27, 2024

@Mugen87 Will these PRs be released in r168?
I have prepared some Chinese translations, but have not submitted PR yet, waiting for your this PR.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Aug 27, 2024

I'd like to wait for at least one feedback (see #29146 (comment)) so the API change is approved. Hence, the change might not be included in r168.

@Mugen87 Mugen87 modified the milestones: r168, r169 Aug 29, 2024
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Sep 12, 2024

It has been a month since the PR was filed so I'm going ahead and merge it so we can finish the migration to THREE.Controls.

Of course we can update the API at any point if things like getGizmo() or the connect/disconnect routines require changes.

@Mugen87 Mugen87 merged commit aaf577d into mrdoob:dev Sep 12, 2024
11 checks passed
LD2Studio pushed a commit to LD2Studio/LD2Studio-Editor that referenced this pull request Sep 13, 2024
* TransformControls: Derive from `Controls`.

* Docs: Clean up.

* TransformControls: Clean up.

* Docs: Clean up.

* Docs: Clean up.
LD2Studio pushed a commit to LD2Studio/LD2Studio-Editor that referenced this pull request Sep 13, 2024
* TransformControls: Derive from `Controls`.

* Docs: Clean up.

* TransformControls: Clean up.

* Docs: Clean up.

* Docs: Clean up.
@VegarRingdalAibel
Copy link
Contributor

Updated from 167 to 169.
Got error when calling dispose(), error looks to be this:
https://github.com/mrdoob/three.js/blob/dev/examples/jsm/controls/TransformControls.js#L539-L544

Traverse was part of Object3D so dispose might need some changes. Unless Ive manged to overlook/mess something up.

@jacksontan
Copy link

Hi, how do you get the function getGizmo from controls? I cannot seem to see it in
https://threejs.org/docs/#examples/en/controls/TransformControls or https://threejs.org/docs/#api/en/extras/Controls

As the suggested comment, this code scene.add(controls) will break on r169 and suggestion is to use scene.add( controls.getGizmo() ); but cannot get the gizmo.

@VegarRingdalAibel
Copy link
Contributor

image

@jacksontan
Copy link

ah right, thanks.

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

Successfully merging this pull request may close these issues.

5 participants