facebookarchive / react-360

Create amazing 360 and VR content using React
https://facebook.github.io/react-360
Other
8.73k stars 1.23k forks source link

[Question] Component world-coordinates #261

Closed timoxley closed 6 years ago

timoxley commented 7 years ago

Is there a recommended way to get the world coordinates of a ReactVR Component, either from the component itself or externally by querying/walking the scene graph?

For example, how would you:

It seems this is currently only possible if all the components in question are absolutely positioned, immediate children of a single parent View.

I asked a similar question on stackoverflow a few days ago, and someone suggested I open an issue here.

edit note the replies below regarding camera-relative positioning/coordinates probably belong in a different issue. This question is specifically requesting advice on how to read the camera-agnostic, world position of elements in a scene, at arbitrary levels of View nesting.

hggeorgiev commented 7 years ago

I have a similar issue - I'm trying to position a nested component using position: 'absolute', but it's still placed relatively to its parent elements. I suppose we need some equivalent of posiiton: 'fixed'.

copypasteearth commented 7 years ago

id like to have a model always 1 meter in front of the VrHeadModel centered on the screen anyone know how to acomplish this? maybe they could make a helper class or something, they say the point of reactVR is to make things easy on us haha

hggeorgiev commented 7 years ago

@copypasteearth I have a similar case as well. Still haven't had luck achieving it. If I do, I will post here.

timoxley commented 7 years ago

@copypasteearth the usual way to do that is to make the item a child of the camera object (or the camera's container, whatever transforms the camera). Then when the camera is moved or rotated, the object will automatically have those transformations applied as well. I'm not sure what the best way to achieve this is with ReactVR.

mikearmstrong001 commented 7 years ago

Currently there is not a way to describe this relationship in React VR. It is possible to use the headmodel but this will lag by a frame or so as the two sets of code run asynchronously. The way we are looking at this problem is via a component which would take on the transform of the head, input controller etc in the runtime. eg

<Attachment type="head'>
  <Model ... />
</Attachment>

There are some loose ends to tie up to make sure this scales how we anticipate, I think it would fit your requirements though.

timoxley commented 7 years ago

@mikearmstrong001 any comments/suggestions regarding the original question i.e. local -> world coordinates?

hggeorgiev commented 7 years ago

I agree that having a <Camera/> or <Head/> component would be great for attaching and de-attaching things to the user's head. Non-diegetic UI would be very easy to implement this way.

mannyhenri commented 7 years ago

Is it me but as we add more items into the 3D space we constantly have to reposition the other items. Anyone else facing the same issue and/or what's the solution?

timoxley commented 7 years ago

@mannyhenri this is off-topic for this issue, however I think you may simply need to use absolute positioning to disable the flexbox layout.

andrewimm commented 6 years ago

This behavior is now supported with the introduction of Locations, which are mount points that can be controlled from the client.