Pryme8 Posted August 28, 2018 Share Posted August 28, 2018 https://doc.babylonjs.com/how_to/gui3d I cant find on here how to use my own mesh as a button... I might be just dumb and am overlooking it. *UPDATE* I think this is it: var pushButton = new BABYLON.GUI.MeshButton3D(mesh, "pushButton"); Quote Link to comment Share on other sites More sharing options...
Guest Posted August 28, 2018 Share Posted August 28, 2018 Well it is right here: https://doc.babylonjs.com/how_to/gui3d#meshbutton3d Demo: https://www.babylonjs-playground.com/#8Y780Y#20 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2018 Author Share Posted August 28, 2018 Hmmm, maybe there might be a better way to do what I need. Is there a fast way/better way to position meshes in accordance to 2d screenspace not 3d. Or should I just use the GUI3d and the MeshButton with no interactions. Quote Link to comment Share on other sites More sharing options...
Guest Posted August 28, 2018 Share Posted August 28, 2018 well why not just unprojecting the 2d coordinates into 3d like here: https://github.com/BabylonJS/Babylon.js/blob/0d5a115ffa1eabde8d330b4068e3bcf49810ad24/src/Culling/babylon.ray.ts#L335 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2018 Author Share Posted August 28, 2018 Vector3.UnprojectFloatsToRef(x, y, 0, viewportWidth, viewportHeight, world, view, projection, this.origin); where do I get the world, view, projection, and this origin vars? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 28, 2018 Share Posted August 28, 2018 world must be set to Identity as you want world coordinates view = camera.getViewMatrix() projection = camera.getProjectionMatrix() this.origin is the result vector3: you must provide one to store the result Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2018 Author Share Posted August 28, 2018 Ok I am struggling, I am trying to effectively have 3d Meshes stay in an even spaced manor stay in the bottom right of the screen in front of all other things being rendered. The camera never moves but the screens size might not be consistent. Like a 3d Ammo Bar. Ive tried messing with the 3dGUI but I seem to be flubbing and cant even see the meshes. It might be because of renderGroupId's though or possibly I cant use Instances as the mesh? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 28, 2018 Share Posted August 28, 2018 Probably because of rendergroupid My technique should work btw, on every frame you call my code to make sure the meshes stay at the correct position Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2018 Author Share Posted August 28, 2018 Roger that. Quote Link to comment Share on other sites More sharing options...
DylanD Posted August 28, 2018 Share Posted August 28, 2018 it is interesting that when you try to set the position of the panel to the camera it forces the camera to the position of the panel. See here: https://www.babylonjs-playground.com/#8Y780Y#28 it also does the same with the opposite, setting the cameras position to the panel which was expected. https://www.babylonjs-playground.com/#8Y780Y%2329 In this one they move a bit they move back, so interesting Quote Link to comment Share on other sites More sharing options...
DylanD Posted August 28, 2018 Share Posted August 28, 2018 did it? https://www.babylonjs-playground.com/#8Y780Y#32 set anchor.parent = camera; or the player or whatever. Quote Link to comment Share on other sites More sharing options...
DylanD Posted August 28, 2018 Share Posted August 28, 2018 oh maybe you meant, where its positioned on the screen, not if it will follow... lol whoops hope it helps anyway! maybe just switch to a regular panel not a cylinder one... Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2018 Author Share Posted August 28, 2018 I think I figured out a work around for now. using some hacky math and simple positioning with rendergroupID's pulled it off. 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.