Jump to content

Using CSG


Aidoru
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...