@threlte/rapier 3.1.5 → 3.2.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/README.md +0 -4
- package/dist/components/Attractor/Attractor.svelte +58 -32
- package/dist/components/Attractor/Attractor.svelte.d.ts +2 -1
- package/dist/components/Attractor/types.d.ts +1 -1
- package/dist/components/Colliders/AutoColliders/AutoColliders.svelte +123 -76
- package/dist/components/Colliders/AutoColliders/AutoColliders.svelte.d.ts +15 -4
- package/dist/components/Colliders/AutoColliders/types.d.ts +1 -1
- package/dist/components/Colliders/Collider/Collider.svelte +181 -126
- package/dist/components/Colliders/Collider/Collider.svelte.d.ts +13 -4
- package/dist/components/Colliders/Collider/types.d.ts +1 -1
- package/dist/components/CollisionGroups/CollisionGroups.svelte +27 -7
- package/dist/components/CollisionGroups/CollisionGroups.svelte.d.ts +11 -4
- package/dist/components/Debug/Debug.svelte +28 -18
- package/dist/components/Debug/Debug.svelte.d.ts +2 -1
- package/dist/components/RigidBody/RigidBody.svelte +173 -113
- package/dist/components/RigidBody/RigidBody.svelte.d.ts +2 -1
- package/dist/components/RigidBody/types.d.ts +2 -2
- package/dist/components/World/InnerWorld.svelte +53 -22
- package/dist/components/World/InnerWorld.svelte.d.ts +2 -1
- package/dist/components/World/World.svelte +6 -3
- package/dist/components/World/World.svelte.d.ts +2 -1
- package/dist/components/World/types.d.ts +1 -1
- package/dist/hooks/useFixedJoint.js +2 -2
- package/dist/hooks/useJoint.d.ts +1 -1
- package/dist/hooks/useJoint.js +1 -1
- package/dist/hooks/usePhysicsTask.js +1 -1
- package/dist/hooks/usePrismaticJoint.js +2 -2
- package/dist/hooks/useRapier.d.ts +1 -1
- package/dist/hooks/useRevoluteJoint.js +2 -2
- package/dist/hooks/useRigidBody.d.ts +1 -1
- package/dist/hooks/useRopeJoint.js +2 -2
- package/dist/hooks/useSphericalJoint.js +2 -2
- package/dist/index.d.ts +12 -12
- package/dist/index.js +11 -11
- package/dist/lib/applyColliderActiveEvents.d.ts +1 -1
- package/dist/lib/createCollidersFromChildren.d.ts +1 -1
- package/dist/lib/createPhysicsStages.d.ts +1 -1
- package/dist/lib/createPhysicsStages.js +1 -1
- package/dist/lib/createPhysicsTasks.d.ts +1 -1
- package/dist/lib/createPhysicsTasks.js +1 -1
- package/dist/lib/createRapierContext.d.ts +1 -1
- package/dist/lib/createRapierContext.js +2 -2
- package/dist/lib/scaleColliderArgs.d.ts +1 -1
- package/dist/lib/useCreateEvent.d.ts +1 -1
- package/package.json +10 -11
|
@@ -1,106 +1,164 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createParentObject3DContext, useParentObject3D, watch } from '@threlte/core'
|
|
3
|
+
import { onDestroy, setContext, tick } from 'svelte'
|
|
4
|
+
import { Object3D, Vector3 } from 'three'
|
|
5
|
+
import { useRapier } from '../../hooks/useRapier.js'
|
|
6
|
+
import {
|
|
7
|
+
initializeRigidBodyUserData,
|
|
8
|
+
setInitialRigidBodyState
|
|
9
|
+
} from '../../lib/createPhysicsTasks.js'
|
|
10
|
+
import {
|
|
11
|
+
getWorldPosition,
|
|
12
|
+
getWorldQuaternion,
|
|
13
|
+
getWorldScale
|
|
14
|
+
} from '../../lib/getWorldTransforms.js'
|
|
15
|
+
import { parseRigidBodyType } from '../../lib/parseRigidBodyType.js'
|
|
16
|
+
import { setParentRigidbodyObject } from '../../lib/rigidBodyObjectContext.js'
|
|
17
|
+
import { useCreateEvent } from '../../lib/useCreateEvent.js'
|
|
18
|
+
import type { RigidBodyContext, ThrelteRigidBody } from '../../types/types.js'
|
|
19
|
+
import { overrideTeleportMethods } from './overrideTeleportMethods.js'
|
|
20
|
+
import type { RigidBodyProps } from './types.js'
|
|
21
|
+
|
|
22
|
+
const { world, rapier, addRigidBodyToContext, removeRigidBodyFromContext } = useRapier()
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
linearVelocity,
|
|
26
|
+
angularVelocity,
|
|
27
|
+
type = 'dynamic',
|
|
28
|
+
canSleep = true,
|
|
29
|
+
gravityScale = 1,
|
|
30
|
+
ccd = false,
|
|
31
|
+
angularDamping = 0,
|
|
32
|
+
linearDamping = 0,
|
|
33
|
+
lockRotations = false,
|
|
34
|
+
lockTranslations = false,
|
|
35
|
+
enabledRotations = [true, true, true],
|
|
36
|
+
enabledTranslations = [true, true, true],
|
|
37
|
+
dominance = 0,
|
|
38
|
+
enabled = true,
|
|
39
|
+
userData = {},
|
|
40
|
+
rigidBody = $bindable(),
|
|
41
|
+
oncreate,
|
|
42
|
+
oncollisionenter,
|
|
43
|
+
oncollisionexit,
|
|
44
|
+
oncontact,
|
|
45
|
+
onsensorenter,
|
|
46
|
+
onsensorexit,
|
|
47
|
+
onsleep,
|
|
48
|
+
onwake,
|
|
49
|
+
children
|
|
50
|
+
}: RigidBodyProps = $props()
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Every RigidBody receives and forwards collision-related events
|
|
54
|
+
*/
|
|
55
|
+
const { updateRef } = useCreateEvent(oncreate)
|
|
56
|
+
|
|
57
|
+
const object = new Object3D()
|
|
58
|
+
initializeRigidBodyUserData(object)
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* isSleeping used for events "sleep" and "wake" in `createPhysicsTasks`
|
|
62
|
+
*/
|
|
63
|
+
object.userData.isSleeping = false
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* RigidBody Description
|
|
67
|
+
*/
|
|
68
|
+
const desc = new rapier.RigidBodyDesc(parseRigidBodyType(type)).setCanSleep(canSleep)
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Temporary RigidBody init
|
|
72
|
+
*/
|
|
73
|
+
let rigidBodyInternal = world.createRigidBody(desc) as ThrelteRigidBody
|
|
74
|
+
|
|
75
|
+
overrideTeleportMethods(rigidBodyInternal, object)
|
|
76
|
+
|
|
77
|
+
rigidBody = rigidBodyInternal
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Apply transforms after the parent component added "object" to itself
|
|
81
|
+
*/
|
|
82
|
+
const initPosition = async () => {
|
|
83
|
+
await tick()
|
|
84
|
+
object.updateMatrix()
|
|
85
|
+
object.updateWorldMatrix(true, false)
|
|
86
|
+
const parentWorldScale = object.parent ? getWorldScale(object.parent) : new Vector3(1, 1, 1)
|
|
87
|
+
const worldPosition = getWorldPosition(object).multiply(parentWorldScale)
|
|
88
|
+
const worldQuaternion = getWorldQuaternion(object)
|
|
89
|
+
setInitialRigidBodyState(object, worldPosition, worldQuaternion)
|
|
90
|
+
rigidBodyInternal.setTranslation(worldPosition, true)
|
|
91
|
+
rigidBodyInternal.setRotation(worldQuaternion, true)
|
|
92
|
+
updateRef(rigidBodyInternal)
|
|
93
|
+
}
|
|
94
|
+
initPosition()
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Will come in handy in the future for joints
|
|
98
|
+
*/
|
|
99
|
+
object.userData.rigidBody = rigidBodyInternal
|
|
100
|
+
|
|
101
|
+
$effect.pre(() => rigidBodyInternal.setBodyType(parseRigidBodyType(type), true))
|
|
102
|
+
$effect.pre(() => {
|
|
55
103
|
if (linearVelocity) {
|
|
56
|
-
|
|
104
|
+
rigidBodyInternal.setLinvel(
|
|
105
|
+
{ x: linearVelocity[0], y: linearVelocity[1], z: linearVelocity[2] },
|
|
106
|
+
true
|
|
107
|
+
)
|
|
57
108
|
}
|
|
58
|
-
})
|
|
59
|
-
$effect.pre(() => {
|
|
109
|
+
})
|
|
110
|
+
$effect.pre(() => {
|
|
60
111
|
if (angularVelocity) {
|
|
61
|
-
|
|
112
|
+
rigidBodyInternal.setAngvel(
|
|
113
|
+
{ x: angularVelocity[0], y: angularVelocity[1], z: angularVelocity[2] },
|
|
114
|
+
true
|
|
115
|
+
)
|
|
62
116
|
}
|
|
63
|
-
})
|
|
64
|
-
$effect.pre(() => rigidBodyInternal.setGravityScale(gravityScale, true))
|
|
65
|
-
$effect.pre(() => rigidBodyInternal.enableCcd(ccd))
|
|
66
|
-
$effect.pre(() => rigidBodyInternal.setDominanceGroup(dominance))
|
|
67
|
-
$effect.pre(() => rigidBodyInternal.lockRotations(lockRotations, true))
|
|
68
|
-
$effect.pre(() => rigidBodyInternal.lockTranslations(lockTranslations, true))
|
|
69
|
-
$effect.pre(() => rigidBodyInternal.setEnabledRotations(...enabledRotations, true))
|
|
70
|
-
$effect.pre(() => rigidBodyInternal.setEnabledTranslations(...enabledTranslations, true))
|
|
71
|
-
$effect.pre(() => rigidBodyInternal.setAngularDamping(angularDamping))
|
|
72
|
-
$effect.pre(() => rigidBodyInternal.setLinearDamping(linearDamping))
|
|
73
|
-
$effect.pre(() => rigidBodyInternal.setEnabled(enabled))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
117
|
+
})
|
|
118
|
+
$effect.pre(() => rigidBodyInternal.setGravityScale(gravityScale, true))
|
|
119
|
+
$effect.pre(() => rigidBodyInternal.enableCcd(ccd))
|
|
120
|
+
$effect.pre(() => rigidBodyInternal.setDominanceGroup(dominance))
|
|
121
|
+
$effect.pre(() => rigidBodyInternal.lockRotations(lockRotations, true))
|
|
122
|
+
$effect.pre(() => rigidBodyInternal.lockTranslations(lockTranslations, true))
|
|
123
|
+
$effect.pre(() => rigidBodyInternal.setEnabledRotations(...enabledRotations, true))
|
|
124
|
+
$effect.pre(() => rigidBodyInternal.setEnabledTranslations(...enabledTranslations, true))
|
|
125
|
+
$effect.pre(() => rigidBodyInternal.setAngularDamping(angularDamping))
|
|
126
|
+
$effect.pre(() => rigidBodyInternal.setLinearDamping(linearDamping))
|
|
127
|
+
$effect.pre(() => rigidBodyInternal.setEnabled(enabled))
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Add userData to the rigidBody
|
|
131
|
+
*/
|
|
132
|
+
$effect.pre(() => {
|
|
78
133
|
rigidBodyInternal.userData = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
134
|
+
events: {
|
|
135
|
+
oncollisionenter,
|
|
136
|
+
oncollisionexit,
|
|
137
|
+
oncontact,
|
|
138
|
+
onsensorenter,
|
|
139
|
+
onsensorexit,
|
|
140
|
+
onsleep,
|
|
141
|
+
onwake
|
|
142
|
+
},
|
|
143
|
+
...userData
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Setting the RigidBody context so that colliders can
|
|
149
|
+
* hook onto.
|
|
150
|
+
*/
|
|
151
|
+
setContext<RigidBodyContext>('threlte-rapier-rigidbody', rigidBodyInternal)
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Used by child colliders to restore transform
|
|
155
|
+
*/
|
|
156
|
+
setParentRigidbodyObject(object)
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Add the mesh to the context
|
|
160
|
+
*/
|
|
161
|
+
addRigidBodyToContext(rigidBodyInternal, object, {
|
|
104
162
|
oncollisionenter,
|
|
105
163
|
oncollisionexit,
|
|
106
164
|
oncontact,
|
|
@@ -108,22 +166,24 @@ addRigidBodyToContext(rigidBodyInternal, object, {
|
|
|
108
166
|
onsensorexit,
|
|
109
167
|
onsleep,
|
|
110
168
|
onwake
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* cleanup
|
|
173
|
+
*/
|
|
174
|
+
onDestroy(() => {
|
|
175
|
+
removeRigidBodyFromContext(rigidBodyInternal)
|
|
176
|
+
world.removeRigidBody(rigidBodyInternal)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
const parent3DObject = useParentObject3D()
|
|
180
|
+
createParentObject3DContext(object)
|
|
181
|
+
watch(parent3DObject, (parent) => {
|
|
182
|
+
parent?.add(object)
|
|
123
183
|
return () => {
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
})
|
|
184
|
+
parent?.remove(object)
|
|
185
|
+
}
|
|
186
|
+
})
|
|
127
187
|
</script>
|
|
128
188
|
|
|
129
189
|
{@render children?.({ rigidBody: rigidBodyInternal })}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RigidBody as RapierRigidBody } from '@dimforge/rapier3d-compat';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { Euler, Vector3 } from 'three';
|
|
4
|
-
import type { RigidBodyTypeString } from '../../lib/parseRigidBodyType';
|
|
5
|
-
import type { CreateEvent, RigidBodyEvents } from '../../types/types';
|
|
4
|
+
import type { RigidBodyTypeString } from '../../lib/parseRigidBodyType.js';
|
|
5
|
+
import type { CreateEvent, RigidBodyEvents } from '../../types/types.js';
|
|
6
6
|
export type Boolean3Array = [x: boolean, y: boolean, z: boolean];
|
|
7
7
|
export type RigidBodyProps = CreateEvent<RapierRigidBody> & RigidBodyEvents & {
|
|
8
8
|
rigidBody?: RapierRigidBody | undefined;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy, setContext, tick } from 'svelte'
|
|
3
|
+
import { createRapierContext } from '../../lib/createRapierContext.js'
|
|
4
|
+
import type { RapierContext } from '../../types/types.js'
|
|
5
|
+
import type { WorldProps } from './types.js'
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
gravity = [0, -9.81, 0],
|
|
6
9
|
rawIntegrationParameters,
|
|
7
10
|
rawIslands,
|
|
8
11
|
rawBroadPhase,
|
|
@@ -15,27 +18,55 @@ const rapierContext = createRapierContext([
|
|
|
15
18
|
rawQueryPipeline,
|
|
16
19
|
rawPhysicsPipeline,
|
|
17
20
|
rawSerializationPipeline,
|
|
18
|
-
rawDebugRenderPipeline
|
|
19
|
-
], {
|
|
21
|
+
rawDebugRenderPipeline,
|
|
20
22
|
framerate,
|
|
21
|
-
autoStart,
|
|
23
|
+
autoStart = true,
|
|
22
24
|
simulationStageOptions,
|
|
23
|
-
synchronizationStageOptions
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
synchronizationStageOptions,
|
|
26
|
+
children
|
|
27
|
+
}: WorldProps = $props()
|
|
28
|
+
|
|
29
|
+
const rapierContext = createRapierContext(
|
|
30
|
+
[
|
|
31
|
+
{ x: gravity[0], y: gravity[1], z: gravity[2] },
|
|
32
|
+
rawIntegrationParameters,
|
|
33
|
+
rawIslands,
|
|
34
|
+
rawBroadPhase,
|
|
35
|
+
rawNarrowPhase,
|
|
36
|
+
rawBodies,
|
|
37
|
+
rawColliders,
|
|
38
|
+
rawImpulseJoints,
|
|
39
|
+
rawMultibodyJoints,
|
|
40
|
+
rawCCDSolver,
|
|
41
|
+
rawQueryPipeline,
|
|
42
|
+
rawPhysicsPipeline,
|
|
43
|
+
rawSerializationPipeline,
|
|
44
|
+
rawDebugRenderPipeline
|
|
45
|
+
],
|
|
46
|
+
{
|
|
47
|
+
framerate,
|
|
48
|
+
autoStart,
|
|
49
|
+
simulationStageOptions,
|
|
50
|
+
synchronizationStageOptions
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
setContext<RapierContext>('threlte-rapier-context', rapierContext)
|
|
55
|
+
|
|
56
|
+
$effect.pre(() => {
|
|
27
57
|
if (gravity !== undefined) {
|
|
28
|
-
|
|
58
|
+
rapierContext.world.gravity = { x: gravity[0], y: gravity[1], z: gravity[2] }
|
|
29
59
|
}
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
$effect.pre(() => {
|
|
63
|
+
if (framerate !== undefined) rapierContext.framerate.set(framerate)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
onDestroy(async () => {
|
|
67
|
+
await tick()
|
|
68
|
+
rapierContext.world.free()
|
|
69
|
+
})
|
|
39
70
|
</script>
|
|
40
71
|
|
|
41
72
|
{@render children?.()}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { initRapier } from '../../lib/initRapier.svelte.js'
|
|
3
|
+
import InnerWorld from './InnerWorld.svelte'
|
|
4
|
+
import type { WorldProps } from './types.js'
|
|
5
|
+
|
|
6
|
+
let { fallback, children, ...rest }: WorldProps = $props()
|
|
4
7
|
</script>
|
|
5
8
|
|
|
6
9
|
{#await initRapier() then}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RawBroadPhase, RawCCDSolver, RawColliderSet, RawDebugRenderPipeline, RawImpulseJointSet, RawIntegrationParameters, RawIslandManager, RawMultibodyJointSet, RawNarrowPhase, RawPhysicsPipeline, RawQueryPipeline, RawRigidBodySet, RawSerializationPipeline } from '@dimforge/rapier3d-compat/raw';
|
|
1
|
+
import type { RawBroadPhase, RawCCDSolver, RawColliderSet, RawDebugRenderPipeline, RawImpulseJointSet, RawIntegrationParameters, RawIslandManager, RawMultibodyJointSet, RawNarrowPhase, RawPhysicsPipeline, RawQueryPipeline, RawRigidBodySet, RawSerializationPipeline } from '@dimforge/rapier3d-compat/raw.js';
|
|
2
2
|
import type { Key, Stage } from '@threlte/core';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import type { Vector3 } from 'three';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Euler, Quaternion, Vector3 } from 'three';
|
|
2
|
-
import { useJoint } from './useJoint';
|
|
3
|
-
import { isEuler, isVector3 } from './utils';
|
|
2
|
+
import { useJoint } from './useJoint.js';
|
|
3
|
+
import { isEuler, isVector3 } from './utils.js';
|
|
4
4
|
export const useFixedJoint = (anchorA, frameA, anchorB, frameB) => {
|
|
5
5
|
const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
|
|
6
6
|
const jfA = new Quaternion().setFromEuler(isEuler(frameA) ? frameA : new Euler(...frameA));
|
package/dist/hooks/useJoint.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MultibodyJoint, type ImpulseJoint, type RigidBody } from '@dimforge/rapier3d-compat';
|
|
2
|
-
import type { RapierContext } from '../types/types';
|
|
2
|
+
import type { RapierContext } from '../types/types.js';
|
|
3
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>;
|
package/dist/hooks/useJoint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MultibodyJoint } from '@dimforge/rapier3d-compat';
|
|
2
2
|
import { onDestroy } from 'svelte';
|
|
3
3
|
import { derived, get, writable } from 'svelte/store';
|
|
4
|
-
import { useRapier } from './useRapier';
|
|
4
|
+
import { useRapier } from './useRapier.js';
|
|
5
5
|
export const useJoint = (initializeJoint) => {
|
|
6
6
|
const rigidBodyA = writable(undefined);
|
|
7
7
|
const rigidBodyB = writable(undefined);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3 } from 'three';
|
|
2
|
-
import { useJoint } from './useJoint';
|
|
3
|
-
import { isVector3 } from './utils';
|
|
2
|
+
import { useJoint } from './useJoint.js';
|
|
3
|
+
import { isVector3 } from './utils.js';
|
|
4
4
|
export const usePrismaticJoint = (anchorA, anchorB, axis, limits) => {
|
|
5
5
|
return useJoint((rbA, rbB, { world, rapier }) => {
|
|
6
6
|
const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RapierContext } from '../types/types';
|
|
1
|
+
import type { RapierContext } from '../types/types.js';
|
|
2
2
|
export declare const useRapier: () => RapierContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3 } from 'three';
|
|
2
|
-
import { useJoint } from './useJoint';
|
|
3
|
-
import { isVector3 } from './utils';
|
|
2
|
+
import { useJoint } from './useJoint.js';
|
|
3
|
+
import { isVector3 } from './utils.js';
|
|
4
4
|
export const useRevoluteJoint = (anchorA, anchorB, axis, limits) => {
|
|
5
5
|
return useJoint((rbA, rbB, { world, rapier }) => {
|
|
6
6
|
const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RigidBodyContext } from '../types/types';
|
|
1
|
+
import type { RigidBodyContext } from '../types/types.js';
|
|
2
2
|
export declare const useRigidBody: () => RigidBodyContext | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3 } from 'three';
|
|
2
|
-
import { useJoint } from './useJoint';
|
|
3
|
-
import { isVector3 } from './utils';
|
|
2
|
+
import { useJoint } from './useJoint.js';
|
|
3
|
+
import { isVector3 } from './utils.js';
|
|
4
4
|
/**
|
|
5
5
|
* The rope joint limits the max distance between two bodies.
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3 } from 'three';
|
|
2
|
-
import { useJoint } from './useJoint';
|
|
3
|
-
import { isVector3 } from './utils';
|
|
2
|
+
import { useJoint } from './useJoint.js';
|
|
3
|
+
import { isVector3 } from './utils.js';
|
|
4
4
|
export const useSphericalJoint = (anchorA, anchorB) => {
|
|
5
5
|
return useJoint((rbA, rbB, { world, rapier }) => {
|
|
6
6
|
const jaA = isVector3(anchorA) ? anchorA : new Vector3(...anchorA);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { useRapier } from './hooks/useRapier';
|
|
2
|
-
export { useCollisionGroups } from './hooks/useCollisionGroups';
|
|
3
|
-
export { useRigidBody } from './hooks/useRigidBody';
|
|
4
|
-
export { usePhysicsTask } from './hooks/usePhysicsTask';
|
|
5
|
-
export { useRevoluteJoint } from './hooks/useRevoluteJoint';
|
|
6
|
-
export { usePrismaticJoint } from './hooks/usePrismaticJoint';
|
|
7
|
-
export { useFixedJoint } from './hooks/useFixedJoint';
|
|
8
|
-
export { useSphericalJoint } from './hooks/useSphericalJoint';
|
|
9
|
-
export { useJoint } from './hooks/useJoint';
|
|
10
|
-
export { useRopeJoint } from './hooks/useRopeJoint';
|
|
1
|
+
export { useRapier } from './hooks/useRapier.js';
|
|
2
|
+
export { useCollisionGroups } from './hooks/useCollisionGroups.js';
|
|
3
|
+
export { useRigidBody } from './hooks/useRigidBody.js';
|
|
4
|
+
export { usePhysicsTask } from './hooks/usePhysicsTask.js';
|
|
5
|
+
export { useRevoluteJoint } from './hooks/useRevoluteJoint.js';
|
|
6
|
+
export { usePrismaticJoint } from './hooks/usePrismaticJoint.js';
|
|
7
|
+
export { useFixedJoint } from './hooks/useFixedJoint.js';
|
|
8
|
+
export { useSphericalJoint } from './hooks/useSphericalJoint.js';
|
|
9
|
+
export { useJoint } from './hooks/useJoint.js';
|
|
10
|
+
export { useRopeJoint } from './hooks/useRopeJoint.js';
|
|
11
11
|
export { default as World } from './components/World/World.svelte';
|
|
12
12
|
export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
|
|
13
13
|
export { default as Debug } from './components/Debug/Debug.svelte';
|
|
@@ -15,5 +15,5 @@ export { default as Collider } from './components/Colliders/Collider/Collider.sv
|
|
|
15
15
|
export { default as AutoColliders } from './components/Colliders/AutoColliders/AutoColliders.svelte';
|
|
16
16
|
export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
|
|
17
17
|
export { default as Attractor } from './components/Attractor/Attractor.svelte';
|
|
18
|
-
export { computeBitMask } from './lib/computeBitMask';
|
|
19
|
-
export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderShapes, RapierContext, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent, GravityType, CreateEvent, Framerate } from './types/types';
|
|
18
|
+
export { computeBitMask } from './lib/computeBitMask.js';
|
|
19
|
+
export type { CollisionGroupsBitMask, AutoCollidersShapes, ColliderShapes, RapierContext, CollisionEnterEvent, CollisionExitEvent, SensorEnterEvent, SensorExitEvent, ContactEvent, GravityType, CreateEvent, Framerate } from './types/types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// hooks
|
|
2
|
-
export { useRapier } from './hooks/useRapier';
|
|
3
|
-
export { useCollisionGroups } from './hooks/useCollisionGroups';
|
|
4
|
-
export { useRigidBody } from './hooks/useRigidBody';
|
|
5
|
-
export { usePhysicsTask } from './hooks/usePhysicsTask';
|
|
2
|
+
export { useRapier } from './hooks/useRapier.js';
|
|
3
|
+
export { useCollisionGroups } from './hooks/useCollisionGroups.js';
|
|
4
|
+
export { useRigidBody } from './hooks/useRigidBody.js';
|
|
5
|
+
export { usePhysicsTask } from './hooks/usePhysicsTask.js';
|
|
6
6
|
// Joints
|
|
7
|
-
export { useRevoluteJoint } from './hooks/useRevoluteJoint';
|
|
8
|
-
export { usePrismaticJoint } from './hooks/usePrismaticJoint';
|
|
9
|
-
export { useFixedJoint } from './hooks/useFixedJoint';
|
|
10
|
-
export { useSphericalJoint } from './hooks/useSphericalJoint';
|
|
11
|
-
export { useJoint } from './hooks/useJoint';
|
|
12
|
-
export { useRopeJoint } from './hooks/useRopeJoint';
|
|
7
|
+
export { useRevoluteJoint } from './hooks/useRevoluteJoint.js';
|
|
8
|
+
export { usePrismaticJoint } from './hooks/usePrismaticJoint.js';
|
|
9
|
+
export { useFixedJoint } from './hooks/useFixedJoint.js';
|
|
10
|
+
export { useSphericalJoint } from './hooks/useSphericalJoint.js';
|
|
11
|
+
export { useJoint } from './hooks/useJoint.js';
|
|
12
|
+
export { useRopeJoint } from './hooks/useRopeJoint.js';
|
|
13
13
|
// components
|
|
14
14
|
export { default as World } from './components/World/World.svelte';
|
|
15
15
|
export { default as RigidBody } from './components/RigidBody/RigidBody.svelte';
|
|
@@ -19,4 +19,4 @@ export { default as AutoColliders } from './components/Colliders/AutoColliders/A
|
|
|
19
19
|
export { default as CollisionGroups } from './components/CollisionGroups/CollisionGroups.svelte';
|
|
20
20
|
export { default as Attractor } from './components/Attractor/Attractor.svelte';
|
|
21
21
|
// lib
|
|
22
|
-
export { computeBitMask } from './lib/computeBitMask';
|
|
22
|
+
export { computeBitMask } from './lib/computeBitMask.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Collider } from '@dimforge/rapier3d-compat';
|
|
2
|
-
import type { ColliderEvents, RigidBodyEvents } from '../types/types';
|
|
2
|
+
import type { ColliderEvents, RigidBodyEvents } from '../types/types.js';
|
|
3
3
|
export declare const applyColliderActiveEvents: (collider: Collider, colliderEvents?: ColliderEvents, rigidBodyEvents?: RigidBodyEvents) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Collider, RigidBody, World } from '@dimforge/rapier3d-compat';
|
|
2
2
|
import { type Object3D } from 'three';
|
|
3
|
-
import type { AutoCollidersShapes } from '../types/types';
|
|
3
|
+
import type { AutoCollidersShapes } from '../types/types.js';
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* Creates collider descriptions including default translations
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CurrentWritable, type Key, type Stage } from '@threlte/core';
|
|
2
|
-
import type { Framerate } from '../types/types';
|
|
2
|
+
import type { Framerate } from '../types/types.js';
|
|
3
3
|
export declare const createPhysicsStages: (framerate: CurrentWritable<Framerate>, simulationOffset: CurrentWritable<number>, updateRigidBodySimulationData: CurrentWritable<boolean>, options?: {
|
|
4
4
|
simulationStageOptions?: {
|
|
5
5
|
before?: (Key | Stage) | (Key | Stage)[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useStage, useThrelte } from '@threlte/core';
|
|
2
|
-
import { simulationKey, synchronizationKey } from './keys';
|
|
2
|
+
import { simulationKey, synchronizationKey } from './keys.js';
|
|
3
3
|
export const createPhysicsStages = (framerate, simulationOffset, updateRigidBodySimulationData, options) => {
|
|
4
4
|
let fixedStepTimeAccumulator = 0;
|
|
5
5
|
let simulationTime = 0;
|