Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions examples/jsm/controls/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ class OrbitControls extends Controls {
*/
this.zoom0 = this.object.zoom;

this._cursorStyle = 'auto';

// the target DOM element for key events
this._domElementKeyEvents = null;

Expand Down Expand Up @@ -462,6 +464,34 @@ class OrbitControls extends Controls {

}

/**
* Defines the visual representation of the cursor.
*
* @type {('auto'|'grab')}
* @default 'auto'
*/
set cursorStyle( type ) {

this._cursorStyle = type;

if ( type === 'grab' ) {

this.domElement.style.cursor = 'grab';

} else {

this.domElement.style.cursor = 'auto';

}

}

get cursorStyle() {

return this._cursorStyle;

}

connect( element ) {

super.connect( element );
Expand Down Expand Up @@ -1542,6 +1572,12 @@ function onPointerDown( event ) {

}

if ( this._cursorStyle === 'grab' ) {

this.domElement.style.cursor = 'grabbing';

}

}

function onPointerMove( event ) {
Expand Down Expand Up @@ -1577,6 +1613,12 @@ function onPointerUp( event ) {

this.state = _STATE.NONE;

if ( this._cursorStyle === 'grab' ) {

this.domElement.style.cursor = 'grab';

}

break;

case 1:
Expand Down
2 changes: 2 additions & 0 deletions examples/misc_controls_orbit.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
controls.minDistance = 100;
controls.maxDistance = 500;

controls.cursorStyle = 'grab';

controls.maxPolarAngle = Math.PI / 2;

// world
Expand Down