docs/csg.js
function(cuberadius) {
            var csg = this.reTesselated();

            var result = new CSG();

            // make a list of all unique vertices
            // For each vertex we also collect the list of normals of the planes touching the vertices
            var vertexmap = {};
            csg.polygons.map(function(polygon) {
                polygon.vertices.map(function(vertex) {
                    vertexmap[vertex.getTag()] = vertex.pos;
                });
            });

            for (var vertextag in vertexmap) {
                var pos = vertexmap[vertextag];
                var cube = CSG.cube({
                    center: pos,
                    radius: cuberadius
                });
                result = result.unionSub(cube, false, false);
            }
            result = result.reTesselated();
            return result;
        }
function(cuberadius) {
            var csg = this.reTesselated();

            var result = new CSG();

            // make a list of all unique vertices
            // For each vertex we also collect the list of normals of the planes touching the vertices
            var vertexmap = {};
            csg.polygons.map(function(polygon) {
                polygon.vertices.map(function(vertex) {
                    vertexmap[vertex.getTag()] = vertex.pos;
                });
            });

            for (var vertextag in vertexmap) {
                var pos = vertexmap[vertextag];
                var cube = CSG.cube({
                    center: pos,
                    radius: cuberadius
                });
                result = result.unionSub(cube, false, false);
            }
            result = result.reTesselated();
            return result;
        }
function ( cuberadius ) { var csg = this . reTesselated ( ) ; var result = new CSG ( ) ; // make a list of all unique vertices // For each vertex we also collect the list of normals of the planes touching the vertices var vertexmap = { } ; csg . polygons . map ( function ( polygon ) { polygon . vertices . map ( function ( vertex ) { vertexmap [ vertex . getTag ( ) ] = vertex . pos ; } ) ; } ) ; for ( var vertextag in vertexmap ) { var pos = vertexmap [ vertextag ] ; var cube = CSG . cube ( { center : pos , radius : cuberadius } ) ; result = result . unionSub ( cube , false , false ) ; } result = result . reTesselated ( ) ; return result ; }
For debugging Creates a new solid with a tiny cube at every vertex of the source solid
For debugging Creates a new solid with a tiny cube at every vertex of the source solid