diff --git a/src/app/pages/algorithms/physarum/physarum.component.ts b/src/app/pages/algorithms/physarum/physarum.component.ts index b096db2..3647501 100644 --- a/src/app/pages/algorithms/physarum/physarum.component.ts +++ b/src/app/pages/algorithms/physarum/physarum.component.ts @@ -70,7 +70,8 @@ export class PhysarumComponent implements OnDestroy { private canvas: HTMLCanvasElement | null = null; private pointerAttached = false; private agentCountInitialized = false; - private readonly pointerLeaveHandler = () => { this.food.active = false; }; + private pressed = false; + private readonly pointerLeaveHandler = () => { this.pressed = false; this.food.active = false; }; private readonly fpsCounter = new FpsCounter(); readonly minAgents = MIN_AGENTS; @@ -231,17 +232,16 @@ export class PhysarumComponent implements OnDestroy { scene.onPointerObservable.add((info) => { if (info.type === PointerEventTypes.POINTERUP) { + this.pressed = false; this.food.active = false; return; } - if (info.type !== PointerEventTypes.POINTERDOWN && info.type !== PointerEventTypes.POINTERMOVE) { + if (info.type === PointerEventTypes.POINTERDOWN) { + this.pressed = true; + } else if (info.type !== PointerEventTypes.POINTERMOVE || !this.pressed) { return; } const event = info.event as PointerEvent; - if (!(event.buttons & 1) && event.pointerType !== 'touch') { - this.food.active = false; - return; - } const target = event.target as HTMLElement; const cell = pointerToCell(event.offsetX, event.offsetY, target.clientWidth, target.clientHeight, this.mapSize(), this.mapSize()); this.food.x = cell.x;