Skip to content

ArcballControls gizmos position lost after saveState() and reset() #31174

@13thirteen

Description

@13thirteen

Description

Calling saveState() and reset() on an ArcballControls instance whose target is off-origin resets the gizmos position and rotation center to the origin again. The value of target remains off-origin though.

Reproduction steps

  1. Add ArcballControls
  2. Set target to some coordinate (away from origin)
  3. Call update() to update gizmos to the new target
  4. Call saveState() to remember current state
  5. gizmos are centered around target as expected
  6. Call reset() to restore remembered state
  7. gizmos are centered around origin -> not expected

Code

    mesh.position.set(-5, 5, 5);     // Move sphere away from origin

    const controls = new ArcballControls(camera, canvas, scene);
    controls.target.set(-5, 5, 5);   // look at center of sphere
    controls.update();               // update gizmos
    
    controls.saveState();

    console.log(controls.target);           // Object { x: -5, y: 5, z: 5 }
    console.log(controls._gizmos.position); // Object { x: -5, y: 5, z: 5 }

    controls.reset();

    console.log(controls.target);           // Object { x: -5, y: 5, z: 5 }
    console.log(controls._gizmos.position); // Object { x: 0, y: 0, z: 0 }    
}

Live example

  • jsfiddle with the code above, was used to generate the screenshots below

Screenshots

After saveState():
Image

After reset():
Image

Version

r176

Device

Desktop

Browser

Firefox

OS

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions