Democore Posted July 13, 2016 Share Posted July 13, 2016 Hey everyone, I'm currently facing the problem, that whenever I try to rotate a Mesh using the .rotation property, it won't rotate at all. It only works via the rotate() method. Example: m.rotate(BABYLON.Axis.X, Math.PI/4, BABYLON.Space.WORLD); //works m.rotation.x = Math.PI/4; //won't work m.rotation = new BABYLON.Vector3(Math.PI/4, 0, 0); //won't work The code gets executed from an event handler. Changing scale and position works no problem btw. I also checked several .babylon models, which all had the same problem. I feel like I'm missing something big, since this is such a basic feature. Any Help is much appreciated! Quote Link to comment Share on other sites More sharing options...
adam Posted July 13, 2016 Share Posted July 13, 2016 The rotate function rotates a mesh on an axis by a certain amount. The rotation property is used to set the mesh to a particular rotation. This PG might help: http://playground.babylonjs.com/#NZXLT#1 Quote Link to comment Share on other sites More sharing options...
Democore Posted July 14, 2016 Author Share Posted July 14, 2016 Hey adam, thanks for the responce! I'm aware of what the difference between the two methods is. The Problem is, that I want to set the rotation to a static value using mesh.rotation, which is not working. If I'd use mesh.rotate(), the mesh would turn further instead of snapping to the right rotation. Quote Link to comment Share on other sites More sharing options...
adam Posted July 14, 2016 Share Posted July 14, 2016 It would help if you created a PG that demonstrates the issue you're having. Quote Link to comment Share on other sites More sharing options...
Temechon Posted July 14, 2016 Share Posted July 14, 2016 If you try on an imported mesh, you have to first reset the rotaionQuaternion : m.rotationQuaternion = null; m.rotation.x = Math.PI/4; adam and Democore 2 Quote Link to comment Share on other sites More sharing options...
Democore Posted July 14, 2016 Author Share Posted July 14, 2016 2 hours ago, Temechon said: If you try on an imported mesh, you have to first reset the rotaionQuaternion : m.rotationQuaternion = null; m.rotation.x = Math.PI/4; Yep, that was it! Thanks so much! Why is this not documented in the rotation documentation? Quote Link to comment Share on other sites More sharing options...
adam Posted July 14, 2016 Share Posted July 14, 2016 What version of BabylonJS are you using @Democore ? This doesn't seem to be an issue in 2.5. Quote Link to comment Share on other sites More sharing options...
Democore Posted July 14, 2016 Author Share Posted July 14, 2016 I managed to reproduce the problem in a playground: http://playground.babylonjs.com/#NDPY6 But as I allready stated, Temechon's solution worked for me adam 1 Quote Link to comment Share on other sites More sharing options...
adam Posted July 14, 2016 Share Posted July 14, 2016 I wonder what's causing the issue. In this PG I am able to rotate box6 using rotation even though it has a rotationQuaternion. http://playground.babylonjs.com/#NZXLT#3 Democore 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 14, 2016 Share Posted July 14, 2016 @adam : this is something new introduced by bjs 2.4. @Democore: this is documented http://doc.babylonjs.com/overviews/How_Rotations_and_Translations_Work ( rotation will be used if rotationQuaternion property is null (This is the default behavior). rotationQuaternion is used if both are set. ) regarding your PG it was a bug in cache engine it is fixed now! adam and Democore 2 Quote Link to comment Share on other sites More sharing options...
Democore Posted July 14, 2016 Author Share Posted July 14, 2016 Cool, thanks for clearing things up! GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.