Closed abbazabacto closed 3 years ago
Was not able to push a branch on this repo, here my local git diff
if that will help you in any way adding this feature request (lines with +
are added).
diff --git a/src/hooks.ts b/src/hooks.ts
index aa15c9c..5662c66 100644
--- a/src/hooks.ts
+++ b/src/hooks.ts
@@ -15,6 +15,7 @@ export type AtomicProps = {
sleepTimeLimit?: number
collisionFilterGroup?: number
collisionFilterMask?: number
+ collisionResponse?: number
fixedRotation?: boolean
}
@@ -269,6 +270,7 @@ function useBody(
collisionFilterMask: makeAtomic('collisionFilterMask', index),
+ collisionResponse: makeAtomic('collisionResponse', index),
fixedRotation: makeAtomic('fixedRotation', index),
// Apply functions
applyForce(force: number[], worldPoint: number[]) {
diff --git a/src/worker.js b/src/worker.js
index 68fa155..d44c45e 100644
--- a/src/worker.js
+++ b/src/worker.js
@@ -144,6 +144,7 @@ self.onmessage = (e) => {
material,
shapes,
onCollide,
+ collisionResponse,
...extra
} = props[i]
@@ -155,6 +156,10 @@ self.onmessage = (e) => {
})
body.uuid = uuid[i]
+ if (collisionResponse !== undefined) {
+ body.collisionResponse = collisionResponse
+ }
+
if (type === 'Compound') {
shapes.forEach(({ type, args, position, rotation, material, ...extra }) => {
const shapeBody = body.addShape(
@@ -262,6 +267,9 @@ self.onmessage = (e) => {
case 'setCollisionFilterMask':
bodies[uuid].collisionFilterMask = props
break
+ case 'setCollisionResponse':
+ bodies[uuid].collisionResponse = props
+ break
case 'setFixedRotation':
bodies[uuid].fixedRotation = props
break
would also love this feature :)
Each body has a
collisionResponse
property which can be set after instantiation.Setting the
collisionResponse
to0
will keep the collision detection, without applying contact forces on collision.