chandlerprall / ThreeCSG

CSG plugin for Three.js
MIT License
453 stars 152 forks source link

Porting to C++ to WASM #53

Open avalero opened 5 years ago

avalero commented 5 years ago

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

chandlerprall commented 5 years ago

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.

avalero commented 5 years ago

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 commented 5 years ago

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?

chandlerprall commented 5 years ago

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

chandlerprall commented 5 years ago

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.

WREQI commented 5 years ago

嗨@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.

makc commented 4 years ago

this link is broken now; did it mean

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

?