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

bug report : unable to access bounding box data from an other component #38

Open
arthurmougin opened this issue Dec 7, 2020 · 6 comments

Comments

@arthurmougin
Copy link

Hi,
i am trying to access bounding box for a layout script, but i can't read it (value always infinite).
i made troika-text the dependency of my component without result.
can you help me ?

@lojjic
Copy link
Owner

lojjic commented Dec 7, 2020

How are you attempting to access the bounding box?

@arthurmougin
Copy link
Author

arthurmougin commented Dec 7, 2020

I added my component to the a-troika-text primitive.
At update, the component store in a value the content of this.el.components["troika-text"]:
If that value is not empty, It read the value.troikaTextMesh.geometry.bou'dingBox;

When the initial update happen, every variable when logging .min.x, .min.y....
Return infinity.

I bypassed the issue by testing on tick when they are no longer infinite before recalling update but I don't think it is a great practice.

Edit : I tried adding troika-text to the component depencies but it didnt change the problem

@lojjic
Copy link
Owner

lojjic commented Dec 7, 2020

Ah, I see. Text is processed asynchronously, so it's expected that the bounds are initially unknown. See "Handling Asynchronous Updates" here for more info on how to react to the layout completion: https://github.com/protectwise/troika/blob/master/packages/troika-three-text/README.md#handling-asynchronous-updates

Let me know if you have suggestions on how to make this easier to handle in the Aframe wrapper.

@arthurmougin
Copy link
Author

arthurmougin commented Dec 7, 2020

I personally think that an event triggered when the text render would be great.
For example, when the scene load, there is a "loaded" event

Edit : this would help me and other devs : we could then have a more cleaner implementation on our side then

@lojjic
Copy link
Owner

lojjic commented Dec 7, 2020

OK, I'll look into how AFrame does events and see if there's an appropriate common event type I can fire. "loaded" seems perhaps not quite the right event name since it would fire anytime the text is updated.

@arthurmougin
Copy link
Author

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

2 participants