r3f-native-orbitcontrols icon indicating copy to clipboard operation
r3f-native-orbitcontrols copied to clipboard

Release Event

Open MainzerKaiser opened this issue 1 year ago • 2 comments

Are there plans to introduce more methods to the OrbitControl than the onChange Event? I would like to trigger a function upon release of the touch event.

Wrapping the canvas with the orbitControl inside a view, a pressable or a TouchableWithoutFeedback and use its release event didnt work so far.

MainzerKaiser avatar Jan 13 '24 11:01 MainzerKaiser

Hi @MainzerKaiser, thanks for creating the issues, and sorry for the long delay in answering!

This seems like a great addition!

While this still hasn't been implemented, you can achieve almost the same behavior by using the touch events in the Canvas (though the behavior isn't the same when using multiple canvases with the same controls).

<View style={{ flex: 1 }} {...events}>
  <Canvas
    onTouchStart={() => { /*  */ }}
    onTouchMove={() => { /*  */ }}
    onTouchEnd={() => { /*  */ }}
    onTouchEndCapture={() => { /*  */ }}
    onTouchCancel={() => { /*  */ }}
  >
    <OrbitControls /* ... */>

    {/* ... */}
  </Canvas>
</View>

TiagoCavalcante avatar Feb 17 '24 22:02 TiagoCavalcante

Hi Tiago, thank you for the idea. The solution in the other issue regarding the first touch fix is related to this as i thought i have a performance issue. With the fix I can smoothly run my app with the onChange in the Orbitcrontrol with having up to 6 canvases in parallel on my android phone. Also, switching to the Canvas onTouchEnd leads to the problem of not having the orbit event (including target camera position). I would not know how to solve that yet. But there is no need anymore. Thanks for the hint anyways, that is much appreciated!!

MainzerKaiser avatar Feb 18 '24 08:02 MainzerKaiser