Files
modeling-app/public/kcl-samples/kitt/main.kcl
Jonathan Tran 69553fded7 test: Vendor kcl-samples and add simulation tests for them (#5460)
* Change to unzip

* Download kcl-samples as zip to public dir

* Fix fetch:samples, e2e electron still not working

* Change error message to be clearer

* Refactor so that input and output directories of sim tests can be different

* Add kcl samples test implementation

* Update output since adding kcl_samples tests

* Update kcl-samples branch

* Fix git-ignore pattern to only apply to the root

* Fix yarn install and yarn fetch:samples to work the first time

* Remove unneeded exists check

* Change to use kcl-samples in public directory

* Add kcl-samples

* Update output since updating kcl-samples

* Update output files

* Change to not fetch samples during yarn install

* Update output after merge

* Ignore kcl-samples in codespell

* WIP: Don't run e2e if only kcl-samples changed

* Conditionally run cargo tests

* Fix to round floating point values in program memory arrays

* Update output since merge and rounding numbers in memory

* Fix memory redaction for floating point to find more values

* Fix float redaction pattern

* Update output since rounding floating point numbers

* Add center to floating point pattern

* Fix trigger to use picomatch syntax

* Update output since rounding center

* Remove kcl-samples github workflows

* Enable Rust backtrace

* Update output after re-running

* Update output after changing order of post-extrude commands

* Fix to have deterministic order of commands

* Update output after reverting ordering changes

* Update kcl-samples

* Update output after updating samples

* Fix error messages to show the names of all samples that failed

* Change cargo test command to match current one

* Update kcl-samples

* Update output since updating kcl-samples

* Add generate manifest workflow and yarn script

* Fix error check to actually work

* Change util function to be what we actually need

* Move new files after merge

* Fix paths since directory move

* Add dependabot updates for kcl-samples

* Add GitHub workflow to make PR to kcl-samples repo

* Add GitHub workflow to check kcl-samples header comments

* Fix worfklow to change to the right directory

* Add auto-commit simulation test output changes

* Add permissions to workflows

* Fix to run git commit step

* Install just if needed

* Fix directory of justfile

* Add installation of cargo-insta

* Fix to use underscore

* Fix to allow just command failure

* Change to always install CLI tools and cache them

* Trying to fix overwrite failing

* Combine commands

* Change reviewer

* Change to PR targeting the next branch

* Change git commands to not do unnecessary fetch

* Comment out trigger for creating a PR

* Update kcl-samples from next branch

* Update outputs after kcl-samples change

* Fix to use bash pipefail

* Add rust backtrace

* Print full env from sim tests

* Change command to use long option name

* Fix to use ci profile even when calling through just

* Add INSTA_UPDATE=always

* Fix git push by using an app token on checkout

* Add comments

* Fix to use bash options

* Change to echo when no changes are found

* Fix so that kcl-samples updates don't trigger full run

* Fix paths to reflect new crate location

* Fix path detection

* Fix e2e job to ignore kcl_samples simulation test output

* Fix the fetch logic for the KCL samples after vendoring (#5661)

Fixes the last 2 E2E tests for #5460.

---------

Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Frank Noirot <frank@zoo.dev>
2025-03-06 18:01:24 -05:00

257 lines
9.6 KiB
Plaintext

// Kitt
// The beloved KittyCAD mascot in a voxelized style.
// pixel box function
fn pixelBox(kitExtrude, extrudeTag, positionY, positionZ, width, height, depth) {
pixelBoxBody = startSketchOn(kitExtrude, extrudeTag)
|> startProfileAt([positionY, positionZ], %)
|> line(end = [0, height])
|> line(end = [width, 0])
|> line(end = [0, -height])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = depth)
return pixelBoxBody
}
// 1. Kitty Body
kitBodyElevation = 6
kitBodyWidth = 26
kitBodyHeight = 25
kitBodyDepth = 18
kitBody = startSketchOn('XZ')
|> startProfileAt([-kitBodyWidth / 2, kitBodyElevation], %)
|> line(end = [0, kitBodyHeight])
|> line(end = [kitBodyWidth, 0], tag = $seg01)
|> line(end = [0, -kitBodyHeight], tag = $seg02)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = kitBodyDepth)
// 2. Kitty Head (Frame of display)
kitHeadOffset = 1
kitHeadHeight = 16
kitHeadElevation = kitBodyElevation + kitBodyHeight - kitHeadOffset - kitHeadHeight
kitHeadWidth = kitBodyWidth - (kitHeadOffset * 2)
kitHeadDepth = 3
kitHead = pixelBox(kitBody, 'END', -kitHeadWidth / 2, kitHeadElevation, kitHeadWidth, kitHeadHeight, kitHeadDepth)
kitFaceElevation = kitHeadElevation + 2
// 3. Kitty Face
kitFaceWidth = kitHeadWidth - 4
kitFaceHeight = kitHeadElevation + kitHeadHeight - kitFaceElevation - 3
kitFaceDepth = 2
kitFace = startSketchOn(kitHead, 'END')
|> startProfileAt([-kitFaceWidth / 2, kitFaceElevation], %)
|> line(end = [0, 1]) // left lower corner up
|> line(end = [-1, 0]) // left lower corner left
|> line(end = [0, kitFaceHeight]) // left side up
|> line(end = [1, 0]) // left upper corner right
|> line(end = [0, 1]) // left upper corner up
|> line(end = [kitFaceWidth, 0]) // upper side right
|> line(end = [0, -1]) // right upper corner down
|> line(end = [1, 0]) // right upper corner right
|> line(end = [0, -kitFaceHeight]) // right side down
|> line(end = [-1, 0]) // right lower corner left
|> line(end = [0, -1]) // right lower corner down
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = -kitFaceDepth)
// Kitty Face Features:
// 3.1 Kitty Eyes
// 3.1.1 Kitty Left Eye
kitEyeDepth = 0.5
kitEyeHeihgt = kitFaceElevation + 7
kitEyeOffset = 7
// 3.1.2 Kitty Right Eye
kitLeftEye1 = pixelBox(kitFace, 'START', -kitEyeOffset, kitEyeHeihgt, 1, 1, kitEyeDepth)
// 3.2 Kitty Nose
kitLeftEye2 = pixelBox(kitFace, 'START', -kitEyeOffset + 1, kitEyeHeihgt + 1, 3, 1, kitEyeDepth)
kitLeftEye3 = pixelBox(kitFace, 'START', -kitEyeOffset + 4, kitEyeHeihgt, 1, 1, kitEyeDepth)
kitRightEye = pixelBox(kitFace, 'START', kitEyeOffset - 3, kitEyeHeihgt - 1, 2, 4, kitEyeDepth)
kitNoseElevation = kitEyeHeihgt - 5
kitNose = startSketchOn(kitFace, 'START')
|> startProfileAt([-2, kitNoseElevation], %) // H V
|> line(end = [0, 1]) // lower-left up
|> line(end = [2, 0]) // lower-left right
|> line(end = [0, 2]) // mid-left up
|> line(end = [-1, 0]) // upper-left left
|> line(end = [0, 1]) // upper-left up
|> line(end = [3, 0]) // upper-mid right
|> line(end = [0, -1]) // upper-right down
|> line(end = [-1, 0]) // upper-right left
|> line(end = [0, -2]) // mid-left down
|> line(end = [2, 0]) // lower-right right
|> line(end = [0, -1]) // lower-right down
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = kitEyeDepth)
// 3.3 Kitty Mouth
kitMouthOffset = 4
kitMouthHeight = kitEyeHeihgt - 3
kitMouthUpLeft = pixelBox(kitFace, 'START', -kitMouthOffset, kitMouthHeight, 1, 1, kitEyeDepth)
// 4. Kitty Belly
kitMouthDownLeft = pixelBox(kitFace, 'START', -kitMouthOffset + 1, kitMouthHeight - 1, 1, 1, kitEyeDepth)
kitMouthUpRight = pixelBox(kitFace, 'START', kitMouthOffset, kitMouthHeight, 1, 1, kitEyeDepth)
kitMouthDownRight = pixelBox(kitFace, 'START', kitMouthOffset - 1, kitMouthHeight - 1, 1, 1, kitEyeDepth)
kitBellyElevation = kitBodyElevation + 1
kitBellyHeight = kitHeadElevation - kitBellyElevation - 1
// 4.1 Kitty VHS
kitBellyWidth = kitHeadWidth
kitBellyDepth = kitHeadDepth
kitBelly = pixelBox(kitBody, 'END', -kitBellyWidth / 2, kitBellyElevation, kitBellyWidth, kitBellyHeight, kitBellyDepth)
kitVHSelevation = kitBellyElevation + 1
kitVHSheight = 2
// 4.2 Kitty Floppy
kitVHSwidth = 8
kitVHSdepth = 1
kitVHS = pixelBox(kitBelly, 'END', -kitVHSwidth / 2, kitVHSelevation, kitVHSwidth, kitVHSheight, kitVHSdepth)
kitFloppyElevation = kitBellyElevation + 1
kitFloppyHeight = 1
kitFloppyWidth = 5
kitFloppyOffset = kitBellyWidth / 2 - 1
kitFloppyDepth = 2
// 4.3 Kitty Belly Button
kitFloppy1 = pixelBox(kitBelly, 'END', -kitFloppyOffset, kitFloppyElevation, kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
kitFloppy2 = pixelBox(kitBelly, 'END', -kitFloppyOffset, kitFloppyElevation + 2, kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
kitFloppy3 = pixelBox(kitBelly, 'END', kitFloppyOffset, kitFloppyElevation, -kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
kitBellyButtonOffset = kitHeadWidth / 2 - 3
kitBellyButtonElevation = kitHeadElevation - 1
kitBellyButtonWidth = 2
// 4.4 Kitty Buttons
kitBellyButtonHeight = 1
kitBellyButtonDepth = kitHeadDepth + 1
kitBellyButton = pixelBox(kitBody, 'END', -kitBellyButtonOffset, kitBellyButtonElevation, kitBellyButtonWidth, kitBellyButtonHeight, kitBellyButtonDepth)
kitButtonWidth = 1
kitButtonHeight = 2
kitButtonDepth = kitFloppyDepth
kitButtonElevation = kitFloppyElevation + 2
kitButton1 = pixelBox(kitBelly, 'END', kitFloppyOffset, kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
// 5. Kitty Legs
kitButton2 = pixelBox(kitBelly, 'END', kitFloppyOffset - kitButtonWidth - 1, kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
kitButton3 = pixelBox(kitBelly, 'END', kitFloppyOffset - (2 * (kitButtonWidth + 1)), kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
kitShoeWidth = 7
kitShoeLength = 10
kitShoeHeight = 3
fn kitLeg(offsetFront, offsetSide) {
kitShoeOffsetFront = kitShoeLength / 2 - (kitBodyDepth / 2) - offsetFront
kitFootPrint = startSketchOn('XY')
|> startProfileAt([offsetSide, kitShoeOffsetFront], %)
|> line(end = [kitShoeWidth, 0])
|> line(end = [0, -kitShoeLength])
|> line(end = [-kitShoeWidth, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
kitShoe = extrude(kitFootPrint, length = kitShoeHeight)
kitPantsOffsetSide = offsetSide + 1
kitPantsOffsetFront = 2 * kitShoeOffsetFront - 2
kitPantsWidth = kitShoeWidth - 2
kitPantsFrontWidth = kitPantsWidth
kitPantsHeight = kitBodyElevation - kitShoeHeight
kitPants = pixelBox(kitShoe, 'END', kitPantsOffsetSide, kitPantsOffsetFront, kitPantsFrontWidth, kitPantsWidth, kitPantsHeight)
return kitShoe
}
kitLegOffset = 3
kitRightLeg = kitLeg(0, kitLegOffset)
kitLeftLeg = kitLeg(0, -kitLegOffset - kitShoeWidth)
// 6. Kitty Ears
kitEarWidth = 8
kitEarDepth = 8
kitEarHeight = 2
fn kitEar(earOffsetFront, earOffsetSide) {
kitNewEarOffsetFront = kitBodyDepth - earOffsetFront
kitNewEarOffsetSide = -(kitBodyWidth / 2 - earOffsetSide)
baseVolume = pixelBox(kitBody, seg01, kitNewEarOffsetSide, kitNewEarOffsetFront, kitEarWidth, -kitEarDepth, kitEarHeight)
secondOffset = 1
secondLevel = pixelBox(baseVolume, 'END', kitNewEarOffsetSide + secondOffset, kitNewEarOffsetFront - 0.01, kitEarWidth - (secondOffset * 2), -kitEarDepth + secondOffset * 2, kitEarHeight)
thirdOffset = 2
thirdLevel = pixelBox(secondLevel, 'END', kitNewEarOffsetSide + thirdOffset, kitNewEarOffsetFront - 0.02, kitEarWidth - (thirdOffset * 2), -kitEarDepth + thirdOffset * 2, kitEarHeight)
fourthOffset = 3
fourthLevel = pixelBox(thirdLevel, 'END', kitNewEarOffsetSide + fourthOffset, kitNewEarOffsetFront - 0.03, kitEarWidth - (fourthOffset * 2), -kitEarDepth + fourthOffset * 2, kitEarHeight)
return baseVolume
}
kitEarOffsetFront = 4
kitEarOffsetSide = 1
kitRightEar = kitEar(kitEarOffsetFront, kitEarOffsetSide)
kitLeftEar = kitEar(kitEarOffsetFront, kitBodyWidth - kitEarWidth - kitEarOffsetSide)
// 7. Kitty Side
// 7.1 Grill
grillOffset = 4
grillRowA = kitBodyElevation + kitBodyHeight - grillOffset
grillRowB = grillRowA - 2
grillRowC = grillRowA - 4
grillColumnA = kitBodyDepth - grillOffset
grillColumnB = grillColumnA - 1
grillColumnC = grillColumnA - 2
grillColumnD = grillColumnA - 3
grillColumnE = grillColumnA - 4
grillHoleSize = 1
grillHoleDepth = -2
grillHoleAB = pixelBox(kitBody, seg02, grillRowA, grillColumnB, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleAD = pixelBox(kitBody, seg02, grillRowA, grillColumnD, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleBA = pixelBox(kitBody, seg02, grillRowB, grillColumnA, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleBC = pixelBox(kitBody, seg02, grillRowB, grillColumnC, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleBE = pixelBox(kitBody, seg02, grillRowB, grillColumnE, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleCB = pixelBox(kitBody, seg02, grillRowC, grillColumnB, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleCD = pixelBox(kitBody, seg02, grillRowC, grillColumnD, grillHoleSize, grillHoleSize, grillHoleDepth)
// 7.2 Kitty Vent
kitVentElevation = kitBodyElevation + 1
kitVentOffset = 1
kitVentHoleWidth = 1
kitVentHoleHeight = 4
kitVentHoleDepth = grillHoleDepth
kitVentA = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)
kitVentB = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset + 2, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)
kitVentC = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset + 4, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)