@threlte/rapier 0.4.0 → 1.0.0-next.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 (47) hide show
  1. package/dist/CHANGELOG.md +12 -0
  2. package/dist/components/Attractor/Attractor.svelte +54 -0
  3. package/dist/components/Attractor/Attractor.svelte.d.ts +21 -0
  4. package/dist/components/Colliders/AutoColliders.svelte +16 -10
  5. package/dist/components/Colliders/AutoColliders.svelte.d.ts +74 -0
  6. package/dist/components/Colliders/Collider.svelte +24 -15
  7. package/dist/components/Colliders/Collider.svelte.d.ts +105 -112
  8. package/dist/components/CollisionGroups/CollisionGroups.svelte.d.ts +29 -19
  9. package/dist/components/Debug/Debug.svelte +15 -10
  10. package/dist/components/Debug/Debug.svelte.d.ts +6 -60
  11. package/dist/components/RigidBody/RigidBody.svelte +14 -32
  12. package/dist/components/RigidBody/RigidBody.svelte.d.ts +93 -67
  13. package/dist/components/World/InnerWorld.svelte +9 -6
  14. package/dist/components/World/InnerWorld.svelte.d.ts +14 -15
  15. package/dist/components/World/World.svelte +6 -2
  16. package/dist/components/World/World.svelte.d.ts +35 -32
  17. package/dist/hooks/useFixedJoint.d.ts +2 -2
  18. package/dist/hooks/useFixedJoint.js +6 -3
  19. package/dist/hooks/usePrismaticJoint.d.ts +2 -2
  20. package/dist/hooks/usePrismaticJoint.js +5 -2
  21. package/dist/hooks/useRevoluteJoint.d.ts +2 -2
  22. package/dist/hooks/useRevoluteJoint.js +5 -2
  23. package/dist/hooks/useSphericalJoint.d.ts +2 -2
  24. package/dist/hooks/useSphericalJoint.js +4 -2
  25. package/dist/index.d.ts +2 -1
  26. package/dist/index.js +1 -0
  27. package/dist/lib/applyTransforms.d.ts +2 -3
  28. package/dist/lib/applyTransforms.js +7 -16
  29. package/dist/lib/createRapierContext.d.ts +1 -0
  30. package/dist/lib/createRapierContext.js +3 -1
  31. package/dist/lib/eulerToQuaternion.d.ts +7 -0
  32. package/dist/lib/eulerToQuaternion.js +12 -0
  33. package/dist/lib/scaleColliderArgs.js +2 -2
  34. package/dist/recipes/BasicPlayerController.svelte +12 -6
  35. package/dist/recipes/BasicPlayerController.svelte.d.ts +2 -2
  36. package/dist/types/components.d.ts +29 -88
  37. package/package.json +9 -8
  38. package/dist/components/Joints/RevoluteJoint.svelte +0 -5
  39. package/dist/components/Joints/RevoluteJoint.svelte.d.ts +0 -23
  40. package/dist/lib/positionToVector3.d.ts +0 -3
  41. package/dist/lib/positionToVector3.js +0 -8
  42. package/dist/lib/rotationToEuler.d.ts +0 -3
  43. package/dist/lib/rotationToEuler.js +0 -8
  44. package/dist/lib/rotationToQuaternion.d.ts +0 -3
  45. package/dist/lib/rotationToQuaternion.js +0 -10
  46. package/dist/lib/scaleToVector3.d.ts +0 -3
  47. package/dist/lib/scaleToVector3.js +0 -16
@@ -1,60 +1,6 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- color?: import("three").ColorRepresentation | undefined;
5
- linewidth?: number | undefined;
6
- linecap?: string | undefined;
7
- linejoin?: string | undefined;
8
- alphaTest?: number | undefined;
9
- alphaToCoverage?: boolean | undefined;
10
- blendDst?: import("three").BlendingDstFactor | undefined;
11
- blendDstAlpha?: number | undefined;
12
- blendEquation?: import("three").BlendingEquation | undefined;
13
- blendEquationAlpha?: number | undefined;
14
- blending?: import("three").Blending | undefined;
15
- blendSrc?: import("three").BlendingDstFactor | import("three").BlendingSrcFactor | undefined;
16
- blendSrcAlpha?: number | undefined;
17
- clipIntersection?: boolean | undefined;
18
- clippingPlanes?: import("three").Plane[] | undefined;
19
- clipShadows?: boolean | undefined;
20
- colorWrite?: boolean | undefined;
21
- defines?: any;
22
- depthFunc?: import("three").DepthModes | undefined;
23
- depthTest?: boolean | undefined;
24
- depthWrite?: boolean | undefined;
25
- name?: string | undefined;
26
- opacity?: number | undefined;
27
- polygonOffset?: boolean | undefined;
28
- polygonOffsetFactor?: number | undefined;
29
- polygonOffsetUnits?: number | undefined;
30
- precision?: "highp" | "mediump" | "lowp" | null | undefined;
31
- premultipliedAlpha?: boolean | undefined;
32
- dithering?: boolean | undefined;
33
- side?: import("three").Side | undefined;
34
- shadowSide?: import("three").Side | undefined;
35
- toneMapped?: boolean | undefined;
36
- transparent?: boolean | undefined;
37
- vertexColors?: boolean | undefined;
38
- visible?: boolean | undefined;
39
- format?: import("three").PixelFormat | undefined;
40
- stencilWrite?: boolean | undefined;
41
- stencilFunc?: import("three").StencilFunc | undefined;
42
- stencilRef?: number | undefined;
43
- stencilWriteMask?: number | undefined;
44
- stencilFuncMask?: number | undefined;
45
- stencilFail?: import("three").StencilOp | undefined;
46
- stencilZFail?: import("three").StencilOp | undefined;
47
- stencilZPass?: import("three").StencilOp | undefined;
48
- userData?: any;
49
- };
50
- events: {
51
- [evt: string]: CustomEvent<any>;
52
- };
53
- slots: {};
54
- };
55
- export declare type DebugProps = typeof __propDef.props;
56
- export declare type DebugEvents = typeof __propDef.events;
57
- export declare type DebugSlots = typeof __propDef.slots;
58
- export default class Debug extends SvelteComponentTyped<DebugProps, DebugEvents, DebugSlots> {
59
- }
60
- export {};
1
+ import { SvelteComponentTyped } from 'svelte'
2
+ import type { LineBasicMaterialParameters } from 'three'
3
+
4
+ export type DebugProps = LineBasicMaterialParameters
5
+
6
+ export default class Debug extends SvelteComponentTyped<DebugProps> {}
@@ -1,4 +1,4 @@
1
- <script>import { LayerableObject, SceneGraphObject } from '@threlte/core';
1
+ <script>import { SceneGraphObject } from '@threlte/core';
2
2
  import { createEventDispatcher, onDestroy, setContext, tick } from 'svelte';
3
3
  import { Object3D, Vector3 } from 'three';
4
4
  import { useHasEventListeners } from '../../hooks/useHasEventListener';
@@ -6,35 +6,23 @@ import { useRapier } from '../../hooks/useRapier';
6
6
  import { applyTransforms } from '../../lib/applyTransforms';
7
7
  import { getWorldPosition, getWorldQuaternion, getWorldScale } from '../../lib/getWorldTransforms';
8
8
  import { parseRigidBodyType } from '../../lib/parseRigidBodyType';
9
- import { positionToVector3 } from '../../lib/positionToVector3';
10
- import { rotationToEuler } from '../../lib/rotationToEuler';
11
9
  const { world, rapier, addRigidBodyToContext, removeRigidBodyFromContext } = useRapier();
12
- export let debug = false;
10
+ export let position = undefined;
11
+ export let rotation = undefined;
12
+ export let scale = undefined;
13
+ export let linearVelocity = undefined;
14
+ export let angularVelocity = undefined;
13
15
  export let type = 'dynamic';
14
16
  export let canSleep = true;
15
- export let linearVelocity = {};
16
- export let angularVelocity = {};
17
17
  export let gravityScale = 1;
18
18
  export let ccd = false;
19
19
  export let angularDamping = 0;
20
20
  export let linearDamping = 0;
21
21
  export let lockRotations = false;
22
22
  export let lockTranslations = false;
23
- export let enabledRotations = [
24
- true,
25
- true,
26
- true
27
- ];
28
- export let enabledTranslations = [
29
- true,
30
- true,
31
- true
32
- ];
23
+ export let enabledRotations = [true, true, true];
24
+ export let enabledTranslations = [true, true, true];
33
25
  export let dominance = 0;
34
- export let position = undefined;
35
- export let rotation = undefined;
36
- export let scale = undefined;
37
- export let lookAt = undefined;
38
26
  const dispatcher = createEventDispatcher();
39
27
  const object = new Object3D();
40
28
  /**
@@ -51,7 +39,7 @@ object.userData.isSleeping = false;
51
39
  * This is a one-off operation as RigidBodies should
52
40
  * not be moved around after initialization.
53
41
  */
54
- applyTransforms(object, position, rotation, scale, lookAt);
42
+ applyTransforms(object, position, rotation, scale);
55
43
  /**
56
44
  * Update the world matrix of the object before applying
57
45
  * the world position to the RigidBody
@@ -74,7 +62,7 @@ const rigidBodyTemp = world.createRigidBody(desc);
74
62
  */
75
63
  const initPosition = async () => {
76
64
  await tick();
77
- applyTransforms(object, position, rotation, scale, lookAt);
65
+ applyTransforms(object, position, rotation, scale);
78
66
  object.updateMatrix();
79
67
  object.updateWorldMatrix(true, false);
80
68
  const parentWorldScale = object.parent ? getWorldScale(object.parent) : new Vector3(1, 1, 1);
@@ -82,12 +70,6 @@ const initPosition = async () => {
82
70
  const worldQuaternion = getWorldQuaternion(object);
83
71
  rigidBodyTemp.setTranslation(worldPosition, true);
84
72
  rigidBodyTemp.setRotation(worldQuaternion, true);
85
- if (debug) {
86
- console.log('worldPosition', worldPosition);
87
- console.log('worldQuaternion', worldQuaternion);
88
- }
89
- if (debug)
90
- console.log(JSON.stringify(desc, null, 2));
91
73
  rigidBody = rigidBodyTemp;
92
74
  };
93
75
  initPosition();
@@ -100,8 +82,10 @@ object.userData.rigidBody = rigidBodyTemp;
100
82
  */
101
83
  $: {
102
84
  rigidBodyTemp.setBodyType(parseRigidBodyType(type));
103
- rigidBodyTemp.setLinvel(positionToVector3(linearVelocity), true);
104
- rigidBodyTemp.setAngvel(rotationToEuler(angularVelocity), true);
85
+ if (linearVelocity)
86
+ rigidBodyTemp.setLinvel({ x: linearVelocity[0], y: linearVelocity[1], z: linearVelocity[2] }, true);
87
+ if (angularVelocity)
88
+ rigidBodyTemp.setAngvel({ x: angularVelocity[0], y: angularVelocity[1], z: angularVelocity[2] }, true);
105
89
  rigidBodyTemp.setGravityScale(gravityScale, true);
106
90
  rigidBodyTemp.enableCcd(ccd);
107
91
  rigidBodyTemp.setDominanceGroup(dominance);
@@ -140,5 +124,3 @@ onDestroy(() => {
140
124
  <SceneGraphObject {object}>
141
125
  <slot />
142
126
  </SceneGraphObject>
143
-
144
- <LayerableObject {object} />
@@ -1,68 +1,94 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import type { RigidBody } from '@dimforge/rapier3d-compat';
3
- import type { RigidBodyProperties } from '../../types/components';
4
- declare const __propDef: {
5
- props: {
6
- debug?: boolean | undefined;
7
- type?: import("../../lib/parseRigidBodyType").RigidBodyTypeString | undefined;
8
- canSleep?: boolean | undefined;
9
- linearVelocity?: import("@threlte/core").Position | undefined;
10
- angularVelocity?: import("@threlte/core").Rotation | undefined;
11
- gravityScale?: number | undefined;
12
- ccd?: boolean | undefined;
13
- angularDamping?: number | undefined;
14
- linearDamping?: number | undefined;
15
- lockRotations?: boolean | undefined;
16
- lockTranslations?: boolean | undefined;
17
- enabledRotations?: import("../../types/components").Boolean3Array | undefined;
18
- enabledTranslations?: import("../../types/components").Boolean3Array | undefined;
19
- dominance?: number | undefined;
20
- position?: RigidBodyProperties['position'];
21
- rotation?: RigidBodyProperties['rotation'];
22
- scale?: RigidBodyProperties['scale'];
23
- lookAt?: RigidBodyProperties['lookAt'];
24
- /**
25
- * Export the rigidBody only after positional initialization
26
- */ rigidBody?: RigidBody | undefined;
27
- };
28
- slots: {
29
- default: {};
30
- };
31
- getters: {};
32
- events: {
33
- collisionenter: CustomEvent<{
34
- targetCollider: import("@dimforge/rapier3d-compat").Collider;
35
- targetRigidBody: RigidBody | null;
36
- manifold: import("@dimforge/rapier3d-compat").TempContactManifold;
37
- flipped: boolean;
38
- }>;
39
- collisionexit: CustomEvent<{
40
- targetCollider: import("@dimforge/rapier3d-compat").Collider;
41
- targetRigidBody: RigidBody | null;
42
- }>;
43
- sensorenter: CustomEvent<{
44
- targetCollider: import("@dimforge/rapier3d-compat").Collider;
45
- targetRigidBody: RigidBody | null;
46
- }>;
47
- sensorexit: CustomEvent<{
48
- targetCollider: import("@dimforge/rapier3d-compat").Collider;
49
- targetRigidBody: RigidBody | null;
50
- }>;
51
- contact: CustomEvent<{
52
- targetCollider: import("@dimforge/rapier3d-compat").Collider;
53
- targetRigidBody: RigidBody | null;
54
- maxForceDirection: import("@dimforge/rapier3d-compat").Vector;
55
- maxForceMagnitude: number;
56
- totalForce: import("@dimforge/rapier3d-compat").Vector;
57
- totalForceMagnitude: number;
58
- }>;
59
- sleep: CustomEvent<void>;
60
- wake: CustomEvent<void>;
61
- };
62
- };
63
- export declare type RigidBodyProps = typeof __propDef.props;
64
- export declare type RigidBodyEvents = typeof __propDef.events;
65
- export declare type RigidBodySlots = typeof __propDef.slots;
66
- export default class RigidBody extends SvelteComponentTyped<RigidBodyProps, RigidBodyEvents, RigidBodySlots> {
1
+ import { RigidBody as RapierRigidBody } from '@dimforge/rapier3d-compat'
2
+ import { SvelteComponentTyped } from 'svelte'
3
+ import type { Euler, Vector3 } from 'three'
4
+ import type { RigidBodyTypeString } from '../../lib/parseRigidBodyType'
5
+
6
+ export type Boolean3Array = [x: boolean, y: boolean, z: boolean]
7
+
8
+ export type RigidBodyProps = {
9
+ rigidBody?: RapierRigidBody
10
+
11
+ position?: Parameters<Vector3['set']>
12
+ rotation?: Parameters<Euler['set']>
13
+ scale?: Parameters<Vector3['set']>
14
+
15
+ /**
16
+ * Specify the type of this rigid body
17
+ */
18
+ type?: RigidBodyTypeString
19
+
20
+ /** Whether or not this body can sleep.
21
+ * default: true
22
+ */
23
+ canSleep?: boolean
24
+
25
+ /** The linear velocity of this body.
26
+ * default: zero velocity
27
+ */
28
+ linearVelocity?: Parameters<Vector3['set']>
29
+
30
+ /** The angular velocity of this body.
31
+ * Default: zero velocity.
32
+ */
33
+ angularVelocity?: Parameters<Euler['set']>
34
+
35
+ /**
36
+ * The scaling factor applied to the gravity affecting the rigid-body.
37
+ * Default: 1.0
38
+ */
39
+ gravityScale?: number
40
+
41
+ /**
42
+ * Whether or not Continous Collision Detection is enabled for this rigid-body.
43
+ * https://rapier.rs/docs/user_guides/javascript/rigid_bodies#continuous-collision-detection
44
+ * @default false
45
+ */
46
+ ccd?: boolean
47
+
48
+ /**
49
+ * Locks all rotations that would have resulted from forces on the created rigid-body.
50
+ */
51
+ lockRotations?: boolean
52
+
53
+ /**
54
+ * Locks all translations that would have resulted from forces on the created rigid-body.
55
+ */
56
+ lockTranslations?: boolean
57
+
58
+ /**
59
+ * Allow rotation of this rigid-body only along specific axes.
60
+ */
61
+ enabledRotations?: Boolean3Array
62
+
63
+ /**
64
+ * Allow rotation of this rigid-body only along specific axes.
65
+ */
66
+ enabledTranslations?: Boolean3Array
67
+
68
+ /**
69
+ * Dominance is a non-realistic, but sometimes useful, feature.
70
+ * It can be used to make one rigid-body immune to forces
71
+ * originating from contacts with some other bodies.
72
+ *
73
+ * Number in the range -127 to 127, default is 0
74
+ */
75
+ dominance?: number
76
+
77
+ /**
78
+ * Damping lets you slow down a rigid-body automatically. This can be used to
79
+ * achieve a wide variety of effects like fake air friction. Larger values of
80
+ * damping coefficients lead to a stronger slow-downs. Their default
81
+ * values are 0.0 (no damping at all).
82
+ */
83
+ linearDamping?: number
84
+
85
+ /**
86
+ * Damping lets you slow down a rigid-body automatically. This can be used to
87
+ * achieve a wide variety of effects like fake air friction. Larger values of
88
+ * damping coefficients lead to a stronger slow-downs. Their default
89
+ * values are 0.0 (no damping at all).
90
+ */
91
+ angularDamping?: number
67
92
  }
68
- export {};
93
+
94
+ export default class RigidBody extends SvelteComponentTyped<RigidBodyProps> {}
@@ -1,10 +1,12 @@
1
- <script context="module">import { onDestroy, setContext, tick } from 'svelte';
1
+ <script
2
+ context="module"
3
+
4
+ >import { onDestroy, setContext, tick } from 'svelte';
2
5
  import { useFrameHandler } from '../../hooks/useFrameHandler';
3
6
  import { createRapierContext } from '../../lib/createRapierContext';
4
7
  </script>
5
8
 
6
- <script>import { positionToVector3 } from '../../lib/positionToVector3';
7
- export let gravity = { y: -9.81 };
9
+ <script>export let gravity = [0, -9.81, 0];
8
10
  export let rawIntegrationParameters = undefined;
9
11
  export let rawIslands = undefined;
10
12
  export let rawBroadPhase = undefined;
@@ -18,10 +20,11 @@ export let rawQueryPipeline = undefined;
18
20
  export let rawPhysicsPipeline = undefined;
19
21
  export let rawSerializationPipeline = undefined;
20
22
  export let rawDebugRenderPipeline = undefined;
21
- const rapierContext = createRapierContext(positionToVector3(gravity), rawIntegrationParameters, rawIslands, rawBroadPhase, rawNarrowPhase, rawBodies, rawColliders, rawImpulseJoints, rawMultibodyJoints, rawCCDSolver, rawQueryPipeline, rawPhysicsPipeline, rawSerializationPipeline, rawDebugRenderPipeline);
23
+ const rapierContext = createRapierContext({ x: gravity[0], y: gravity[1], z: gravity[2] }, rawIntegrationParameters, rawIslands, rawBroadPhase, rawNarrowPhase, rawBodies, rawColliders, rawImpulseJoints, rawMultibodyJoints, rawCCDSolver, rawQueryPipeline, rawPhysicsPipeline, rawSerializationPipeline, rawDebugRenderPipeline);
22
24
  setContext('threlte-rapier-context', rapierContext);
23
- $: if (gravity !== undefined)
24
- rapierContext.world.gravity = positionToVector3(gravity);
25
+ $: if (gravity !== undefined) {
26
+ rapierContext.world.gravity = { x: gravity[0], y: gravity[1], z: gravity[2] };
27
+ }
25
28
  useFrameHandler(rapierContext);
26
29
  onDestroy(async () => {
27
30
  await tick();
@@ -1,21 +1,20 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { InnerWorldProperties } from '../../types/components';
3
2
  declare const __propDef: {
4
3
  props: {
5
- gravity?: InnerWorldProperties['gravity'];
6
- rawIntegrationParameters?: InnerWorldProperties['rawIntegrationParameters'];
7
- rawIslands?: InnerWorldProperties['rawIslands'];
8
- rawBroadPhase?: InnerWorldProperties['rawBroadPhase'];
9
- rawNarrowPhase?: InnerWorldProperties['rawNarrowPhase'];
10
- rawBodies?: InnerWorldProperties['rawBodies'];
11
- rawColliders?: InnerWorldProperties['rawColliders'];
12
- rawImpulseJoints?: InnerWorldProperties['rawImpulseJoints'];
13
- rawMultibodyJoints?: InnerWorldProperties['rawMultibodyJoints'];
14
- rawCCDSolver?: InnerWorldProperties['rawCCDSolver'];
15
- rawQueryPipeline?: InnerWorldProperties['rawQueryPipeline'];
16
- rawPhysicsPipeline?: InnerWorldProperties['rawPhysicsPipeline'];
17
- rawSerializationPipeline?: InnerWorldProperties['rawSerializationPipeline'];
18
- rawDebugRenderPipeline?: InnerWorldProperties['rawDebugRenderPipeline'];
4
+ gravity?: [x: number, y: number, z: number] | undefined;
5
+ rawIntegrationParameters?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawIntegrationParameters | undefined;
6
+ rawIslands?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawIslandManager | undefined;
7
+ rawBroadPhase?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawBroadPhase | undefined;
8
+ rawNarrowPhase?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawNarrowPhase | undefined;
9
+ rawBodies?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawRigidBodySet | undefined;
10
+ rawColliders?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawColliderSet | undefined;
11
+ rawImpulseJoints?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawImpulseJointSet | undefined;
12
+ rawMultibodyJoints?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawMultibodyJointSet | undefined;
13
+ rawCCDSolver?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawCCDSolver | undefined;
14
+ rawQueryPipeline?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawQueryPipeline | undefined;
15
+ rawPhysicsPipeline?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawPhysicsPipeline | undefined;
16
+ rawSerializationPipeline?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawSerializationPipeline | undefined;
17
+ rawDebugRenderPipeline?: import("@dimforge/rapier3d-compat/rapier_wasm3d").RawDebugRenderPipeline | undefined;
19
18
  };
20
19
  events: {
21
20
  [evt: string]: CustomEvent<any>;
@@ -1,13 +1,17 @@
1
- <script context="module">import RAPIER from '@dimforge/rapier3d-compat';
1
+ <script
2
+ context="module"
3
+
4
+ >import RAPIER from '@dimforge/rapier3d-compat';
2
5
  import { onMount } from 'svelte';
3
6
  import { writable } from 'svelte/store';
4
7
  /**
5
8
  * RAPIER.init() should only be called once
6
9
  */
7
- let initialized = writable(false);
10
+ const initialized = writable(false);
8
11
  </script>
9
12
 
10
13
  <script>import InnerWorld from './InnerWorld.svelte';
14
+ // self
11
15
  export let gravity = undefined;
12
16
  export let rawIntegrationParameters = undefined;
13
17
  export let rawIslands = undefined;
@@ -1,33 +1,36 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import type { WorldProperties } from '../../types/components';
3
- declare const __propDef: {
4
- props: {
5
- gravity?: WorldProperties['gravity'];
6
- rawIntegrationParameters?: WorldProperties['rawIntegrationParameters'];
7
- rawIslands?: WorldProperties['rawIslands'];
8
- rawBroadPhase?: WorldProperties['rawBroadPhase'];
9
- rawNarrowPhase?: WorldProperties['rawNarrowPhase'];
10
- rawBodies?: WorldProperties['rawBodies'];
11
- rawColliders?: WorldProperties['rawColliders'];
12
- rawImpulseJoints?: WorldProperties['rawImpulseJoints'];
13
- rawMultibodyJoints?: WorldProperties['rawMultibodyJoints'];
14
- rawCCDSolver?: WorldProperties['rawCCDSolver'];
15
- rawQueryPipeline?: WorldProperties['rawQueryPipeline'];
16
- rawPhysicsPipeline?: WorldProperties['rawPhysicsPipeline'];
17
- rawSerializationPipeline?: WorldProperties['rawSerializationPipeline'];
18
- rawDebugRenderPipeline?: WorldProperties['rawDebugRenderPipeline'];
19
- };
20
- events: {
21
- [evt: string]: CustomEvent<any>;
22
- };
23
- slots: {
24
- default: {};
25
- fallback: {};
26
- };
27
- };
28
- export declare type WorldProps = typeof __propDef.props;
29
- export declare type WorldEvents = typeof __propDef.events;
30
- export declare type WorldSlots = typeof __propDef.slots;
31
- export default class World extends SvelteComponentTyped<WorldProps, WorldEvents, WorldSlots> {
1
+ import type {
2
+ RawBroadPhase,
3
+ RawCCDSolver,
4
+ RawColliderSet,
5
+ RawDebugRenderPipeline,
6
+ RawImpulseJointSet,
7
+ RawIntegrationParameters,
8
+ RawIslandManager,
9
+ RawMultibodyJointSet,
10
+ RawNarrowPhase,
11
+ RawPhysicsPipeline,
12
+ RawQueryPipeline,
13
+ RawRigidBodySet,
14
+ RawSerializationPipeline
15
+ } from '@dimforge/rapier3d-compat/raw'
16
+ import { SvelteComponentTyped } from 'svelte'
17
+ import type { Vector3 } from 'three'
18
+
19
+ export type WorldProps = {
20
+ gravity?: Parameters<Vector3['set']>
21
+ rawIntegrationParameters?: RawIntegrationParameters
22
+ rawIslands?: RawIslandManager
23
+ rawBroadPhase?: RawBroadPhase
24
+ rawNarrowPhase?: RawNarrowPhase
25
+ rawBodies?: RawRigidBodySet
26
+ rawColliders?: RawColliderSet
27
+ rawImpulseJoints?: RawImpulseJointSet
28
+ rawMultibodyJoints?: RawMultibodyJointSet
29
+ rawCCDSolver?: RawCCDSolver
30
+ rawQueryPipeline?: RawQueryPipeline
31
+ rawPhysicsPipeline?: RawPhysicsPipeline
32
+ rawSerializationPipeline?: RawSerializationPipeline
33
+ rawDebugRenderPipeline?: RawDebugRenderPipeline
32
34
  }
33
- export {};
35
+
36
+ export default class World extends SvelteComponentTyped<WorldProps> {}
@@ -1,6 +1,6 @@
1
1
  import type { FixedImpulseJoint } from '@dimforge/rapier3d-compat';
2
- import type { Position, Rotation } from '@threlte/core';
3
- export declare const useFixedJoint: (anchorA: Position, frameA: Rotation, anchorB: Position, frameB: Rotation) => {
2
+ import { Euler } from 'three';
3
+ export declare const useFixedJoint: (anchorA: [x: number, y: number, z: number], frameA: Parameters<Euler['set']> | Euler, anchorB: [x: number, y: number, z: number], frameB: Parameters<Euler['set']> | Euler) => {
4
4
  joint: import("svelte/store").Writable<FixedImpulseJoint>;
5
5
  rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
6
6
  rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
@@ -1,10 +1,13 @@
1
- import { positionToVector3 } from '../lib/positionToVector3';
2
- import { rotationToQuaternion } from '../lib/rotationToQuaternion';
1
+ import { Euler, Quaternion, Vector3 } from 'three';
3
2
  import { useJoint } from './useJoint';
4
3
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5
4
  export const useFixedJoint = (anchorA, frameA, anchorB, frameB) => {
5
+ const jaA = anchorA instanceof Vector3 ? anchorA : new Vector3(...anchorA);
6
+ const jfA = new Quaternion().setFromEuler(frameA instanceof Euler ? frameA : new Euler(...frameA));
7
+ const jaB = anchorB instanceof Vector3 ? anchorB : new Vector3(...anchorB);
8
+ const jfB = new Quaternion().setFromEuler(frameB instanceof Euler ? frameB : new Euler(...frameB));
6
9
  return useJoint((rbA, rbB, { world, rapier }) => {
7
- const params = rapier.JointData.fixed(positionToVector3(anchorA), rotationToQuaternion(frameA), positionToVector3(anchorB), rotationToQuaternion(frameB));
10
+ const params = rapier.JointData.fixed(jaA, jfA, jaB, jfB);
8
11
  return world.createImpulseJoint(params, rbA, rbB, true);
9
12
  });
10
13
  };
@@ -1,6 +1,6 @@
1
1
  import type { PrismaticImpulseJoint } from '@dimforge/rapier3d-compat';
2
- import type { Position } from '@threlte/core';
3
- export declare const usePrismaticJoint: (anchorA: Position, anchorB: Position, axis: Position, limits?: [min: number, max: number]) => {
2
+ import { Vector3 } from 'three';
3
+ export declare const usePrismaticJoint: (anchorA: Parameters<Vector3['set']> | Vector3, anchorB: Parameters<Vector3['set']> | Vector3, axis: Parameters<Vector3['set']> | Vector3, limits?: [min: number, max: number]) => {
4
4
  joint: import("svelte/store").Writable<PrismaticImpulseJoint>;
5
5
  rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
6
6
  rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
@@ -1,9 +1,12 @@
1
- import { positionToVector3 } from '../lib/positionToVector3';
1
+ import { Vector3 } from 'three';
2
2
  import { useJoint } from './useJoint';
3
3
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4
4
  export const usePrismaticJoint = (anchorA, anchorB, axis, limits) => {
5
5
  return useJoint((rbA, rbB, { world, rapier }) => {
6
- const params = rapier.JointData.prismatic(positionToVector3(anchorA), positionToVector3(anchorB), positionToVector3(axis).normalize());
6
+ const jaA = anchorA instanceof Vector3 ? anchorA : new Vector3(...anchorA);
7
+ const jaB = anchorB instanceof Vector3 ? anchorB : new Vector3(...anchorB);
8
+ const jAxis = (axis instanceof Vector3 ? axis : new Vector3(...axis)).normalize();
9
+ const params = rapier.JointData.prismatic(jaA, jaB, jAxis);
7
10
  if (limits) {
8
11
  params.limitsEnabled = true;
9
12
  params.limits = limits;
@@ -1,6 +1,6 @@
1
1
  import type { RevoluteImpulseJoint } from '@dimforge/rapier3d-compat';
2
- import type { Position } from '@threlte/core';
3
- export declare const useRevoluteJoint: (anchorA: Position, anchorB: Position, axis: Position, limits?: [min: number, max: number]) => {
2
+ import { Vector3 } from 'three';
3
+ export declare const useRevoluteJoint: (anchorA: Parameters<Vector3['set']> | Vector3, anchorB: Parameters<Vector3['set']> | Vector3, axis: Parameters<Vector3['set']> | Vector3, limits?: [min: number, max: number]) => {
4
4
  joint: import("svelte/store").Writable<RevoluteImpulseJoint>;
5
5
  rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
6
6
  rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
@@ -1,9 +1,12 @@
1
- import { positionToVector3 } from '../lib/positionToVector3';
1
+ import { Vector3 } from 'three';
2
2
  import { useJoint } from './useJoint';
3
3
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4
4
  export const useRevoluteJoint = (anchorA, anchorB, axis, limits) => {
5
5
  return useJoint((rbA, rbB, { world, rapier }) => {
6
- const params = rapier.JointData.revolute(positionToVector3(anchorA), positionToVector3(anchorB), positionToVector3(axis).normalize());
6
+ const jaA = anchorA instanceof Vector3 ? anchorA : new Vector3(...anchorA);
7
+ const jaB = anchorB instanceof Vector3 ? anchorB : new Vector3(...anchorB);
8
+ const jAxis = (axis instanceof Vector3 ? axis : new Vector3(...axis)).normalize();
9
+ const params = rapier.JointData.revolute(jaA, jaB, jAxis);
7
10
  if (limits) {
8
11
  params.limitsEnabled = true;
9
12
  params.limits = limits;
@@ -1,6 +1,6 @@
1
1
  import type { SphericalImpulseJoint } from '@dimforge/rapier3d-compat';
2
- import type { Position } from '@threlte/core';
3
- export declare const useSphericalJoint: (anchorA: Position, anchorB: Position) => {
2
+ import { Vector3 } from 'three';
3
+ export declare const useSphericalJoint: (anchorA: Parameters<Vector3['set']> | Vector3, anchorB: Parameters<Vector3['set']> | Vector3) => {
4
4
  joint: import("svelte/store").Writable<SphericalImpulseJoint>;
5
5
  rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
6
6
  rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
@@ -1,9 +1,11 @@
1
- import { positionToVector3 } from '../lib/positionToVector3';
1
+ import { Vector3 } from 'three';
2
2
  import { useJoint } from './useJoint';
3
3
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4
4
  export const useSphericalJoint = (anchorA, anchorB) => {
5
5
  return useJoint((rbA, rbB, { world, rapier }) => {
6
- const params = rapier.JointData.spherical(positionToVector3(anchorA), positionToVector3(anchorB));
6
+ const jaA = anchorA instanceof Vector3 ? anchorA : new Vector3(...anchorA);
7
+ const jaB = anchorB instanceof Vector3 ? anchorB : new Vector3(...anchorB);
8
+ const params = rapier.JointData.spherical(jaA, jaB);
7
9
  return world.createImpulseJoint(params, rbA, rbB, true);
8
10
  });
9
11
  };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export { default as Debug } from './components/Debug/Debug.svelte';
12
12
  export { default as Collider } from './components/Colliders/Collider.svelte';
13
13
  export { default as AutoColliders } from './components/Colliders/AutoColliders.svelte';
14
14
  export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
15
+ export { default as Attractor } from './components/Attractor/Attractor.svelte';
15
16
  export { default as BasicPlayerController } from './recipes/BasicPlayerController.svelte';
16
- export type { AutoCollidersProperties, Boolean3Array, RigidBodyProperties, WorldProperties } from './types/components';
17
+ export type { AutoCollidersProperties, AttractorProperties } from './types/components';
17
18
  export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderEventDispatcher, ColliderShapes, RapierContext, RigidBodyEventDispatcher, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent } from './types/types';
package/dist/index.js CHANGED
@@ -15,5 +15,6 @@ export { default as Debug } from './components/Debug/Debug.svelte';
15
15
  export { default as Collider } from './components/Colliders/Collider.svelte';
16
16
  export { default as AutoColliders } from './components/Colliders/AutoColliders.svelte';
17
17
  export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
18
+ export { default as Attractor } from './components/Attractor/Attractor.svelte';
18
19
  // recipes
19
20
  export { default as BasicPlayerController } from './recipes/BasicPlayerController.svelte';
@@ -1,3 +1,2 @@
1
- import type { Position, Rotation, Scale, LookAt } from '@threlte/core';
2
- import { Object3D } from 'three';
3
- export declare const applyTransforms: (object: Object3D, position?: Position, rotation?: Rotation, scale?: Scale, lookAt?: LookAt) => void;
1
+ import type { Euler, Object3D, Vector3 } from 'three';
2
+ export declare const applyTransforms: (object: Object3D, position?: Parameters<Vector3['set']>, rotation?: Parameters<Euler['set']>, scale?: Parameters<Vector3['set']>) => void;