Skip to content

Commit

Permalink
fix: Recent changes broke patch's colorizePolygons
Browse files Browse the repository at this point in the history
  • Loading branch information
joeng03 committed Mar 11, 2024
1 parent 96ab861 commit 0ecff0c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"@box2d/debug-draw": "^0.10.0",
"@jscad/modeling": "2.9.6",
"@jscad/regl-renderer": "^2.6.1",
"@jscad/stl-serializer": "^2.1.13",
"@jscad/stl-serializer": "2.1.11",
"ace-builds": "^1.25.1",
"classnames": "^2.3.1",
"dayjs": "^1.10.4",
Expand Down
33 changes: 14 additions & 19 deletions patches/@jscad+modeling+2.9.6.patch
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,15 @@ index 85720f4..9ef2a9d 100644
-declare function toPolygons(geometry: Geom3): Array<Poly3>
+declare function toPolygons(geometry: Geom3, colorizePolygons: boolean): Array<Poly3>
diff --git a/node_modules/@jscad/modeling/src/geometries/geom3/toPolygons.js b/node_modules/@jscad/modeling/src/geometries/geom3/toPolygons.js
index 25f9f50..300aaa4 100644
index 25f9f50..bdb9f16 100644
--- a/node_modules/@jscad/modeling/src/geometries/geom3/toPolygons.js
+++ b/node_modules/@jscad/modeling/src/geometries/geom3/toPolygons.js
@@ -1,5 +1,20 @@
@@ -1,5 +1,15 @@
+const poly3 = require("../poly3")
const applyTransforms = require('./applyTransforms')

+// Colorize poly3
+const colorPoly3 = (color, object) => {
+ // const newpoly = poly3.clone(object)
+ // newpoly.color = color
+ // return newpoly
+ // console.log(object.color)
+ // console.log(color)
+ if(!object.color) {
+ object.color = color
+ }
Expand All @@ -43,7 +38,7 @@ index 25f9f50..300aaa4 100644
/**
* Produces an array of polygons from the given geometry, after applying transforms.
* The returned array should not be modified as the polygons are shared with the geometry.
@@ -10,6 +25,12 @@ const applyTransforms = require('./applyTransforms')
@@ -10,6 +20,12 @@ const applyTransforms = require('./applyTransforms')
* @example
* let sharedpolygons = toPolygons(geometry)
*/
Expand Down Expand Up @@ -143,7 +138,7 @@ index a9370c9..14b674b 100644
}

diff --git a/node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js b/node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js
index b43dd86..6ac481d 100644
index b43dd86..0e45987 100644
--- a/node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js
+++ b/node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js
@@ -15,9 +15,8 @@ const intersectGeom3Sub = (geometry1, geometry2) => {
Expand All @@ -153,8 +148,8 @@ index b43dd86..6ac481d 100644
- const a = new Tree(geom3.toPolygons(geometry1))
- const b = new Tree(geom3.toPolygons(geometry2))
-
+ const a = new Tree(geom3.toPolygons(geometry1, colorizePolygons = true))
+ const b = new Tree(geom3.toPolygons(geometry2, colorizePolygons = true))
+ const a = new Tree(geom3.toPolygons(geometry1, true))
+ const b = new Tree(geom3.toPolygons(geometry2, true))
a.invert()
b.clipTo(a)
b.invert()
Expand All @@ -171,7 +166,7 @@ index df86fec..dba2983 100644
}

diff --git a/node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js b/node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js
index 62eb4cd..815ab38 100644
index 62eb4cd..196a7e0 100644
--- a/node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js
+++ b/node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js
@@ -15,8 +15,8 @@ const subtractGeom3Sub = (geometry1, geometry2) => {
Expand All @@ -180,8 +175,8 @@ index 62eb4cd..815ab38 100644

- const a = new Tree(geom3.toPolygons(geometry1))
- const b = new Tree(geom3.toPolygons(geometry2))
+ const a = new Tree(geom3.toPolygons(geometry1, colorizePolygons = true))
+ const b = new Tree(geom3.toPolygons(geometry2, colorizePolygons = true))
+ const a = new Tree(geom3.toPolygons(geometry1, true))
+ const b = new Tree(geom3.toPolygons(geometry2, true))

a.invert()
a.clipTo(b)
Expand Down Expand Up @@ -227,7 +222,7 @@ index cf9c591..af1842c 100644
}

diff --git a/node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js b/node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js
index a4026e3..2751e56 100644
index a4026e3..3dc6158 100644
--- a/node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js
+++ b/node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js
@@ -14,8 +14,8 @@ const unionSub = (geometry1, geometry2) => {
Expand All @@ -236,8 +231,8 @@ index a4026e3..2751e56 100644

- const a = new Tree(geom3.toPolygons(geometry1))
- const b = new Tree(geom3.toPolygons(geometry2))
+ const a = new Tree(geom3.toPolygons(geometry1, colorizePolygons = true))
+ const b = new Tree(geom3.toPolygons(geometry2, colorizePolygons = true))
+ const a = new Tree(geom3.toPolygons(geometry1, true))
+ const b = new Tree(geom3.toPolygons(geometry2, true))

a.clipTo(b, false)
// b.clipTo(a, true); // ERROR: doesn't work
// b.clipTo(a, true); // ERROR: doesn't work
15 changes: 5 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -773,11 +773,6 @@
resolved "https://registry.yarnpkg.com/@jscad/array-utils/-/array-utils-2.1.4.tgz#05e93c7c0ccaab8fa5e81e3ec685aab9c41e7075"
integrity sha512-c31r4zSKsE+4Xfwk2V8monDA0hx5G89QGzaakWVUvuGNowYS9WSsYCwHiTIXodjR+HEnDu4okQ7k/whmP0Ne2g==

"@jscad/[email protected]":
version "2.11.1"
resolved "https://registry.yarnpkg.com/@jscad/modeling/-/modeling-2.11.1.tgz#a700417b7b768690a5bd21163642c79f597910ca"
integrity sha512-DPrbLcLHDJ1nbpB5FiMwy/DXCdJGkpDyDZQTYHwzK3Fq91x4iPOAABAKkX1QgJ7zlhitMNWo+j7+RmjMzqbYCw==

"@jscad/[email protected]":
version "2.9.6"
resolved "https://registry.yarnpkg.com/@jscad/modeling/-/modeling-2.9.6.tgz#a107e0de932dcdf7777c1dc639a68a9a6e78b9e9"
Expand All @@ -794,13 +789,13 @@
gl-vec3 "1.1.3"
regl "2.1.0"

"@jscad/stl-serializer@^2.1.13":
version "2.1.14"
resolved "https://registry.yarnpkg.com/@jscad/stl-serializer/-/stl-serializer-2.1.14.tgz#9ce9a95b6e636cee8d30608279266bd4d7d3ecd1"
integrity sha512-+q1DIX66iwx1wWLN4x0ASXbykqsIEeGzImZ7sG+xz6hMflaHIK1riiorTSMF8sF2uWZrTMOmODGlNxe3/fh35g==
"@jscad/[email protected].11":
version "2.1.11"
resolved "https://registry.yarnpkg.com/@jscad/stl-serializer/-/stl-serializer-2.1.11.tgz#2732c41a79c0c97c396f639c6b13c752e65c3da9"
integrity sha512-WvqV4PyG36HS3x1BROg8MAX7s/M7wCgA3GeOUZ8jgpQATCBvvI845ds9njZBRHZNvNUkV35AiV5nwBnZB2A9Gw==
dependencies:
"@jscad/array-utils" "2.1.4"
"@jscad/modeling" "2.11.1"
"@jscad/modeling" "2.9.6"

"@nodelib/[email protected]":
version "2.1.5"
Expand Down

0 comments on commit 0ecff0c

Please sign in to comment.