Closed Mathieu-C closed 4 years ago
Where do you declare viewport? You need something like:
const viewport = new PixiViewport()
Thank you for your answer, I was indeed not declaring things properly. However, I have an issue with sprites added to the viewport from another module (I have a global viewport defined in window.viewport
, and sprites gets added to it through a dedicated class). I get a TypeError: box is undefined
error on scroll:
108 | for (let object of list)
109 | {
110 | const box = object[this.AABB]
> 111 | object[this.visible] =
| ^ 112 | box.x + box.width > bounds.x && box.x < bounds.x + bounds.width &&
113 | box.y + box.height > bounds.y && box.y < bounds.y + bounds.height
114 | }
Things do work flawlessly when I add sprites from the same context as the culling, I noticed that sprites added from another module don't have the AABB
attribute.
Let me know if I'm not being clear enough, or if you require more details regarding that issue.
How are you adding your objects to the cull list? when it first adds it, it should create object[this.AABB] (which I think defaults to object.aabb). by default this is done on initialization of the objects within the cull system to avoid having to calculate bounds on each frame.
Indeed, you helped me understand that my Viewport
initialization was happening before the sprites were added to it, so cull's addList
method was being called with an incomplete list.
The issue is now fully resolved, thanks a lot for your work and support 👍
I'm trying to use this library with the (excellent) pixi-viewport, with the following code:
I get this error:
I believe it's because of my use of
import
instead ofrequire
, the documentation doesn't provide a workaround forimport
, is it possible to use it currently?