paperElectron Posted September 4, 2014 Share Posted September 4, 2014 Hey all, I'm looking for some direction on snapping objects into position against other objects edges. I'm also looking to define a snap point on an object and use that to lock it into another objects corresponding point. The first problem is essentially voxel drawing with irregular sized objects (all prisms), I need to be able to click on a face and have the new object placed in relation to the face that I clicked. So if I cast a ray and it finds the top face of an object, the new objects bottom face should align with it. (and snap to whichever side edge the mouse was closer to?) I imagine the second problem as having a little sphere attached to the objects mesh in an arbitrary location, and using that spheres center point to snap into the nearest objects corresponding anchor point. Like defining a hook on an object and using it to snap onto a clothesline. The Babylon.js API is pretty huge and I'm not at all familiar with it, but I have a reasonable grasp of the concepts involved. Any direction or suggestions on how to make a system as I described work would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 4, 2014 Share Posted September 4, 2014 wild guess, but I am assuming that once these 2 objects are 'snapped together', that the behaviour you wish to see is they now move as one? If so, after they are positioned in the correct relation to one another (world space), you could parent one to the other. After that only move / rotate / scale the parent and the relationship will take care of the child. If you wish move the child after that, it gets tricky. Quote Link to comment Share on other sites More sharing options...
paperElectron Posted September 4, 2014 Author Share Posted September 4, 2014 wild guess, but I am assuming that once these 2 objects are 'snapped together', that the behaviour you wish to see is they now move as one? No, not immediately anyway, Once they are positioned they are pretty much going to be static. If I wanted to move them as a group I guess they would have to be put into a group, moved, then removed from the group. But I'm not really concerned with the after yet, as I still haven't fully conceptualized the "before" yet. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 10, 2014 Share Posted September 10, 2014 Hi paperElectron! Have you ever heard of a "Voronoi Diagram"? I have heard rumors that some of the very best "snap tech"... uses such things, or related formulas. I would love to tell you that Babylon.js team has a library of snap-related methods and classes... but that's not the case. This subject is somewhat related to the "slide-along" subject that was momentarily raised in the Smooth Camera Follow thread. These types of things are not really framework-layer things, but instead, scene-assembly tools. But PE, I can almost sure-promise... that if you get some good snap algorithms, code, demos, tests, etc... then Babylon.js admin would LOVE to include some/all of it... in the Babylon.js tools department (with your permission). Snap is important for almost all of us... but especially for those who are building editors and scene layout applications. One suggestion... is Blender. Find its 'align' code and steal the crap out of it, if applicable. Also, find the authors of great 3D snaps that you see in video games and other applications, and just camp on the author's lawn until they agree to donate their time to help with webGL snap tech. And most importantly, tell us of your adventures... right here... on the forum. Meantime, c'mon snappers... let's hear from you guys. My comment here is just noise. Anyone got more info on snapping? Cough it up! 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.