fdeng Posted July 2, 2018 Share Posted July 2, 2018 Hi Everyone, I'm a newbie to Babylon.js, I got a question need someone to help. When I load a 3D model (eg. obj format model) with Babylon.js, it shows a different result than I expected. The correct result should be : (The door is on the left side) But with Babylon.js, the model is like below : (the door is on the right side, it seems that all the meshs are rendered opposite direction) Can anybody tell me why? Is there a parameter that can be set to correct this issue? Quote Link to comment Share on other sites More sharing options...
sable Posted July 2, 2018 Share Posted July 2, 2018 The model might be right handed. You could try: scene.useRightHandedSystem = true; fdeng 1 Quote Link to comment Share on other sites More sharing options...
fdeng Posted July 3, 2018 Author Share Posted July 3, 2018 @sable Yes, it works after set scene.useRightHandedSystem = true; Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 3, 2018 Share Posted July 3, 2018 If you have the original model and are exporting it to .OBJ yourself then you can export without needing the scene to be right handed: The obj model should be exported with -Z axis forward, and Y axis upward to be compatible with Babylon.js https://doc.babylonjs.com/how_to/obj Those options are available in ie: Blender export. Quote Link to comment Share on other sites More sharing options...
fdeng Posted July 13, 2018 Author Share Posted July 13, 2018 @sable Hi, There is another issue with this right-hand model if the active camera is a FreeCamera. When the mouse moves in left - right direction, the model moves up - down, while move the mouse up - down, the model moves left - right. Can anybody tell me how to fix it? Quote Link to comment Share on other sites More sharing options...
sable Posted July 13, 2018 Share Posted July 13, 2018 Would you be able to make a pg showing that behaviour? It might though be easier to just export the model as left handed as per @brianzinn above,. Quote Link to comment Share on other sites More sharing options...
fdeng Posted July 13, 2018 Author Share Posted July 13, 2018 @sable @brianzinn Thanks for you guys' help. I just found that I set the rotation of FreeCamera mistake, sorry, please ignore the mouse move issue. As the exporting tool I use has no such exporting option, I can't get a left handed model. Still, there is something trouble me, it seems that babylon has Y as the up-axis, the building is not standing correctly. Normally I should see the front, not the bottom of the building. (You can use ArcRotateCamera to have a look what the building is) could you please help me on this point. The PG is below: https://playground.babylonjs.com/#4QU0BY Quote Link to comment Share on other sites More sharing options...
acarvallo Posted July 13, 2018 Share Posted July 13, 2018 Hi @fdeng It looks like many CAD/3D software (mainly for buildings) have the height on the Z axis, while Babylon or other WebGL libraries have Y. I encountered the same issue and I used a pivot matrix on my mesh to flip the two axis : https://playground.babylonjs.com/#4QU0BY#2 On lines 25-26 you can see the 1's are switched, an untouched matrix would look like this : 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 (You can also put values different than 1, and it will scale on the corresponding axis) There might be others/better solutions but in my case it seems to work great, and allows to keep original positions. 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.