ThreeCSG
ThreeCSG copied to clipboard
Maximum call stack size exceeded
Hello
I have 2 STL models imported via this code (simplified):
var A, B;
var loader = new THREE.STLLoader();
// Load Object A
loader.load( './stl/A.stl', function ( geometry ) {
material = new THREE.MeshPhongMaterial( {
color: 0xffffff
} );
A = new THREE.Mesh( geometry, material );
scene.add( A );
} );
// Load object B
loader.load( './stl/B.stl', function ( geometry ) {
material = new THREE.MeshPhongMaterial( {
color: 0xffffff
} );
B = new THREE.Mesh( geometry, material );
scene.add( B );
} );
Now I'm goint to use ThreeCSG to subtract B from A (At first I had the problem of unsupported geometry error and after some googling I got here, creating geometries from buffer geometry, that error has gone but the new error appeared! ):
// convert buffer geometry to geometry
var A_geometry = new THREE.Geometry().fromBufferGeometry( A.geometry );
var B_geometry = new THREE.Geometry().fromBufferGeometry( B.geometry );
// convert to BSP
var A_bsp = new ThreeBSP( A_geometry );
var B_bsp = new ThreeBSP( B_geometry );
// subtract
var subtract_bsp = A_bsp.subtract( B_bsp );
// convert back to mesh
var result = subtract_bsp.toMesh();
// add to the scene
scene.add(result);
But the error I get:
ThreeCSG.js:434 Uncaught RangeError: Maximum call stack size exceeded
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:434)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
at new window.ThreeBSP.ThreeBSP.Node (ThreeCSG.js:455)
I think it's because the faces of the STL files are too large (each about 200,000). Is there a way to handle this?
Looks like it should use a stack for bsp state and not the call stack...