aframe icon indicating copy to clipboard operation
aframe copied to clipboard

oob-collider not setting el.object3D as default

Open shabarito opened this issue 1 year ago • 16 comments

Description:

  • A-Frame Version: 1.5.0
  • Platform / Device: any
  • Reproducible Code Snippet or URL:

By checking the obb-collider component I have two doubts:

  1. Is there really a need of calling checkTrackedObject inside tick? As the trackedObject is changed via property update, it should be called inside update and not in every tick. I think it will work the same, but less work.

  2. The oob-collider system emit the event to both collider entities and uses component.trackedObject3D. However inside the component this.trackedObject3D is never defined as default to this.el.object3D and the emit goes empty.

In some of the component methods we see || this.el.object3D, but never assign it to this.trackedObject3D

Regards,

shabarito avatar Mar 24 '24 17:03 shabarito

Can you share an example to reproduce issues with https://glitch.com/~aframe Thanks!

dmarcos avatar Mar 24 '24 20:03 dmarcos

Sure. https://glitch.com/edit/#!/thorn-dusty-conifer?path=index.html%3A23%3A6

I ve tested. Both the sphere and the model have the same behaviour. I think that just with the VR hands colliding it will work properly.

shabarito avatar Mar 25 '24 00:03 shabarito

For some reason I cannot open the glitch

There was an error starting the editor. Maybe try to reload?

dmarcos avatar Mar 25 '24 06:03 dmarcos

Maybe you want to recreate the glitch. I'm getting the same error.

dmarcos avatar Mar 25 '24 15:03 dmarcos

Check in these.

https://jsfiddle.net/Lz2n4mrp/ https://candied-puddle-quilt.glitch.me/ https://glitch.com/edit/#!/candied-puddle-quilt

shabarito avatar Mar 25 '24 19:03 shabarito

Looks like a misunderstanding. Recommend reading the docs. Can improve if necessary:

https://aframe.io/docs/1.5.0/components/obb-collider.html

You don't have to call any function manually. Just setup the component in relevant entities.

I see collision events fired as expected:

 document.body.addEventListener("obbcollisionstarted", function (e) {
        console.log(e.detail.trackedObject3D);
 });

The value you have to check is el.detail.withEl as stated in docs

trackedObject3D is an internal variable that you wouldn't need to check but not sure I'm understanding what you are trying to do. If you can clarify...

dmarcos avatar Mar 26 '24 05:03 dmarcos

On the fiddle, I have called the function manually just to show the behaviour.

You are right that withEl is sent on the emit. But the main collider should also be sent.

Looking at the obb-collider system the emit has two parameters.

Also, in the docs.

trackedObject3D is explained as: Variable path to the object3D used to calculate the collider. el.object3D by default

But this default behaviour does not work.

shabarito avatar Mar 26 '24 12:03 shabarito

What are you trying to accomplish? Why are you trying to use / access the trackedObject3D variable?

dmarcos avatar Mar 26 '24 15:03 dmarcos

trackedObject3D is only used in the rare occasions where you don't want to use the default this.el.object3D to calculate the collider. I don't think you need it in the presented example.

dmarcos avatar Mar 26 '24 15:03 dmarcos

A simplified version of your glitch: https://glitch.com/edit/#!/phantom-bead-vacation?path=index.html%3A29%3A9

See that obbcollisionstarted fires as expected in both entities when they collide. You don't need to define trackedObject3D

dmarcos avatar Mar 26 '24 17:03 dmarcos

Also notice you were using <a-sphere> for the model entity where you should be using <a-entity>

dmarcos avatar Mar 26 '24 17:03 dmarcos

Indeed the component is working as intended.

To correct myself, it is the system that is emitting null.

componentA.el.emit('obbcollisionstarted', {trackedObject3D: componentA.trackedObject3D, withEl: componentB.el});
componentB.el.emit('obbcollisionstarted', {trackedObject3D: componentB.trackedObject3D, withEl: componentA.el});

The system was coded to have both trackedObject3D and withEl in the same emit.

I think, if you have many collisions happening, in one single event you have both entities involved in the collision. This is a good behaviour.

My idea was to increase consistency in the system.

shabarito avatar Mar 26 '24 17:03 shabarito

We should probably remove trackedObject3D from the event details. Probably a vestige and not part of the documented public API

dmarcos avatar Mar 26 '24 17:03 dmarcos

Also notice that trackedObject3D refers to an object path from the entity object el.path.to.your.object. In your initial example that path is undefined and hence this.trackedObject3D is undefined as well

dmarcos avatar Mar 26 '24 17:03 dmarcos

But. Inside the hand-tracking-grab-controls component, the onCollisionStarted method uses this.grabbingObject3D = evt.detail.trackedObject3D;

The usage of trackedObject3D is probably when you have hands.

shabarito avatar Mar 26 '24 17:03 shabarito

Hah.

Reviewing the hand-tracking-grab-controls component it seems this.grabbingObject3D is not used at all.

So probably we should do as you say, remove in the next revision.

shabarito avatar Mar 26 '24 18:03 shabarito