Last active
February 4, 2022 05:54
-
-
Save t1u1/81cf1c9e4d4cce1d0eaf8b1ec6ebff5d to your computer and use it in GitHub Desktop.
Extrude Glitch test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jscad = require('@jscad/modeling') | |
const { union } = jscad.booleans | |
const { extrudeLinear } = jscad.extrusions | |
const { hullChain } = jscad.hulls | |
const { circle } = jscad.primitives | |
const { vectorText } = jscad.text | |
const { translate } = jscad.transforms | |
// Build text by creating the font strokes (2D), then extruding up (3D). | |
const text = (message, extrusionHeight, characterLineWidth, segments) => { | |
const lineRadius = characterLineWidth / 2 | |
const lineCorner = circle({ radius: lineRadius, segments: segments }) | |
const lineSegmentPointArrays = vectorText({ x: 0, y: 0, input: message }) // line segments for each character | |
const lineSegments = [] | |
lineSegmentPointArrays.forEach((segmentPoints) => { // process the line segment | |
const corners = segmentPoints.map((point) => translate(point, lineCorner)) | |
lineSegments.push(hullChain(corners)) | |
}) | |
const message2D = union(lineSegments) | |
const message3D = extrudeLinear({ height: extrusionHeight }, message2D) | |
return message3D; | |
} | |
const main = (params) => { | |
let objs = []; | |
objs.push(text("4", 2, 1, 26)) | |
objs.push(translate([-30,0,0], text("4", 2, 2, 20))) | |
objs.push(translate([-80,0,0], text("7", 2, 2, 32))) | |
objs.push(translate([-80,40,0], text("F", 2, 1, 25))) | |
objs.push(translate([-30,40,0], text("N", 2, 2, 13))) | |
return objs; | |
} | |
module.exports = { main } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment