-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: sensor support integration #141
Conversation
I'm getting the unsupported properties warning when using custom colliders with intersection events: [Vue warn]: Extraneous non-emits event listeners (intersectionEnter, intersectionExit) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.
at <Anonymous name="cuboid-sensor" args= Array(3) position= Array(3) ... >
at <RigidBody type="fixed" >
at <Physics debug="" >
at <App> I understand this is coming from my export const emitIntersection = (
source: sourceTarget,
target: sourceTarget,
started: boolean,
) => {
const collisionType: collisionType = started ? 'enter' : 'exit'
const colliderNode = (source.object as any)?.__vnode?.children?.[1]?.children?.find((child: any) => child?.component?.exposed?.instance?.value === source.context.collider)
colliderNode?.component?.emit?.(`intersection-${collisionType}`, { source, target })
} I don't have a better solution right now to solve the issue, but I'll try to dig in to see if I can improve the integration.
|
Hi @Neosoulink this is probably happening because those new Is it |
Hi @alvarosabu,
|
Hi @Neosoulink if you are in control of the Collider Component, I think you need define the emits using |
Okay, let me try this ✅ |
@Neosoulink in order to use the same "system" that I use, you should emit the events in the parent, the RigidBody which is a 3DGroup... I know it is just a draft (of end documentation) But if you check here: The solution I came was to emit the event in the parent. The BaseCollider is not a Tres component and doesn't have the same vNode properties (in fact is just a You can check here how I handle it: https://github.com/Tresjs/rapier/blob/main/src/utils/collisions.ts#L8 Except that, this is a nice work, thank you. PS: Don't forget to submit the documentation, is missing. |
@JaimeTorrealba I see now, and it's also joining the @alvarosabu note... In that case, we have to define emits directly in the project, |
Hi @alvarosabu @JaimeTorrealba, I just pushed the fix for the properties warning issue. But I'm not sure if I should add documentation in this PR as well, I mean this PR will get bigger Otherwise, this PR is ready for review |
Regarding
It's expected to have documentation in the same scope as the PR whenever there is a new feature or bugfix. It's also a way reviewers can understand the code changes quicker as they were a new user. |
Got it |
### Description - Add new `vNode` extended types - `TresVNodeObject` - `TresVNode` - Add a `TresObject` to collider
5629170
to
1b37050
Compare
I added a minimal senor documentation |
7b6409c
to
20463a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can improve this in the future in order to accept automatic colliders too.
But the implementation is stable, thanks for this one
I spend time looking for a good way to implement it. Let's say you have your RigidBody and add the sensor property. Will the sensor events (Enter & Exit) be triggered when a collider transverses any collider inside that RigidBody? |
### Description - Add `Sensor` to `RigidBody` component props - `RigidBodyProps` inherits types from `ColliderProps`
cea5780
to
ae1ec30
Compare
ae1ec30
to
44de932
Compare
Hey @alvarosabu @JaimeTorrealba, you can take a look at the description of this PR, I added documentation on how to use the sensor |
4403212
to
09a95bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Neosoulink I just polished the doc page and we are ready to merge, thanks a lot for the huge effort 🙏🏻
Let's go 🔥 |
Summary
This PR comes with the
sensor
intersection support!Enable users to use custom colliders as sensors:
Logs
bounding-box
availabilityvNode
extended typesTresVNodeObject
TresVNode
resObject
to collider componentssesnor
demoRecord
Screen.Recording.2024-11-10.at.12.40.45.AM.mov
Documentation addition
Sensor
The Sensor feature allows events to be triggered when there's an intersection or in other words, when the collider is traversed by another collider.
The traversed
Collider
(or the collider that will trigger events), is the sensor and should set theactiveCollision
andsensor
properties totrue
.By passing the above properties, the collider will no longer be affected by the physics law and will now start triggering the following intersection events: