From 37d6d162a4da41c3c81ceaff3f992699c5238f93 Mon Sep 17 00:00:00 2001 From: Shibo Date: Tue, 19 Nov 2024 17:46:38 +0200 Subject: [PATCH] allow plated holes to be either horizontal or vertical (#44) * allow plated holes to be either horizontal or vertical and fixed the error * added biome.json --- biome.json | 7 +- package.json | 3 +- src/CadViewerContainer.tsx | 20 +-- src/geoms/plated-hole.ts | 144 ++++++++++------ src/hooks/render/hooks.tsx | 18 +- src/hooks/render/index.tsx | 14 +- src/hooks/use-global-obj-loader.ts | 6 +- src/hooks/use-stls-from-geom.ts | 2 +- src/plated-hole-board.json | 20 +-- src/soup-to-3d/index.ts | 32 +++- .../cube-with-labeled-sides.tsx | 44 ++--- stories/BadStlUrl.stories.tsx | 16 +- stories/PillShapedHole.stories.tsx | 16 +- stories/assets/soic-with-traces.json | 162 ++++-------------- tsconfig.json | 17 +- vendor/@jscadui/format-three/index.ts | 8 +- 16 files changed, 249 insertions(+), 280 deletions(-) diff --git a/biome.json b/biome.json index ec1121f..8249be5 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", "organizeImports": { "enabled": true }, @@ -28,8 +28,13 @@ "suspicious": { "noExplicitAny": "off" }, + "complexity": { + "noForEach": "info" + }, "style": { + "noUselessElse": "off", "noNonNullAssertion": "off", + "useNumberNamespace": "off", "useFilenamingConvention": { "level": "error", "options": { diff --git a/package.json b/package.json index cfef26c..2444a13 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "prepublish": "npm run build", "preview": "vite preview", "storybook": "storybook dev -p 6006", - "build-storybook": "storybook build" + "build-storybook": "storybook build", + "format": "biome format . --write" }, "dependencies": { "@jscad/modeling": "^2.12.2", diff --git a/src/CadViewerContainer.tsx b/src/CadViewerContainer.tsx index 6d1b01f..215e826 100644 --- a/src/CadViewerContainer.tsx +++ b/src/CadViewerContainer.tsx @@ -1,15 +1,15 @@ -import { Grid, OrbitControls } from "@react-three/drei"; -import { Canvas, useFrame } from "@react-three/fiber"; -import packageJson from "../package.json"; -import { CubeWithLabeledSides } from "./three-components/cube-with-labeled-sides"; +import { Grid, OrbitControls } from "@react-three/drei" +import { Canvas, useFrame } from "@react-three/fiber" +import packageJson from "../package.json" +import { CubeWithLabeledSides } from "./three-components/cube-with-labeled-sides" export const RotationTracker = () => { useFrame(({ camera }) => { - window.TSCI_MAIN_CAMERA_ROTATION = camera.rotation; - }); + window.TSCI_MAIN_CAMERA_ROTATION = camera.rotation + }) - return <>; -}; + return <> +} export const CadViewerContainer = ({ children }: { children: any }) => { return ( @@ -73,5 +73,5 @@ export const CadViewerContainer = ({ children }: { children: any }) => { @{packageJson.version} - ); -}; + ) +} diff --git a/src/geoms/plated-hole.ts b/src/geoms/plated-hole.ts index ba6a3c4..67d12f4 100644 --- a/src/geoms/plated-hole.ts +++ b/src/geoms/plated-hole.ts @@ -8,7 +8,7 @@ import type { GeomContext } from "../GeomContext" export const platedHole = ( plated_hole: PCBPlatedHole, - ctx: GeomContext + ctx: GeomContext, ): Geom3 => { if (!(plated_hole as PCBPlatedHole).shape) plated_hole.shape = "circle" if (plated_hole.shape === "circle") { @@ -30,104 +30,146 @@ export const platedHole = ( center: [plated_hole.x, plated_hole.y, -1.2 / 2], radius: plated_hole.outer_diameter / 2, height: M, - }) + }), ), cylinder({ center: [plated_hole.x, plated_hole.y, 0], radius: plated_hole.hole_diameter / 2 - M, height: 1.5, - }) - ) + }), + ), ) - } if (plated_hole.shape === "pill") { - const holeWidth = plated_hole.hole_width - const holeHeight = plated_hole.hole_height - const outerWidth = plated_hole.outer_width || holeWidth + 0.2 - const outerHeight = plated_hole.outer_height || holeHeight + 0.2 + } + if (plated_hole.shape === "pill") { + const shouldRotate = plated_hole.hole_height! > plated_hole.hole_width! + + const holeWidth = shouldRotate + ? plated_hole.hole_height! + : plated_hole.hole_width! + const holeHeight = shouldRotate + ? plated_hole.hole_width! + : plated_hole.hole_height! + const outerHeight = shouldRotate + ? plated_hole.outer_width || holeWidth + 0.2 + : plated_hole.outer_height || holeHeight + 0.2 + const holeRadius = holeHeight / 2 - const outerRadius = outerHeight / 2 + const rectLength = Math.abs(holeWidth - holeHeight) - // Create inner hole pill shape const mainRect = cuboid({ - center: [plated_hole.x, plated_hole.y, 0], - size: [holeWidth - holeHeight, holeHeight, 1.2] + center: shouldRotate + ? [plated_hole.x, plated_hole.y, 0] + : [plated_hole.x, plated_hole.y, 0], + size: shouldRotate + ? [holeHeight, rectLength, 1.2] + : [rectLength, holeHeight, 1.2], }) - + const leftCap = cylinder({ - center: [plated_hole.x - (holeWidth - holeHeight)/2, plated_hole.y, 0], + center: shouldRotate + ? [plated_hole.x, plated_hole.y - rectLength / 2, 0] + : [plated_hole.x - rectLength / 2, plated_hole.y, 0], radius: holeRadius, - height: 1.2 + height: 1.2, }) const rightCap = cylinder({ - center: [plated_hole.x + (holeWidth - holeHeight)/2, plated_hole.y, 0], + center: shouldRotate + ? [plated_hole.x, plated_hole.y + rectLength / 2, 0] + : [plated_hole.x + rectLength / 2, plated_hole.y, 0], radius: holeRadius, - height: 1.2 + height: 1.2, }) - // Create outer pads const outerMainRect = cuboid({ - center: [plated_hole.x, plated_hole.y, 1.2/2], - size: [outerWidth - outerHeight, outerHeight, M] + center: shouldRotate + ? [plated_hole.x, plated_hole.y, 1.2 / 2] + : [plated_hole.x, plated_hole.y, 1.2 / 2], + size: shouldRotate + ? [outerHeight, rectLength, M] + : [rectLength, outerHeight, M], }) const outerLeftCap = cylinder({ - center: [plated_hole.x - (outerWidth - outerHeight)/2, plated_hole.y, 1.2/2], - radius: outerRadius, - height: M + center: shouldRotate + ? [plated_hole.x, plated_hole.y - rectLength / 2, 1.2 / 2] + : [plated_hole.x - rectLength / 2, plated_hole.y, 1.2 / 2], + radius: outerHeight / 2, + height: M, }) const outerRightCap = cylinder({ - center: [plated_hole.x + (outerWidth - outerHeight)/2, plated_hole.y, 1.2/2], - radius: outerRadius, - height: M + center: shouldRotate + ? [plated_hole.x, plated_hole.y + rectLength / 2, 1.2 / 2] + : [plated_hole.x + rectLength / 2, plated_hole.y, 1.2 / 2], + radius: outerHeight / 2, + height: M, }) - // Bottom pads const bottomMainRect = cuboid({ - center: [plated_hole.x, plated_hole.y, -1.2/2], - size: [outerWidth - outerHeight, outerHeight, M] + center: shouldRotate + ? [plated_hole.x, plated_hole.y, -1.2 / 2] + : [plated_hole.x, plated_hole.y, -1.2 / 2], + size: shouldRotate + ? [outerHeight, rectLength, M] + : [rectLength, outerHeight, M], }) const bottomLeftCap = cylinder({ - center: [plated_hole.x - (outerWidth - outerHeight)/2, plated_hole.y, -1.2/2], - radius: outerRadius, - height: M + center: shouldRotate + ? [plated_hole.x, plated_hole.y - rectLength / 2, -1.2 / 2] + : [plated_hole.x - rectLength / 2, plated_hole.y, -1.2 / 2], + radius: outerHeight / 2, + height: M, }) const bottomRightCap = cylinder({ - center: [plated_hole.x + (outerWidth - outerHeight)/2, plated_hole.y, -1.2/2], - radius: outerRadius, - height: M + center: shouldRotate + ? [plated_hole.x, plated_hole.y + rectLength / 2, -1.2 / 2] + : [plated_hole.x + rectLength / 2, plated_hole.y, -1.2 / 2], + radius: outerHeight / 2, + height: M, }) - return colorize( colors.copper, subtract( union( - mainRect, leftCap, rightCap, - outerMainRect, outerLeftCap, outerRightCap, - bottomMainRect, bottomLeftCap, bottomRightCap - ),[ + mainRect, + leftCap, + rightCap, + outerMainRect, + outerLeftCap, + outerRightCap, + bottomMainRect, + bottomLeftCap, + bottomRightCap, + ), + union( cuboid({ center: [plated_hole.x, plated_hole.y, 0], - size: [holeWidth - holeHeight - M*2, holeHeight - M*2, 1.5] + size: shouldRotate + ? [holeHeight - M, rectLength, 1.5] + : [rectLength, holeHeight - M, 1.5], }), cylinder({ - center: [plated_hole.x - (holeWidth - holeHeight)/2, plated_hole.y, 0], + center: shouldRotate + ? [plated_hole.x, plated_hole.y - rectLength / 2, 0] + : [plated_hole.x - rectLength / 2, plated_hole.y, 0], radius: holeRadius - M, - height: 1.5 + height: 1.5, }), cylinder({ - center: [plated_hole.x + (holeWidth - holeHeight)/2, plated_hole.y, 0], + center: shouldRotate + ? [plated_hole.x, plated_hole.y + rectLength / 2, 0] + : [plated_hole.x + rectLength / 2, plated_hole.y, 0], radius: holeRadius - M, - height: 1.5 - }) - ] - ) + height: 1.5, + }), + ), + ), ) - // biome-ignore lint/style/noUselessElse: + // biome-ignore lint/style/noUselessElse: } else { throw new Error(`Unsupported plated hole shape: ${plated_hole.shape}`) } -} \ No newline at end of file +} diff --git a/src/hooks/render/hooks.tsx b/src/hooks/render/hooks.tsx index 8898b7e..f49e628 100644 --- a/src/hooks/render/hooks.tsx +++ b/src/hooks/render/hooks.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useRef, useState } from 'react' +import { useCallback, useEffect, useRef, useState } from "react" // Based off a tweet and codesandbox: // https://mobile.twitter.com/hieuhlc/status/1164369876825169920 @@ -6,28 +6,28 @@ import { useCallback, useEffect, useRef, useState } from 'react' function useKeyPress( targetKey: string, onKeyDown: () => void, - onKeyUp: () => void + onKeyUp: () => void, ): void { const downHandler = useCallback( ({ key }: KeyboardEvent) => { if (key === targetKey) onKeyDown() }, - [onKeyDown, targetKey] + [onKeyDown, targetKey], ) const upHandler = useCallback( ({ key }: KeyboardEvent) => { if (key === targetKey) onKeyUp() }, - [onKeyUp, targetKey] + [onKeyUp, targetKey], ) useEffect(() => { - window.addEventListener('keydown', downHandler) - window.addEventListener('keyup', upHandler) + window.addEventListener("keydown", downHandler) + window.addEventListener("keyup", upHandler) return () => { - window.removeEventListener('keydown', downHandler) - window.removeEventListener('keyup', upHandler) + window.removeEventListener("keydown", downHandler) + window.removeEventListener("keyup", upHandler) } }, [downHandler, upHandler]) } @@ -35,7 +35,7 @@ function useKeyPress( const useAnimationFrame = ( enabled: boolean, callback: (time: number, delta: number) => void, - deps: React.DependencyList + deps: React.DependencyList, ): void => { const frame = useRef() const last = useRef(performance.now()) diff --git a/src/hooks/render/index.tsx b/src/hooks/render/index.tsx index f5ddbbe..10df9da 100644 --- a/src/hooks/render/index.tsx +++ b/src/hooks/render/index.tsx @@ -252,7 +252,7 @@ const Renderer = React.forwardRef( payload: [event.delta[0], -event.delta[1]], }) }, - { domTarget: ref || forwardRef } + { domTarget: ref || forwardRef }, ) usePinch( @@ -260,14 +260,14 @@ const Renderer = React.forwardRef( if (event.touches === 2) dispatch({ type: "SET_ZOOM_DELTA", payload: -event.delta[0] }) }, - { domTarget: ref || forwardRef } + { domTarget: ref || forwardRef }, ) useWheel( (event) => { dispatch({ type: "SET_ZOOM_DELTA", payload: event.delta[1] }) }, - { domTarget: ref || forwardRef } + { domTarget: ref || forwardRef }, ) const onShiftDown = React.useCallback(() => { @@ -350,7 +350,7 @@ const Renderer = React.forwardRef( camera: state.camera, speed: options?.viewerOptions?.panSpeed, }, - state.panDelta + state.panDelta, ) dispatch({ type: "SET_CONTROLS", @@ -379,7 +379,7 @@ const Renderer = React.forwardRef( camera: state.camera, speed: options?.viewerOptions?.rotateSpeed, }, - state.rotateDelta + state.rotateDelta, ) dispatch({ type: "SET_CONTROLS", @@ -403,7 +403,7 @@ const Renderer = React.forwardRef( camera: state.camera, speed: options?.viewerOptions?.zoomSpeed, }, - state.zoomDelta + state.zoomDelta, ) dispatch({ type: "SET_CONTROLS", @@ -431,7 +431,7 @@ const Renderer = React.forwardRef( if (!forwardRef) return
return
- } + }, ) Renderer.displayName = "Renderer" diff --git a/src/hooks/use-global-obj-loader.ts b/src/hooks/use-global-obj-loader.ts index 3a29686..9c365df 100644 --- a/src/hooks/use-global-obj-loader.ts +++ b/src/hooks/use-global-obj-loader.ts @@ -46,9 +46,9 @@ export function useGlobalObjLoader(url: string | null): Group | null | Error { const materials = mtlLoader.parse( mtlContent.replace( /Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g, - "Kd $2 $2 $2" + "Kd $2 $2 $2", ), - "test.mtl" + "test.mtl", ) const objLoader = new OBJLoader() @@ -97,4 +97,4 @@ export function useGlobalObjLoader(url: string | null): Group | null | Error { }, [url]) return obj -} \ No newline at end of file +} diff --git a/src/hooks/use-stls-from-geom.ts b/src/hooks/use-stls-from-geom.ts index 75ef59b..ae5f06c 100644 --- a/src/hooks/use-stls-from-geom.ts +++ b/src/hooks/use-stls-from-geom.ts @@ -16,7 +16,7 @@ function blobToBase64Url(blob: Blob): Promise { type StlObj = { stlUrl: string; color: number[] } export const useStlsFromGeom = ( - geom: Geom3[] | Geom3 | null + geom: Geom3[] | Geom3 | null, ): { stls: StlObj[] loading: boolean diff --git a/src/plated-hole-board.json b/src/plated-hole-board.json index 039b547..a58d483 100644 --- a/src/plated-hole-board.json +++ b/src/plated-hole-board.json @@ -112,29 +112,19 @@ "type": "pcb_plated_hole", "x": -1.5, "y": 0, - "layers": [ - "top", - "bottom" - ], + "layers": ["top", "bottom"], "hole_diameter": 1, "outer_diameter": 1.2, - "port_hints": [ - "1" - ] + "port_hints": ["1"] }, { "type": "pcb_plated_hole", "x": 1.5, "y": 0, - "layers": [ - "top", - "bottom" - ], + "layers": ["top", "bottom"], "hole_diameter": 1, "outer_diameter": 1.2, - "port_hints": [ - "2" - ] + "port_hints": ["2"] }, { "type": "pcb_silkscreen_path", @@ -210,4 +200,4 @@ "width": 5, "height": 5 } -] \ No newline at end of file +] diff --git a/src/soup-to-3d/index.ts b/src/soup-to-3d/index.ts index 16f053a..72a50f4 100644 --- a/src/soup-to-3d/index.ts +++ b/src/soup-to-3d/index.ts @@ -42,29 +42,45 @@ export const createBoardGeomFromSoup = (soup: AnySoupElement[]): Geom3[] => { center: [plated_hole.x, plated_hole.y, 0], radius: plated_hole.hole_diameter / 2 + M, }) - + boardGeom = subtract(boardGeom, cyGeom) const platedHoleGeom = platedHole(plated_hole, ctx) platedHoleGeoms.push(platedHoleGeom) } else if (plated_hole.shape === "pill") { - // Create pill-shaped hole in board - const holeRadius = plated_hole.hole_height! / 2 + const shouldRotate = plated_hole.hole_height! > plated_hole.hole_width! + + const holeWidth = shouldRotate + ? plated_hole.hole_height! + : plated_hole.hole_width! + const holeHeight = shouldRotate + ? plated_hole.hole_width! + : plated_hole.hole_height! + + const holeRadius = holeHeight / 2 + const rectLength = Math.abs(holeWidth - holeHeight) + const pillHole = union( cuboid({ center: [plated_hole.x, plated_hole.y, 0], - size: [plated_hole.hole_width! - plated_hole.hole_height!, plated_hole.hole_height!, 1.5], + size: shouldRotate + ? [holeHeight, rectLength, 1.5] + : [rectLength, holeHeight, 1.5], }), cylinder({ - center: [plated_hole.x - (plated_hole.hole_width! - plated_hole.hole_height!) / 2, plated_hole.y, 0], + center: shouldRotate + ? [plated_hole.x, plated_hole.y - rectLength / 2, 0] + : [plated_hole.x - rectLength / 2, plated_hole.y, 0], radius: holeRadius, height: 1.5, }), cylinder({ - center: [plated_hole.x + (plated_hole.hole_width! - plated_hole.hole_height!) / 2, plated_hole.y, 0], + center: shouldRotate + ? [plated_hole.x, plated_hole.y + rectLength / 2, 0] + : [plated_hole.x + rectLength / 2, plated_hole.y, 0], radius: holeRadius, height: 1.5, - }) + }), ) boardGeom = subtract(boardGeom, pillHole) @@ -89,7 +105,7 @@ export const createBoardGeomFromSoup = (soup: AnySoupElement[]): Geom3[] => { } for (const pad of pads) { - const layerSign = pad.layer === "bottom" ? -1 : 1; + const layerSign = pad.layer === "bottom" ? -1 : 1 if (pad.shape === "rect") { const padGeom = colorize( colors.copper, diff --git a/src/three-components/cube-with-labeled-sides.tsx b/src/three-components/cube-with-labeled-sides.tsx index 8f4599c..a7d578d 100644 --- a/src/three-components/cube-with-labeled-sides.tsx +++ b/src/three-components/cube-with-labeled-sides.tsx @@ -1,49 +1,49 @@ -import { Text } from "@react-three/drei"; -import { useFrame } from "@react-three/fiber"; -import { useRef } from "react"; -import * as THREE from "three"; +import { Text } from "@react-three/drei" +import { useFrame } from "@react-three/fiber" +import { useRef } from "react" +import * as THREE from "three" declare global { interface Window { - TSCI_MAIN_CAMERA_ROTATION: THREE.Euler; + TSCI_MAIN_CAMERA_ROTATION: THREE.Euler } } if (typeof window !== "undefined") { - window.TSCI_MAIN_CAMERA_ROTATION = new THREE.Euler(0, 0, 0); + window.TSCI_MAIN_CAMERA_ROTATION = new THREE.Euler(0, 0, 0) } function computePointInFront(rotationVector, distance) { // Create a quaternion from the rotation vector const quaternion = new THREE.Quaternion().setFromEuler( - new THREE.Euler(rotationVector.x, rotationVector.y, rotationVector.z) - ); + new THREE.Euler(rotationVector.x, rotationVector.y, rotationVector.z), + ) // Create a vector pointing forward (along the negative z-axis) - const forwardVector = new THREE.Vector3(0, 0, 1); + const forwardVector = new THREE.Vector3(0, 0, 1) // Apply the rotation to the forward vector - forwardVector.applyQuaternion(quaternion); + forwardVector.applyQuaternion(quaternion) // Scale the rotated vector by the distance - const result = forwardVector.multiplyScalar(distance); + const result = forwardVector.multiplyScalar(distance) - return result; + return result } export const CubeWithLabeledSides = ({}: any) => { - const ref = useRef(); - const rotationTrackingRef = useRef({ lastRotation: new THREE.Euler() }); + const ref = useRef() + const rotationTrackingRef = useRef({ lastRotation: new THREE.Euler() }) useFrame((state, delta) => { - if (!ref.current) return; + if (!ref.current) return - const mainRot = window.TSCI_MAIN_CAMERA_ROTATION; + const mainRot = window.TSCI_MAIN_CAMERA_ROTATION // Use window.TSCI_CAMERA_ROTATION to compute the position of the camera - const cameraPosition = computePointInFront(mainRot, 2); + const cameraPosition = computePointInFront(mainRot, 2) - state.camera.position.copy(cameraPosition); - state.camera.lookAt(0, 0, 0); - }); + state.camera.position.copy(cameraPosition) + state.camera.lookAt(0, 0, 0) + }) return ( @@ -101,5 +101,5 @@ export const CubeWithLabeledSides = ({}: any) => { } /> - ); -}; + ) +} diff --git a/stories/BadStlUrl.stories.tsx b/stories/BadStlUrl.stories.tsx index e252483..cc3049f 100644 --- a/stories/BadStlUrl.stories.tsx +++ b/stories/BadStlUrl.stories.tsx @@ -1,13 +1,13 @@ -import type { CadComponent } from "@tscircuit/soup"; -import { CadViewer } from "src/CadViewer"; -import bugsPadsAndTracesSoup from "./assets/soic-with-traces.json"; +import type { CadComponent } from "@tscircuit/soup" +import { CadViewer } from "src/CadViewer" +import bugsPadsAndTracesSoup from "./assets/soic-with-traces.json" export default { title: "CadViewer", component: CadViewer, -}; +} -const badStlUrl = "https://example.com/nonexistent.stl"; +const badStlUrl = "https://example.com/nonexistent.stl" const cad_component: CadComponent = { type: "cad_component", @@ -17,12 +17,12 @@ const cad_component: CadComponent = { rotation: { x: 0, y: 0, z: 0 }, pcb_component_id: "todo", source_component_id: "todo", -}; +} export const BadStlUrl = () => { return ( - ); -}; + ) +} diff --git a/stories/PillShapedHole.stories.tsx b/stories/PillShapedHole.stories.tsx index 04e32fd..d3ea60e 100644 --- a/stories/PillShapedHole.stories.tsx +++ b/stories/PillShapedHole.stories.tsx @@ -23,7 +23,7 @@ export const MultiplePillHoles: Story = { }, { type: "pcb_plated_hole", - pcb_plated_hole_id: "some-id", + pcb_plated_hole_id: "some-id-0", x: -2, y: 0, shape: "pill", @@ -35,7 +35,19 @@ export const MultiplePillHoles: Story = { }, { type: "pcb_plated_hole", - pcb_plated_hole_id: "some-id", + pcb_plated_hole_id: "some-id-1", + x: -2, + y: 3, + shape: "pill", + hole_width: 1, + hole_height: 3, + outer_width: 2, + outer_height: 4, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "some-id-2", x: 2, y: 0, shape: "pill", diff --git a/stories/assets/soic-with-traces.json b/stories/assets/soic-with-traces.json index ccc63d2..35a2995 100644 --- a/stories/assets/soic-with-traces.json +++ b/stories/assets/soic-with-traces.json @@ -72,10 +72,7 @@ "source_port_id": "source_port_0", "source_component_id": "simple_bug_0", "pin_number": 1, - "port_hints": [ - "VCC", - "1" - ] + "port_hints": ["VCC", "1"] }, { "type": "schematic_port", @@ -108,9 +105,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": -2.65, "y": 1.905, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -118,10 +113,7 @@ "source_port_id": "source_port_1", "source_component_id": "simple_bug_0", "pin_number": 2, - "port_hints": [ - "TRIG1", - "2" - ] + "port_hints": ["TRIG1", "2"] }, { "type": "schematic_port", @@ -154,9 +146,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": -2.65, "y": 0.635, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -164,10 +154,7 @@ "source_port_id": "source_port_2", "source_component_id": "simple_bug_0", "pin_number": 3, - "port_hints": [ - "TRIG2", - "3" - ] + "port_hints": ["TRIG2", "3"] }, { "type": "schematic_port", @@ -200,9 +187,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": -2.65, "y": -0.635, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -210,10 +195,7 @@ "source_port_id": "source_port_3", "source_component_id": "simple_bug_0", "pin_number": 4, - "port_hints": [ - "OUT1", - "4" - ] + "port_hints": ["OUT1", "4"] }, { "type": "schematic_port", @@ -246,9 +228,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": -2.65, "y": -1.905, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -256,10 +236,7 @@ "source_port_id": "source_port_4", "source_component_id": "simple_bug_0", "pin_number": 5, - "port_hints": [ - "OUT2", - "5" - ] + "port_hints": ["OUT2", "5"] }, { "type": "schematic_port", @@ -292,9 +269,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": 2.65, "y": -1.905, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -302,10 +277,7 @@ "source_port_id": "source_port_5", "source_component_id": "simple_bug_0", "pin_number": 6, - "port_hints": [ - "RESET", - "6" - ] + "port_hints": ["RESET", "6"] }, { "type": "schematic_port", @@ -338,9 +310,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": 2.65, "y": -0.635, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -348,10 +318,7 @@ "source_port_id": "source_port_6", "source_component_id": "simple_bug_0", "pin_number": 7, - "port_hints": [ - "CTRL", - "7" - ] + "port_hints": ["CTRL", "7"] }, { "type": "schematic_port", @@ -384,9 +351,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": 2.65, "y": 0.635, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -394,10 +359,7 @@ "source_port_id": "source_port_7", "source_component_id": "simple_bug_0", "pin_number": 8, - "port_hints": [ - "GND", - "8" - ] + "port_hints": ["GND", "8"] }, { "type": "schematic_port", @@ -430,9 +392,7 @@ "pcb_component_id": "pcb_component_simple_bug_0", "x": 2.65, "y": 1.905, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "schematic_text", @@ -553,9 +513,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "1" - ], + "port_hints": ["1"], "pcb_port_id": "pcb_port_0" }, { @@ -568,9 +526,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "2" - ], + "port_hints": ["2"], "pcb_port_id": "pcb_port_1" }, { @@ -583,9 +539,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "3" - ], + "port_hints": ["3"], "pcb_port_id": "pcb_port_2" }, { @@ -598,9 +552,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "4" - ], + "port_hints": ["4"], "pcb_port_id": "pcb_port_3" }, { @@ -613,9 +565,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "5" - ], + "port_hints": ["5"], "pcb_port_id": "pcb_port_4" }, { @@ -628,9 +578,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "6" - ], + "port_hints": ["6"], "pcb_port_id": "pcb_port_5" }, { @@ -643,9 +591,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "7" - ], + "port_hints": ["7"], "pcb_port_id": "pcb_port_6" }, { @@ -658,9 +604,7 @@ "height": 0.6, "layer": "top", "pcb_component_id": "pcb_component_simple_bug_0", - "port_hints": [ - "8" - ], + "port_hints": ["8"], "pcb_port_id": "pcb_port_7" }, { @@ -776,9 +720,7 @@ "pcb_component_id": "pcb_component_simple_resistor_0", "x": 5.765730710285985, "y": -0.08702981863769477, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -804,9 +746,7 @@ "pcb_component_id": "pcb_component_simple_resistor_0", "x": 7.6657307102859855, "y": -0.08702981863769477, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "schematic_text", @@ -855,10 +795,7 @@ "height": 1.2, "layer": "top", "pcb_component_id": "pcb_component_simple_resistor_0", - "port_hints": [ - "1", - "left" - ], + "port_hints": ["1", "left"], "pcb_port_id": "pcb_port_8" }, { @@ -871,10 +808,7 @@ "height": 1.2, "layer": "top", "pcb_component_id": "pcb_component_simple_resistor_0", - "port_hints": [ - "2", - "right" - ], + "port_hints": ["2", "right"], "pcb_port_id": "pcb_port_9" }, { @@ -926,9 +860,7 @@ "pcb_component_id": "pcb_component_simple_capacitor_0", "x": -5.690865047818071, "y": -0.9002686750641746, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "source_port", @@ -954,9 +886,7 @@ "pcb_component_id": "pcb_component_simple_capacitor_0", "x": -5.690865047818071, "y": 0.9997313249358253, - "layers": [ - "top" - ] + "layers": ["top"] }, { "type": "schematic_text", @@ -1005,10 +935,7 @@ "height": 1.2, "layer": "top", "pcb_component_id": "pcb_component_simple_capacitor_0", - "port_hints": [ - "1", - "left" - ], + "port_hints": ["1", "left"], "pcb_port_id": "pcb_port_10" }, { @@ -1021,10 +948,7 @@ "height": 1.2, "layer": "top", "pcb_component_id": "pcb_component_simple_capacitor_0", - "port_hints": [ - "2", - "right" - ], + "port_hints": ["2", "right"], "pcb_port_id": "pcb_port_11" }, { @@ -1079,10 +1003,7 @@ { "type": "source_trace", "source_trace_id": "source_trace_0", - "connected_source_port_ids": [ - "source_port_8", - "source_port_0" - ] + "connected_source_port_ids": ["source_port_8", "source_port_0"] }, { "type": "schematic_trace", @@ -1334,10 +1255,7 @@ { "type": "source_trace", "source_trace_id": "source_trace_1", - "connected_source_port_ids": [ - "source_port_9", - "source_port_6" - ] + "connected_source_port_ids": ["source_port_9", "source_port_6"] }, { "type": "schematic_trace", @@ -1444,10 +1362,7 @@ { "type": "source_trace", "source_trace_id": "source_trace_2", - "connected_source_port_ids": [ - "source_port_10", - "source_port_0" - ] + "connected_source_port_ids": ["source_port_10", "source_port_0"] }, { "type": "schematic_trace", @@ -1569,10 +1484,7 @@ { "type": "source_trace", "source_trace_id": "source_trace_3", - "connected_source_port_ids": [ - "source_port_11", - "source_port_7" - ] + "connected_source_port_ids": ["source_port_11", "source_port_7"] }, { "type": "schematic_trace", @@ -1799,4 +1711,4 @@ "width": 20, "height": 20 } -] \ No newline at end of file +] diff --git a/tsconfig.json b/tsconfig.json index 2ebf1c4..1a9c868 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,18 +22,9 @@ "jsx": "react-jsx", "noEmit": true, // Include the DOM types - "lib": [ - "es2022", - "dom", - "dom.iterable" - ] + "lib": ["es2022", "dom", "dom.iterable"] }, // Include the necessary files for your project - "include": [ - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "include": ["**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} diff --git a/vendor/@jscadui/format-three/index.ts b/vendor/@jscadui/format-three/index.ts index b6ff83b..54be0c2 100644 --- a/vendor/@jscadui/format-three/index.ts +++ b/vendor/@jscadui/format-three/index.ts @@ -72,7 +72,7 @@ export function CommonToThree({ if (colors) geo.setAttribute( "color", - new BufferAttribute(colors, isTransparent ? 4 : 3) + new BufferAttribute(colors, isTransparent ? 4 : 3), ) let mesh @@ -85,13 +85,13 @@ export function CommonToThree({ mesh = new InstancedMesh( geo, materials.mesh.make({ color: 0x0084d1 }), - list.length + list.length, ) list.forEach((item, i) => { copyTransformToArray( item.transforms, mesh.instanceMatrix.array, - i * 16 + i * 16, ) }) transforms = null @@ -163,7 +163,7 @@ export function CommonToThree({ function toCreasedNormals( { Vector3, BufferAttribute }, geometry, - creaseAngle = Math.PI / 3 /* 60 degrees */ + creaseAngle = Math.PI / 3 /* 60 degrees */, ) { const creaseDot = Math.cos(creaseAngle) const hashMultiplier = (1 + 1e-10) * 1e2