Pixi.js: renderer.plugins.interaction.mouse.global bad coords

Created on 28 Jan 2020  Β·  7Comments  Β·  Source: pixijs/pixi.js

hi ^-^
first of all thanks for such a great library

just migrated from PixiJS 5.0.0-rc.2 to PixiJS 5.2.0

const {x, y} = renderer.plugins.interaction.mouse.global;

this stuff is used to work before, but now it gives me pair of NaN's

Selection_031

πŸ‘ Not A Bug

All 7 comments

That's the first time I see that and, honestly, no idea how could that happen. Please give more information.

Must be -99999 before first mouseMoveEvent.

I made test, its works normaly:
https://www.pixiplayground.com/#/edit/FyzfzajVdiAypT1MSC_bY

unfortunately i don't use pixi.Application

i figured out the problem actually.
x,y coordinates for some reason are always NaN if you pass the custom canvas to the Renderer constructor in v 5.2.0.
but if you omit the view property and do something like document.body.appendChild(renderer.view) - then it works perfectly.

please check this little example with both 5.2.0 and 5.0.0-rc.2 versions:
https://www.pixiplayground.com/#/edit/cYdlslHuIPAdyxuLj3VwI

image

Of course this will not work unless added to the DOM.
Upd, this is works on <= 5.0.rc.

UPD:

Renderer's constructor signature was changed:
https://pixijs.download/dev/docs/PIXI.Renderer.html

U must pass width and height as property of options.

https://www.pixiplayground.com/#/edit/cYdlslHuIPAdyxuLj3VwI

Yes, new PIXI.Renderer(window.innerWidth, window.innerHeight) doesnt work anymore, you should use new PIXI.Renderer({width: window.innerWidth, height: window.innerHeight}); instead

Please read https://github.com/pixijs/pixi.js/wiki/v5-Migration-Guide#renderer-parameters just in case you stumble across more version-dependent changes.

спасибо)

Если Ρ…ΠΎΡ‡Π΅ΡˆΡŒ, моТСшь Π·Π°ΠΉΡ‚ΠΈ Π½Π° https://t.me/gamedevforweb ΠΈ https://t.me/threejs_ru - Ρ‚Π°ΠΌ ΠΌΡ‹ ΠΏΠΎΠΌΠΎΠ³Π°Π΅ΠΌ с пикси ΠΈ с Π΄Ρ€ΡƒΠ³ΠΈΠΌΠΈ ΡˆΡ‚ΡƒΠΊΠ°ΠΌΠΈ ΠΏΠΎ html5-ΠΈΠ³Ρ€Π°ΠΌ Π½Π° русском.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

confile picture confile  Β·  25Comments

GoodBoyDigital picture GoodBoyDigital  Β·  31Comments

manudurgoni picture manudurgoni  Β·  24Comments

doebi picture doebi  Β·  30Comments

Lyoko-Jeremie picture Lyoko-Jeremie  Β·  28Comments