mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
101.55k stars 35.29k forks source link

ThreeCSG does not work with the three/editor #3609

Closed menasce closed 11 years ago

menasce commented 11 years ago

Hello, I copied (verbatim) the editor (beta) from threejs.org/editor into my own private area. I verified that my replica works locally exactly like the original. Since it does, I tried to add the following lines of code (from 46 to 63 ) to the MenubarAdd.js script of the editor (I need to be able to perform boolean operations on solids using csg.js and it's wrapper for three.js, ThreeCSG.js):

temp

The problem is that what I assume to be the most up-to-date repository, namely https://github.com/chandlerprall/ThreeCSG/blob/master/ThreeCSG.js contains and object named ThreeBSP and not what I would expect, ThreeCSG. Firebug therefore complains that Three.CSG (line 53) is undefined. I'm definitely confused.

Can you please point me to the correct repository of csg.js and ThreeCSG.js in order to accomplish this simple exercise?

I tried also to download csg.js and ThreeCSG.js from http://www.chandlerprall.com/2011/12/constructive-solid-geometry-with-three-js/ but in that case I get the following error (using Firebug):

temp

Can anyone please help me?

WestLangley commented 11 years ago

As stated in the guidelines, help requests should be directed to stackoverflow. This board is for bugs and feature requests.

mrdoob commented 11 years ago

@chandlerprall ping?

chandlerprall commented 11 years ago

@menasce the github repo is the most up to date, and has no dependency on Evan Wallace's csg.js. As you noted, it (confusingly) creates a ThreeBSP object instead of ThreeCSG. Please look at the examples file to see the new usage.

menasce commented 11 years ago

I tried the example you mention: I spent some additional time on this and found out that your ThreeCSG.js code spends an awful amount of time in a deep recursion (I'm using your example.html code as-is from the github repository as you suggested). The recursion happens at lines 444 and 448 (below a snapshot of ThreeCSG.js which I stepped into with Firebug): temp I'm not sure what are you trying to do there, but you're creating a lot of nodes and the browser becomes more and more sluggish, popping up several times the "your script is taking too long".

If I substitute the sphere with another cube in your examples.html (at line 44 below), everything works well (even in my modified version of the three/editor). It's just the sphere that causes this deep recursion. temp

Thanks for the time you're spending on this.

chandlerprall commented 11 years ago

@menasce please recreate this issue on the ThreeCSG issue tracker as it isn't a problem with Three.js