@threlte/rapier 0.2.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @threlte/extras
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c7e226f: useJoint is now exported and its types are fixed
8
+
9
+ ## 0.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 9d29fc0: removed unused variable
14
+
15
+ ## 0.3.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 1a0f305: removed properties "manifold" and "flipped" from contact force event
20
+
21
+ ### Patch Changes
22
+
23
+ - 291af9b: Exporting rapier event types for easier method typing
24
+
3
25
  ## 0.2.0
4
26
 
5
27
  ### Minor Changes
@@ -76,8 +76,6 @@ declare class __sveltets_Render<Shape extends 'ball' | 'capsule' | 'segment' | '
76
76
  contact: CustomEvent<{
77
77
  targetCollider: Collider;
78
78
  targetRigidBody: RigidBody | null;
79
- manifold: import("@dimforge/rapier3d-compat").TempContactManifold;
80
- flipped: boolean;
81
79
  maxForceDirection: import("@dimforge/rapier3d-compat").Vector;
82
80
  maxForceMagnitude: number;
83
81
  totalForce: import("@dimforge/rapier3d-compat").Vector;
@@ -49,8 +49,6 @@ declare const __propDef: {
49
49
  contact: CustomEvent<{
50
50
  targetCollider: import("@dimforge/rapier3d-compat").Collider;
51
51
  targetRigidBody: RigidBody | null;
52
- manifold: import("@dimforge/rapier3d-compat").TempContactManifold;
53
- flipped: boolean;
54
52
  maxForceDirection: import("@dimforge/rapier3d-compat").Vector;
55
53
  maxForceMagnitude: number;
56
54
  totalForce: import("@dimforge/rapier3d-compat").Vector;
@@ -80,49 +80,39 @@ export const useFrameHandler = (ctx) => {
80
80
  const { colliderDispatcher1, colliderDispatcher2, rigidBodyDispatcher1, rigidBodyDispatcher2 } = getEventDispatchers(ctx, collider1, collider2);
81
81
  const rigidBody1 = collider1.parent();
82
82
  const rigidBody2 = collider2.parent();
83
- world.contactPair(collider1, collider2, (manifold, flipped) => {
84
- // Collider events
85
- colliderDispatcher1?.('contact', {
86
- flipped,
87
- manifold,
88
- targetCollider: collider2,
89
- targetRigidBody: rigidBody2,
90
- maxForceDirection: e.maxForceDirection(),
91
- maxForceMagnitude: e.maxForceMagnitude(),
92
- totalForce: e.totalForce(),
93
- totalForceMagnitude: e.totalForceMagnitude()
94
- });
95
- colliderDispatcher2?.('contact', {
96
- flipped,
97
- manifold,
98
- targetCollider: collider1,
99
- targetRigidBody: rigidBody1,
100
- maxForceDirection: e.maxForceDirection(),
101
- maxForceMagnitude: e.maxForceMagnitude(),
102
- totalForce: e.totalForce(),
103
- totalForceMagnitude: e.totalForceMagnitude()
104
- });
105
- // RigidBody Events
106
- rigidBodyDispatcher1?.('contact', {
107
- flipped,
108
- manifold,
109
- targetCollider: collider2,
110
- targetRigidBody: rigidBody2,
111
- maxForceDirection: e.maxForceDirection(),
112
- maxForceMagnitude: e.maxForceMagnitude(),
113
- totalForce: e.totalForce(),
114
- totalForceMagnitude: e.totalForceMagnitude()
115
- });
116
- rigidBodyDispatcher2?.('contact', {
117
- flipped,
118
- manifold,
119
- targetCollider: collider1,
120
- targetRigidBody: rigidBody1,
121
- maxForceDirection: e.maxForceDirection(),
122
- maxForceMagnitude: e.maxForceMagnitude(),
123
- totalForce: e.totalForce(),
124
- totalForceMagnitude: e.totalForceMagnitude()
125
- });
83
+ // Collider events
84
+ colliderDispatcher1?.('contact', {
85
+ targetCollider: collider2,
86
+ targetRigidBody: rigidBody2,
87
+ maxForceDirection: e.maxForceDirection(),
88
+ maxForceMagnitude: e.maxForceMagnitude(),
89
+ totalForce: e.totalForce(),
90
+ totalForceMagnitude: e.totalForceMagnitude()
91
+ });
92
+ colliderDispatcher2?.('contact', {
93
+ targetCollider: collider1,
94
+ targetRigidBody: rigidBody1,
95
+ maxForceDirection: e.maxForceDirection(),
96
+ maxForceMagnitude: e.maxForceMagnitude(),
97
+ totalForce: e.totalForce(),
98
+ totalForceMagnitude: e.totalForceMagnitude()
99
+ });
100
+ // RigidBody Events
101
+ rigidBodyDispatcher1?.('contact', {
102
+ targetCollider: collider2,
103
+ targetRigidBody: rigidBody2,
104
+ maxForceDirection: e.maxForceDirection(),
105
+ maxForceMagnitude: e.maxForceMagnitude(),
106
+ totalForce: e.totalForce(),
107
+ totalForceMagnitude: e.totalForceMagnitude()
108
+ });
109
+ rigidBodyDispatcher2?.('contact', {
110
+ targetCollider: collider1,
111
+ targetRigidBody: rigidBody1,
112
+ maxForceDirection: e.maxForceDirection(),
113
+ maxForceMagnitude: e.maxForceMagnitude(),
114
+ totalForce: e.totalForce(),
115
+ totalForceMagnitude: e.totalForceMagnitude()
126
116
  });
127
117
  });
128
118
  // Collision events
@@ -1,6 +1,6 @@
1
- import type { ImpulseJoint, RigidBody } from '@dimforge/rapier3d-compat';
1
+ import { MultibodyJoint, type ImpulseJoint, type RigidBody } from '@dimforge/rapier3d-compat';
2
2
  import type { RapierContext } from '../types/types';
3
- export declare const useJoint: <T extends ImpulseJoint>(initializeJoint: (rigidBodyA: RigidBody, rigidBodyB: RigidBody, ctx: RapierContext) => T) => {
3
+ export declare const useJoint: <T extends ImpulseJoint | MultibodyJoint>(initializeJoint: (rigidBodyA: RigidBody, rigidBodyB: RigidBody, ctx: RapierContext) => T) => {
4
4
  joint: import("svelte/store").Writable<T>;
5
5
  rigidBodyA: import("svelte/store").Writable<RigidBody | undefined>;
6
6
  rigidBodyB: import("svelte/store").Writable<RigidBody | undefined>;
@@ -1,3 +1,4 @@
1
+ import { MultibodyJoint } from '@dimforge/rapier3d-compat';
1
2
  import { onDestroy } from 'svelte';
2
3
  import { derived, get, writable } from 'svelte/store';
3
4
  import { useRapier } from './useRapier';
@@ -21,7 +22,12 @@ export const useJoint = (initializeJoint) => {
21
22
  const j = get(joint);
22
23
  if (!j)
23
24
  return;
24
- ctx.world.removeImpulseJoint(j, true);
25
+ if (j instanceof MultibodyJoint) {
26
+ ctx.world.removeMultibodyJoint(j, true);
27
+ }
28
+ else {
29
+ ctx.world.removeImpulseJoint(j, true);
30
+ }
25
31
  });
26
32
  return {
27
33
  joint,
@@ -1,4 +1,3 @@
1
- import { navigating } from '$app/stores';
2
1
  import { positionToVector3 } from '../lib/positionToVector3';
3
2
  import { useJoint } from './useJoint';
4
3
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -8,4 +7,3 @@ export const useSphericalJoint = (anchorA, anchorB) => {
8
7
  return world.createImpulseJoint(params, rbA, rbB, true);
9
8
  });
10
9
  };
11
- navigating;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { useRevoluteJoint } from './hooks/useRevoluteJoint';
5
5
  export { usePrismaticJoint } from './hooks/usePrismaticJoint';
6
6
  export { useFixedJoint } from './hooks/useFixedJoint';
7
7
  export { useSphericalJoint } from './hooks/useSphericalJoint';
8
+ export { useJoint } from './hooks/useJoint';
8
9
  export { default as World } from './components/World/World.svelte';
9
10
  export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
10
11
  export { default as Debug } from './components/Debug/Debug.svelte';
@@ -13,4 +14,4 @@ export { default as AutoColliders } from './components/Colliders/AutoColliders.s
13
14
  export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
14
15
  export { default as BasicPlayerController } from './recipes/BasicPlayerController.svelte';
15
16
  export type { AutoCollidersProperties, Boolean3Array, RigidBodyProperties, WorldProperties } from './types/components';
16
- export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderEventDispatcher, ColliderShapes, RapierContext, RigidBodyEventDispatcher } from './types/types';
17
+ export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderEventDispatcher, ColliderShapes, RapierContext, RigidBodyEventDispatcher, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent } from './types/types';
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export { useRevoluteJoint } from './hooks/useRevoluteJoint';
7
7
  export { usePrismaticJoint } from './hooks/usePrismaticJoint';
8
8
  export { useFixedJoint } from './hooks/useFixedJoint';
9
9
  export { useSphericalJoint } from './hooks/useSphericalJoint';
10
+ export { useJoint } from './hooks/useJoint';
10
11
  // components
11
12
  export { default as World } from './components/World/World.svelte';
12
13
  export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
@@ -27,14 +27,17 @@ export declare type ColliderEventMap = {
27
27
  contact: {
28
28
  targetCollider: Collider;
29
29
  targetRigidBody: RigidBody | null;
30
- manifold: TempContactManifold;
31
- flipped: boolean;
32
30
  maxForceDirection: Vector;
33
31
  maxForceMagnitude: number;
34
32
  totalForce: Vector;
35
33
  totalForceMagnitude: number;
36
34
  };
37
35
  };
36
+ export declare type CollisionEnterEvent = CustomEvent<ColliderEventMap['collisionenter']>;
37
+ export declare type CollisionExitEvent = CustomEvent<ColliderEventMap['collisionexit']>;
38
+ export declare type SensorEnterEvent = CustomEvent<ColliderEventMap['sensorenter']>;
39
+ export declare type SensorExitEvent = CustomEvent<ColliderEventMap['sensorexit']>;
40
+ export declare type ContactEvent = CustomEvent<ColliderEventMap['contact']>;
38
41
  export declare type RigidBodyEventMap = ColliderEventMap & {
39
42
  sleep: void;
40
43
  wake: void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threlte/rapier",
3
- "version": "0.2.0",
3
+ "version": "0.3.2",
4
4
  "author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
5
5
  "license": "MIT",
6
6
  "devDependencies": {