firtoz / react-three-renderer

Render into a three.js canvas using React.
https://toxicfork.github.com/react-three-renderer-example/
MIT License
1.49k stars 155 forks source link

Add 'up' property to Object3D #141

Open Blackth0rn opened 7 years ago

Blackth0rn commented 7 years ago

Added the 'up' property to the Object3DDescriptor class to allow setting the 'up' vector for cameras (and other objects), see: https://threejs.org/docs/?q=Cam#Reference/Core/Object3D.up for THREE documentation on the property.

Added a brief item to the documentation for the Object3D class to note the new property being added.

toxicFork commented 7 years ago

Hmm... this is one of those special cases where we may need to decide on priority:

I am thinking if quaternion exists use that, then rotation, then fwd/up perhaps? Any thoughts?

Blackth0rn commented 7 years ago

I hadn't thought of that, was just following what three.js had and trying to work out why my camera was sideways :)

Using the rotation or quaternion sounds pretty reasonable however from looking in the three.js source it seems that the 'up' property is only used by the Object3D.lookAt function. In this function (https://github.com/mrdoob/three.js/blob/dev/src/core/Object3D.js#L274) the rotation/quaternion seem to be ignored so I guess the 'up' value could be defaulted to the rotation/quaternion if the 'up' prop isn't set on an Object3D, which would be the opposite priority order to what you have listed though. 'up' is used if set, if not then check for a quaternion or rotation and use that?