react-three-rapier icon indicating copy to clipboard operation
react-three-rapier copied to clipboard

textures disappear on InstancedRigidBodies when moving or changing pointer

Open s0-david opened this issue 1 year ago • 4 comments

when i move around or change the pointer direction, the textures on InstancedRigidBodies vanish. it works fine with instances from drei.

"@react-three/rapier": "^1.3.1", "three": "^0.165.0", "next": "14.2.3",

Screenshot 2024-06-06 at 1 25 50 AM

https://github.com/pmndrs/react-three-rapier/assets/54137057/1f75a827-8438-4b2f-aa72-7e144ca9a7b8

any help or suggestions would be appreciated!

s0-david avatar Jun 05 '24 16:06 s0-david

useEffect(() => {
    meshRef.current?.computeBoundingBox()
  }, [blocks])

ok so calling the method solved the issue

s0-david avatar Jun 06 '24 09:06 s0-david

and computeBoundingSphere too...

s0-david avatar Jun 06 '24 10:06 s0-david

on onAfterShadow

s0-david avatar Jun 06 '24 10:06 s0-david

It's because of frustumCulled (this is set by default, it checks every frame if the object is in the frustum of the camera before rendering the object. If set to false the object gets rendered every frame even if it is not in the frustum of the camera.)

You either need to set boundingBox\Sphere big enough to cover possible translations of instances or set <instancedMesh frustumCulled={false}

oknesar avatar Oct 07 '24 09:10 oknesar