Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle local coordinates? #24

Open
KKzLEO opened this issue Oct 5, 2021 · 2 comments
Open

How to handle local coordinates? #24

KKzLEO opened this issue Oct 5, 2021 · 2 comments

Comments

@KKzLEO
Copy link

KKzLEO commented Oct 5, 2021

Hi, thanks for creating this library, it's awesome.
I encountered an issue is that my coordinate system is based on container, so the structure will be like
image

the coordinate of my graphics object is a local coordinate(relative to the parent container), and I wanna do culling so I add the children of the container to cull object, it will be like

const collectChildren = (viewport: Viewport) => {
  return _flatten((viewport.children as Container[]).map(({ children }) => children));
};

cull.addList(collectChildren(viewport));
cull.cull(viewport.getVisibleBounds());

seems the cull method is to use the x and y of the object directly instead of worldTransforms.x to do a comparison, it will cull some objects that are still in my view unexpectedly, is there any direction I can try?

@davidfig
Copy link
Collaborator

davidfig commented Oct 5, 2021

When I wrote this library, I ran into a bunch of problems with pixi's getBounds implementation. I ended up rolling a simpler version that, regrettably, assumes it shares a coordinate system with the viewport. An update to the library using getLocalBounds relative to a set parent (like the viewport) would fix the issue. I'm happy to accept a PR if you have the time. Otherwise you can extends SpatialHash or Simple to change the updateObject function with this type of functionality.

@ArthurTimofey
Copy link

@KKzLEO were you able to come to a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants