JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
This PR preserves the color attribute when applying operations like offset and extrude and project.
This seems like a clear improvement for users of JSCAD. If you have a 2D object with color like on the left, would you expect extrusion to preserve the color? Or lose it?
If someone really want no color, it's easy to remove using colorize. But if you want to preserve color of sub-components through an operation... there's really no good way to do it without this change.
All Submissions:
[x] Have you followed the guidelines in our Contributing document?
[x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
This PR preserves the color attribute when applying operations like
offset
andextrude
andproject
.This seems like a clear improvement for users of JSCAD. If you have a 2D object with color like on the left, would you expect extrusion to preserve the color? Or lose it?
preserve-color.js
```js import * as jscad from '@jscad/modeling' const { colorize } = jscad.colors const { extrudeLinear } = jscad.extrusions const { square } = jscad.primitives const { translate } = jscad.transforms export const main = () => { const obj2d = [ colorize([1, 0, 0], square({ center: [0, -4] })), colorize([0, 1, 0], square({ center: [0, 0] })), colorize([0, 0, 1], square({ center: [0, 4] })), ] return [ translate([-4, 0], obj2d), translate([4, 0, 0], extrudeLinear({}, obj2d)), ] } ```If someone really want no color, it's easy to remove using
colorize
. But if you want to preserve color of sub-components through an operation... there's really no good way to do it without this change.All Submissions: