@threlte/rapier 0.5.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.
- package/dist/CHANGELOG.md +6 -0
- package/dist/components/Attractor/Attractor.svelte +17 -13
- package/dist/components/Attractor/Attractor.svelte.d.ts +20 -22
- package/dist/components/Colliders/AutoColliders.svelte +16 -10
- package/dist/components/Colliders/AutoColliders.svelte.d.ts +74 -0
- package/dist/components/Colliders/Collider.svelte +24 -15
- package/dist/components/Colliders/Collider.svelte.d.ts +105 -112
- package/dist/components/CollisionGroups/CollisionGroups.svelte.d.ts +29 -19
- package/dist/components/Debug/Debug.svelte +13 -10
- package/dist/components/Debug/Debug.svelte.d.ts +6 -60
- package/dist/components/RigidBody/RigidBody.svelte +14 -32
- package/dist/components/RigidBody/RigidBody.svelte.d.ts +93 -67
- package/dist/components/World/InnerWorld.svelte +9 -6
- package/dist/components/World/InnerWorld.svelte.d.ts +14 -15
- package/dist/components/World/World.svelte +6 -2
- package/dist/components/World/World.svelte.d.ts +35 -32
- package/dist/hooks/useFixedJoint.d.ts +2 -2
- package/dist/hooks/useFixedJoint.js +6 -3
- package/dist/hooks/usePrismaticJoint.d.ts +2 -2
- package/dist/hooks/usePrismaticJoint.js +5 -2
- package/dist/hooks/useRevoluteJoint.d.ts +2 -2
- package/dist/hooks/useRevoluteJoint.js +5 -2
- package/dist/hooks/useSphericalJoint.d.ts +2 -2
- package/dist/hooks/useSphericalJoint.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/lib/applyTransforms.d.ts +2 -3
- package/dist/lib/applyTransforms.js +7 -16
- package/dist/lib/eulerToQuaternion.d.ts +7 -0
- package/dist/lib/eulerToQuaternion.js +12 -0
- package/dist/lib/scaleColliderArgs.js +2 -2
- package/dist/recipes/BasicPlayerController.svelte +12 -6
- package/dist/recipes/BasicPlayerController.svelte.d.ts +2 -2
- package/dist/types/components.d.ts +1 -88
- package/package.json +9 -8
- package/dist/components/Joints/RevoluteJoint.svelte +0 -5
- package/dist/components/Joints/RevoluteJoint.svelte.d.ts +0 -23
- package/dist/lib/positionToVector3.d.ts +0 -3
- package/dist/lib/positionToVector3.js +0 -8
- package/dist/lib/rotationToEuler.d.ts +0 -3
- package/dist/lib/rotationToEuler.js +0 -8
- package/dist/lib/rotationToQuaternion.d.ts +0 -3
- package/dist/lib/rotationToQuaternion.js +0 -10
- package/dist/lib/scaleToVector3.d.ts +0 -3
- package/dist/lib/scaleToVector3.js +0 -16
|
@@ -1,60 +1,6 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
104
|
-
|
|
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 {
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
93
|
+
|
|
94
|
+
export default class RigidBody extends SvelteComponentTyped<RigidBodyProps> {}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
<script
|
|
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>
|
|
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(
|
|
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 =
|
|
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?:
|
|
6
|
-
rawIntegrationParameters?:
|
|
7
|
-
rawIslands?:
|
|
8
|
-
rawBroadPhase?:
|
|
9
|
-
rawNarrowPhase?:
|
|
10
|
-
rawBodies?:
|
|
11
|
-
rawColliders?:
|
|
12
|
-
rawImpulseJoints?:
|
|
13
|
-
rawMultibodyJoints?:
|
|
14
|
-
rawCCDSolver?:
|
|
15
|
-
rawQueryPipeline?:
|
|
16
|
-
rawPhysicsPipeline?:
|
|
17
|
-
rawSerializationPipeline?:
|
|
18
|
-
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
|
|
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
|
-
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
35
|
+
|
|
36
|
+
export default class World extends SvelteComponentTyped<WorldProps> {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FixedImpulseJoint } from '@dimforge/rapier3d-compat';
|
|
2
|
-
import
|
|
3
|
-
export declare const useFixedJoint: (anchorA:
|
|
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 {
|
|
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(
|
|
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
|
|
3
|
-
export declare const usePrismaticJoint: (anchorA:
|
|
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 {
|
|
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
|
|
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
|
|
3
|
-
export declare const useRevoluteJoint: (anchorA:
|
|
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 {
|
|
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
|
|
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
|
|
3
|
-
export declare const useSphericalJoint: (anchorA:
|
|
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 {
|
|
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
|
|
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
|
@@ -14,5 +14,5 @@ export { default as AutoColliders } from './components/Colliders/AutoColliders.s
|
|
|
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 { default as BasicPlayerController } from './recipes/BasicPlayerController.svelte';
|
|
17
|
-
export type { AutoCollidersProperties,
|
|
17
|
+
export type { AutoCollidersProperties, AttractorProperties } from './types/components';
|
|
18
18
|
export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderEventDispatcher, ColliderShapes, RapierContext, RigidBodyEventDispatcher, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent } from './types/types';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
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;
|