Transformable patterns (#2824)
This commit is contained in:
26
src/wasm-lib/tests/executor/inputs/pattern_vase.kcl
Normal file
26
src/wasm-lib/tests/executor/inputs/pattern_vase.kcl
Normal file
@ -0,0 +1,26 @@
|
||||
// Parameters
|
||||
const r = 50 // base radius
|
||||
const h = 10 // layer height
|
||||
const t = 0.005 // taper factor [0-1)
|
||||
// Defines how to modify each layer of the vase.
|
||||
// Each replica is shifted up the Z axis, and has a smoothly-varying radius
|
||||
fn transform = (replicaId) => {
|
||||
let scale = r * abs(1 - (t * replicaId)) * (5 + cos(replicaId / 8))
|
||||
return {
|
||||
translate: [0, 0, replicaId * 10],
|
||||
scale: [scale, scale, 0],
|
||||
}
|
||||
}
|
||||
// Each layer is just a pretty thin cylinder with a fillet.
|
||||
fn layer = () => {
|
||||
return startSketchOn("XY") // or some other plane idk
|
||||
|> circle([0, 0], 1, %, 'tag1')
|
||||
|> extrude(h, %)
|
||||
// |> fillet({
|
||||
// radius: h / 2.01,
|
||||
// tags: ["tag1", getOppositeEdge("tag1", %)]
|
||||
// }, %)
|
||||
}
|
||||
// The vase is 100 layers tall.
|
||||
// The 100 layers are replica of each other, with a slight transformation applied to each.
|
||||
let vase = layer() |> patternTransform(100, transform, %)
|
@ -2464,3 +2464,10 @@ async fn serial_test_global_tags() {
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/global_tags.png", &result, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_pattern_vase() {
|
||||
let code = include_str!("inputs/pattern_vase.kcl");
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/pattern_vase.png", &result, 0.999);
|
||||
}
|
||||
|
BIN
src/wasm-lib/tests/executor/outputs/pattern_vase.png
Normal file
BIN
src/wasm-lib/tests/executor/outputs/pattern_vase.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 333 KiB |
Reference in New Issue
Block a user