@threlte/rapier 3.1.4 → 3.2.0

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.
Files changed (51) hide show
  1. package/README.md +0 -4
  2. package/dist/components/Attractor/Attractor.svelte +58 -32
  3. package/dist/components/Attractor/Attractor.svelte.d.ts +2 -1
  4. package/dist/components/Attractor/types.d.ts +1 -1
  5. package/dist/components/Colliders/AutoColliders/AutoColliders.svelte +123 -76
  6. package/dist/components/Colliders/AutoColliders/AutoColliders.svelte.d.ts +15 -4
  7. package/dist/components/Colliders/AutoColliders/types.d.ts +2 -2
  8. package/dist/components/Colliders/AutoColliders/types.js +1 -1
  9. package/dist/components/Colliders/Collider/Collider.svelte +181 -126
  10. package/dist/components/Colliders/Collider/Collider.svelte.d.ts +13 -4
  11. package/dist/components/Colliders/Collider/types.d.ts +2 -2
  12. package/dist/components/Colliders/Collider/types.js +1 -1
  13. package/dist/components/CollisionGroups/CollisionGroups.svelte +27 -7
  14. package/dist/components/CollisionGroups/CollisionGroups.svelte.d.ts +11 -4
  15. package/dist/components/CollisionGroups/types.d.ts +1 -1
  16. package/dist/components/CollisionGroups/types.js +1 -1
  17. package/dist/components/Debug/Debug.svelte +28 -18
  18. package/dist/components/Debug/Debug.svelte.d.ts +2 -1
  19. package/dist/components/RigidBody/RigidBody.svelte +173 -113
  20. package/dist/components/RigidBody/RigidBody.svelte.d.ts +2 -1
  21. package/dist/components/RigidBody/types.d.ts +4 -4
  22. package/dist/components/RigidBody/types.js +1 -2
  23. package/dist/components/World/InnerWorld.svelte +53 -22
  24. package/dist/components/World/InnerWorld.svelte.d.ts +2 -1
  25. package/dist/components/World/World.svelte +6 -3
  26. package/dist/components/World/World.svelte.d.ts +2 -1
  27. package/dist/components/World/types.d.ts +2 -2
  28. package/dist/components/World/types.js +1 -1
  29. package/dist/hooks/useFixedJoint.js +2 -2
  30. package/dist/hooks/useJoint.d.ts +1 -1
  31. package/dist/hooks/useJoint.js +1 -1
  32. package/dist/hooks/usePhysicsTask.js +1 -1
  33. package/dist/hooks/usePrismaticJoint.js +2 -2
  34. package/dist/hooks/useRapier.d.ts +1 -1
  35. package/dist/hooks/useRevoluteJoint.js +2 -2
  36. package/dist/hooks/useRigidBody.d.ts +1 -1
  37. package/dist/hooks/useRopeJoint.js +2 -2
  38. package/dist/hooks/useSphericalJoint.js +2 -2
  39. package/dist/index.d.ts +12 -12
  40. package/dist/index.js +11 -11
  41. package/dist/lib/applyColliderActiveEvents.d.ts +1 -1
  42. package/dist/lib/createCollidersFromChildren.d.ts +1 -1
  43. package/dist/lib/createPhysicsStages.d.ts +1 -1
  44. package/dist/lib/createPhysicsStages.js +1 -1
  45. package/dist/lib/createPhysicsTasks.d.ts +1 -1
  46. package/dist/lib/createPhysicsTasks.js +1 -1
  47. package/dist/lib/createRapierContext.d.ts +1 -1
  48. package/dist/lib/createRapierContext.js +2 -2
  49. package/dist/lib/scaleColliderArgs.d.ts +1 -1
  50. package/dist/lib/useCreateEvent.d.ts +1 -1
  51. package/package.json +11 -12
@@ -1,106 +1,164 @@
1
- <script lang="ts">import { createParentObject3DContext, useParentObject3D, watch } from '@threlte/core';
2
- import { onDestroy, setContext, tick } from 'svelte';
3
- import { Object3D, Vector3 } from 'three';
4
- import { useRapier } from '../../hooks/useRapier';
5
- import { initializeRigidBodyUserData, setInitialRigidBodyState } from '../../lib/createPhysicsTasks';
6
- import { getWorldPosition, getWorldQuaternion, getWorldScale } from '../../lib/getWorldTransforms';
7
- import { parseRigidBodyType } from '../../lib/parseRigidBodyType';
8
- import { setParentRigidbodyObject } from '../../lib/rigidBodyObjectContext';
9
- import { useCreateEvent } from '../../lib/useCreateEvent';
10
- import { overrideTeleportMethods } from './overrideTeleportMethods';
11
- const { world, rapier, addRigidBodyToContext, removeRigidBodyFromContext } = useRapier();
12
- let { linearVelocity, angularVelocity, type = 'dynamic', canSleep = true, gravityScale = 1, ccd = false, angularDamping = 0, linearDamping = 0, lockRotations = false, lockTranslations = false, enabledRotations = [true, true, true], enabledTranslations = [true, true, true], dominance = 0, enabled = true, userData = {}, rigidBody = $bindable(), oncreate, oncollisionenter, oncollisionexit, oncontact, onsensorenter, onsensorexit, onsleep, onwake, children } = $props();
13
- /**
14
- * Every RigidBody receives and forwards collision-related events
15
- */
16
- const { updateRef } = useCreateEvent(oncreate);
17
- const object = new Object3D();
18
- initializeRigidBodyUserData(object);
19
- /**
20
- * isSleeping used for events "sleep" and "wake" in `createPhysicsTasks`
21
- */
22
- object.userData.isSleeping = false;
23
- /**
24
- * RigidBody Description
25
- */
26
- const desc = new rapier.RigidBodyDesc(parseRigidBodyType(type)).setCanSleep(canSleep);
27
- /**
28
- * Temporary RigidBody init
29
- */
30
- let rigidBodyInternal = world.createRigidBody(desc);
31
- overrideTeleportMethods(rigidBodyInternal, object);
32
- rigidBody = rigidBodyInternal;
33
- /**
34
- * Apply transforms after the parent component added "object" to itself
35
- */
36
- const initPosition = async () => {
37
- await tick();
38
- object.updateMatrix();
39
- object.updateWorldMatrix(true, false);
40
- const parentWorldScale = object.parent ? getWorldScale(object.parent) : new Vector3(1, 1, 1);
41
- const worldPosition = getWorldPosition(object).multiply(parentWorldScale);
42
- const worldQuaternion = getWorldQuaternion(object);
43
- setInitialRigidBodyState(object, worldPosition, worldQuaternion);
44
- rigidBodyInternal.setTranslation(worldPosition, true);
45
- rigidBodyInternal.setRotation(worldQuaternion, true);
46
- updateRef(rigidBodyInternal);
47
- };
48
- initPosition();
49
- /**
50
- * Will come in handy in the future for joints
51
- */
52
- object.userData.rigidBody = rigidBodyInternal;
53
- $effect.pre(() => rigidBodyInternal.setBodyType(parseRigidBodyType(type), true));
54
- $effect.pre(() => {
1
+ <script lang="ts">
2
+ import { createParentObject3DContext, useParentObject3D, watch } from '@threlte/core'
3
+ import { onDestroy, setContext, tick } from 'svelte'
4
+ import { Object3D, Vector3 } from 'three'
5
+ import { useRapier } from '../../hooks/useRapier.js'
6
+ import {
7
+ initializeRigidBodyUserData,
8
+ setInitialRigidBodyState
9
+ } from '../../lib/createPhysicsTasks.js'
10
+ import {
11
+ getWorldPosition,
12
+ getWorldQuaternion,
13
+ getWorldScale
14
+ } from '../../lib/getWorldTransforms.js'
15
+ import { parseRigidBodyType } from '../../lib/parseRigidBodyType.js'
16
+ import { setParentRigidbodyObject } from '../../lib/rigidBodyObjectContext.js'
17
+ import { useCreateEvent } from '../../lib/useCreateEvent.js'
18
+ import type { RigidBodyContext, ThrelteRigidBody } from '../../types/types.js'
19
+ import { overrideTeleportMethods } from './overrideTeleportMethods.js'
20
+ import type { RigidBodyProps } from './types.js'
21
+
22
+ const { world, rapier, addRigidBodyToContext, removeRigidBodyFromContext } = useRapier()
23
+
24
+ let {
25
+ linearVelocity,
26
+ angularVelocity,
27
+ type = 'dynamic',
28
+ canSleep = true,
29
+ gravityScale = 1,
30
+ ccd = false,
31
+ angularDamping = 0,
32
+ linearDamping = 0,
33
+ lockRotations = false,
34
+ lockTranslations = false,
35
+ enabledRotations = [true, true, true],
36
+ enabledTranslations = [true, true, true],
37
+ dominance = 0,
38
+ enabled = true,
39
+ userData = {},
40
+ rigidBody = $bindable(),
41
+ oncreate,
42
+ oncollisionenter,
43
+ oncollisionexit,
44
+ oncontact,
45
+ onsensorenter,
46
+ onsensorexit,
47
+ onsleep,
48
+ onwake,
49
+ children
50
+ }: RigidBodyProps = $props()
51
+
52
+ /**
53
+ * Every RigidBody receives and forwards collision-related events
54
+ */
55
+ const { updateRef } = useCreateEvent(oncreate)
56
+
57
+ const object = new Object3D()
58
+ initializeRigidBodyUserData(object)
59
+
60
+ /**
61
+ * isSleeping used for events "sleep" and "wake" in `createPhysicsTasks`
62
+ */
63
+ object.userData.isSleeping = false
64
+
65
+ /**
66
+ * RigidBody Description
67
+ */
68
+ const desc = new rapier.RigidBodyDesc(parseRigidBodyType(type)).setCanSleep(canSleep)
69
+
70
+ /**
71
+ * Temporary RigidBody init
72
+ */
73
+ let rigidBodyInternal = world.createRigidBody(desc) as ThrelteRigidBody
74
+
75
+ overrideTeleportMethods(rigidBodyInternal, object)
76
+
77
+ rigidBody = rigidBodyInternal
78
+
79
+ /**
80
+ * Apply transforms after the parent component added "object" to itself
81
+ */
82
+ const initPosition = async () => {
83
+ await tick()
84
+ object.updateMatrix()
85
+ object.updateWorldMatrix(true, false)
86
+ const parentWorldScale = object.parent ? getWorldScale(object.parent) : new Vector3(1, 1, 1)
87
+ const worldPosition = getWorldPosition(object).multiply(parentWorldScale)
88
+ const worldQuaternion = getWorldQuaternion(object)
89
+ setInitialRigidBodyState(object, worldPosition, worldQuaternion)
90
+ rigidBodyInternal.setTranslation(worldPosition, true)
91
+ rigidBodyInternal.setRotation(worldQuaternion, true)
92
+ updateRef(rigidBodyInternal)
93
+ }
94
+ initPosition()
95
+
96
+ /**
97
+ * Will come in handy in the future for joints
98
+ */
99
+ object.userData.rigidBody = rigidBodyInternal
100
+
101
+ $effect.pre(() => rigidBodyInternal.setBodyType(parseRigidBodyType(type), true))
102
+ $effect.pre(() => {
55
103
  if (linearVelocity) {
56
- rigidBodyInternal.setLinvel({ x: linearVelocity[0], y: linearVelocity[1], z: linearVelocity[2] }, true);
104
+ rigidBodyInternal.setLinvel(
105
+ { x: linearVelocity[0], y: linearVelocity[1], z: linearVelocity[2] },
106
+ true
107
+ )
57
108
  }
58
- });
59
- $effect.pre(() => {
109
+ })
110
+ $effect.pre(() => {
60
111
  if (angularVelocity) {
61
- rigidBodyInternal.setAngvel({ x: angularVelocity[0], y: angularVelocity[1], z: angularVelocity[2] }, true);
112
+ rigidBodyInternal.setAngvel(
113
+ { x: angularVelocity[0], y: angularVelocity[1], z: angularVelocity[2] },
114
+ true
115
+ )
62
116
  }
63
- });
64
- $effect.pre(() => rigidBodyInternal.setGravityScale(gravityScale, true));
65
- $effect.pre(() => rigidBodyInternal.enableCcd(ccd));
66
- $effect.pre(() => rigidBodyInternal.setDominanceGroup(dominance));
67
- $effect.pre(() => rigidBodyInternal.lockRotations(lockRotations, true));
68
- $effect.pre(() => rigidBodyInternal.lockTranslations(lockTranslations, true));
69
- $effect.pre(() => rigidBodyInternal.setEnabledRotations(...enabledRotations, true));
70
- $effect.pre(() => rigidBodyInternal.setEnabledTranslations(...enabledTranslations, true));
71
- $effect.pre(() => rigidBodyInternal.setAngularDamping(angularDamping));
72
- $effect.pre(() => rigidBodyInternal.setLinearDamping(linearDamping));
73
- $effect.pre(() => rigidBodyInternal.setEnabled(enabled));
74
- /**
75
- * Add userData to the rigidBody
76
- */
77
- $effect.pre(() => {
117
+ })
118
+ $effect.pre(() => rigidBodyInternal.setGravityScale(gravityScale, true))
119
+ $effect.pre(() => rigidBodyInternal.enableCcd(ccd))
120
+ $effect.pre(() => rigidBodyInternal.setDominanceGroup(dominance))
121
+ $effect.pre(() => rigidBodyInternal.lockRotations(lockRotations, true))
122
+ $effect.pre(() => rigidBodyInternal.lockTranslations(lockTranslations, true))
123
+ $effect.pre(() => rigidBodyInternal.setEnabledRotations(...enabledRotations, true))
124
+ $effect.pre(() => rigidBodyInternal.setEnabledTranslations(...enabledTranslations, true))
125
+ $effect.pre(() => rigidBodyInternal.setAngularDamping(angularDamping))
126
+ $effect.pre(() => rigidBodyInternal.setLinearDamping(linearDamping))
127
+ $effect.pre(() => rigidBodyInternal.setEnabled(enabled))
128
+
129
+ /**
130
+ * Add userData to the rigidBody
131
+ */
132
+ $effect.pre(() => {
78
133
  rigidBodyInternal.userData = {
79
- events: {
80
- oncollisionenter,
81
- oncollisionexit,
82
- oncontact,
83
- onsensorenter,
84
- onsensorexit,
85
- onsleep,
86
- onwake
87
- },
88
- ...userData
89
- };
90
- });
91
- /**
92
- * Setting the RigidBody context so that colliders can
93
- * hook onto.
94
- */
95
- setContext('threlte-rapier-rigidbody', rigidBodyInternal);
96
- /**
97
- * Used by child colliders to restore transform
98
- */
99
- setParentRigidbodyObject(object);
100
- /**
101
- * Add the mesh to the context
102
- */
103
- addRigidBodyToContext(rigidBodyInternal, object, {
134
+ events: {
135
+ oncollisionenter,
136
+ oncollisionexit,
137
+ oncontact,
138
+ onsensorenter,
139
+ onsensorexit,
140
+ onsleep,
141
+ onwake
142
+ },
143
+ ...userData
144
+ }
145
+ })
146
+
147
+ /**
148
+ * Setting the RigidBody context so that colliders can
149
+ * hook onto.
150
+ */
151
+ setContext<RigidBodyContext>('threlte-rapier-rigidbody', rigidBodyInternal)
152
+
153
+ /**
154
+ * Used by child colliders to restore transform
155
+ */
156
+ setParentRigidbodyObject(object)
157
+
158
+ /**
159
+ * Add the mesh to the context
160
+ */
161
+ addRigidBodyToContext(rigidBodyInternal, object, {
104
162
  oncollisionenter,
105
163
  oncollisionexit,
106
164
  oncontact,
@@ -108,22 +166,24 @@ addRigidBodyToContext(rigidBodyInternal, object, {
108
166
  onsensorexit,
109
167
  onsleep,
110
168
  onwake
111
- });
112
- /**
113
- * cleanup
114
- */
115
- onDestroy(() => {
116
- removeRigidBodyFromContext(rigidBodyInternal);
117
- world.removeRigidBody(rigidBodyInternal);
118
- });
119
- const parent3DObject = useParentObject3D();
120
- createParentObject3DContext(object);
121
- watch(parent3DObject, (parent) => {
122
- parent?.add(object);
169
+ })
170
+
171
+ /**
172
+ * cleanup
173
+ */
174
+ onDestroy(() => {
175
+ removeRigidBodyFromContext(rigidBodyInternal)
176
+ world.removeRigidBody(rigidBodyInternal)
177
+ })
178
+
179
+ const parent3DObject = useParentObject3D()
180
+ createParentObject3DContext(object)
181
+ watch(parent3DObject, (parent) => {
182
+ parent?.add(object)
123
183
  return () => {
124
- parent?.remove(object);
125
- };
126
- });
184
+ parent?.remove(object)
185
+ }
186
+ })
127
187
  </script>
128
188
 
129
189
  {@render children?.({ rigidBody: rigidBodyInternal })}
@@ -1,3 +1,4 @@
1
- import type { RigidBodyProps } from './types';
1
+ import type { RigidBodyProps } from './types.js';
2
2
  declare const RigidBody: import("svelte").Component<RigidBodyProps, {}, "rigidBody">;
3
+ type RigidBody = ReturnType<typeof RigidBody>;
3
4
  export default RigidBody;
@@ -1,8 +1,8 @@
1
- import { RigidBody as RapierRigidBody } from '@dimforge/rapier3d-compat';
2
- import { type Snippet } from 'svelte';
1
+ import type { RigidBody as RapierRigidBody } from '@dimforge/rapier3d-compat';
2
+ import type { Snippet } from 'svelte';
3
3
  import type { Euler, Vector3 } from 'three';
4
- import type { RigidBodyTypeString } from '../../lib/parseRigidBodyType';
5
- import type { CreateEvent, RigidBodyEvents } from '../../types/types';
4
+ import type { RigidBodyTypeString } from '../../lib/parseRigidBodyType.js';
5
+ import type { CreateEvent, RigidBodyEvents } from '../../types/types.js';
6
6
  export type Boolean3Array = [x: boolean, y: boolean, z: boolean];
7
7
  export type RigidBodyProps = CreateEvent<RapierRigidBody> & RigidBodyEvents & {
8
8
  rigidBody?: RapierRigidBody | undefined;
@@ -1,2 +1 @@
1
- import { RigidBody as RapierRigidBody } from '@dimforge/rapier3d-compat';
2
- import {} from 'svelte';
1
+ export {};
@@ -1,8 +1,11 @@
1
- <script lang="ts">import { onDestroy, setContext, tick } from 'svelte';
2
- import { createRapierContext } from '../../lib/createRapierContext';
3
- let { gravity = [0, -9.81, 0], rawIntegrationParameters, rawIslands, rawBroadPhase, rawNarrowPhase, rawBodies, rawColliders, rawImpulseJoints, rawMultibodyJoints, rawCCDSolver, rawQueryPipeline, rawPhysicsPipeline, rawSerializationPipeline, rawDebugRenderPipeline, framerate, autoStart = true, simulationStageOptions, synchronizationStageOptions, children } = $props();
4
- const rapierContext = createRapierContext([
5
- { x: gravity[0], y: gravity[1], z: gravity[2] },
1
+ <script lang="ts">
2
+ import { onDestroy, setContext, tick } from 'svelte'
3
+ import { createRapierContext } from '../../lib/createRapierContext.js'
4
+ import type { RapierContext } from '../../types/types.js'
5
+ import type { WorldProps } from './types.js'
6
+
7
+ let {
8
+ gravity = [0, -9.81, 0],
6
9
  rawIntegrationParameters,
7
10
  rawIslands,
8
11
  rawBroadPhase,
@@ -15,27 +18,55 @@ const rapierContext = createRapierContext([
15
18
  rawQueryPipeline,
16
19
  rawPhysicsPipeline,
17
20
  rawSerializationPipeline,
18
- rawDebugRenderPipeline
19
- ], {
21
+ rawDebugRenderPipeline,
20
22
  framerate,
21
- autoStart,
23
+ autoStart = true,
22
24
  simulationStageOptions,
23
- synchronizationStageOptions
24
- });
25
- setContext('threlte-rapier-context', rapierContext);
26
- $effect.pre(() => {
25
+ synchronizationStageOptions,
26
+ children
27
+ }: WorldProps = $props()
28
+
29
+ const rapierContext = createRapierContext(
30
+ [
31
+ { x: gravity[0], y: gravity[1], z: gravity[2] },
32
+ rawIntegrationParameters,
33
+ rawIslands,
34
+ rawBroadPhase,
35
+ rawNarrowPhase,
36
+ rawBodies,
37
+ rawColliders,
38
+ rawImpulseJoints,
39
+ rawMultibodyJoints,
40
+ rawCCDSolver,
41
+ rawQueryPipeline,
42
+ rawPhysicsPipeline,
43
+ rawSerializationPipeline,
44
+ rawDebugRenderPipeline
45
+ ],
46
+ {
47
+ framerate,
48
+ autoStart,
49
+ simulationStageOptions,
50
+ synchronizationStageOptions
51
+ }
52
+ )
53
+
54
+ setContext<RapierContext>('threlte-rapier-context', rapierContext)
55
+
56
+ $effect.pre(() => {
27
57
  if (gravity !== undefined) {
28
- rapierContext.world.gravity = { x: gravity[0], y: gravity[1], z: gravity[2] };
58
+ rapierContext.world.gravity = { x: gravity[0], y: gravity[1], z: gravity[2] }
29
59
  }
30
- });
31
- $effect.pre(() => {
32
- if (framerate !== undefined)
33
- rapierContext.framerate.set(framerate);
34
- });
35
- onDestroy(async () => {
36
- await tick();
37
- rapierContext.world.free();
38
- });
60
+ })
61
+
62
+ $effect.pre(() => {
63
+ if (framerate !== undefined) rapierContext.framerate.set(framerate)
64
+ })
65
+
66
+ onDestroy(async () => {
67
+ await tick()
68
+ rapierContext.world.free()
69
+ })
39
70
  </script>
40
71
 
41
72
  {@render children?.()}
@@ -1,3 +1,4 @@
1
- import type { WorldProps } from './types';
1
+ import type { WorldProps } from './types.js';
2
2
  declare const InnerWorld: import("svelte").Component<WorldProps, {}, "">;
3
+ type InnerWorld = ReturnType<typeof InnerWorld>;
3
4
  export default InnerWorld;
@@ -1,6 +1,9 @@
1
- <script lang="ts">import { initRapier } from '../../lib/initRapier.svelte';
2
- import InnerWorld from './InnerWorld.svelte';
3
- let { fallback, children, ...rest } = $props();
1
+ <script lang="ts">
2
+ import { initRapier } from '../../lib/initRapier.svelte.js'
3
+ import InnerWorld from './InnerWorld.svelte'
4
+ import type { WorldProps } from './types.js'
5
+
6
+ let { fallback, children, ...rest }: WorldProps = $props()
4
7
  </script>
5
8
 
6
9
  {#await initRapier() then}
@@ -1,3 +1,4 @@
1
- import type { WorldProps } from './types';
1
+ import type { WorldProps } from './types.js';
2
2
  declare const World: import("svelte").Component<WorldProps, {}, "">;
3
+ type World = ReturnType<typeof World>;
3
4
  export default World;
@@ -1,6 +1,6 @@
1
- import type { RawBroadPhase, RawCCDSolver, RawColliderSet, RawDebugRenderPipeline, RawImpulseJointSet, RawIntegrationParameters, RawIslandManager, RawMultibodyJointSet, RawNarrowPhase, RawPhysicsPipeline, RawQueryPipeline, RawRigidBodySet, RawSerializationPipeline } from '@dimforge/rapier3d-compat/raw';
1
+ import type { RawBroadPhase, RawCCDSolver, RawColliderSet, RawDebugRenderPipeline, RawImpulseJointSet, RawIntegrationParameters, RawIslandManager, RawMultibodyJointSet, RawNarrowPhase, RawPhysicsPipeline, RawQueryPipeline, RawRigidBodySet, RawSerializationPipeline } from '@dimforge/rapier3d-compat/raw.js';
2
2
  import type { Key, Stage } from '@threlte/core';
3
- import { type Snippet } from 'svelte';
3
+ import type { Snippet } from 'svelte';
4
4
  import type { Vector3 } from 'three';
5
5
  export type WorldProps = {
6
6
  framerate?: number | 'varying';
@@ -1 +1 @@
1
- import {} from 'svelte';
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { Euler, Quaternion, Vector3 } from 'three';
2
- import { useJoint } from './useJoint';
3
- import { isEuler, isVector3 } from './utils';
2
+ import { useJoint } from './useJoint.js';
3
+ import { isEuler, isVector3 } from './utils.js';
4
4
  export const useFixedJoint = (anchorA, frameA, anchorB, frameB) => {
5
5
  const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
6
6
  const jfA = new Quaternion().setFromEuler(isEuler(frameA) ? frameA : new Euler(...frameA));
@@ -1,5 +1,5 @@
1
1
  import { MultibodyJoint, type ImpulseJoint, type RigidBody } from '@dimforge/rapier3d-compat';
2
- import type { RapierContext } from '../types/types';
2
+ import type { RapierContext } from '../types/types.js';
3
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>;
@@ -1,7 +1,7 @@
1
1
  import { MultibodyJoint } from '@dimforge/rapier3d-compat';
2
2
  import { onDestroy } from 'svelte';
3
3
  import { derived, get, writable } from 'svelte/store';
4
- import { useRapier } from './useRapier';
4
+ import { useRapier } from './useRapier.js';
5
5
  export const useJoint = (initializeJoint) => {
6
6
  const rigidBodyA = writable(undefined);
7
7
  const rigidBodyB = writable(undefined);
@@ -1,5 +1,5 @@
1
1
  import { useTask } from '@threlte/core';
2
- import { useRapier } from './useRapier';
2
+ import { useRapier } from './useRapier.js';
3
3
  const isKey = (value) => {
4
4
  return typeof value === 'string' || typeof value === 'symbol';
5
5
  };
@@ -1,6 +1,6 @@
1
1
  import { Vector3 } from 'three';
2
- import { useJoint } from './useJoint';
3
- import { isVector3 } from './utils';
2
+ import { useJoint } from './useJoint.js';
3
+ import { isVector3 } from './utils.js';
4
4
  export const usePrismaticJoint = (anchorA, anchorB, axis, limits) => {
5
5
  return useJoint((rbA, rbB, { world, rapier }) => {
6
6
  const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
@@ -1,2 +1,2 @@
1
- import type { RapierContext } from '../types/types';
1
+ import type { RapierContext } from '../types/types.js';
2
2
  export declare const useRapier: () => RapierContext;
@@ -1,6 +1,6 @@
1
1
  import { Vector3 } from 'three';
2
- import { useJoint } from './useJoint';
3
- import { isVector3 } from './utils';
2
+ import { useJoint } from './useJoint.js';
3
+ import { isVector3 } from './utils.js';
4
4
  export const useRevoluteJoint = (anchorA, anchorB, axis, limits) => {
5
5
  return useJoint((rbA, rbB, { world, rapier }) => {
6
6
  const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
@@ -1,2 +1,2 @@
1
- import type { RigidBodyContext } from '../types/types';
1
+ import type { RigidBodyContext } from '../types/types.js';
2
2
  export declare const useRigidBody: () => RigidBodyContext | undefined;
@@ -1,6 +1,6 @@
1
1
  import { Vector3 } from 'three';
2
- import { useJoint } from './useJoint';
3
- import { isVector3 } from './utils';
2
+ import { useJoint } from './useJoint.js';
3
+ import { isVector3 } from './utils.js';
4
4
  /**
5
5
  * The rope joint limits the max distance between two bodies.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import { Vector3 } from 'three';
2
- import { useJoint } from './useJoint';
3
- import { isVector3 } from './utils';
2
+ import { useJoint } from './useJoint.js';
3
+ import { isVector3 } from './utils.js';
4
4
  export const useSphericalJoint = (anchorA, anchorB) => {
5
5
  return useJoint((rbA, rbB, { world, rapier }) => {
6
6
  const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export { useRapier } from './hooks/useRapier';
2
- export { useCollisionGroups } from './hooks/useCollisionGroups';
3
- export { useRigidBody } from './hooks/useRigidBody';
4
- export { usePhysicsTask } from './hooks/usePhysicsTask';
5
- export { useRevoluteJoint } from './hooks/useRevoluteJoint';
6
- export { usePrismaticJoint } from './hooks/usePrismaticJoint';
7
- export { useFixedJoint } from './hooks/useFixedJoint';
8
- export { useSphericalJoint } from './hooks/useSphericalJoint';
9
- export { useJoint } from './hooks/useJoint';
10
- export { useRopeJoint } from './hooks/useRopeJoint';
1
+ export { useRapier } from './hooks/useRapier.js';
2
+ export { useCollisionGroups } from './hooks/useCollisionGroups.js';
3
+ export { useRigidBody } from './hooks/useRigidBody.js';
4
+ export { usePhysicsTask } from './hooks/usePhysicsTask.js';
5
+ export { useRevoluteJoint } from './hooks/useRevoluteJoint.js';
6
+ export { usePrismaticJoint } from './hooks/usePrismaticJoint.js';
7
+ export { useFixedJoint } from './hooks/useFixedJoint.js';
8
+ export { useSphericalJoint } from './hooks/useSphericalJoint.js';
9
+ export { useJoint } from './hooks/useJoint.js';
10
+ export { useRopeJoint } from './hooks/useRopeJoint.js';
11
11
  export { default as World } from './components/World/World.svelte';
12
12
  export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
13
13
  export { default as Debug } from './components/Debug/Debug.svelte';
@@ -15,5 +15,5 @@ export { default as Collider } from './components/Colliders/Collider/Collider.sv
15
15
  export { default as AutoColliders } from './components/Colliders/AutoColliders/AutoColliders.svelte';
16
16
  export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
17
17
  export { default as Attractor } from './components/Attractor/Attractor.svelte';
18
- export { computeBitMask } from './lib/computeBitMask';
19
- export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderShapes, RapierContext, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent, GravityType, CreateEvent, Framerate } from './types/types';
18
+ export { computeBitMask } from './lib/computeBitMask.js';
19
+ export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderShapes, RapierContext, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent, GravityType, CreateEvent, Framerate } from './types/types.js';
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  // hooks
2
- export { useRapier } from './hooks/useRapier';
3
- export { useCollisionGroups } from './hooks/useCollisionGroups';
4
- export { useRigidBody } from './hooks/useRigidBody';
5
- export { usePhysicsTask } from './hooks/usePhysicsTask';
2
+ export { useRapier } from './hooks/useRapier.js';
3
+ export { useCollisionGroups } from './hooks/useCollisionGroups.js';
4
+ export { useRigidBody } from './hooks/useRigidBody.js';
5
+ export { usePhysicsTask } from './hooks/usePhysicsTask.js';
6
6
  // Joints
7
- export { useRevoluteJoint } from './hooks/useRevoluteJoint';
8
- export { usePrismaticJoint } from './hooks/usePrismaticJoint';
9
- export { useFixedJoint } from './hooks/useFixedJoint';
10
- export { useSphericalJoint } from './hooks/useSphericalJoint';
11
- export { useJoint } from './hooks/useJoint';
12
- export { useRopeJoint } from './hooks/useRopeJoint';
7
+ export { useRevoluteJoint } from './hooks/useRevoluteJoint.js';
8
+ export { usePrismaticJoint } from './hooks/usePrismaticJoint.js';
9
+ export { useFixedJoint } from './hooks/useFixedJoint.js';
10
+ export { useSphericalJoint } from './hooks/useSphericalJoint.js';
11
+ export { useJoint } from './hooks/useJoint.js';
12
+ export { useRopeJoint } from './hooks/useRopeJoint.js';
13
13
  // components
14
14
  export { default as World } from './components/World/World.svelte';
15
15
  export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
@@ -19,4 +19,4 @@ export { default as AutoColliders } from './components/Colliders/AutoColliders/A
19
19
  export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
20
20
  export { default as Attractor } from './components/Attractor/Attractor.svelte';
21
21
  // lib
22
- export { computeBitMask } from './lib/computeBitMask';
22
+ export { computeBitMask } from './lib/computeBitMask.js';
@@ -1,3 +1,3 @@
1
1
  import { type Collider } from '@dimforge/rapier3d-compat';
2
- import type { ColliderEvents, RigidBodyEvents } from '../types/types';
2
+ import type { ColliderEvents, RigidBodyEvents } from '../types/types.js';
3
3
  export declare const applyColliderActiveEvents: (collider: Collider, colliderEvents?: ColliderEvents, rigidBodyEvents?: RigidBodyEvents) => void;
@@ -1,6 +1,6 @@
1
1
  import { Collider, RigidBody, World } from '@dimforge/rapier3d-compat';
2
2
  import { type Object3D } from 'three';
3
- import type { AutoCollidersShapes } from '../types/types';
3
+ import type { AutoCollidersShapes } from '../types/types.js';
4
4
  /**
5
5
  *
6
6
  * Creates collider descriptions including default translations