From 6c3e1ae64ebdf39d013cddc5e0640cbf38ffa2e3 Mon Sep 17 00:00:00 2001 From: "azykov@mail.ru" Date: Fri, 5 Jun 2026 20:08:07 +0300 Subject: [PATCH] fixed pointerlock securityerror --- src/components/CharacterView.tsx | 2 +- src/components/ObjectViewInternal.tsx | 5 ++--- src/model/gameFactory.ts | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/CharacterView.tsx b/src/components/CharacterView.tsx index 4fdb8ca..eb91034 100644 --- a/src/components/CharacterView.tsx +++ b/src/components/CharacterView.tsx @@ -69,7 +69,7 @@ export const PlayerObjectView = observer(function ({ object, objectType }: Playe useEffect(() => { const canvas = gl.domElement; - const onClick = () => canvas.requestPointerLock(); + const onClick = () => { if (document.pointerLockElement !== canvas) canvas.requestPointerLock()?.catch(() => {}); }; const onMouseMove = (e: MouseEvent) => { if (document.pointerLockElement !== canvas) return; mouseRef.current.x += e.movementX; diff --git a/src/components/ObjectViewInternal.tsx b/src/components/ObjectViewInternal.tsx index 970186e..a7bea32 100644 --- a/src/components/ObjectViewInternal.tsx +++ b/src/components/ObjectViewInternal.tsx @@ -63,13 +63,12 @@ export const ObjectViewInternal = function ({ object, objectType, ref, ...props return reaction( () => gameObj.pendingActions.impulse, (impulse) => { - if (!impulse) return; - if (!rbRef.current) { console.warn('applyImpulse: rbRef is null for', gameObj.id); return; } + if (!impulse || !rbRef.current) + return; let { direction, amplitude } = impulse; amplitude *= 100; const v = { x: direction[0] * amplitude, y: direction[1] * amplitude, z: direction[2] * amplitude }; - console.log('applyImpulse', gameObj.id, v, 'bodyType', rbRef.current.bodyType()); rbRef.current.applyImpulse(v, true); runInAction(() => { gameObj.pendingActions.impulse = undefined; diff --git a/src/model/gameFactory.ts b/src/model/gameFactory.ts index 6f8a2dc..8fe9257 100644 --- a/src/model/gameFactory.ts +++ b/src/model/gameFactory.ts @@ -29,7 +29,6 @@ export class GameEventBus { emit(event: string, context: GameEventContext): void { console.log('emitting ' + event); - console.log(Array.from(this.handlers.entries())); this.handlers.get(event) ?.forEach((handler) => handler(context)); }