You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm experimenting with Rapier for physics in a voxel world - mostly things work great, but I'm seeing a lot of non-physical behavior when ball primitives collide with edges or corners of adjacent voxels. I'm using Typescript but at a guess it's probably not TS related.
Visually, here's a repro of an egregious example - a ball object shoots into a 3x3x3 block of voxels, and depending on the positioning will pass through the chunk, only bouncing around the inside.
Screen.Recording.2026-08-16.at.22.49.31.mov
Code reproduction is below.
I noticed this TODO comment in the voxels-ball collision code, so I guess maybe this results from a known issue? If so, I thought maybe the repro steps might make it easier to fix.
But I should note that the thing in the video isn't the only bug I saw - generally whenever a ball primitive collides with the edge of two adjacent voxels, depending on the angle/velocity/etc the collision often sends the ball off in a nonphysical direction.
Thanks for checking!
Minimal repro of what's in the video (in an empty world except for the 3x3x3 span of solid voxels). If you check the console logs, after 15-20 ticks the ball projectile is fully within the solid voxels.
importRAPIERfrom"@dimforge/rapier3d-compat"consttimestep=1/60constticks=20constprojectileRadius=0.25constblockMinimum=5constblockMaximum=7constvoxelData=newInt32Array(3*3*3*3)letindex=0for(lety=blockMinimum;y<=blockMaximum;y+=1){for(letz=blockMinimum;z<=blockMaximum;z+=1){for(letx=blockMinimum;x<=blockMaximum;x+=1){voxelData[index]=xvoxelData[index+1]=yvoxelData[index+2]=zindex+=3}}}/** * Reproduces a sphere shooting into the top edge of a 3×3×3 voxel cube, * then passing into the interior and bouncing around inside. */exportconstrunReproduction=async()=>{awaitRAPIER.init()constworld=newRAPIER.World({x: 0,y: -10,z: 0})constevents=newRAPIER.EventQueue(true)try{constterrain=RAPIER.ColliderDesc.voxels(voxelData,{x: 1,y: 1,z: 1}).setFriction(0.8).setRestitution(0)world.createCollider(terrain)constprojectile=world.createRigidBody(RAPIER.RigidBodyDesc.dynamic().setTranslation(5.068835807168076,10.666715670475918,10.803566521990922).setLinvel(5.966327745035736,-12.77696104762374,-14.182813529984893).setCcdEnabled(true),)constprojectileCollider=RAPIER.ColliderDesc.ball(projectileRadius).setDensity(1).setFriction(0.8).setRestitution(0.45).setActiveEvents(RAPIER.ActiveEvents.COLLISION_EVENTS)world.createCollider(projectileCollider,projectile)letcollisionStartCount=0for(lettick=0;tick<ticks;tick+=1){world.timestep=timestepworld.step(events)events.drainCollisionEvents((_first,_second,started)=>{if(started)collisionStartCount+=1if(started)console.log(`tick ${tick+1}: collision start event`)})console.log(`tick ${tick+1}: position=${JSON.stringify(projectile.translation())}`)}return{position: projectile.translation(),velocity: projectile.linvel(),
collisionStartCount,}}finally{events.free()world.free()}}runReproduction().then((result)=>{console.info("Rapier voxel-ball repro result",result)})
Hi! I'm experimenting with Rapier for physics in a voxel world - mostly things work great, but I'm seeing a lot of non-physical behavior when ball primitives collide with edges or corners of adjacent voxels. I'm using Typescript but at a guess it's probably not TS related.
Visually, here's a repro of an egregious example - a ball object shoots into a 3x3x3 block of voxels, and depending on the positioning will pass through the chunk, only bouncing around the inside.
Screen.Recording.2026-08-16.at.22.49.31.mov
Code reproduction is below.
I noticed this TODO comment in the voxels-ball collision code, so I guess maybe this results from a known issue? If so, I thought maybe the repro steps might make it easier to fix.
But I should note that the thing in the video isn't the only bug I saw - generally whenever a ball primitive collides with the edge of two adjacent voxels, depending on the angle/velocity/etc the collision often sends the ball off in a nonphysical direction.
Thanks for checking!
Minimal repro of what's in the video (in an empty world except for the 3x3x3 span of solid voxels). If you check the console logs, after 15-20 ticks the ball projectile is fully within the solid voxels.
Log output: