debug: add logging for pointer lock and custom cursor
Add extensive console logging to debug cursor visibility: **PlayingPhase:** - Log when pointer lock listeners attach/detach - Log pointer lock state changes with element details - Log container click events with conditions - Log pointerLocked state changes **MapRenderer:** - Log custom cursor render conditions on every render - Log when cursor should be visible - Log cursor position when rendering This will help diagnose why custom cursor isn't visible. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5d6d6b4ddc
commit
0dbb2eb83c
|
|
@ -1222,7 +1222,19 @@ export function MapRenderer({
|
|||
))}
|
||||
|
||||
{/* Custom Cursor - Visible when pointer lock is active */}
|
||||
{pointerLocked && cursorPosition && (
|
||||
{(() => {
|
||||
console.log('[Custom Cursor] Render check:', {
|
||||
pointerLocked,
|
||||
hasCursorPosition: !!cursorPosition,
|
||||
cursorPosition,
|
||||
shouldRender: pointerLocked && cursorPosition,
|
||||
})
|
||||
|
||||
if (pointerLocked && cursorPosition) {
|
||||
console.log('[Custom Cursor] ✅ RENDERING at position:', cursorPosition)
|
||||
}
|
||||
|
||||
return pointerLocked && cursorPosition ? (
|
||||
<div
|
||||
data-element="custom-cursor"
|
||||
style={{
|
||||
|
|
@ -1264,7 +1276,8 @@ export function MapRenderer({
|
|||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
) : null
|
||||
})()}
|
||||
|
||||
{/* Magnifier Window - Always rendered when cursor exists, opacity controlled by spring */}
|
||||
{cursorPosition && svgRef.current && containerRef.current && (
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ export function PlayingPhase() {
|
|||
useEffect(() => {
|
||||
const handlePointerLockChange = () => {
|
||||
const isLocked = document.pointerLockElement === containerRef.current
|
||||
console.log('[PlayingPhase] Pointer lock change event:', {
|
||||
isLocked,
|
||||
pointerLockElement: document.pointerLockElement,
|
||||
containerElement: containerRef.current,
|
||||
elementsMatch: document.pointerLockElement === containerRef.current,
|
||||
})
|
||||
setPointerLocked(isLocked)
|
||||
console.log('[Pointer Lock]', isLocked ? '🔒 LOCKED' : '🔓 UNLOCKED')
|
||||
}
|
||||
|
|
@ -46,9 +52,12 @@ export function PlayingPhase() {
|
|||
document.addEventListener('pointerlockchange', handlePointerLockChange)
|
||||
document.addEventListener('pointerlockerror', handlePointerLockError)
|
||||
|
||||
console.log('[PlayingPhase] Pointer lock listeners attached')
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('pointerlockchange', handlePointerLockChange)
|
||||
document.removeEventListener('pointerlockerror', handlePointerLockError)
|
||||
console.log('[PlayingPhase] Pointer lock listeners removed')
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
|
@ -64,13 +73,30 @@ export function PlayingPhase() {
|
|||
|
||||
// Request pointer lock on first click
|
||||
const handleContainerClick = () => {
|
||||
console.log('[PlayingPhase] Container clicked:', {
|
||||
pointerLocked,
|
||||
hasContainer: !!containerRef.current,
|
||||
showLockPrompt,
|
||||
willRequestLock: !pointerLocked && containerRef.current && showLockPrompt,
|
||||
})
|
||||
|
||||
if (!pointerLocked && containerRef.current && showLockPrompt) {
|
||||
console.log('[Pointer Lock] 🔒 REQUESTING pointer lock (user clicked)')
|
||||
try {
|
||||
containerRef.current.requestPointerLock()
|
||||
console.log('[Pointer Lock] Request sent successfully')
|
||||
} catch (error) {
|
||||
console.error('[Pointer Lock] Request failed with error:', error)
|
||||
}
|
||||
setShowLockPrompt(false) // Hide prompt after first click
|
||||
}
|
||||
}
|
||||
|
||||
// Log when pointerLocked state changes
|
||||
useEffect(() => {
|
||||
console.log('[PlayingPhase] pointerLocked state changed:', pointerLocked)
|
||||
}, [pointerLocked])
|
||||
|
||||
// Get the display name for the current prompt
|
||||
const currentRegionName = state.currentPrompt
|
||||
? mapData.regions.find((r) => r.id === state.currentPrompt)?.name
|
||||
|
|
|
|||
Loading…
Reference in New Issue