Closed DennisSmolek closed 6 months ago
@isaac-mason is this something you can fix in webidl-dts-gen?
Seems the root issue here is JSImplementation method arguments don't have correct types.
As an example, currently the ContactListenerJS type is:
class ContactListenerJS {
constructor();
OnContactValidate(inBody1: Body, inBody2: Body, inBaseOffset: RVec3, inCollisionResult: CollideShapeResult): number;
OnContactAdded(inBody1: Body, inBody2: Body, inManifold: ContactManifold, ioSettings: ContactSettings): void;
OnContactPersisted(inBody1: Body, inBody2: Body, inManifold: ContactManifold, ioSettings: ContactSettings): void;
OnContactRemoved(inSubShapePair: SubShapeIDPair): void;
}
But the webidl binder calls the methods with pointers, so this needs to change to:
class ContactListenerJS {
constructor();
OnContactValidate(inBody1: number, inBody2: number, inBaseOffset: number, inCollisionResult: number): number;
OnContactAdded(inBody1: number, inBody2: number, inManifold: number, ioSettings: number): void;
OnContactPersisted(inBody1: number, inBody2: number, inManifold: number, ioSettings: number): void;
OnContactRemoved(inSubShapePair: number): void;
}
I'll cut a fix in webidl-dts-gen
shortly.
I've released a fix for webidl-dts-gen under 1.9.0: https://github.com/pmndrs/webidl-dts-gen/releases/tag/webidl-dts-gen%401.9.0
And raised a PR to bump it's version here: https://github.com/jrouwe/JoltPhysics.js/pull/130
Thanks for fixing this! I've released a new package 0.20.0 with this fix.
No worries!
When setting up listeners I need to wrap pointers in the callbacks. For example from the contactListener example:
In this example
body1
andbody2
areJolt.BodyID
's but thewrapPointer
is set as a number :Types.d.ts Line 7
does it need to be an
unknown
likecastObject
?Typescript is complaining: