fixed pointerlock securityerror
This commit is contained in:
parent
b017beca2d
commit
6c3e1ae64e
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue