Skip to content

TransformControls may jump a random distance while starting translation after translating another axis on mobile #31280

@wxfred

Description

@wxfred

Description

I tested TransformControls on mobile and chrome mobile debug mode, my program has this problem on both.
My codes are complicated, sorry I can't paste them, and I can't reproduce this problem with official demo which is a simple usage. I'm not sure if it only occurs when the scenario is too complex.

But I add console.log to debug the source code of TransformControls, I found in pointerDown and the first pointerMove , planeIntersect may get big difference values when you have just moved another axis
const planeIntersect = intersectObjectWithRay( this._plane, _raycaster, true );

For example, if I moved x axis, released the mouse, then move the same x axis again, no problem. If I moved x axis, released the mouse, then move y or z axis, the problem may occur.

Then, I tried to invoke updateMatrixWorld like below, the problem solved.

pointerDown( pointer ) {

        this._plane.updateMatrixWorld() // add this line will solve the problem

	if ( this.object === undefined || this.dragging === true || ( pointer != null && pointer.button !== 0 ) ) return;

Maybe consider to add this protection to make sure the ray intersection on this._plane return the correct result?

Reproduction steps

Problem
1.move x axis, release mouse
2.move y axis with a slightly movement (don't release mouse), the object may jump a random distance through y axis
3.continue move y axis, no random jumps

No Problem
1.move x axis, release mouse
2.move x axis again, no random jumps

Code

Sorry to provide only parts.

// init
const transformControls = new TransformControls(camera, Renderer.canvas)
const gizmo = transformControls.getHelper()
scene.add(gizmo)
transformControls.addEventListener('dragging-changed', function (event) {
  console.log('dragging-changed', event.value)
  orbitControls.enabled = !event.value
  vm.isDragging = event.value
})
// attach
const intersects = raycaster.intersectObjects(group.children, true)
if (intersects.length > 0) {
  const object = intersects[0].object
  transformControls.attach(object)
  ...
} else {
  transformControls.detach()
  ...
}

Live example

none

Screenshots

No response

Version

0.177.0

Device

Mobile

Browser

Chrome

OS

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions