[SOLVED] Initializing the mouse (Engine-only)

Hi, i have a problem initializing a mouse deivce in the engine;
here’s my code:

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

with that i have multiple error in the console:
Uncaught TypeError: this._target.getBoundingClientRect is not a function
at a._getTargetCoords (playcanvas-stable.min.js?r=1501102167:768)
at new e (playcanvas-stable.min.js?r=1501102167:761)
at a._handleMove (playcanvas-stable.min.js?r=1501102167:767)
like this one.

What is wrong mith my mouse definition?

hm, i changed mouse creation to new pc.Mouse(canvas) and everything is fine

If you publish a PlayCanvas app from the Editor, it generates a script called __start__.js which initializes your application. It has the following function:

    var createInputDevices = function (canvas) {
        var devices = {
            keyboard: new pc.Keyboard(window),
            mouse: new pc.Mouse(canvas),
            gamepads: new pc.GamePads(),
        if ('ontouchstart' in window) {
            devices.touch = new pc.TouchDevice(canvas);

        return devices;

So, yes, as you can see, passing the canvas of the app is the thing to do, but you can pass window to create the keyboard.

It’s probably OK to pass document.body as well when creating the Mouse.

I guess we could output a warning if you don’t pass a valid DOM element into the pc.Mouse constructor.