From 90cf9e8ff7aff8dacbe33648057339ddad925308 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Tue, 10 Feb 2026 01:08:14 +0100 Subject: [PATCH] OrbitControls: Add `cursorStyle` property. (#32981) --- examples/jsm/controls/OrbitControls.js | 42 ++++++++++++++++++++++++++ examples/misc_controls_orbit.html | 2 ++ 2 files changed, 44 insertions(+) diff --git a/examples/jsm/controls/OrbitControls.js b/examples/jsm/controls/OrbitControls.js index ff9c1b2f22cd95..3e7df978474979 100644 --- a/examples/jsm/controls/OrbitControls.js +++ b/examples/jsm/controls/OrbitControls.js @@ -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; @@ -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 ); @@ -1542,6 +1572,12 @@ function onPointerDown( event ) { } + if ( this._cursorStyle === 'grab' ) { + + this.domElement.style.cursor = 'grabbing'; + + } + } function onPointerMove( event ) { @@ -1577,6 +1613,12 @@ function onPointerUp( event ) { this.state = _STATE.NONE; + if ( this._cursorStyle === 'grab' ) { + + this.domElement.style.cursor = 'grab'; + + } + break; case 1: diff --git a/examples/misc_controls_orbit.html b/examples/misc_controls_orbit.html index 4521bc06523e0b..e161e3e357f749 100644 --- a/examples/misc_controls_orbit.html +++ b/examples/misc_controls_orbit.html @@ -72,6 +72,8 @@ controls.minDistance = 100; controls.maxDistance = 500; + controls.cursorStyle = 'grab'; + controls.maxPolarAngle = Math.PI / 2; // world