-
Similar to my previous question, I'm translating a project from OpenSCAD to JSCAD. This line has an OpenSCAD Is there any way for me to scale in an extrusion? Thank you 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
I just realized I may be able to use extrudeFromSlices for a similar effect, I'll just have to specify the 2D shapes for both ends. I'd still love to hear alternate answers though! Edit: after reading through |
Beta Was this translation helpful? Give feedback.
-
to be able to suggest sth in jscad i would need an example how that scale parameter affects the result
is the whole object scaled or just one end of the extrusion ? |
Beta Was this translation helpful? Give feedback.
-
there is no such option in extrudeLinear, but a utilit func can be made using const jscad = require('@jscad/modeling')
const {transform, translate, scale} = jscad.transforms
const {circle} = jscad.primitives
const {geom2} = jscad.geometries
const {mat4} = jscad.maths
const {extrudeFromSlices, extrudeLinear, slice} = jscad.extrusions
// extrudeFromSlices is complicated, especially because of usage of slices
function extrudeLinerScaled({height=1,scaleTop=1}, base){
const callback = (progress,index)=>{
let localshape = base
if(index> 0) localshape = scale([scaleTop,scaleTop,scaleTop],base)
const shape = slice.fromSides(geom2.toSides(localshape))
const out = slice.transform(mat4.fromTranslation([],[0, 0, index*height]), shape)
return out
}
return extrudeFromSlices({numberOfSlices:2, callback},base)
}
const main = ()=>{
return [
translate([20,0,0],extrudeLinear({height:20}, circle({radius:6}))),
extrudeLinerScaled({height:20, scaleTop:0.5}, circle({radius:6}))
]
}
module.exports = {main} |
Beta Was this translation helpful? Give feedback.
-
@abejfehr also if you use discord you can find me there https://discord.com/channels/775984095250612234/914627480512503829 still, it is good to have questions like this here on github for others to find |
Beta Was this translation helpful? Give feedback.
there is no such option in extrudeLinear, but a utilit func can be made using
extrudeFromSlices