Griva Posted January 11, 2018 Share Posted January 11, 2018 I have on stage special "workspace" pixi container - I use it to allow user to draw on it. It works perfect if I set hitArea dimensions to renderer width and height but the problem is that user can move this layer or zoom in/out. I think result is obvious, after move/zoom it is not possible to draw on canvas because hitArea "run" out from the screen or it is too small. My question is what is the best actual solution for this (pixi v4)? I was thinking about setting Infinite hitArea but this is not possible. I could set hitArea Rectangle to be like 999999px so it should not be possible to go out of drawing area but is it ok? Can setting very big hitArea slow down interaction manager? Also another option was to replace hitArea (make it bigger) after move/zoom but this is proably not the best idea. Is there any elegant solution to cover this case easly? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 11, 2018 Share Posted January 11, 2018 According to https://github.com/pixijs/pixi.js/blob/dev/src/interaction/InteractionManager.js#L1092 , there's another way: override containsPoint and return true. Griva 1 Quote Link to comment Share on other sites More sharing options...
themoonrat Posted January 11, 2018 Share Posted January 11, 2018 You could also consider adding your events at the renderer level, and do some maths to translate to your container. ie. let location = new PIXI.Point(); renderer.plugins.interaction.on( 'pointerdown', ( event ) => { container.worldTransform.applyInverse( event.data.global, location ); } Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 11, 2018 Share Posted January 11, 2018 I suggest to use toLocal instead of direct applyinverse. themoonrat 1 Quote Link to comment Share on other sites More sharing options...
Griva Posted January 14, 2018 Author Share Posted January 14, 2018 I think override of single function can be easier in general, at least it does not change any positions and translations and I don't have to change any deeper logic. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.