diff --git a/docs/examples/en/controls/TransformControls.html b/docs/examples/en/controls/TransformControls.html index 1dc3b3b68348c4..def5a62b76f0f5 100644 --- a/docs/examples/en/controls/TransformControls.html +++ b/docs/examples/en/controls/TransformControls.html @@ -174,6 +174,11 @@

[method:String getMode] ()

Returns the transformation mode.

+

[method:undefined reset] ()

+

+ Resets the object's position, rotation and scale to when the current transform began. +

+

[method:undefined setMode] ( [param:String mode] )

@@ -194,6 +199,16 @@

[method:undefined setRotationSnap] ( [param:Number rotationSnap] )

+

[method:undefined setScaleSnap] ( [param:Number scaleSnap] )

+

+

+ [page:Number scaleSnap]: The scale snap. +

+

+ Sets the scale snap. +

+

+

[method:undefined setSize] ( [param:Number size] )

diff --git a/examples/js/controls/TransformControls.js b/examples/js/controls/TransformControls.js index 6610ec9c84f7a6..ac2163b0b5b299 100644 --- a/examples/js/controls/TransformControls.js +++ b/examples/js/controls/TransformControls.js @@ -532,6 +532,25 @@ } + reset() { + + if ( ! this.enabled ) return; + + if ( this.dragging ) { + + this.object.position.copy( this._positionStart ); + this.object.quaternion.copy( this._quaternionStart ); + this.object.scale.copy( this._scaleStart ); + + this.dispatchEvent( _changeEvent ); + this.dispatchEvent( _objectChangeEvent ); + + this.pointStart.copy( this.pointEnd ); + + } + + } + getRaycaster() { return _raycaster; diff --git a/examples/jsm/controls/TransformControls.js b/examples/jsm/controls/TransformControls.js index 443c19d92dab3b..76f949f3820565 100644 --- a/examples/jsm/controls/TransformControls.js +++ b/examples/jsm/controls/TransformControls.js @@ -564,6 +564,25 @@ class TransformControls extends Object3D { } + reset() { + + if ( ! this.enabled ) return; + + if ( this.dragging ) { + + this.object.position.copy( this._positionStart ); + this.object.quaternion.copy( this._quaternionStart ); + this.object.scale.copy( this._scaleStart ); + + this.dispatchEvent( _changeEvent ); + this.dispatchEvent( _objectChangeEvent ); + + this.pointStart.copy( this.pointEnd ); + + } + + } + getRaycaster() { return _raycaster; diff --git a/examples/misc_controls_transform.html b/examples/misc_controls_transform.html index 807f3affb79f6c..2ccc46d99abdce 100644 --- a/examples/misc_controls_transform.html +++ b/examples/misc_controls_transform.html @@ -12,6 +12,7 @@ "W" translate | "E" rotate | "R" scale | "+/-" adjust size
"Q" toggle world/local space | "Shift" snap to grid
"X" toggle X | "Y" toggle Y | "Z" toggle Z | "Spacebar" toggle enabled
+ "Esc" reset current transform
"C" toggle camera | "V" random zoom @@ -156,6 +157,10 @@ control.enabled = ! control.enabled; break; + case 27: // Esc + control.reset(); + break; + } } );