babbleon Posted May 3, 2018 Share Posted May 3, 2018 Hello, Can mesh.lookAt be hardcoded into a .babylon file? If so, how? I have a few meshes in blender that I would like to use the 'Track To' constraint but I see that these are not supported for meshes in the exporter, whereas they are for cameras. I am hoping I can tweak the Blender > Bablyon exporter. I appreciate I can do the same thing in the js script, but I'd rather have Blender and the exporter do it for me. Cheers, Quote Link to comment Share on other sites More sharing options...
Guest Posted May 3, 2018 Share Posted May 3, 2018 I don't think we are calling mesh.lookAt during Babylon files loading. We can think about adding a target property on mesh exportation and use this info (could be a vector3 or another node) to set the mesh.lookAt on it at loading time Quote Link to comment Share on other sites More sharing options...
babbleon Posted May 4, 2018 Author Share Posted May 4, 2018 Thank you @Deltakosh, I have got this to work and for anyone else looking to do the same, here goes: in the Blender exporter mesh.py, I added this above # hasSkeleton detection & skeletonID determination: # constraint for constraint in object.constraints: if constraint.type == 'TRACK_TO': self.lockedTargetId = constraint.target.name break and this above # Sub meshes: # constraint if hasattr(self, 'lockedTargetId'): file_handler.write('\n,"metadata":[{') write_string(file_handler, 'lookAt', self.lockedTargetId, True) file_handler.write('}]') You can now apply a constraint in Blender: And here's a PG showing example: http://www.babylonjs-playground.com/#JJIEPB There's probably a better / neater way of doing it but it works for me. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 4, 2018 Share Posted May 4, 2018 Why not doing a PR? this is definitely a good idea to share! Quote Link to comment Share on other sites More sharing options...
babbleon Posted May 8, 2018 Author Share Posted May 8, 2018 Thank you. Created a PR here: https://github.com/BabylonJS/Exporters/pull/179 Not done a PR before, so hopefully is correct. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted May 8, 2018 Share Posted May 8, 2018 Thanks. As anyone who has ever did a PR knows, doing the first PR is more about figuring out the process than the change. You did fine in that respect. As far as the content, I think BillBoarding actually fully does this already. I did not really pay attention to this topic till it was already solved. I'll wait till @Deltakosh is back, but some other thoughts as well. Camera.py also uses track to for ArcRotate & follow cameras, but of course a camera can only track one mesh (that's where billboarding came in) Billboarding is implemented in the GAME Engine render, which has been removed for Blender 2.8. I do not know if or how this is replaced in EEVEE. There is a branch in the repo for 2.8, called EEVEE. I have not done anything yet, but thought was going to initially just start ripping stuff out till it ran on a 2.8 build. Kind of worried that I might be too early & some things might not be added back yet. The result might inform as to your approach being required though. If you wished to play with the ripping out on the EEVEE branch that would be great. Just keep deleting (probably all of Materials) till it runs. No need to be really careful, once we know what the full scope of what needs to change, that branch can just be trashed & recreated. Just do not merge to Master, or your local repo will need to be rebuilt. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted May 8, 2018 Share Posted May 8, 2018 Ok, I realized this is between 2 meshes, not a mesh and a camera, so will put this through. 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.