ecctrl icon indicating copy to clipboard operation
ecctrl copied to clipboard

ecctrlRef.current.translation() causes null pointer

Open campbellgoe opened this issue 1 year ago • 4 comments

Here's my component:

import { useFrame } from '@react-three/fiber'

const Respawn = ({ ecctrlRef, setPos, levelPos }) => {
  useFrame(() => {
    if (ecctrlRef.current) {
      try {
        const { y } = ecctrlRef.current.translation()
        if (y < 0) {
          // this random hack ensures position is reset
          setPos(levelPos.map(a => a + Math.random() * 0.02 - 0.01))
        }
      } catch (err) {
        console.warn('error in getting ecctrl translation', err)
      }
    }
  })
  return null
}

export { Respawn }

And I'm getting this in the console:

Respawn.jsx:13 error in getting ecctrl translation Error: null pointer passed to rust
    at I3.wbg.__wbindgen_throw (chunk-GZS6NCTV.js?v=4fa056a0:2477:13)
    at 0057ee2e:0x14f24a
    at 0057ee2e:0x14f257
    at 0057ee2e:0x11b55b
    at _AA.rbTranslation (chunk-GZS6NCTV.js?v=4fa056a0:1811:18)
    at lA.translation (chunk-GZS6NCTV.js?v=4fa056a0:2650:26)
    at Object.current (Respawn.jsx:7:41)
    at render$1 (chunk-PEHQA6ZE.js?v=4fa056a0:17451:22)
    at loop (chunk-PEHQA6ZE.js?v=4fa056a0:17474:19)

The player does respawn in the level so the code works mostly, but it's strange it's throwing the null pointer error.

Thanks.

campbellgoe avatar Apr 25 '24 06:04 campbellgoe

Other users have reported this issue, we thought it could be related to Rapier Ray. I'll need to do more tests to figure this out.

ErdongChen-Andrew avatar Apr 28 '24 23:04 ErdongChen-Andrew

any updates on this?

MULUALEM-TEKLE avatar Jan 16 '25 16:01 MULUALEM-TEKLE

+1, having this too

gwendall avatar Mar 25 '25 10:03 gwendall

+1, still relevant.

  • my dependencies: "@react-three/drei": "^10.0.5", "@react-three/fiber": "^9.1.0", "@react-three/rapier": "^2.0.0", "ecctrl": "^1.0.92", "react": "^19.0.0", "react-dom": "^19.0.0", "three": "^0.174.0"

ovitorhilario avatar Mar 26 '25 23:03 ovitorhilario