-
Notifications
You must be signed in to change notification settings - Fork 14
Update three-to-ammo to 1.0.4 #67
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
Conversation
|
I am now getting |
|
Hi, the fact that this error is not thrown in some examples tells me that it might have to do with some components used in the examples. I can investigate this and try to find the culprit and go from there |
|
I found out that importing aframe-physics-system with local files throws this error. While doing it with the following does no trhow any error: Maybe this can be solved by rebuilding the dist files? EDIT: This is incorrect, importing from cdn does not throw error because it seems that the physic system is not even initializing. This is very strange because the updates made to three-to-ammo should not cause something like this. I will continue my investigation |
|
I didn't release 4.2.4 or made a tag yet, so the url gives a 404. |
|
I found out that the changes on three-to-ammo is causing this error. Im working on a fix |
|
This is the if statment that i will be takling from now on I will try to explain myself the best i can. This error occurs because something crucial must happen insisde this if statment block for every mesh that the physics system tracks. When a mesh is skipped (when the condition returns false = mesh invisible), the error is thrown. I suspect that this was a old error, because the As identified in the comments of issue #66, this adition is a bad fix. The mesh.visible property is always true even when the parent A-Frame entity's visible component is false. By including || mesh.visible, the code was likely forcing all meshes (even the logically invisible ones) to pass the condition and execute the processing block, thus inadvertently preventing the error. Keep in mind that my WebXR knowledge is very limited as i am starting to learn, but i think i solution to this is to find what peice of code of the if statment block is cruscial to run even when a mesh is invisible. I will continue my investigation but i think its better to revert this commit until there is a definitive fix. |
|
Yes I saw this out of memory error when I was originally experimenting with the issue you reported. Will add some notes later on what might be causing this (when I have had a chance to refresh my memory) |
|
Ok, this was my note from before... "When I use this, it's also necessary to set "includeInvisible: true" on the invisible child (else you hit an infinite loop in the ammo wasm, I guess because you have an ammo shape with no geometries?)" Based on this observation, I will look a bit more carefully at what might actually be going on here... |
|
I have been looking at the compund example (it's a fairly simple one). I can fix it by replacing this: with: Most other examples have the same invisible floor, so I think this is probably the issue for all of them. Stack trace is this: Interestingly, if I remove the controllers completely ("left-hand"" and "right-hand"), without the change above, that also avoids the "memory access out of bounds" error. However the floor doesn't function as expected, because we don't get an ammo shape for it because it's invisible. Question I have is whether an invisible floor, without So let's look at how to define the behaviour of the |
|
So @Tpleme's use case involved an entity like this... The intention was that the child entity should not be included in shape calculations because includeInvisible was "false", and the child was invisible. But the following pattern is common in examples: Here, the box is also invisible, includeInvisible is "false", but we expect the mesh to be included in the shape calculation - presumably because it is the mesh on this entity, not a child. So maybe the logic we want is that includeInvisible controls only whether meshes on child entities are included, based on their visibility? There's no documentation on the "includeInvisible" option in the three-to-ammo repo. The only documentation of this option is in aframe-physics-system, where it says:
That's not very clear. Based on the above, and established usage patterns, maybe the best update would be like this:
If we updated code to match that, we might get behaviour we want in all cases. There is also a separate question as to why we are seeing the out-of-memory error. But it's not clear that problem will remain if we adjust the usage of |
|
yes, i agree with you. This property is not very clear at all, but if we do as you suggest thing become more clear, it should affect invisible children of the object, and this property should be on the parent itself. In the if statment, instead of checking if includeInvisible is true, should we check if the parent has this property as true? Yet i don't know if this in going to mitigate the nemory error. |
That would mean the issue is in the wasm collision algorithm between the kinematic body and an empty static body. |
|
I also agree with your proposal, checking visibility of |
|
Looking some more at this - I have expressed this in terms of A-Frame concepts (entities), but we will be implementing in three-to-ammo, which is a generic three js library, and should not depend on A-Frame. It's not obvious to me how to distinguish between the parts of a multi-mesh GLTF attached to an A-Frame entity (where we'd want to include all parts) and a mesh that is a child of an entity that's a child of the A-Frame entity. @vincentfretin 's suggestion of looking for meshes that are not The best option I can see is to vary behaviour depending on where the visibility is set to "false" in the object hierarchy. If the mesh is invisible because the root (i.e. the A-Frame Entity) is invisible, then we include it no matter what. But if it's invisible because of a visibility setting on some child of the root, then we excude it (unless includeInvisible is true). So code becomes... That seems to fix all the examples. It should also fix @Tpleme 's use case - though I haven't tested that yet. |
|
I've tested your solution with my use case and can confirme that it does solve the problem. I have also checked the examples and none returns the memory error. |
|
That's great - can you fix up the PR and resubmit? Then one of us will merge. |
|
A new PR was created to address this issue: c-frame/three-to-ammo#7 |
|
I have published 1.0.5 just now, so you should be able to fix up this PR by including 1.0.5 and rebuilding. |
|
Done |
This closes #66