Izzimach / react-three-legacy

React bindings to create and control a 3D scene using three.js
Other
1.52k stars 128 forks source link

issues setting rotation when constructing a 3d object #77

Closed eeh closed 8 years ago

eeh commented 8 years ago

Hello,

It seems that it is not possible to set rotation on 3d object using this strategy:

<Object3D position={somePosition} quaternion={someQuat} />

I believe that this is due to some changes on three.js -- the issue disappears when downgrading to three.js rev 68, but it is evident on current rev 74.

I had a look around, and in current three.js versions, many of the relevant properties are defined using Object.defineProperty, making it impossible to replace the contents in runtime (as you do in the Object3DMixin), at least when using recent versions of Chrome.

It would be great if you were able to switch to another strategy when setting properties on Object3D's.

Thanks, Emil

Izzimach commented 8 years ago

Can you run any of the examples? Most of the examples set rotation via the quaternion prop, so I'm not sure that is the problem.

The thing with defineProperty shouldn't be a problem since the position and rotation are set not by replacing members but using the set or copy methods.

eeh commented 8 years ago

This is peculiar. I am pretty certain that I saw code setting quaternion directly (using = ) earlier. Maybe i had an older version of your library kicking around somehow?

Was that recently changed?

Anyway, still can't get it to work, but now I know that it's most likely my code that is bad.

Sorry for the confusion...

Izzimach commented 8 years ago

No worries. At some point threejs switched over to using quaternions as the default representation for rotation (previously it was either euler angles or axis-angle) so that might be related to the issues you're seeing.

In any case, if you do manage to generate some broken code (perhaps by modifying cupcake.js) please post it here so I can reproduce.

eeh commented 8 years ago

I sort of got around the issue by using rotation with a THREE.Euler instead of quaternion, don't know what I did wrong earlier. I guess I deserve that for randomly copying stuff off the Internet and expecting it to work! ;-)

Thanks anyway!