TransformControls no longer works after Three.js update

I updated from r108 to 121. Now hovering, clicking, or dragging does not interact with the controls.

Looks like the reason is

because in the app I’m in, we traverse TransformControls to place it in its own layer, and the raycaster now does not match the same layer.

Furthermore, the raycaster variable is private inside the TransformControls constructor, so it can not be modified.

To fix the issue I need to either

  • fork TransformControls and run raycaster.layers.enable(transformControlsLayer) within the constructor
  • or don’t put TransformControls in any layer other than default.

I used the excellent patch-package to manage and commit a patch of the three module into my project.

patch-package allows you to make edits to packages in node_modules, then it will generate a .patch out of the changes and save it in your project which you can then commit into your VCS (git, svn, etc).

It will then apply patches to modules in node_modules during the postinstall phase of your project’s npm install.

The patch I added in my case changes

	var raycaster = new Raycaster();


	var raycaster = new Raycaster();

	// Enable all layers so that TransformControls works regardless of which layer it is in.
1 Like

is there some info about this change somewhere? like why it was made to behave like that?

@drcmda Hello! That change is listed in the r113 -> r114 migration guide describing the new Raycaster#layers property.

Here’s a fix that make the TransformControls.raycaster property be public, then the end user can change the layers on the raycaster too:

1 Like

^ @Mugen87 Can you please get this fix in, or open a PR with the change? (I’m not allowed to open PRs).

1 Like

Here is a PR:

1 Like

@arpu ^ The PR got closed.

Mrdoob said:

I guess it would be good to know a bit more in depth what the use case is/was. And other use cases too.

The OP describes one such situation:

I updated from r108 to 121. Now hovering, clicking, or dragging does not interact with the controls.

Basically, it is not possible to put TransformControls in its own layer, because there is no way to also configure the private raycaster to operate on the same layers.

Simply put, there’s a layers feature, but it doesn’t work with TransformControls.

Seems that everybody forgot about previous PR, so here new one.

1 Like

I added a change as PR on your @munrocket, made it public and added docs. Do we need to add an example for it?

Sorry for the late reply but raycaster will finally be exposed with r131, see: