Closed as not planned
Closed as not planned
Description
Description
If TransformControls is created without domElement
parameter, which is marked as optional, and then dispose()
method is called, "this.domElement is null" error occurs and crashes the application.
Reproduction steps
- create TransformControls without the domElement parameter
- call dispose() method
Quickest way to see this is to change examples/misc_controls_transform.html
line
control = new TransformControls( currentCamera, renderer.domElement );
to
control = new TransformControls( currentCamera );
control.dispose();
and reload page, Dev Tools console will show the "this.domElement is null" error inside the dispose()
method.
The solution to this is to check for this.domElement
in both connect()
and disconnect()
methods like so:
connect() {
if( this.domElement == null ) return;
this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
this.domElement.addEventListener( 'pointermove', this._onPointerHover );
this.domElement.addEventListener( 'pointerup', this._onPointerUp );
this.domElement.style.touchAction = 'none'; // disable touch scroll
}
disconnect() {
if( this.domElement == null ) return;
this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
this.domElement.removeEventListener( 'pointermove', this._onPointerHover );
this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
this.domElement.removeEventListener( 'pointerup', this._onPointerUp );
this.domElement.style.touchAction = 'auto';
}
and remove the
if ( domElement !== null ) {
check in constructor which only guards call to connect()
.
Code
let control = new TransformControls( currentCamera );
control.dispose(); //<-- this crashes with "this.domElement is null"
Live example
- jsfiddle-latest-release WebGLRenderer
- jsfiddle-dev WebGLRenderer
- jsfiddle-latest-release WebGPURenderer
- jsfiddle-dev WebGPURenderer
Screenshots
No response
Version
0.170.0
Device
No response
Browser
No response
OS
No response
Metadata
Metadata
Assignees
Labels
No labels