add jscad debugging helper

This commit is contained in:
Stewart Allen 2022-02-26 12:42:06 -05:00
commit fb9e10eb6c
2 changed files with 12 additions and 2 deletions

View file

@ -29,7 +29,7 @@
"connect": "^3.7.0", "connect": "^3.7.0",
"earcut": "^2.2.3", "earcut": "^2.2.3",
"express-useragent": "^1.0.13", "express-useragent": "^1.0.13",
"@jscad/modeling": "^2.7.1", "@jscad/modeling": "^2.7.2",
"jszip": "^3.7.1", "jszip": "^3.7.1",
"moment": "^2.24.0", "moment": "^2.24.0",
"pixi.js": "^4.8.9", "pixi.js": "^4.8.9",

View file

@ -3,13 +3,20 @@
"use strict"; "use strict";
// dep: geo.base // dep: geo.base
// jscad dep injected in app so it comes before everything else
gapp.register("geo.csg", [], (root, exports) => { gapp.register("geo.csg", [], (root, exports) => {
const { base } = root; const { base } = root;
const debug = false;
const CSG = { const CSG = {
union() { union() {
if (debug) {
for (let p of [ ...arguments ].map(a => a.polygons.map(p => p.vertices))) {
console.log(JSON.stringify(p));
}
}
return jscadModeling.booleans.union(...arguments); return jscadModeling.booleans.union(...arguments);
}, },
@ -30,7 +37,10 @@ const CSG = {
// Construct a CSG from a THREE Geometry BufferAttribute array (or similar) // Construct a CSG from a THREE Geometry BufferAttribute array (or similar)
fromPositionArray(array) { fromPositionArray(array) {
let polys = []; const polys = [];
if (debug) {
array = [...array].map(v => v.round(3));
}
for (let i=0, l=array.length; i<l; ) { for (let i=0, l=array.length; i<l; ) {
polys.push([ [ polys.push([ [
array[i++], array[i++],