Skip to content

Commit d9011b1

Browse files
Drag Mode Camera Focus Fix [AARD-2028] (#1245)
Co-authored-by: Alexey Dmitriev <157652245+AlexD717@users.noreply.github.com>
2 parents 342872c + 95abf30 commit d9011b1

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

fission/src/mirabuf/MirabufSceneObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
867867
data.items.push({
868868
name: "Camera: Unfocus",
869869
func: () => {
870-
cameraControls.focusProvider = undefined
870+
cameraControls.unfocus()
871871
},
872872
})
873873

fission/src/systems/scene/CameraControls.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

fission/src/systems/scene/DragModeSystem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ class DragModeSystem extends WorldSystem {
112112
return this._enabled
113113
}
114114

115+
public get isTransitioning(): boolean {
116+
return this._cameraTransition.isTransitioning
117+
}
118+
115119
public set enabled(enabled: boolean) {
116120
if (this._enabled === enabled) return
117121

0 commit comments

Comments
 (0)