ThreeCSG icon indicating copy to clipboard operation
ThreeCSG copied to clipboard

Porting to C++ to WASM

Open avalero opened this issue 5 years ago • 7 comments

I am porting this great lib to C++ to be compiled to WASM using ecmscripten. Just to let you know. It is so to speak a blind porting, as I am not really going into the algorithms, just "translating" to C++.

The goal is to recude the computation time.

It is to be used in https://beta.bitbloq.cc/app/playground/3d

avalero avatar Jun 06 '19 16:06 avalero

FYI there is a https://github.com/chandlerprall/ThreeCSG/tree/v1 branch that is a complete rewrite. The split-plane selection algorithm needs small optimization pass, but otherwise it's stable.

chandlerprall avatar Jun 06 '19 17:06 chandlerprall

Great to know .I wish I would have known one week ago! 😅 But I'll work on new version. Thanks! You've done a great job!

avalero avatar Jun 06 '19 18:06 avalero

Hi @chandlerprall ,

I have migrated bitbloq to v1 and performace (from computation time point of view) is lower. CSG operations take 2 o 3 times more time to finish. Is this expected?

avalero avatar Jun 14 '19 09:06 avalero

That's almost definitely from the split-plane selection. I'll set a reminder for myself and address that in about 12 hours.

chandlerprall avatar Jun 14 '19 15:06 chandlerprall

I'm going to take some extra time to look at a wider spread of solutions for this, but for now, changing

https://github.com/chandlerprall/ThreeCSG/blob/v1/src/BSPNode.ts#L13

to return triangles[0];

resets that part of the algorithm to mimic what's on the master branch. It's a lot faster for generating BSPs, but the resulting BSP is far from optimal.

chandlerprall avatar Jun 15 '19 02:06 chandlerprall

嗨@chandlerprall,

我已将bitbloq迁移到v1,并且Performanceace(从计算时间的角度来看)较低。CSG操作需要2到3倍的时间才能完成。这是预期的吗? Have you transplanted successfully now?How fast, I also wanted to make a wasm to speed up recently.

WREQI avatar Oct 30 '19 03:10 WREQI

this link is broken now; did it mean

function chooseDividingTriangle(triangles: Triangle[]): Triangle | undefined {
  return triangles[0];
}

?

makc avatar Dec 01 '19 16:12 makc