rnc-archive / react-native-webgl

DEPRECATED: use expo-gl – Implements WebGL for react-native
295 stars 73 forks source link

Add onFrame callback #30

Closed emilebres closed 4 years ago

emilebres commented 6 years ago

This pull request adds an onFrame callback as described in https://github.com/expo/expo/issues/538 and https://github.com/react-community/react-native-webgl/issues/14. The implementation may have some problems but it works on both Android and iOS. I updated the Three.js example to use the onFrame callback. Also add start/stop rotation on touch to Three.js example.

gre commented 6 years ago

Won't the self.onFrame call always be too late? I mean I don't think the react-native callback exec in sync so it's always scheduling for the next frame? At least it fixes doing too much frames.

I wonder if it should be called something like onAfterFrame because we could imagine another onFrame implementation that exec from the CPP javascriptcore runtime at the frame time, in sync. (But I have no idea if it even easily possible)

I wish @nikki93 can give his thoughts on this

gre commented 4 years ago

https://github.com/react-native-community/react-native-webgl/pull/100