Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum call stack size exceeded #34

Open
pooriamo opened this issue Jun 2, 2017 · 1 comment
Open

Maximum call stack size exceeded #34

pooriamo opened this issue Jun 2, 2017 · 1 comment

Comments

@pooriamo
Copy link

pooriamo commented Jun 2, 2017

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?

@DanielJoyce
Copy link

Looks like it should use a stack for bsp state and not the call stack...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants