@@ -95,6 +95,7 @@ export class CustomOrbitControls extends CameraControls {
9595 private _focus : THREE . Matrix4
9696
9797 private _focusProvider : MirabufSceneObject | undefined
98+ private _isExplicitlyUnfocused : boolean = false
9899 public locked : boolean
99100
100101 private _interactionHandler : ScreenInteractionHandler
@@ -108,11 +109,22 @@ export class CustomOrbitControls extends CameraControls {
108109
109110 public set focusProvider ( provider : MirabufSceneObject | undefined ) {
110111 this . _focusProvider = provider
112+ if ( provider !== undefined ) {
113+ this . _isExplicitlyUnfocused = false
114+ }
111115 }
112116 public get focusProvider ( ) {
113117 return this . _focusProvider
114118 }
115119
120+ /**
121+ * Explicitly unfocus the camera (user-initiated action)
122+ */
123+ public unfocus ( ) : void {
124+ this . _focusProvider = undefined
125+ this . _isExplicitlyUnfocused = true
126+ }
127+
116128 public get coords ( ) : SphericalCoords {
117129 return this . _coords
118130 }
@@ -166,7 +178,7 @@ export class CustomOrbitControls extends CameraControls {
166178 * If not, automatically finds a suitable replacement.
167179 */
168180 private validateFocusProvider ( ) : void {
169- if ( ! World . sceneRenderer ?. sceneObjects ) {
181+ if ( ! World . sceneRenderer ?. sceneObjects || World . dragModeSystem . isTransitioning ) {
170182 return
171183 }
172184
@@ -176,8 +188,9 @@ export class CustomOrbitControls extends CameraControls {
176188 if ( this . _focusProvider ) {
177189 if ( ! mirabufObjects . includes ( this . _focusProvider ) ) {
178190 this . _focusProvider = this . findFallbackFocus ( mirabufObjects )
191+ this . _isExplicitlyUnfocused = false
179192 }
180- } else {
193+ } else if ( ! this . _isExplicitlyUnfocused ) {
181194 this . _focusProvider = this . findFallbackFocus ( mirabufObjects )
182195 }
183196 }
0 commit comments