Aidoru Posted December 5, 2016 Share Posted December 5, 2016 Hello, I'm trying to use realtime CSG, but rendering is really slow. I tried to use animation but it doesn't work, so i put code in registerBeforeRender function: scene.registerBeforeRender(function () { boxCSG = BABYLON.CSG.FromMesh(box1); cylinderCSG = BABYLON.CSG.FromMesh(cylinder); boxCSG = boxCSG.subtract(cylinderCSG); var newBox = boxCSG.toMesh("test", null, scene, false); cylinder.position.x -= 1; box1.dispose(); box1 = newBox; }); box1 and cylinder are simple Mesh created using CreateCylinder and CreateBox Could someone help me? Thank you. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 5, 2016 Share Posted December 5, 2016 Hey! what is your goal? (You cannot use CSG in registerBeforeRender because it will be called on every frame) Quote Link to comment Share on other sites More sharing options...
Aidoru Posted December 5, 2016 Author Share Posted December 5, 2016 Thank you Deltakosh for your answer, my goal is to use CSG at runtime, in that example I simply want to cut that box with cylinder, but if I use animation with an event attached I was only able to do it using a position of the cilinder (for example cylinder at x -2), but I want to "cut" all the part of box till stop (for example till x -10) and update box1 without reset it every call. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 5, 2016 Share Posted December 5, 2016 I see. you may need to provide a sample repro using the Playground to help us helping you Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 5, 2016 Share Posted December 5, 2016 One reminder though: CSG is not intended to be used in realtime so you have to be cautious when using it Quote Link to comment Share on other sites More sharing options...
Aidoru Posted December 5, 2016 Author Share Posted December 5, 2016 So probably the problem is that, I can't use it in realtime. My goal is something like you can see in that video. Do you think there is no way to do something like that? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 5, 2016 Share Posted December 5, 2016 Everything is possible:) But for this specific case you may end up with doing more code than expected Quote Link to comment Share on other sites More sharing options...
Aidoru Posted December 5, 2016 Author Share Posted December 5, 2016 The problem is that at the moment cutting "animation" is something like: translate in x + cut + render + stop + translate in x + cut + render + stop and so on...., and browser after a little time crash. Do you know any way to get a smooth cut animation? Without stop on every frame e without crash? Thank you Quote Link to comment Share on other sites More sharing options...
Wingnut Posted December 6, 2016 Share Posted December 6, 2016 Gruesome challenge. I think... if you switched to wire-frame... and "watched" CSG after CSG activity, you would understand why the browser crashes. I bet the wire-frame turns into a spaghetti festival... after 3-15 Boolean subtractions (trying to carve a channel). A monumental challenge... to do that video... real-time, with webGL. Way way difficult, I suspect. Possibly not feasible/plausible, but that's only my low-edu opinion. Quote Link to comment Share on other sites More sharing options...
Convergence Posted December 6, 2016 Share Posted December 6, 2016 Better to model the finished product and overlay all the grooves with meshes representing chunks that the chisel will 'remove'. No csg necessary and much better performance. Quote Link to comment Share on other sites More sharing options...
adam Posted December 6, 2016 Share Posted December 6, 2016 I bet this could be done with a GroundMesh. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted December 6, 2016 Share Posted December 6, 2016 Super-hi-rez heightMap? nod. Not really removing vertices... just lowering them to the depth of the cut channel. phew. But yeah, that would stand a chance of being successful. Wow, interesting idea. Quote Link to comment Share on other sites More sharing options...
JohnK Posted December 8, 2016 Share Posted December 8, 2016 @Aidoru @Wingnut couldn't resist the interesting idea. Went for a sort of semi voxel approach. Not all that successful but kept me happy for a couple of days. Still rather slow loading and slow working and there are more than likely many better ways to achieve a better result. For what it is worth here is a PG http://www.babylonjs-playground.com/#1Y33PT#0 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.