Skip to content

Conversation

@dreammonkey
Copy link

Hello,

This PR is related to implementing RaycastVehicle in use-cannon 84

Changes:

  • Added a RaycastVehicle Y-up example in demos
  • Added some extra comments to clarify the necessary steps to properly implement RaycastVehicle (both Z-up & Y-up)
  • Added world getter/setter to RaycastVehicle.ts class (avoiding the usage of the addToWorld api)
  • Promoted Vec3 instances to class properties (so they can be reused and need not be re-created on each frame) (*)

(*) I'm not 100% certain if this is has much positive impact on performance but I think it was a sane thing to do...

Let me now what you think.

Cheers !

PS: please have a look at 84 ?

@marcofugaro
Copy link
Member

Hey, thanks for the contribution! I agree, more comments on the raycastVehicle stuff could be useful, however I already did the axis conversion for every example in #34, also for the raycastVehicle one. We decided to keep the y-up version only.

So I'd say let's wait until my PR is merged and then you can make a PR on top of that. I'm almost done with that PR.

Added world getter/setter to RaycastVehicle.ts class (avoiding the usage of the addToWorld api)

Could you clarify the reason for this change?

@dreammonkey
Copy link
Author

Thanks for your reply !

I noticed there has been a lot of activity lately, I didn't know about the Y-up example, but it seems like a good choice. Looking forward to your merge !

I've been working on a RaycastVehicle hook for use-cannon in parallel to this PR, it's working already, but currently the use-cannon examples are broken, so I'm unable to create a PR for it. If you look at the addToWorld method, you'll notice that it also adds (to world) the chassisBody. I think this is undesirable. If you have a look at my code example you can see that the chassisBody is created in a separate hook (useBox, but could be anything really...) and thus gets added to world before the raycast vehicle hook is called. Using the addToWorld api would add it twice, which I think is something that is to be avoided.

PS: What do you think about the promotion of all the Vec3 instances ? I believe it's always better to reuse Vec3's than to create new ones on the fly, but I could be wrong... BTW: I think I missed some :)

@marcofugaro
Copy link
Member

New version of cannon-es has been published! The RaycastVehicle is now y-up!
Will update the cannon-es version in use-cannon soon.

PS: What do you think about the promotion of all the Vec3 instances?
It doesn't look like there is any difference in performance, did you do some tests?

Closing this PR for now.

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

Successfully merging this pull request may close these issues.

2 participants