Giter VIP home page Giter VIP logo

Comments (3)

macrozone avatar macrozone commented on May 24, 2024

@Secretmapper not yet, but that might make sense for that.

usually you "control" all node properties from react, but in this case, its computed. Are there any more properties that should be readable?

from react-native-arkit.

code-matt avatar code-matt commented on May 24, 2024

@macrozone for something like position or rotation being updated at 60fps, would it be better to access the native objects this way and avoid RN re-renders for performance reasons ?

from react-native-arkit.

macrozone avatar macrozone commented on May 24, 2024

@code-matt

you cannot access it directly anyway. it always involves serialisation.

in case of rotation, this is what happens:

  • you update the rotation property of your Ar-Component (e.g. with Animated Library) once per frame (requestAnimationFrame)
  • it will serialize these updates and send these to native
  • native part will apply the new values to the internal scenekit-nodes

so the scenekit nodes will reflect whats in your react-tree.

But in case the scenekit nodes gets rotated by something else (e.g. physics), then we have a problem, because you no longer know its real rotation (or even position). In this case, you would need some mechanism to get the new properties from scenekit: either a callback onRotation or similar. or an imperative api to get the current values getNodeProperties (e.g. getNodeProperties(nodeId, "textNode.boundingBox"), or some api on the node's ref as you suggest. But this will involve serialisation anyway.

Some more thoughts:

  • react-native team seems to do some bigger changes regarding js <--> native communication that might help in this case, but i don't know how it will look like.
  • something like shared-memory would be the most efficient way, but i doubt that this is possible given the sandbox nature of most js-vms, but who knows...

And some more tipps about rotation or changing properties quickly:

  • usually the 16ms timeframe is enough to update, but it leads to more cpu usage than needed. And if the js thread is blocked, you get stutters.
  • There is a transition property on ar components, that will use scenekit to change values smoothly to a new value, similar how css transitions work. Use that to smooth things out. You can even experiment with reducing your update-interval-frequency

from react-native-arkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.