@threlte/rapier 3.0.0-next.9 → 3.1.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 (55) hide show
  1. package/README.md +1 -8
  2. package/dist/components/Attractor/Attractor.svelte.d.ts +3 -34
  3. package/dist/components/Attractor/types.d.ts +30 -0
  4. package/dist/components/Attractor/types.js +1 -0
  5. package/dist/components/Colliders/{AutoColliders.svelte → AutoColliders/AutoColliders.svelte} +17 -10
  6. package/dist/components/Colliders/AutoColliders/AutoColliders.svelte.d.ts +22 -0
  7. package/dist/components/Colliders/AutoColliders/types.d.ts +74 -0
  8. package/dist/components/Colliders/AutoColliders/types.js +1 -0
  9. package/dist/components/Colliders/{Collider.svelte → Collider/Collider.svelte} +20 -16
  10. package/dist/components/Colliders/Collider/Collider.svelte.d.ts +20 -0
  11. package/dist/components/Colliders/Collider/types.d.ts +83 -0
  12. package/dist/components/Colliders/Collider/types.js +1 -0
  13. package/dist/components/CollisionGroups/CollisionGroups.svelte +4 -1
  14. package/dist/components/CollisionGroups/CollisionGroups.svelte.d.ts +16 -33
  15. package/dist/components/CollisionGroups/types.d.ts +19 -0
  16. package/dist/components/CollisionGroups/types.js +1 -0
  17. package/dist/components/Debug/Debug.svelte +5 -5
  18. package/dist/components/Debug/Debug.svelte.d.ts +3 -7
  19. package/dist/components/Debug/types.d.ts +3 -0
  20. package/dist/components/Debug/types.js +1 -0
  21. package/dist/components/RigidBody/RigidBody.svelte.d.ts +3 -102
  22. package/dist/components/RigidBody/types.d.ts +85 -0
  23. package/dist/components/RigidBody/types.js +2 -0
  24. package/dist/components/World/InnerWorld.svelte.d.ts +3 -15
  25. package/dist/components/World/World.svelte.d.ts +3 -49
  26. package/dist/components/World/types.d.ts +32 -0
  27. package/dist/components/World/types.js +1 -0
  28. package/dist/hooks/useFixedJoint.d.ts +7 -0
  29. package/dist/hooks/useJoint.d.ts +7 -0
  30. package/dist/hooks/usePhysicsTask.d.ts +16 -0
  31. package/dist/hooks/usePhysicsTask.js +32 -0
  32. package/dist/hooks/usePrismaticJoint.d.ts +7 -0
  33. package/dist/hooks/useRevoluteJoint.d.ts +7 -0
  34. package/dist/hooks/useRopeJoint.d.ts +10 -0
  35. package/dist/hooks/useRopeJoint.js +14 -0
  36. package/dist/hooks/useSphericalJoint.d.ts +7 -0
  37. package/dist/hooks/utils.js +3 -2
  38. package/dist/index.d.ts +5 -4
  39. package/dist/index.js +4 -4
  40. package/dist/lib/applyTransforms.d.ts +1 -1
  41. package/dist/lib/createCollidersFromChildren.d.ts +1 -1
  42. package/dist/lib/createCollidersFromChildren.js +24 -5
  43. package/dist/lib/createPhysicsTasks.js +1 -1
  44. package/dist/lib/createRapierContext.d.ts +1 -1
  45. package/dist/lib/eulerToQuaternion.d.ts +2 -2
  46. package/dist/lib/getWorldTransforms.js +1 -1
  47. package/dist/lib/useCreateEvent.d.ts +2 -2
  48. package/dist/lib/useCreateEvent.js +3 -5
  49. package/dist/types/types.d.ts +3 -5
  50. package/dist/types/types.js +2 -1
  51. package/package.json +12 -12
  52. package/dist/components/Colliders/AutoColliders.svelte.d.ts +0 -84
  53. package/dist/components/Colliders/Collider.svelte.d.ts +0 -109
  54. package/dist/recipes/BasicPlayerController.svelte +0 -142
  55. package/dist/recipes/BasicPlayerController.svelte.d.ts +0 -29
package/README.md CHANGED
@@ -35,14 +35,7 @@ This is a great way to implement key features of games or simulators, such as co
35
35
 
36
36
  ### Installation
37
37
 
38
- For a quick interactive setup of a fresh Threlte project, run:
39
-
40
- ```sh
41
- npm create threlte my-project
42
- ```
43
- and select the `@threlte/rapier` option.
44
-
45
- Alternatively you can check out the full [installation instructions](https://threlte.xyz/docs/learn/getting-started/installation).
38
+ Check out the [installation instructions](https://threlte.xyz/docs/learn/getting-started/installation).
46
39
 
47
40
  ### Support
48
41
 
@@ -1,34 +1,3 @@
1
- import { Props } from '@threlte/core'
2
- import { SvelteComponent } from 'svelte'
3
- import type { Group } from 'three'
4
- import type { GravityType } from '../../types/types'
5
-
6
- type AttractorProps = Props<Group> & {
7
- /**
8
- * The strength factor applied to the impulse affecting rigid-bodies within range. For newtonian
9
- * calculations, strength is treated as m1 mass.
10
- * Default: 1.0
11
- */
12
- strength?: number
13
- /**
14
- * The radius for the Attractor's sphere of influence within which rigid-bodies will be affected.
15
- * Default: 10.0
16
- */
17
- range?: number
18
- /**
19
- * The method of calculating gravity on rigid bodies within range.
20
- * 'static' = the same force (strength) is applied on bodies within range, regardless of distance
21
- * 'linear' = force is calculated as strength * distance / range (force decreases the farther a body is from the attractor position)
22
- * 'newtonian' = force is calculated as gravitationalConstant * mass1 * mass2 / Math.pow(distance, 2)
23
- * Default: 'static'
24
- */
25
- gravityType?: GravityType
26
- /**
27
- * The gravitational constant used to calculate force in newtonian calculations. Most people probably won't use this,
28
- * but it provides an option for more realistic physics simulations.
29
- * Default: 6.673e-11
30
- */
31
- gravitationalConstant?: number
32
- }
33
-
34
- export default class Attractor extends SvelteComponent<AttractorProps> {}
1
+ import type { AttractorProps } from './types';
2
+ declare const Attractor: import("svelte").Component<AttractorProps, {}, "ref">;
3
+ export default Attractor;
@@ -0,0 +1,30 @@
1
+ import type { Props } from '@threlte/core';
2
+ import type { Group } from 'three';
3
+ import type { GravityType } from '../../types/types';
4
+ export type AttractorProps = Props<Group> & {
5
+ /**
6
+ * The strength factor applied to the impulse affecting rigid-bodies within range. For newtonian
7
+ * calculations, strength is treated as m1 mass.
8
+ * Default: 1.0
9
+ */
10
+ strength?: number;
11
+ /**
12
+ * The radius for the Attractor's sphere of influence within which rigid-bodies will be affected.
13
+ * Default: 10.0
14
+ */
15
+ range?: number;
16
+ /**
17
+ * The method of calculating gravity on rigid bodies within range.
18
+ * 'static' = the same force (strength) is applied on bodies within range, regardless of distance
19
+ * 'linear' = force is calculated as strength * distance / range (force decreases the farther a body is from the attractor position)
20
+ * 'newtonian' = force is calculated as gravitationalConstant * mass1 * mass2 / Math.pow(distance, 2)
21
+ * Default: 'static'
22
+ */
23
+ gravityType?: GravityType;
24
+ /**
25
+ * The gravitational constant used to calculate force in newtonian calculations. Most people probably won't use this,
26
+ * but it provides an option for more realistic physics simulations.
27
+ * Default: 6.673e-11
28
+ */
29
+ gravitationalConstant?: number;
30
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,16 +1,19 @@
1
- <script lang="ts">import { ActiveCollisionTypes, CoefficientCombineRule } from '@dimforge/rapier3d-compat';
1
+ <script
2
+ lang="ts"
3
+ generics="TMassDef extends MassDef"
4
+ >import { ActiveCollisionTypes, CoefficientCombineRule } from '@dimforge/rapier3d-compat';
2
5
  import { createParentObject3DContext, useParentObject3D, watch } from '@threlte/core';
3
6
  import { onDestroy, onMount } from 'svelte';
4
7
  import { Group } from 'three';
5
- import { useCollisionGroups } from '../../hooks/useCollisionGroups';
6
- import { useRapier } from '../../hooks/useRapier';
7
- import { useRigidBody } from '../../hooks/useRigidBody';
8
- import { applyColliderActiveEvents } from '../../lib/applyColliderActiveEvents';
9
- import { createCollidersFromChildren } from '../../lib/createCollidersFromChildren';
10
- import { eulerToQuaternion } from '../../lib/eulerToQuaternion';
11
- import { useParentRigidbodyObject } from '../../lib/rigidBodyObjectContext';
12
- import { useCreateEvent } from '../../lib/useCreateEvent';
13
- let { shape = 'convexHull', restitution, restitutionCombineRule, friction, frictionCombineRule, sensor, contactForceEventThreshold, density, mass, centerOfMass, principalAngularInertia, angularInertiaLocalFrame, refresh = $bindable(() => create()), colliders = $bindable(), oncreate, oncollisionenter, oncollisionexit, oncontact, onsensorenter, onsensorexit, children } = $props();
8
+ import { useCollisionGroups } from '../../../hooks/useCollisionGroups';
9
+ import { useRapier } from '../../../hooks/useRapier';
10
+ import { useRigidBody } from '../../../hooks/useRigidBody';
11
+ import { applyColliderActiveEvents } from '../../../lib/applyColliderActiveEvents';
12
+ import { createCollidersFromChildren } from '../../../lib/createCollidersFromChildren';
13
+ import { eulerToQuaternion } from '../../../lib/eulerToQuaternion';
14
+ import { useParentRigidbodyObject } from '../../../lib/rigidBodyObjectContext';
15
+ import { useCreateEvent } from '../../../lib/useCreateEvent';
16
+ let { shape = 'convexHull', restitution, restitutionCombineRule, friction, frictionCombineRule, sensor, contactForceEventThreshold, density, mass, centerOfMass, principalAngularInertia, angularInertiaLocalFrame, colliders = $bindable(), oncreate, oncollisionenter, oncollisionexit, oncontact, onsensorenter, onsensorexit, children } = $props();
14
17
  const group = new Group();
15
18
  const { updateRef } = useCreateEvent(oncreate);
16
19
  const rigidBody = useRigidBody();
@@ -63,6 +66,10 @@ const create = () => {
63
66
  });
64
67
  updateRef(colliders);
65
68
  };
69
+ /**
70
+ * Refresh the colliders.
71
+ */
72
+ export const refresh = () => create();
66
73
  onMount(() => {
67
74
  create();
68
75
  });
@@ -0,0 +1,22 @@
1
+ import type { AutoCollidersProps, MassDef } from './types';
2
+ declare class __sveltets_Render<TMassDef extends MassDef> {
3
+ props(): AutoCollidersProps<TMassDef>;
4
+ events(): {};
5
+ slots(): {};
6
+ bindings(): "colliders";
7
+ exports(): {
8
+ /**
9
+ * Refresh the colliders.
10
+ */ refresh: () => void;
11
+ };
12
+ }
13
+ interface $$IsomorphicComponent {
14
+ new <TMassDef extends MassDef>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TMassDef>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TMassDef>['props']>, ReturnType<__sveltets_Render<TMassDef>['events']>, ReturnType<__sveltets_Render<TMassDef>['slots']>> & {
15
+ $$bindings?: ReturnType<__sveltets_Render<TMassDef>['bindings']>;
16
+ } & ReturnType<__sveltets_Render<TMassDef>['exports']>;
17
+ <TMassDef extends MassDef>(internal: unknown, props: ReturnType<__sveltets_Render<TMassDef>['props']> & {}): ReturnType<__sveltets_Render<TMassDef>['exports']>;
18
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
19
+ }
20
+ declare const AutoColliders: $$IsomorphicComponent;
21
+ type AutoColliders<TMassDef extends MassDef> = InstanceType<typeof AutoColliders<TMassDef>>;
22
+ export default AutoColliders;
@@ -0,0 +1,74 @@
1
+ import type { CoefficientCombineRule, Collider } from '@dimforge/rapier3d-compat';
2
+ import { type Snippet } from 'svelte';
3
+ import type { Euler, Vector3 } from 'three';
4
+ import type { AutoCollidersShapes, ColliderEvents, CreateEvent } from '../../../types/types';
5
+ type BaseProps = {
6
+ /**
7
+ * The shape of the collider.
8
+ */
9
+ shape?: AutoCollidersShapes;
10
+ /** The restitution coefficient of this collider. */
11
+ restitution?: number;
12
+ /** he rule used to combine the restitution coefficients of two colliders involved in a contact. */
13
+ restitutionCombineRule?: CoefficientCombineRule;
14
+ /** The friction coefficient of this collider. */
15
+ friction?: number;
16
+ /** The rule used to combine the friction coefficients of two colliders involved in a contact. */
17
+ frictionCombineRule?: CoefficientCombineRule;
18
+ /** Whether this collider is a sensor. A sensor collider does not generate
19
+ * contacts. They only generate intersection events when one sensor collider
20
+ * and another collider start/stop touching. Sensor colliders are generally
21
+ * used to detect when something enters an area. Note that, for symmetry with
22
+ * non-sensor colliders, sensors do contribute to the mass of a rigid-body
23
+ * they are attached to.
24
+ */
25
+ sensor?: boolean;
26
+ colliders?: Collider[];
27
+ /** The total force magnitude beyond which a contact force event can be emitted. */
28
+ contactForceEventThreshold?: number;
29
+ };
30
+ type Density = {
31
+ /** The density of this collider. */
32
+ density: number;
33
+ mass?: never;
34
+ centerOfMass?: never;
35
+ principalAngularInertia?: never;
36
+ angularInertiaLocalFrame?: never;
37
+ };
38
+ type Mass = {
39
+ /** The mass of this collider. */
40
+ mass: number;
41
+ density?: never;
42
+ centerOfMass?: never;
43
+ principalAngularInertia?: never;
44
+ angularInertiaLocalFrame?: never;
45
+ };
46
+ type MassProperties = {
47
+ /** The mass of this collider. */
48
+ mass: number;
49
+ /** The center of mass of this collider. */
50
+ centerOfMass: Parameters<Vector3['set']>;
51
+ /** The principal angular inertia of this collider. */
52
+ principalAngularInertia: Parameters<Vector3['set']>;
53
+ /** The angular inertia local frame of this collider. */
54
+ angularInertiaLocalFrame: Parameters<Euler['set']>;
55
+ density?: never;
56
+ };
57
+ type NoMassProperties = {
58
+ density?: never;
59
+ mass?: never;
60
+ centerOfMass?: never;
61
+ principalAngularInertia?: never;
62
+ angularInertiaLocalFrame?: never;
63
+ };
64
+ export type MassDef = Density | Mass | MassProperties | NoMassProperties;
65
+ type MassProps<TMassDef extends MassDef> = TMassDef extends Density ? Density : TMassDef extends MassProperties ? MassProperties : TMassDef extends Mass ? Mass : NoMassProperties;
66
+ export type AutoCollidersProps<TMassDef extends MassDef> = CreateEvent<Collider[]> & ColliderEvents & BaseProps & MassProps<TMassDef> & {
67
+ children?: Snippet<[
68
+ {
69
+ colliders: Collider[];
70
+ refresh: () => void;
71
+ }
72
+ ]>;
73
+ };
74
+ export {};
@@ -0,0 +1 @@
1
+ import {} from 'svelte';
@@ -1,22 +1,20 @@
1
- <script lang="ts">import { ActiveCollisionTypes, CoefficientCombineRule, Collider, ColliderDesc } from '@dimforge/rapier3d-compat';
1
+ <script
2
+ lang="ts"
3
+ generics="TShape extends Shape, TMassDef extends MassDef"
4
+ >import { ActiveCollisionTypes, CoefficientCombineRule, ColliderDesc } from '@dimforge/rapier3d-compat';
2
5
  import { createParentObject3DContext, useParentObject3D, useTask, watch } from '@threlte/core';
3
6
  import { onDestroy, onMount, tick } from 'svelte';
4
7
  import { Object3D, Quaternion, Vector3 } from 'three';
5
- import { useCollisionGroups } from '../../hooks/useCollisionGroups';
6
- import { useRapier } from '../../hooks/useRapier';
7
- import { useRigidBody } from '../../hooks/useRigidBody';
8
- import { applyColliderActiveEvents } from '../../lib/applyColliderActiveEvents';
9
- import { eulerToQuaternion } from '../../lib/eulerToQuaternion';
10
- import { getWorldPosition, getWorldQuaternion } from '../../lib/getWorldTransforms';
11
- import { useParentRigidbodyObject } from '../../lib/rigidBodyObjectContext';
12
- import { scaleColliderArgs } from '../../lib/scaleColliderArgs';
13
- import { useCreateEvent } from '../../lib/useCreateEvent';
14
- let { shape, args, type, restitution, restitutionCombineRule, friction, frictionCombineRule, sensor, contactForceEventThreshold, density, mass, centerOfMass, principalAngularInertia, angularInertiaLocalFrame, collider = $bindable(), refresh = $bindable(() => {
15
- if (!collider)
16
- return;
17
- collider.setTranslation(getWorldPosition(object));
18
- collider.setRotation(getWorldQuaternion(object));
19
- }), oncreate, oncollisionenter, oncollisionexit, oncontact, onsensorenter, onsensorexit, children } = $props();
8
+ import { useCollisionGroups } from '../../../hooks/useCollisionGroups';
9
+ import { useRapier } from '../../../hooks/useRapier';
10
+ import { useRigidBody } from '../../../hooks/useRigidBody';
11
+ import { applyColliderActiveEvents } from '../../../lib/applyColliderActiveEvents';
12
+ import { eulerToQuaternion } from '../../../lib/eulerToQuaternion';
13
+ import { getWorldPosition, getWorldQuaternion } from '../../../lib/getWorldTransforms';
14
+ import { useParentRigidbodyObject } from '../../../lib/rigidBodyObjectContext';
15
+ import { scaleColliderArgs } from '../../../lib/scaleColliderArgs';
16
+ import { useCreateEvent } from '../../../lib/useCreateEvent';
17
+ let { shape, args, type, restitution, restitutionCombineRule, friction, frictionCombineRule, sensor, contactForceEventThreshold, density, mass, centerOfMass, principalAngularInertia, angularInertiaLocalFrame, collider = $bindable(), oncreate, oncollisionenter, oncollisionexit, oncontact, onsensorenter, onsensorexit, children } = $props();
20
18
  const object = new Object3D();
21
19
  const { updateRef } = useCreateEvent(oncreate);
22
20
  const rigidBody = useRigidBody();
@@ -108,6 +106,12 @@ $effect.pre(() => {
108
106
  applyColliderActiveEvents(collider, events, rigidBody?.userData?.events);
109
107
  }
110
108
  });
109
+ export const refresh = () => {
110
+ if (!collider)
111
+ return;
112
+ collider.setTranslation(getWorldPosition(object));
113
+ collider.setRotation(getWorldQuaternion(object));
114
+ };
111
115
  /**
112
116
  * If the Collider isAttached (i.e. NOT child of a RigidBody), update the
113
117
  * transforms on every frame.
@@ -0,0 +1,20 @@
1
+ import type { ColliderProps, MassDef, Shape } from './types';
2
+ declare class __sveltets_Render<TShape extends Shape, TMassDef extends MassDef> {
3
+ props(): ColliderProps<TShape, TMassDef>;
4
+ events(): {};
5
+ slots(): {};
6
+ bindings(): "collider";
7
+ exports(): {
8
+ refresh: () => void;
9
+ };
10
+ }
11
+ interface $$IsomorphicComponent {
12
+ new <TShape extends Shape, TMassDef extends MassDef>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TShape, TMassDef>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TShape, TMassDef>['props']>, ReturnType<__sveltets_Render<TShape, TMassDef>['events']>, ReturnType<__sveltets_Render<TShape, TMassDef>['slots']>> & {
13
+ $$bindings?: ReturnType<__sveltets_Render<TShape, TMassDef>['bindings']>;
14
+ } & ReturnType<__sveltets_Render<TShape, TMassDef>['exports']>;
15
+ <TShape extends Shape, TMassDef extends MassDef>(internal: unknown, props: ReturnType<__sveltets_Render<TShape, TMassDef>['props']> & {}): ReturnType<__sveltets_Render<TShape, TMassDef>['exports']>;
16
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
17
+ }
18
+ declare const Collider: $$IsomorphicComponent;
19
+ type Collider<TShape extends Shape, TMassDef extends MassDef> = InstanceType<typeof Collider<TShape, TMassDef>>;
20
+ export default Collider;
@@ -0,0 +1,83 @@
1
+ import type { CoefficientCombineRule, Collider, ColliderDesc, Collider as RapierCollider } from '@dimforge/rapier3d-compat';
2
+ import { type Snippet } from 'svelte';
3
+ import type { Euler, Vector3 } from 'three';
4
+ import type { ColliderEvents, CreateEvent } from '../../../types/types';
5
+ type Type = 'static' | 'dynamic';
6
+ type BaseProps = {
7
+ /**
8
+ * If a collider is *not* attached to a RigidBody and its type is `static`,
9
+ * its transform is only applied once on initialization. If the transform
10
+ * should be updated every frame, set the type to `dynamic`.
11
+ */
12
+ type?: Type;
13
+ /** The restitution coefficient of this collider. */
14
+ restitution?: number;
15
+ /** he rule used to combine the restitution coefficients of two colliders involved in a contact. */
16
+ restitutionCombineRule?: CoefficientCombineRule;
17
+ /** The friction coefficient of this collider. */
18
+ friction?: number;
19
+ /** The rule used to combine the friction coefficients of two colliders involved in a contact. */
20
+ frictionCombineRule?: CoefficientCombineRule;
21
+ /** Whether this collider is a sensor. A sensor collider does not generate
22
+ * contacts. They only generate intersection events when one sensor collider
23
+ * and another collider start/stop touching. Sensor colliders are generally
24
+ * used to detect when something enters an area. Note that, for symmetry with
25
+ * non-sensor colliders, sensors do contribute to the mass of a rigid-body
26
+ * they are attached to.
27
+ */
28
+ sensor?: boolean;
29
+ collider?: RapierCollider;
30
+ /** The total force magnitude beyond which a contact force event can be emitted. */
31
+ contactForceEventThreshold?: number;
32
+ };
33
+ /**
34
+ * The shape of the collider.
35
+ */
36
+ export type Shape = 'ball' | 'capsule' | 'segment' | 'triangle' | 'roundTriangle' | 'polyline' | 'trimesh' | 'cuboid' | 'roundCuboid' | 'heightfield' | 'cylinder' | 'roundCylinder' | 'cone' | 'roundCone' | 'convexHull' | 'convexMesh' | 'roundConvexHull' | 'roundConvexMesh';
37
+ type Args<TShape extends Shape> = Parameters<(typeof ColliderDesc)[TShape]>;
38
+ type ShapeProps<TShape extends Shape> = {
39
+ shape: TShape;
40
+ args: Args<TShape>;
41
+ };
42
+ type Density = {
43
+ /** The density of this collider. */
44
+ density: number;
45
+ mass?: never;
46
+ centerOfMass?: never;
47
+ principalAngularInertia?: never;
48
+ angularInertiaLocalFrame?: never;
49
+ };
50
+ type Mass = {
51
+ /** The mass of this collider. */
52
+ mass: number;
53
+ density?: never;
54
+ centerOfMass?: never;
55
+ principalAngularInertia?: never;
56
+ angularInertiaLocalFrame?: never;
57
+ };
58
+ type MassProperties = {
59
+ /** The mass of this collider. */
60
+ mass: number;
61
+ /** The center of mass of this collider. */
62
+ centerOfMass: Parameters<Vector3['set']>;
63
+ /** The principal angular inertia of this collider. */
64
+ principalAngularInertia: Parameters<Vector3['set']>;
65
+ /** The angular inertia local frame of this collider. */
66
+ angularInertiaLocalFrame: Parameters<Euler['set']>;
67
+ density?: never;
68
+ };
69
+ type NoMassProperties = {
70
+ density?: never;
71
+ mass?: never;
72
+ centerOfMass?: never;
73
+ principalAngularInertia?: never;
74
+ angularInertiaLocalFrame?: never;
75
+ };
76
+ export type MassDef = Density | Mass | MassProperties | NoMassProperties;
77
+ type MassProps<TMassDef extends MassDef> = TMassDef extends Density ? Density : TMassDef extends MassProperties ? MassProperties : TMassDef extends Mass ? Mass : NoMassProperties;
78
+ export type ColliderProps<TShape extends Shape, TMassDef extends MassDef> = CreateEvent<Collider> & ColliderEvents & BaseProps & ShapeProps<TShape> & MassProps<TMassDef> & {
79
+ children?: Snippet<[{
80
+ collider?: RapierCollider;
81
+ }]>;
82
+ };
83
+ export {};
@@ -0,0 +1 @@
1
+ import {} from 'svelte';
@@ -1,4 +1,7 @@
1
- <script lang="ts">import { setContext } from 'svelte';
1
+ <script
2
+ lang="ts"
3
+ generics="TGroupsDef extends GroupsDef"
4
+ >import { setContext } from 'svelte';
2
5
  import { writable } from 'svelte/store';
3
6
  import { computeBitMask } from '../../lib/computeBitMask';
4
7
  let { groups, filter, memberships, children } = $props();
@@ -1,35 +1,18 @@
1
- import { SvelteComponent, type Snippet } from 'svelte'
2
-
3
- type N = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15
4
-
5
- export type Groups = N[]
6
-
7
- export type MembershipsAndFilter = N[]
8
-
9
- type GroupsProps = {
10
- groups: N[]
11
-
12
- filter?: never
13
- memberships?: never
14
-
15
- children?: Snippet
1
+ import type { CollisionGroupsProps, GroupsDef } from './types';
2
+ declare class __sveltets_Render<TGroupsDef extends GroupsDef> {
3
+ props(): CollisionGroupsProps<TGroupsDef>;
4
+ events(): {};
5
+ slots(): {};
6
+ bindings(): "";
7
+ exports(): {};
16
8
  }
17
-
18
- type MembershipsAndFilterProps = {
19
- filter: N[]
20
- memberships: N[]
21
-
22
- groups?: never
23
-
24
- children?: Snippet
9
+ interface $$IsomorphicComponent {
10
+ new <TGroupsDef extends GroupsDef>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TGroupsDef>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TGroupsDef>['props']>, ReturnType<__sveltets_Render<TGroupsDef>['events']>, ReturnType<__sveltets_Render<TGroupsDef>['slots']>> & {
11
+ $$bindings?: ReturnType<__sveltets_Render<TGroupsDef>['bindings']>;
12
+ } & ReturnType<__sveltets_Render<TGroupsDef>['exports']>;
13
+ <TGroupsDef extends GroupsDef>(internal: unknown, props: ReturnType<__sveltets_Render<TGroupsDef>['props']> & {}): ReturnType<__sveltets_Render<TGroupsDef>['exports']>;
14
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
25
15
  }
26
-
27
- type GroupsDef = GroupsProps | MembershipsAndFilterProps
28
-
29
- export type CollisionGroupsProps<TGroupsDef extends GroupsDef> = TGroupsDef extends GroupsProps
30
- ? GroupsProps
31
- : MembershipsAndFilterProps
32
-
33
- export default class CollisionGroups<TGroupsDef extends GroupsDef> extends SvelteComponent<
34
- CollisionGroupsProps<TGroupsDef>
35
- > {}
16
+ declare const CollisionGroups: $$IsomorphicComponent;
17
+ type CollisionGroups<TGroupsDef extends GroupsDef> = InstanceType<typeof CollisionGroups<TGroupsDef>>;
18
+ export default CollisionGroups;
@@ -0,0 +1,19 @@
1
+ import { type Snippet } from 'svelte';
2
+ type N = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
3
+ export type Groups = N[];
4
+ export type MembershipsAndFilter = N[];
5
+ type GroupsProps = {
6
+ groups: N[];
7
+ filter?: never;
8
+ memberships?: never;
9
+ children?: Snippet;
10
+ };
11
+ type MembershipsAndFilterProps = {
12
+ filter: N[];
13
+ memberships: N[];
14
+ groups?: never;
15
+ children?: Snippet;
16
+ };
17
+ export type GroupsDef = GroupsProps | MembershipsAndFilterProps;
18
+ export type CollisionGroupsProps<TGroupsDef extends GroupsDef> = TGroupsDef extends GroupsProps ? GroupsProps : MembershipsAndFilterProps;
19
+ export {};
@@ -0,0 +1 @@
1
+ import {} from 'svelte';
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">import { T, useTask } from '@threlte/core';
2
2
  import { onDestroy } from 'svelte';
3
- import { BufferAttribute, BufferGeometry } from 'three';
3
+ import { BufferAttribute, BufferGeometry, LineSegments } from 'three';
4
4
  import { useRapier } from '../../hooks/useRapier';
5
- let { ref = $bindable(), ...props } = $props();
5
+ let { ref = $bindable(new LineSegments()), ...props } = $props();
6
6
  const { world, debug } = useRapier();
7
7
  const geometry = new BufferGeometry();
8
8
  debug.set(true);
@@ -18,12 +18,12 @@ onDestroy(() => {
18
18
  });
19
19
  </script>
20
20
 
21
- <T.LineSegments
22
- bind:ref
21
+ <T
22
+ is={ref}
23
23
  frustumCulled={false}
24
24
  renderOrder={Infinity}
25
25
  {...props}
26
26
  >
27
27
  <T is={geometry} />
28
28
  <T.LineBasicMaterial vertexColors />
29
- </T.LineSegments>
29
+ </T>
@@ -1,7 +1,3 @@
1
- import type { Props } from '@threlte/core'
2
- import { SvelteComponent } from 'svelte'
3
- import type { LineSegments } from 'three'
4
-
5
- export type DebugProps = Props<LineSegments>
6
-
7
- export default class Debug extends SvelteComponent<DebugProps> {}
1
+ import type { DebugProps } from './types';
2
+ declare const Debug: import("svelte").Component<DebugProps, {}, "ref">;
3
+ export default Debug;
@@ -0,0 +1,3 @@
1
+ import type { Props } from '@threlte/core';
2
+ import type { LineSegments } from 'three';
3
+ export type DebugProps = Props<LineSegments>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,102 +1,3 @@
1
- import { RigidBody as RapierRigidBody } from '@dimforge/rapier3d-compat'
2
- import { SvelteComponent, type Snippet } from 'svelte'
3
- import type { Euler, Vector3 } from 'three'
4
- import type { RigidBodyTypeString } from '../../lib/parseRigidBodyType'
5
- import type { RigidBodyEvents } from '../../types/types'
6
-
7
- export type Boolean3Array = [x: boolean, y: boolean, z: boolean]
8
-
9
- export type RigidBodyProps = {
10
- rigidBody?: RapierRigidBody | undefined
11
-
12
- /**
13
- * Specify the type of this rigid body
14
- */
15
- type?: RigidBodyTypeString
16
-
17
- /** Whether or not this body can sleep.
18
- * default: true
19
- */
20
- canSleep?: boolean
21
-
22
- /** The linear velocity of this body.
23
- * default: zero velocity
24
- */
25
- linearVelocity?: Parameters<Vector3['set']>
26
-
27
- /** The angular velocity of this body.
28
- * Default: zero velocity.
29
- */
30
- angularVelocity?: Parameters<Euler['set']>
31
-
32
- /**
33
- * The scaling factor applied to the gravity affecting the rigid-body.
34
- * Default: 1.0
35
- */
36
- gravityScale?: number
37
-
38
- /**
39
- * Whether or not Continous Collision Detection is enabled for this rigid-body.
40
- * https://rapier.rs/docs/user_guides/javascript/rigid_bodies#continuous-collision-detection
41
- * @default false
42
- */
43
- ccd?: boolean
44
-
45
- /**
46
- * Locks all rotations that would have resulted from forces on the created rigid-body.
47
- */
48
- lockRotations?: boolean
49
-
50
- /**
51
- * Locks all translations that would have resulted from forces on the created rigid-body.
52
- */
53
- lockTranslations?: boolean
54
-
55
- /**
56
- * Allow rotation of this rigid-body only along specific axes.
57
- */
58
- enabledRotations?: Boolean3Array
59
-
60
- /**
61
- * Allow translations of this rigid-body only along specific axes.
62
- */
63
- enabledTranslations?: Boolean3Array
64
-
65
- /**
66
- * Dominance is a non-realistic, but sometimes useful, feature.
67
- * It can be used to make one rigid-body immune to forces
68
- * originating from contacts with some other bodies.
69
- *
70
- * Number in the range -127 to 127, default is 0
71
- */
72
- dominance?: number
73
-
74
- /**
75
- * Damping lets you slow down a rigid-body automatically. This can be used to
76
- * achieve a wide variety of effects like fake air friction. Larger values of
77
- * damping coefficients lead to a stronger slow-downs. Their default
78
- * values are 0.0 (no damping at all).
79
- */
80
- linearDamping?: number
81
-
82
- /**
83
- * Damping lets you slow down a rigid-body automatically. This can be used to
84
- * achieve a wide variety of effects like fake air friction. Larger values of
85
- * damping coefficients lead to a stronger slow-downs. Their default
86
- * values are 0.0 (no damping at all).
87
- */
88
- angularDamping?: number
89
-
90
- /**
91
- * Set the rigidBody as enabled or disabled.
92
- */
93
- enabled?: boolean
94
- /**
95
- * An arbitrary user-defined object associated with this rigid-body.
96
- */
97
- userData?: Record<string, any>
98
-
99
- children?: Snippet<[{ rigidBody: RapierRigidBody }]>
100
- }
101
-
102
- export default class RigidBody extends SvelteComponent<RigidBodyProps & RigidBodyEvents> {}
1
+ import type { RigidBodyProps } from './types';
2
+ declare const RigidBody: import("svelte").Component<RigidBodyProps, {}, "rigidBody">;
3
+ export default RigidBody;