debug: add verbose pointer lock logging
Add detailed logging to debug pointer lock activation: - Log useEffect triggers with all conditions - Log pointer lock request attempts and results - Log pointer lock state in precision mode checks - Add try/catch around requestPointerLock - Warn if container ref is missing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4d5953d034
commit
cf2d63f5e6
|
|
@ -216,13 +216,29 @@ export function MapRenderer({
|
||||||
|
|
||||||
// Request/release pointer lock based on precision mode
|
// Request/release pointer lock based on precision mode
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!containerRef.current) return
|
console.log('[Pointer Lock] Effect triggered:', {
|
||||||
|
precisionMode,
|
||||||
|
pointerLocked,
|
||||||
|
hasContainer: !!containerRef.current,
|
||||||
|
willRequest: precisionMode && !pointerLocked,
|
||||||
|
willRelease: !precisionMode && pointerLocked,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!containerRef.current) {
|
||||||
|
console.warn('[Pointer Lock] No container ref!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (precisionMode && !pointerLocked) {
|
if (precisionMode && !pointerLocked) {
|
||||||
console.log('[Pointer Lock] Requesting pointer lock for precision mode')
|
console.log('[Pointer Lock] 🔒 REQUESTING pointer lock for precision mode')
|
||||||
containerRef.current.requestPointerLock()
|
try {
|
||||||
|
containerRef.current.requestPointerLock()
|
||||||
|
console.log('[Pointer Lock] Request sent successfully')
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[Pointer Lock] Request failed:', error)
|
||||||
|
}
|
||||||
} else if (!precisionMode && pointerLocked) {
|
} else if (!precisionMode && pointerLocked) {
|
||||||
console.log('[Pointer Lock] Releasing pointer lock')
|
console.log('[Pointer Lock] 🔓 RELEASING pointer lock')
|
||||||
document.exitPointerLock()
|
document.exitPointerLock()
|
||||||
}
|
}
|
||||||
}, [precisionMode, pointerLocked])
|
}, [precisionMode, pointerLocked])
|
||||||
|
|
@ -951,11 +967,12 @@ export function MapRenderer({
|
||||||
currentPrecisionMode: precisionMode,
|
currentPrecisionMode: precisionMode,
|
||||||
willChangeTo: shouldEnablePrecisionMode,
|
willChangeTo: shouldEnablePrecisionMode,
|
||||||
smallestRegion: detectedSmallestSize.toFixed(2) + 'px',
|
smallestRegion: detectedSmallestSize.toFixed(2) + 'px',
|
||||||
|
pointerLocked,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (shouldEnablePrecisionMode !== precisionMode) {
|
if (shouldEnablePrecisionMode !== precisionMode) {
|
||||||
console.log(
|
console.log(
|
||||||
`[Precision Mode] ⚡ CHANGING STATE: ${shouldEnablePrecisionMode ? '🎯 ENABLING' : '❌ DISABLING'} precision mode | Smallest region: ${detectedSmallestSize.toFixed(2)}px${cooldownActive ? ' (COOLDOWN ACTIVE - ' + cooldownTimeRemaining.toFixed(0) + 'ms remaining)' : ''}`
|
`[Precision Mode] ⚡ CHANGING STATE: ${shouldEnablePrecisionMode ? '🎯 ENABLING' : '❌ DISABLING'} precision mode | Smallest region: ${detectedSmallestSize.toFixed(2)}px${cooldownActive ? ' (COOLDOWN ACTIVE - ' + cooldownTimeRemaining.toFixed(0) + 'ms remaining)' : ''} | Pointer locked: ${pointerLocked}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
setPrecisionMode(shouldEnablePrecisionMode)
|
setPrecisionMode(shouldEnablePrecisionMode)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue