0

I am try to implement a threecsg library, but when trying to use the functions implemented I get an error saying: "Uncaught RangeError: Maximum call stack size exceeded at Plane.splitPolygon (code.html:229)"

the code is:

    /******Code ommitted above******/
    // Split `polygon` by this plane if needed, then put the polygon or polygon
    // fragments in the appropriate lists. Coplanar polygons go into either
    // `coplanarFront` or `coplanarBack` depending on their orientation with
    // respect to this plane. Polygons in front or in back of this plane go into
    // either `front` or `back`.
    splitPolygon(polygon, coplanarFront, coplanarBack, front, back) {   //this is the line with issues
        var COPLANAR = 0;
        var FRONT = 1;
        var BACK = 2;
        var SPANNING = 3;

        // Classify each point as well as the entire polygon into one of the above
        // four classes.
        var polygonType = 0;
        var types = [];
        for (var i = 0; i < polygon.vertices.length; i++) {
            var t = this.normal.dot(polygon.vertices[i].pos) - this.w;
            var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
            polygonType |= type;
            types.push(type);
        }
    /******code omitted below******/
Fort-P
  • 5
  • 6
  • That error almost always means you've got infinite recursion going on. Either from `splitPolygon` calling itself infinitely, or from it being involved in a group of functions which successively call each other and never stop. It's not clear from your code snippet that this is happening, but it might well be in the "code omitted below", and/or combined with other functions you've not shown us. (Looking at the callstack of the error should make it clearer what's happening though!) – Robin Zigmond Dec 15 '20 at 22:28
  • 2
    Your code sample doesn't show the issue, but it's most certainly hitting a recursion limit. This question has many helpful answers: [Maximum call stack size exceeded error](https://stackoverflow.com/questions/6095530/maximum-call-stack-size-exceeded-error) – M - Dec 15 '20 at 22:30

0 Answers0