@threlte/rapier 0.3.1 → 0.4.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.
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @threlte/extras
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4b4d7be: Added rapiers damping properties to the component <RigidBody>
8
+
9
+ ## 0.3.2
10
+
11
+ ### Patch Changes
12
+
13
+ - c7e226f: useJoint is now exported and its types are fixed
14
+
3
15
  ## 0.3.1
4
16
 
5
17
  ### Patch Changes
@@ -16,10 +16,8 @@ export let linearVelocity = {};
16
16
  export let angularVelocity = {};
17
17
  export let gravityScale = 1;
18
18
  export let ccd = false;
19
- export let position = undefined;
20
- export let rotation = undefined;
21
- export let scale = undefined;
22
- export let lookAt = undefined;
19
+ export let angularDamping = 0;
20
+ export let linearDamping = 0;
23
21
  export let lockRotations = false;
24
22
  export let lockTranslations = false;
25
23
  export let enabledRotations = [
@@ -33,6 +31,10 @@ export let enabledTranslations = [
33
31
  true
34
32
  ];
35
33
  export let dominance = 0;
34
+ export let position = undefined;
35
+ export let rotation = undefined;
36
+ export let scale = undefined;
37
+ export let lookAt = undefined;
36
38
  const dispatcher = createEventDispatcher();
37
39
  const object = new Object3D();
38
40
  /**
@@ -107,6 +109,8 @@ $: {
107
109
  rigidBodyTemp.lockTranslations(lockTranslations, true);
108
110
  rigidBodyTemp.setEnabledRotations(...enabledRotations, true);
109
111
  rigidBodyTemp.setEnabledTranslations(...enabledTranslations, true);
112
+ rigidBodyTemp.setAngularDamping(angularDamping);
113
+ rigidBodyTemp.setLinearDamping(linearDamping);
110
114
  }
111
115
  /**
112
116
  * Add userData to the rigidBody
@@ -10,15 +10,17 @@ declare const __propDef: {
10
10
  angularVelocity?: import("@threlte/core").Rotation | undefined;
11
11
  gravityScale?: number | undefined;
12
12
  ccd?: boolean | undefined;
13
- position?: RigidBodyProperties['position'];
14
- rotation?: RigidBodyProperties['rotation'];
15
- scale?: RigidBodyProperties['scale'];
16
- lookAt?: RigidBodyProperties['lookAt'];
13
+ angularDamping?: number | undefined;
14
+ linearDamping?: number | undefined;
17
15
  lockRotations?: boolean | undefined;
18
16
  lockTranslations?: boolean | undefined;
19
17
  enabledRotations?: import("../../types/components").Boolean3Array | undefined;
20
18
  enabledTranslations?: import("../../types/components").Boolean3Array | undefined;
21
19
  dominance?: number | undefined;
20
+ position?: RigidBodyProperties['position'];
21
+ rotation?: RigidBodyProperties['rotation'];
22
+ scale?: RigidBodyProperties['scale'];
23
+ lookAt?: RigidBodyProperties['lookAt'];
22
24
  /**
23
25
  * Export the rigidBody only after positional initialization
24
26
  */ rigidBody?: RigidBody | undefined;
@@ -1,6 +1,6 @@
1
- import type { ImpulseJoint, RigidBody } from '@dimforge/rapier3d-compat';
1
+ import { MultibodyJoint, type ImpulseJoint, type RigidBody } from '@dimforge/rapier3d-compat';
2
2
  import type { RapierContext } from '../types/types';
3
- export declare const useJoint: <T extends ImpulseJoint>(initializeJoint: (rigidBodyA: RigidBody, rigidBodyB: RigidBody, ctx: RapierContext) => T) => {
3
+ export declare const useJoint: <T extends ImpulseJoint | MultibodyJoint>(initializeJoint: (rigidBodyA: RigidBody, rigidBodyB: RigidBody, ctx: RapierContext) => T) => {
4
4
  joint: import("svelte/store").Writable<T>;
5
5
  rigidBodyA: import("svelte/store").Writable<RigidBody | undefined>;
6
6
  rigidBodyB: import("svelte/store").Writable<RigidBody | undefined>;
@@ -1,3 +1,4 @@
1
+ import { MultibodyJoint } from '@dimforge/rapier3d-compat';
1
2
  import { onDestroy } from 'svelte';
2
3
  import { derived, get, writable } from 'svelte/store';
3
4
  import { useRapier } from './useRapier';
@@ -21,7 +22,12 @@ export const useJoint = (initializeJoint) => {
21
22
  const j = get(joint);
22
23
  if (!j)
23
24
  return;
24
- ctx.world.removeImpulseJoint(j, true);
25
+ if (j instanceof MultibodyJoint) {
26
+ ctx.world.removeMultibodyJoint(j, true);
27
+ }
28
+ else {
29
+ ctx.world.removeImpulseJoint(j, true);
30
+ }
25
31
  });
26
32
  return {
27
33
  joint,
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { useRevoluteJoint } from './hooks/useRevoluteJoint';
5
5
  export { usePrismaticJoint } from './hooks/usePrismaticJoint';
6
6
  export { useFixedJoint } from './hooks/useFixedJoint';
7
7
  export { useSphericalJoint } from './hooks/useSphericalJoint';
8
+ export { useJoint } from './hooks/useJoint';
8
9
  export { default as World } from './components/World/World.svelte';
9
10
  export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
10
11
  export { default as Debug } from './components/Debug/Debug.svelte';
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export { useRevoluteJoint } from './hooks/useRevoluteJoint';
7
7
  export { usePrismaticJoint } from './hooks/usePrismaticJoint';
8
8
  export { useFixedJoint } from './hooks/useFixedJoint';
9
9
  export { useSphericalJoint } from './hooks/useSphericalJoint';
10
+ export { useJoint } from './hooks/useJoint';
10
11
  // components
11
12
  export { default as World } from './components/World/World.svelte';
12
13
  export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
@@ -57,6 +57,20 @@ export declare type RigidBodyProperties = Omit<TransformableObjectProperties, 'o
57
57
  * Number in the range -127 to 127, default is 0
58
58
  */
59
59
  dominance?: number;
60
+ /**
61
+ * Damping lets you slow down a rigid-body automatically. This can be used to
62
+ * achieve a wide variety of effects like fake air friction. Larger values of
63
+ * damping coefficients lead to a stronger slow-downs. Their default
64
+ * values are 0.0 (no damping at all).
65
+ */
66
+ linearDamping?: number;
67
+ /**
68
+ * Damping lets you slow down a rigid-body automatically. This can be used to
69
+ * achieve a wide variety of effects like fake air friction. Larger values of
70
+ * damping coefficients lead to a stronger slow-downs. Their default
71
+ * values are 0.0 (no damping at all).
72
+ */
73
+ angularDamping?: number;
60
74
  };
61
75
  export declare type ColliderProperties<Shape extends ColliderShapes> = Omit<TransformableObjectProperties, 'object'> & {
62
76
  shape: Shape;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threlte/rapier",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
5
5
  "license": "MIT",
6
6
  "devDependencies": {