supermedium / aframe-react

:atom: Build virtual reality experiences with A-Frame and React.
https://ngokevin.github.io/aframe-react-boilerplate/
MIT License
1.42k stars 151 forks source link

Pass array or object as position instead of "0 1 -5"? #12

Closed meta-meta closed 8 years ago

meta-meta commented 8 years ago

I'm wondering if you have any strong opinions on how this should work. It's inconvenient to have to convert a Vector3 into a string that a-frame can work with. Should this be handled by aframe-react? Or should this be some external utility function? Likewise for rotation and scale, maybe even color: convert RGB to Hex?

I currently do this:

let {x,y,z} = someVectorObject
position={`${x} ${y} ${z}`}

would be nice to be able to do this:

position={someVectorObject}

and/or

position={[x, y, z]}
ngokevin commented 8 years ago

Yeah, that would be nice. I wonder of passing an {x, y, z} object works already. For taking an array, I think I can make that happen on the A-Frame level.

meta-meta commented 8 years ago

Passing an {x, y, z} object does not work. I believe aframe parses the "x y z" string into an {x y z} but won't accept an object.

I don't know that it would be advantageous to accept an array at the aframe level. I believe you'd have to JSON.stringify([x, y, z]) to pass the array as an attribute. If a developer has to do that, they might as well just transform it to a string that aframe already accepts.

And then in the pure HTML case, I definitely would prefer "x y z" to '["x","y","z"]'.

mayognaise commented 8 years ago

:+1:

ngokevin commented 8 years ago

https://github.com/ngokevin/aframe-react/pull/20