How to disable or enable pc.mouse


I’m using playcanvas engine and I don’t know how to disable mouse pointer events over canvas.

Here’s the situation. I’m using orbit control script in canvas

The html I made covers the canvas a little like follow image.

So I don’t want to use the canvas mouse depending on the situation.

I added a mouse like following code

const app = new pc.Application(canvas, {
      mouse: new pc.Mouse(canvas),
      keyboard: new pc.Keyboard(window),

Is there any code that works like this?

app.mouse.disabled = false; //pseudocode

AFAIK, there isn’t.

You would either have to patch pc.Mouse to have a global flag to enable/disable the events or add/remove the listeners to pc.Mouse when you need to.

In your case where you want to disable canvas mouse events when the mouse is over the HTML DOM object, you can stop propagation of the event in the event callback on the DOM.

1 Like

Oh, yeah. I think I can use a patch.

var app = new pc.Application(canvas, {
    mouse: new pc.Mouse