|
| 1 | +import { Circuit } from "tscircuit" |
| 2 | +import { test, expect } from "bun:test" |
| 3 | +import { convertCircuitJsonToGltf } from "../../lib" |
| 4 | +import { getBestCameraPosition } from "../../lib/utils/camera-position" |
| 5 | +import { renderGLTFToPNGBufferFromGLBBuffer } from "poppygl" |
| 6 | +import type { ChipProps } from "@tscircuit/props" |
| 7 | + |
| 8 | +const pinLabels = { |
| 9 | + pin1: ["pin1"], |
| 10 | + pin2: ["pin2"], |
| 11 | + pin3: ["pin3"], |
| 12 | +} as const |
| 13 | + |
| 14 | +export const PJ_002AH = (props: ChipProps<typeof pinLabels>) => { |
| 15 | + return ( |
| 16 | + <chip |
| 17 | + pinLabels={pinLabels} |
| 18 | + supplierPartNumbers={{ |
| 19 | + jlcpcb: ["C2961147"], |
| 20 | + }} |
| 21 | + manufacturerPartNumber="PJ_002AH" |
| 22 | + footprint={ |
| 23 | + <footprint> |
| 24 | + <platedhole |
| 25 | + portHints={["pin3"]} |
| 26 | + pcbX="-0mm" |
| 27 | + pcbY="2.2750082mm" |
| 28 | + holeWidth="0.999998mm" |
| 29 | + holeHeight="3.1999936mm" |
| 30 | + outerWidth="1.7999964mm" |
| 31 | + outerHeight="3.999992mm" |
| 32 | + pcbRotation="90deg" |
| 33 | + shape="pill" |
| 34 | + /> |
| 35 | + <platedhole |
| 36 | + portHints={["pin2"]} |
| 37 | + pcbX="2.999994mm" |
| 38 | + pcbY="-2.4250078mm" |
| 39 | + holeWidth="0.999998mm" |
| 40 | + holeHeight="3.1999936mm" |
| 41 | + outerWidth="1.7999964mm" |
| 42 | + outerHeight="3.999992mm" |
| 43 | + shape="pill" |
| 44 | + /> |
| 45 | + <platedhole |
| 46 | + portHints={["pin1"]} |
| 47 | + pcbX="-2.999994mm" |
| 48 | + pcbY="-2.4250078mm" |
| 49 | + holeWidth="0.999998mm" |
| 50 | + holeHeight="3.499993mm" |
| 51 | + outerWidth="1.999996mm" |
| 52 | + outerHeight="4.499991mm" |
| 53 | + pcbRotation="180deg" |
| 54 | + shape="pill" |
| 55 | + /> |
| 56 | + <silkscreenpath |
| 57 | + route={[ |
| 58 | + { x: 7.199985599999991, y: 2.075008599999819 }, |
| 59 | + { x: 7.199985599999991, y: -6.924973400000113 }, |
| 60 | + ]} |
| 61 | + /> |
| 62 | + <silkscreenpath |
| 63 | + route={[ |
| 64 | + { x: -3.699992599999973, y: -4.687208000000055 }, |
| 65 | + { x: -3.699992599999973, y: -6.924973400000113 }, |
| 66 | + { x: 10.699978599999895, y: -6.924973400000113 }, |
| 67 | + { x: 10.699978599999895, y: 2.0550187999999707 }, |
| 68 | + ]} |
| 69 | + /> |
| 70 | + <silkscreenpath |
| 71 | + route={[ |
| 72 | + { x: -2.213279800000123, y: 2.075008599999819 }, |
| 73 | + { x: -3.699992599999973, y: 2.075008599999819 }, |
| 74 | + { x: -3.699992599999973, y: -0.16275680000001103 }, |
| 75 | + ]} |
| 76 | + /> |
| 77 | + <silkscreenpath |
| 78 | + route={[ |
| 79 | + { x: 10.699978599999895, y: 2.075008599999819 }, |
| 80 | + { x: 2.2132798000000093, y: 2.075008599999819 }, |
| 81 | + ]} |
| 82 | + /> |
| 83 | + <silkscreentext |
| 84 | + text="{NAME}" |
| 85 | + pcbX="3.51282mm" |
| 86 | + pcbY="3.4756682mm" |
| 87 | + anchorAlignment="center" |
| 88 | + fontSize="1mm" |
| 89 | + /> |
| 90 | + <courtyardoutline |
| 91 | + outline={[ |
| 92 | + { x: -4.039679999999976, y: 2.725668199999973 }, |
| 93 | + { x: 11.065319999999929, y: 2.725668199999973 }, |
| 94 | + { x: 11.065319999999929, y: -7.223131800000033 }, |
| 95 | + { x: -4.039679999999976, y: -7.223131800000033 }, |
| 96 | + { x: -4.039679999999976, y: 2.725668199999973 }, |
| 97 | + ]} |
| 98 | + /> |
| 99 | + </footprint> |
| 100 | + } |
| 101 | + {...props} |
| 102 | + /> |
| 103 | + ) |
| 104 | +} |
| 105 | + |
| 106 | +test("PJ_002AH glb snapshot", async () => { |
| 107 | + const circuit = new Circuit() |
| 108 | + circuit.add( |
| 109 | + <board width="20mm" height="20mm"> |
| 110 | + <PJ_002AH name="U1" /> |
| 111 | + </board>, |
| 112 | + ) |
| 113 | + |
| 114 | + const circuitJson = await circuit.getCircuitJson() |
| 115 | + |
| 116 | + const glb = await convertCircuitJsonToGltf(circuitJson, { |
| 117 | + format: "glb", |
| 118 | + boardTextureResolution: 512, |
| 119 | + includeModels: true, |
| 120 | + showBoundingBoxes: false, |
| 121 | + }) |
| 122 | + |
| 123 | + expect(glb).toBeInstanceOf(ArrayBuffer) |
| 124 | + expect((glb as ArrayBuffer).byteLength).toBeGreaterThan(0) |
| 125 | + |
| 126 | + expect( |
| 127 | + renderGLTFToPNGBufferFromGLBBuffer( |
| 128 | + glb as ArrayBuffer, |
| 129 | + getBestCameraPosition(circuitJson), |
| 130 | + ), |
| 131 | + ).toMatchPngSnapshot(import.meta.path) |
| 132 | +}, 10_000) |
0 commit comments