@threlte/rapier 3.0.0-next.14 → 3.0.0-next.16
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/components/Attractor/Attractor.svelte.d.ts +3 -34
- package/dist/components/Attractor/types.d.ts +30 -0
- package/dist/components/Attractor/types.js +1 -0
- package/dist/components/Colliders/{AutoColliders.svelte → AutoColliders/AutoColliders.svelte} +17 -10
- package/dist/components/Colliders/AutoColliders/AutoColliders.svelte.d.ts +22 -0
- package/dist/components/Colliders/AutoColliders/types.d.ts +74 -0
- package/dist/components/Colliders/AutoColliders/types.js +1 -0
- package/dist/components/Colliders/{Collider.svelte → Collider/Collider.svelte} +20 -16
- package/dist/components/Colliders/Collider/Collider.svelte.d.ts +20 -0
- package/dist/components/Colliders/Collider/types.d.ts +83 -0
- package/dist/components/Colliders/Collider/types.js +1 -0
- package/dist/components/CollisionGroups/CollisionGroups.svelte +4 -1
- package/dist/components/CollisionGroups/CollisionGroups.svelte.d.ts +16 -33
- package/dist/components/CollisionGroups/types.d.ts +19 -0
- package/dist/components/CollisionGroups/types.js +1 -0
- package/dist/components/Debug/Debug.svelte +5 -5
- package/dist/components/Debug/Debug.svelte.d.ts +3 -7
- package/dist/components/Debug/types.d.ts +3 -0
- package/dist/components/Debug/types.js +1 -0
- package/dist/components/RigidBody/RigidBody.svelte.d.ts +3 -102
- package/dist/components/RigidBody/types.d.ts +85 -0
- package/dist/components/RigidBody/types.js +1 -0
- package/dist/components/World/InnerWorld.svelte.d.ts +1 -2
- package/dist/components/World/World.svelte.d.ts +3 -49
- package/dist/components/World/types.d.ts +32 -0
- package/dist/components/World/types.js +1 -0
- package/dist/hooks/useFixedJoint.d.ts +2 -3
- package/dist/hooks/useJoint.d.ts +0 -1
- package/dist/hooks/usePrismaticJoint.d.ts +1 -2
- package/dist/hooks/useRevoluteJoint.d.ts +1 -2
- package/dist/hooks/useSphericalJoint.d.ts +1 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -4
- package/dist/lib/applyTransforms.d.ts +1 -1
- package/dist/lib/createRapierContext.d.ts +1 -1
- package/dist/lib/eulerToQuaternion.d.ts +2 -2
- package/dist/lib/useCreateEvent.d.ts +2 -2
- package/dist/lib/useCreateEvent.js +3 -5
- package/dist/types/types.d.ts +3 -5
- package/package.json +8 -8
- package/dist/components/Colliders/AutoColliders.svelte.d.ts +0 -84
- package/dist/components/Colliders/Collider.svelte.d.ts +0 -109
- package/dist/recipes/BasicPlayerController.svelte +0 -142
- package/dist/recipes/BasicPlayerController.svelte.d.ts +0 -40
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RigidBody as RapierRigidBody } from '@dimforge/rapier3d-compat';
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
import type { Euler, Vector3 } from 'three';
|
|
4
|
+
import type { RigidBodyTypeString } from '../../lib/parseRigidBodyType';
|
|
5
|
+
import type { CreateEvent, RigidBodyEvents } from '../../types/types';
|
|
6
|
+
export type Boolean3Array = [x: boolean, y: boolean, z: boolean];
|
|
7
|
+
export type RigidBodyProps = CreateEvent<RapierRigidBody> & RigidBodyEvents & {
|
|
8
|
+
rigidBody?: RapierRigidBody | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Specify the type of this rigid body
|
|
11
|
+
*/
|
|
12
|
+
type?: RigidBodyTypeString;
|
|
13
|
+
/** Whether or not this body can sleep.
|
|
14
|
+
* default: true
|
|
15
|
+
*/
|
|
16
|
+
canSleep?: boolean;
|
|
17
|
+
/** The linear velocity of this body.
|
|
18
|
+
* default: zero velocity
|
|
19
|
+
*/
|
|
20
|
+
linearVelocity?: Parameters<Vector3['set']>;
|
|
21
|
+
/** The angular velocity of this body.
|
|
22
|
+
* Default: zero velocity.
|
|
23
|
+
*/
|
|
24
|
+
angularVelocity?: Parameters<Euler['set']>;
|
|
25
|
+
/**
|
|
26
|
+
* The scaling factor applied to the gravity affecting the rigid-body.
|
|
27
|
+
* Default: 1.0
|
|
28
|
+
*/
|
|
29
|
+
gravityScale?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not Continous Collision Detection is enabled for this rigid-body.
|
|
32
|
+
* https://rapier.rs/docs/user_guides/javascript/rigid_bodies#continuous-collision-detection
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
ccd?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Locks all rotations that would have resulted from forces on the created rigid-body.
|
|
38
|
+
*/
|
|
39
|
+
lockRotations?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Locks all translations that would have resulted from forces on the created rigid-body.
|
|
42
|
+
*/
|
|
43
|
+
lockTranslations?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Allow rotation of this rigid-body only along specific axes.
|
|
46
|
+
*/
|
|
47
|
+
enabledRotations?: Boolean3Array;
|
|
48
|
+
/**
|
|
49
|
+
* Allow translations of this rigid-body only along specific axes.
|
|
50
|
+
*/
|
|
51
|
+
enabledTranslations?: Boolean3Array;
|
|
52
|
+
/**
|
|
53
|
+
* Dominance is a non-realistic, but sometimes useful, feature.
|
|
54
|
+
* It can be used to make one rigid-body immune to forces
|
|
55
|
+
* originating from contacts with some other bodies.
|
|
56
|
+
*
|
|
57
|
+
* Number in the range -127 to 127, default is 0
|
|
58
|
+
*/
|
|
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;
|
|
74
|
+
/**
|
|
75
|
+
* Set the rigidBody as enabled or disabled.
|
|
76
|
+
*/
|
|
77
|
+
enabled?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* An arbitrary user-defined object associated with this rigid-body.
|
|
80
|
+
*/
|
|
81
|
+
userData?: Record<string, any>;
|
|
82
|
+
children?: Snippet<[{
|
|
83
|
+
rigidBody: RapierRigidBody;
|
|
84
|
+
}]>;
|
|
85
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,49 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
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 { SvelteComponent, type Snippet } from 'svelte'
|
|
17
|
-
import type { Vector3 } from 'three'
|
|
18
|
-
import type { Key, Stage } from '@threlte/core'
|
|
19
|
-
|
|
20
|
-
export type WorldProps = {
|
|
21
|
-
framerate?: number | 'varying'
|
|
22
|
-
autoStart?: boolean
|
|
23
|
-
gravity?: Parameters<Vector3['set']>
|
|
24
|
-
rawIntegrationParameters?: RawIntegrationParameters
|
|
25
|
-
rawIslands?: RawIslandManager
|
|
26
|
-
rawBroadPhase?: RawBroadPhase
|
|
27
|
-
rawNarrowPhase?: RawNarrowPhase
|
|
28
|
-
rawBodies?: RawRigidBodySet
|
|
29
|
-
rawColliders?: RawColliderSet
|
|
30
|
-
rawImpulseJoints?: RawImpulseJointSet
|
|
31
|
-
rawMultibodyJoints?: RawMultibodyJointSet
|
|
32
|
-
rawCCDSolver?: RawCCDSolver
|
|
33
|
-
rawQueryPipeline?: RawQueryPipeline
|
|
34
|
-
rawPhysicsPipeline?: RawPhysicsPipeline
|
|
35
|
-
rawSerializationPipeline?: RawSerializationPipeline
|
|
36
|
-
rawDebugRenderPipeline?: RawDebugRenderPipeline
|
|
37
|
-
simulationStageOptions?: {
|
|
38
|
-
before?: (Key | Stage) | (Key | Stage)[]
|
|
39
|
-
after?: (Key | Stage) | (Key | Stage)[]
|
|
40
|
-
}
|
|
41
|
-
synchronizationStageOptions?: {
|
|
42
|
-
before?: (Key | Stage) | (Key | Stage)[]
|
|
43
|
-
after?: (Key | Stage) | (Key | Stage)[]
|
|
44
|
-
}
|
|
45
|
-
children?: Snippet
|
|
46
|
-
fallback?: Snippet<[error: any]>
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default class World extends SvelteComponent<WorldProps> {}
|
|
1
|
+
import type { WorldProps } from './types';
|
|
2
|
+
declare const World: import("svelte").Component<WorldProps, {}, "">;
|
|
3
|
+
export default World;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { RawBroadPhase, RawCCDSolver, RawColliderSet, RawDebugRenderPipeline, RawImpulseJointSet, RawIntegrationParameters, RawIslandManager, RawMultibodyJointSet, RawNarrowPhase, RawPhysicsPipeline, RawQueryPipeline, RawRigidBodySet, RawSerializationPipeline } from '@dimforge/rapier3d-compat/raw';
|
|
2
|
+
import type { Key, Stage } from '@threlte/core';
|
|
3
|
+
import { type Snippet } from 'svelte';
|
|
4
|
+
import type { Vector3 } from 'three';
|
|
5
|
+
export type WorldProps = {
|
|
6
|
+
framerate?: number | 'varying';
|
|
7
|
+
autoStart?: boolean;
|
|
8
|
+
gravity?: Parameters<Vector3['set']>;
|
|
9
|
+
rawIntegrationParameters?: RawIntegrationParameters;
|
|
10
|
+
rawIslands?: RawIslandManager;
|
|
11
|
+
rawBroadPhase?: RawBroadPhase;
|
|
12
|
+
rawNarrowPhase?: RawNarrowPhase;
|
|
13
|
+
rawBodies?: RawRigidBodySet;
|
|
14
|
+
rawColliders?: RawColliderSet;
|
|
15
|
+
rawImpulseJoints?: RawImpulseJointSet;
|
|
16
|
+
rawMultibodyJoints?: RawMultibodyJointSet;
|
|
17
|
+
rawCCDSolver?: RawCCDSolver;
|
|
18
|
+
rawQueryPipeline?: RawQueryPipeline;
|
|
19
|
+
rawPhysicsPipeline?: RawPhysicsPipeline;
|
|
20
|
+
rawSerializationPipeline?: RawSerializationPipeline;
|
|
21
|
+
rawDebugRenderPipeline?: RawDebugRenderPipeline;
|
|
22
|
+
simulationStageOptions?: {
|
|
23
|
+
before?: (Key | Stage) | (Key | Stage)[];
|
|
24
|
+
after?: (Key | Stage) | (Key | Stage)[];
|
|
25
|
+
};
|
|
26
|
+
synchronizationStageOptions?: {
|
|
27
|
+
before?: (Key | Stage) | (Key | Stage)[];
|
|
28
|
+
after?: (Key | Stage) | (Key | Stage)[];
|
|
29
|
+
};
|
|
30
|
+
children?: Snippet;
|
|
31
|
+
fallback?: Snippet<[error: any]>;
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
1
|
import type { FixedImpulseJoint } from '@dimforge/rapier3d-compat';
|
|
3
|
-
import { Euler } from 'three';
|
|
4
|
-
export declare const useFixedJoint: (anchorA: [
|
|
2
|
+
import { Euler, Vector3 } from 'three';
|
|
3
|
+
export declare const useFixedJoint: (anchorA: Parameters<Vector3["set"]>, frameA: Parameters<Euler["set"]> | Euler, anchorB: Parameters<Vector3["set"]>, frameB: Parameters<Euler["set"]> | Euler) => {
|
|
5
4
|
joint: import("svelte/store").Writable<FixedImpulseJoint>;
|
|
6
5
|
rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
7
6
|
rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
package/dist/hooks/useJoint.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
1
|
import { MultibodyJoint, type ImpulseJoint, type RigidBody } from '@dimforge/rapier3d-compat';
|
|
3
2
|
import type { RapierContext } from '../types/types';
|
|
4
3
|
export declare const useJoint: <T extends ImpulseJoint | MultibodyJoint>(initializeJoint: (rigidBodyA: RigidBody, rigidBodyB: RigidBody, ctx: RapierContext) => T) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
1
|
import type { PrismaticImpulseJoint } from '@dimforge/rapier3d-compat';
|
|
3
2
|
import { Vector3 } from 'three';
|
|
4
|
-
export declare const usePrismaticJoint: (anchorA: Parameters<Vector3[
|
|
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]) => {
|
|
5
4
|
joint: import("svelte/store").Writable<PrismaticImpulseJoint>;
|
|
6
5
|
rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
7
6
|
rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
1
|
import type { RevoluteImpulseJoint } from '@dimforge/rapier3d-compat';
|
|
3
2
|
import { Vector3 } from 'three';
|
|
4
|
-
export declare const useRevoluteJoint: (anchorA: Parameters<Vector3[
|
|
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]) => {
|
|
5
4
|
joint: import("svelte/store").Writable<RevoluteImpulseJoint>;
|
|
6
5
|
rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
7
6
|
rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
1
|
import type { SphericalImpulseJoint } from '@dimforge/rapier3d-compat';
|
|
3
2
|
import { Vector3 } from 'three';
|
|
4
|
-
export declare const useSphericalJoint: (anchorA: Parameters<Vector3[
|
|
3
|
+
export declare const useSphericalJoint: (anchorA: Parameters<Vector3["set"]> | Vector3, anchorB: Parameters<Vector3["set"]> | Vector3) => {
|
|
5
4
|
joint: import("svelte/store").Writable<SphericalImpulseJoint>;
|
|
6
5
|
rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
7
6
|
rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,10 +9,9 @@ export { useJoint } from './hooks/useJoint';
|
|
|
9
9
|
export { default as World } from './components/World/World.svelte';
|
|
10
10
|
export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
|
|
11
11
|
export { default as Debug } from './components/Debug/Debug.svelte';
|
|
12
|
-
export { default as Collider } from './components/Colliders/Collider.svelte';
|
|
13
|
-
export { default as AutoColliders } from './components/Colliders/AutoColliders.svelte';
|
|
12
|
+
export { default as Collider } from './components/Colliders/Collider/Collider.svelte';
|
|
13
|
+
export { default as AutoColliders } from './components/Colliders/AutoColliders/AutoColliders.svelte';
|
|
14
14
|
export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
|
|
15
15
|
export { default as Attractor } from './components/Attractor/Attractor.svelte';
|
|
16
16
|
export { computeBitMask } from './lib/computeBitMask';
|
|
17
|
-
export {
|
|
18
|
-
export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderEventDispatcher, ColliderShapes, RapierContext, RigidBodyEventDispatcher, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent, GravityType } from './types/types';
|
|
17
|
+
export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderShapes, RapierContext, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent, GravityType, CreateEvent, Framerate } from './types/types';
|
package/dist/index.js
CHANGED
|
@@ -12,11 +12,9 @@ export { useJoint } from './hooks/useJoint';
|
|
|
12
12
|
export { default as World } from './components/World/World.svelte';
|
|
13
13
|
export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
|
|
14
14
|
export { default as Debug } from './components/Debug/Debug.svelte';
|
|
15
|
-
export { default as Collider } from './components/Colliders/Collider.svelte';
|
|
16
|
-
export { default as AutoColliders } from './components/Colliders/AutoColliders.svelte';
|
|
15
|
+
export { default as Collider } from './components/Colliders/Collider/Collider.svelte';
|
|
16
|
+
export { default as AutoColliders } from './components/Colliders/AutoColliders/AutoColliders.svelte';
|
|
17
17
|
export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
|
|
18
18
|
export { default as Attractor } from './components/Attractor/Attractor.svelte';
|
|
19
19
|
// lib
|
|
20
20
|
export { computeBitMask } from './lib/computeBitMask';
|
|
21
|
-
// recipes
|
|
22
|
-
export { default as BasicPlayerController } from './recipes/BasicPlayerController.svelte';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Euler, Object3D, Vector3 } from 'three';
|
|
2
|
-
export declare const applyTransforms: (object: Object3D, position?: Parameters<Vector3[
|
|
2
|
+
export declare const applyTransforms: (object: Object3D, position?: Parameters<Vector3["set"]>, rotation?: Parameters<Euler["set"]>, scale?: Parameters<Vector3["set"]>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import RAPIER from '@dimforge/rapier3d-compat';
|
|
2
2
|
import { type Key, type Stage } from '@threlte/core';
|
|
3
3
|
import type { Framerate, RapierContext } from '../types/types';
|
|
4
|
-
export declare const createRapierContext: (worldArgs:
|
|
4
|
+
export declare const createRapierContext: (worldArgs: ConstructorParameters<typeof RAPIER.World>, options: {
|
|
5
5
|
framerate?: Framerate;
|
|
6
6
|
autoStart?: boolean;
|
|
7
7
|
simulationStageOptions?: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Quaternion } from 'three';
|
|
1
|
+
import { Euler, Quaternion } from 'three';
|
|
2
2
|
/**
|
|
3
3
|
* Sets the values of a temporary Euler and returns the quaternion from that
|
|
4
4
|
* @param values
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export declare const eulerToQuaternion: (values: [
|
|
7
|
+
export declare const eulerToQuaternion: (values: Parameters<Euler["set"]>) => Quaternion;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const useCreateEvent: <T>(oncreate?:
|
|
1
|
+
import type { CreateEvent } from '../types/types';
|
|
2
|
+
export declare const useCreateEvent: <T>(oncreate?: CreateEvent<T>["oncreate"]) => {
|
|
3
3
|
updateRef: (newRef: T) => void;
|
|
4
4
|
};
|
|
@@ -7,13 +7,11 @@ export const useCreateEvent = (oncreate) => {
|
|
|
7
7
|
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
8
8
|
// clear the cleanup functions array
|
|
9
9
|
cleanupFunctions.length = 0;
|
|
10
|
-
const cleanup = (callback) => {
|
|
11
|
-
// add cleanup function to array
|
|
12
|
-
cleanupFunctions.push(callback);
|
|
13
|
-
};
|
|
14
10
|
if (ref === undefined)
|
|
15
11
|
return;
|
|
16
|
-
oncreate?.(
|
|
12
|
+
const cleanup = oncreate?.(ref);
|
|
13
|
+
if (cleanup)
|
|
14
|
+
cleanupFunctions.push(cleanup);
|
|
17
15
|
};
|
|
18
16
|
const updateRef = (newRef) => {
|
|
19
17
|
ref = newRef;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
1
|
import { World, type Collider, type RigidBody, type TempContactManifold, type Vector } from '@dimforge/rapier3d-compat';
|
|
3
2
|
import RAPIER from '@dimforge/rapier3d-compat';
|
|
4
3
|
import type { CurrentWritable, Stage, Task } from '@threlte/core';
|
|
@@ -6,11 +5,10 @@ import type { Readable, Writable } from 'svelte/store';
|
|
|
6
5
|
import type { Object3D } from 'three';
|
|
7
6
|
export type ColliderShapes = 'ball' | 'capsule' | 'segment' | 'triangle' | 'roundTriangle' | 'polyline' | 'trimesh' | 'cuboid' | 'roundCuboid' | 'heightfield' | 'cylinder' | 'roundCylinder' | 'cone' | 'roundCone' | 'convexHull' | 'convexMesh' | 'roundConvexHull' | 'roundConvexMesh';
|
|
8
7
|
export type AutoCollidersShapes = 'cuboid' | 'ball' | 'trimesh' | 'convexHull' | 'capsule';
|
|
8
|
+
export type CreateEvent<T> = {
|
|
9
|
+
oncreate?: (ref: T) => void | (() => void);
|
|
10
|
+
};
|
|
9
11
|
export type ColliderEvents = {
|
|
10
|
-
oncreate?: (event: {
|
|
11
|
-
ref: Collider;
|
|
12
|
-
cleanup: (callback: () => void) => void;
|
|
13
|
-
}) => void;
|
|
14
12
|
oncollisionenter?: (event: {
|
|
15
13
|
targetCollider: Collider;
|
|
16
14
|
targetRigidBody: RigidBody | null;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threlte/rapier",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.16",
|
|
4
4
|
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Components and hooks to use the Rapier physics engine in Threlte",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@dimforge/rapier3d-compat": "^0.14.0",
|
|
9
|
-
"@sveltejs/adapter-auto": "^3.
|
|
10
|
-
"@sveltejs/kit": "^2.7.
|
|
9
|
+
"@sveltejs/adapter-auto": "^3.3.1",
|
|
10
|
+
"@sveltejs/kit": "^2.7.7",
|
|
11
11
|
"@sveltejs/package": "^2.3.7",
|
|
12
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
12
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
13
13
|
"@types/node": "^20.12.7",
|
|
14
14
|
"@types/three": "^0.169.0",
|
|
15
15
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"prettier-plugin-svelte": "^3.2.2",
|
|
23
23
|
"publint": "^0.2.7",
|
|
24
24
|
"rimraf": "^5.0.5",
|
|
25
|
-
"svelte": "^5.1.
|
|
25
|
+
"svelte": "^5.1.10",
|
|
26
26
|
"svelte-check": "^3.6.9",
|
|
27
27
|
"svelte-preprocess": "^5.1.3",
|
|
28
28
|
"svelte2tsx": "^0.7.6",
|
|
29
|
-
"three": "^0.
|
|
29
|
+
"three": "^0.170.0",
|
|
30
30
|
"tslib": "^2.6.2",
|
|
31
31
|
"type-fest": "^4.15.0",
|
|
32
|
-
"typescript": "^5.
|
|
32
|
+
"typescript": "^5.6.3",
|
|
33
33
|
"vite": "^5.2.8",
|
|
34
|
-
"@threlte/core": "8.0.0-next.
|
|
34
|
+
"@threlte/core": "8.0.0-next.28"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@dimforge/rapier3d-compat": ">=0.14",
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { CoefficientCombineRule, Collider } from '@dimforge/rapier3d-compat'
|
|
2
|
-
import { SvelteComponent, type Snippet } from 'svelte'
|
|
3
|
-
import type { Euler, Vector3 } from 'three'
|
|
4
|
-
import type { AutoCollidersShapes, ColliderEvents } from '../../types/types'
|
|
5
|
-
|
|
6
|
-
// ------------------ BASE ------------------
|
|
7
|
-
|
|
8
|
-
type BaseProps = {
|
|
9
|
-
shape?: AutoCollidersShapes
|
|
10
|
-
restitution?: number
|
|
11
|
-
restitutionCombineRule?: CoefficientCombineRule
|
|
12
|
-
friction?: number
|
|
13
|
-
frictionCombineRule?: CoefficientCombineRule
|
|
14
|
-
sensor?: boolean
|
|
15
|
-
colliders?: Collider[]
|
|
16
|
-
contactForceEventThreshold?: number
|
|
17
|
-
|
|
18
|
-
refresh?: () => void
|
|
19
|
-
|
|
20
|
-
oncreate?: () => void
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ------------------ MASS ------------------
|
|
24
|
-
|
|
25
|
-
type Density = {
|
|
26
|
-
density: number
|
|
27
|
-
|
|
28
|
-
mass?: never
|
|
29
|
-
centerOfMass?: never
|
|
30
|
-
principalAngularInertia?: never
|
|
31
|
-
angularInertiaLocalFrame?: never
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type Mass = {
|
|
35
|
-
mass: number
|
|
36
|
-
density?: never
|
|
37
|
-
centerOfMass?: never
|
|
38
|
-
principalAngularInertia?: never
|
|
39
|
-
angularInertiaLocalFrame?: never
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type MassProperties = {
|
|
43
|
-
mass: number
|
|
44
|
-
centerOfMass: Parameters<Vector3['set']>
|
|
45
|
-
principalAngularInertia: Parameters<Vector3['set']>
|
|
46
|
-
angularInertiaLocalFrame: Parameters<Euler['set']>
|
|
47
|
-
density?: never
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type NoMassProperties = {
|
|
51
|
-
density?: never
|
|
52
|
-
mass?: never
|
|
53
|
-
centerOfMass?: never
|
|
54
|
-
principalAngularInertia?: never
|
|
55
|
-
angularInertiaLocalFrame?: never
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type MassDef = Density | Mass | MassProperties | NoMassProperties
|
|
59
|
-
|
|
60
|
-
type MassProps<TMassDef extends MassDef> = TMassDef extends Density
|
|
61
|
-
? Density
|
|
62
|
-
: TMassDef extends MassProperties
|
|
63
|
-
? MassProperties
|
|
64
|
-
: TMassDef extends Mass
|
|
65
|
-
? Mass
|
|
66
|
-
: NoMassProperties
|
|
67
|
-
|
|
68
|
-
// ------------------ COLLIDER ------------------
|
|
69
|
-
|
|
70
|
-
export type AutoCollidersProps<TMassDef extends MassDef> = BaseProps &
|
|
71
|
-
MassProps<TMassDef> & {
|
|
72
|
-
children?: Snippet<
|
|
73
|
-
[
|
|
74
|
-
{
|
|
75
|
-
colliders: Collider[]
|
|
76
|
-
refresh: () => void
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
>
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export default class AutoColliders<TMassDef extends MassDef> extends SvelteComponent<
|
|
83
|
-
AutoCollidersProps<TMassDef>
|
|
84
|
-
> {}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CoefficientCombineRule,
|
|
3
|
-
Collider as RapierCollider,
|
|
4
|
-
ColliderDesc
|
|
5
|
-
} from '@dimforge/rapier3d-compat'
|
|
6
|
-
import { SvelteComponent, type Snippet } from 'svelte'
|
|
7
|
-
import type { Euler, Vector3 } from 'three'
|
|
8
|
-
import type { ColliderEvents } from '../../types/types'
|
|
9
|
-
|
|
10
|
-
// ------------------ BASE ------------------
|
|
11
|
-
|
|
12
|
-
type Type = 'static' | 'dynamic'
|
|
13
|
-
|
|
14
|
-
type BaseProps = {
|
|
15
|
-
type?: Type
|
|
16
|
-
restitution?: number
|
|
17
|
-
restitutionCombineRule?: CoefficientCombineRule
|
|
18
|
-
friction?: number
|
|
19
|
-
frictionCombineRule?: CoefficientCombineRule
|
|
20
|
-
sensor?: boolean
|
|
21
|
-
collider?: RapierCollider
|
|
22
|
-
contactForceEventThreshold?: number
|
|
23
|
-
refresh?: () => void
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// ------------------ SHAPE ------------------
|
|
27
|
-
|
|
28
|
-
export type Shape =
|
|
29
|
-
| 'ball'
|
|
30
|
-
| 'capsule'
|
|
31
|
-
| 'segment'
|
|
32
|
-
| 'triangle'
|
|
33
|
-
| 'roundTriangle'
|
|
34
|
-
| 'polyline'
|
|
35
|
-
| 'trimesh'
|
|
36
|
-
| 'cuboid'
|
|
37
|
-
| 'roundCuboid'
|
|
38
|
-
| 'heightfield'
|
|
39
|
-
| 'cylinder'
|
|
40
|
-
| 'roundCylinder'
|
|
41
|
-
| 'cone'
|
|
42
|
-
| 'roundCone'
|
|
43
|
-
| 'convexHull'
|
|
44
|
-
| 'convexMesh'
|
|
45
|
-
| 'roundConvexHull'
|
|
46
|
-
| 'roundConvexMesh'
|
|
47
|
-
|
|
48
|
-
type Args<TShape extends Shape> = Parameters<(typeof ColliderDesc)[TShape]>
|
|
49
|
-
|
|
50
|
-
type ShapeProps<TShape extends Shape> = {
|
|
51
|
-
shape: TShape
|
|
52
|
-
args: Args<TShape>
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ------------------ MASS ------------------
|
|
56
|
-
|
|
57
|
-
type Density = {
|
|
58
|
-
density: number
|
|
59
|
-
mass?: never
|
|
60
|
-
centerOfMass?: never
|
|
61
|
-
principalAngularInertia?: never
|
|
62
|
-
angularInertiaLocalFrame?: never
|
|
63
|
-
}
|
|
64
|
-
type Mass = {
|
|
65
|
-
mass: number
|
|
66
|
-
density?: never
|
|
67
|
-
centerOfMass?: never
|
|
68
|
-
principalAngularInertia?: never
|
|
69
|
-
angularInertiaLocalFrame?: never
|
|
70
|
-
}
|
|
71
|
-
type MassProperties = {
|
|
72
|
-
mass: number
|
|
73
|
-
centerOfMass: Parameters<Vector3['set']>
|
|
74
|
-
principalAngularInertia: Parameters<Vector3['set']>
|
|
75
|
-
angularInertiaLocalFrame: Parameters<Euler['set']>
|
|
76
|
-
density?: never
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
type NoMassProperties = {
|
|
80
|
-
density?: never
|
|
81
|
-
mass?: never
|
|
82
|
-
centerOfMass?: never
|
|
83
|
-
principalAngularInertia?: never
|
|
84
|
-
angularInertiaLocalFrame?: never
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export type MassDef = Density | Mass | MassProperties | NoMassProperties
|
|
88
|
-
|
|
89
|
-
type MassProps<TMassDef extends MassDef> = TMassDef extends Density
|
|
90
|
-
? Density
|
|
91
|
-
: TMassDef extends MassProperties
|
|
92
|
-
? MassProperties
|
|
93
|
-
: TMassDef extends Mass
|
|
94
|
-
? Mass
|
|
95
|
-
: NoMassProperties
|
|
96
|
-
|
|
97
|
-
// ------------------ COLLIDER ------------------
|
|
98
|
-
|
|
99
|
-
export type ColliderProps<TShape extends Shape, TMassDef extends MassDef> = BaseProps &
|
|
100
|
-
ColliderEvents &
|
|
101
|
-
ShapeProps<TShape> &
|
|
102
|
-
MassProps<TMassDef> & {
|
|
103
|
-
children?: Snippet<[{ collider?: RapierCollider }]>
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export default class Collider<
|
|
107
|
-
TShape extends Shape,
|
|
108
|
-
TMassDef extends MassDef
|
|
109
|
-
> extends SvelteComponent<ColliderProps<TShape, TMassDef>> {}
|