@tscircuit/3d-viewer 0.0.101 → 0.0.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -613,7 +613,7 @@ var import_fiber3 = require("@react-three/fiber");
|
|
|
613
613
|
// package.json
|
|
614
614
|
var package_default = {
|
|
615
615
|
name: "@tscircuit/3d-viewer",
|
|
616
|
-
version: "0.0.
|
|
616
|
+
version: "0.0.101",
|
|
617
617
|
main: "./dist/index.js",
|
|
618
618
|
files: [
|
|
619
619
|
"dist"
|
|
@@ -636,7 +636,7 @@ var package_default = {
|
|
|
636
636
|
"@jscad/stl-serializer": "^2.1.17",
|
|
637
637
|
"@react-three/drei": "^9.115.0",
|
|
638
638
|
"@react-three/fiber": "^8.16.8",
|
|
639
|
-
"@tscircuit/core": "^0.0.
|
|
639
|
+
"@tscircuit/core": "^0.0.274",
|
|
640
640
|
"@tscircuit/props": "^0.0.130",
|
|
641
641
|
"@tscircuit/react-fiber": "^1.1.29",
|
|
642
642
|
"@tscircuit/soup": "^0.0.69",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/hooks/exporter/gltf.ts","../src/hooks/use-convert-children-to-soup.ts","../src/CadViewer.tsx","../src/soup-to-3d/index.ts","../src/geoms/plated-hole.ts","../src/geoms/constants.ts","../src/geoms/create-board-with-outline.ts","../src/geoms/create-geoms-for-silkscreen-text.ts","../src/hooks/use-stls-from-geom.ts","../src/three-components/STLModel.tsx","../src/CadViewerContainer.tsx","../package.json","../src/three-components/cube-with-labeled-sides.tsx","../src/ContainerWithTooltip.tsx","../src/hooks/use-global-obj-loader.ts","../src/three-components/MixedStlModel.tsx","../src/three-components/JscadModel.tsx","../src/three-components/FootprinterModel.tsx","../src/utils/tuple.ts","../src/AnyCadComponent.tsx","../src/three-components/ThreeErrorBoundary.tsx","../src/three-components/Error3d.tsx"],"sourcesContent":["export * from \"./hooks/index.ts\"\nexport { CadViewer } from \"./CadViewer.tsx\"\n","import type * as React from \"react\"\nimport type * as THREE from \"three\"\nimport { GLTFExporter, type GLTFExporterOptions } from \"three-stdlib\"\nimport { useEffect, useState, useMemo, useCallback } from \"react\"\n\ntype Options = Omit<\n GLTFExporterOptions,\n \"animations\" | \"includeCustomExtensions\"\n>\n\nexport function useSaveGltfAs(\n options = {} as Options & { filename?: string },\n): [\n ref3D: React.ForwardedRef<THREE.Object3D>,\n saveAs: (filename?: string) => Promise<void>,\n] {\n const parse = useParser(options)\n const link = useMemo(() => document.createElement(\"a\"), [])\n const saveAs = async (filename?: string) => {\n const name = filename ?? options.filename ?? \"\"\n if (options.binary == null) options.binary = name.endsWith(\".glb\")\n const url = await parse(instance!)\n link.download = name\n link.href = url\n link.dispatchEvent(new MouseEvent(\"click\"))\n URL.revokeObjectURL(url)\n }\n\n useEffect(\n () => () => {\n link.remove()\n instance = null\n },\n [],\n )\n\n let instance: THREE.Object3D | null\n const ref = useCallback((obj3D: THREE.Object3D | null) => {\n instance = obj3D!\n }, [])\n\n return [ref, saveAs]\n}\n\nexport function useExportGltfUrl(\n options = {} as Options,\n): [\n ref3D: React.ForwardedRef<THREE.Object3D>,\n url: string | undefined,\n error: ErrorEvent | undefined,\n] {\n const parse = useParser(options)\n const [url, setUrl] = useState<string>()\n const [error, setError] = useState<ErrorEvent>()\n const ref = useCallback(\n (instance: THREE.Object3D | null) =>\n parse(instance!).then(setUrl).catch(setError),\n [],\n )\n useEffect(() => () => URL.revokeObjectURL(url!), [url])\n return [ref, url, error]\n}\n\nfunction useParser(options = {} as Options) {\n const exporter = useMemo(() => new GLTFExporter(), [])\n return (instance: THREE.Object3D) => {\n const { promise, resolve, reject } = Promise.withResolvers<string>()\n exporter.parse(\n instance,\n (gltf) => {\n const type = options.binary ? \"gltf-binary\" : \"gltf+json\"\n const blob = new Blob(\n [gltf instanceof ArrayBuffer ? gltf : JSON.stringify(gltf)],\n { type: `model/${type}` },\n )\n resolve(URL.createObjectURL(blob))\n },\n reject,\n options,\n )\n return promise\n }\n}\n","import { Circuit } from \"@tscircuit/core\"\nimport { useMemo } from \"react\"\nimport type { AnyCircuitElement } from \"circuit-json\"\n\nexport const useConvertChildrenToSoup = (\n children?: any,\n defaultSoup?: AnyCircuitElement[],\n): AnyCircuitElement[] => {\n return useMemo(() => {\n if (!children) return\n const circuit = new Circuit()\n circuit.add(children)\n circuit.render()\n return circuit.getCircuitJson() as any\n }, [children])\n}\n","import type { AnySoupElement } from \"@tscircuit/soup\"\nimport type * as React from \"react\"\nimport type * as THREE from \"three\"\nimport { useConvertChildrenToSoup } from \"./hooks/use-convert-children-to-soup\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { useEffect, useMemo, useState, forwardRef } from \"react\"\nimport { createBoardGeomFromSoup } from \"./soup-to-3d\"\nimport { useStlsFromGeom } from \"./hooks/use-stls-from-geom\"\nimport { STLModel } from \"./three-components/STLModel\"\nimport { CadViewerContainer } from \"./CadViewerContainer\"\nimport { MixedStlModel } from \"./three-components/MixedStlModel\"\nimport { Euler } from \"three\"\nimport { JscadModel } from \"./three-components/JscadModel\"\nimport { Footprinter3d } from \"jscad-electronics\"\nimport { FootprinterModel } from \"./three-components/FootprinterModel\"\nimport { tuple } from \"./utils/tuple\"\nimport { AnyCadComponent } from \"./AnyCadComponent\"\nimport { Text } from \"@react-three/drei\"\nimport { ThreeErrorBoundary } from \"./three-components/ThreeErrorBoundary\"\nimport { Error3d } from \"./three-components/Error3d\"\n\ninterface Props {\n soup?: AnySoupElement[]\n}\n\nexport const CadViewer = forwardRef<\n THREE.Object3D,\n React.PropsWithChildren<Props>\n>(({ soup, children }, ref) => {\n const [hoveredComponent, setHoveredComponent] = useState<null | {\n cad_component_id: string\n name: string\n mousePosition: [number, number, number]\n }>(null)\n soup ??= useConvertChildrenToSoup(children, soup) as any\n\n if (!soup) return null\n\n const boardGeom = useMemo(() => {\n if (!soup.some((e) => e.type === \"pcb_board\")) return null\n return createBoardGeomFromSoup(soup)\n }, [soup])\n\n const { stls: boardStls, loading } = useStlsFromGeom(boardGeom)\n\n const cad_components = su(soup).cad_component.list()\n\n return (\n <CadViewerContainer ref={ref} hoveredComponent={hoveredComponent}>\n {boardStls.map(({ stlUrl, color }, index) => (\n <STLModel\n key={stlUrl}\n stlUrl={stlUrl}\n color={color}\n opacity={index === 0 ? 0.95 : 1}\n />\n ))}\n {cad_components.map((cad_component) => (\n <ThreeErrorBoundary\n key={cad_component.cad_component_id}\n fallback={({ error }) => (\n <Error3d cad_component={cad_component} error={error} />\n )}\n >\n <AnyCadComponent\n key={cad_component.cad_component_id}\n onHover={(e) => {\n // TODO this should be done by onUnhover\n if (!e) {\n setHoveredComponent(null)\n }\n if (!e.mousePosition) return\n\n const componentName = su(soup as any).source_component.getUsing({\n source_component_id: cad_component.source_component_id,\n })?.name\n setHoveredComponent({\n cad_component_id: cad_component.cad_component_id,\n name: componentName ?? \"<unknown>\",\n mousePosition: e.mousePosition,\n })\n }}\n cad_component={cad_component}\n isHovered={\n hoveredComponent?.cad_component_id ===\n cad_component.cad_component_id\n }\n />\n </ThreeErrorBoundary>\n ))}\n </CadViewerContainer>\n )\n})\n","import type { Geom3 } from \"@jscad/modeling/src/geometries/types\"\nimport type { AnySoupElement, PCBPlatedHole } from \"@tscircuit/soup\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { translate } from \"@jscad/modeling/src/operations/transforms\"\nimport { cuboid, cylinder, line } from \"@jscad/modeling/src/primitives\"\nimport { colorize } from \"@jscad/modeling/src/colors\"\nimport { subtract, union } from \"@jscad/modeling/src/operations/booleans\"\nimport { platedHole } from \"../geoms/plated-hole\"\nimport { M, colors } from \"../geoms/constants\"\nimport { extrudeLinear } from \"@jscad/modeling/src/operations/extrusions\"\nimport { expand } from \"@jscad/modeling/src/operations/expansions\"\nimport { createBoardWithOutline } from \"src/geoms/create-board-with-outline\"\nimport { Vec2 } from \"@jscad/modeling/src/maths/types\"\nimport { createSilkscreenTextGeoms } from \"src/geoms/create-geoms-for-silkscreen-text\"\nimport { PcbSilkscreenText } from \"circuit-json\"\nexport const createBoardGeomFromSoup = (soup: AnySoupElement[]): Geom3[] => {\n const board = su(soup).pcb_board.list()[0]\n if (!board) {\n throw new Error(\"No pcb_board found\")\n }\n const plated_holes = su(soup).pcb_plated_hole.list()\n const holes = su(soup).pcb_hole.list()\n const pads = su(soup).pcb_smtpad.list()\n const traces = su(soup).pcb_trace.list()\n const pcb_vias = su(soup).pcb_via.list()\n const silkscreenTexts = su(soup).pcb_silkscreen_text.list()\n\n // PCB Board\n let boardGeom: Geom3\n if (board.outline && board.outline.length > 0)\n boardGeom = createBoardWithOutline(board.outline, 1.2)\n else boardGeom = cuboid({ size: [board.width, board.height, 1.2] })\n\n const platedHoleGeoms: Geom3[] = []\n const holeGeoms: Geom3[] = []\n const padGeoms: Geom3[] = []\n const traceGeoms: Geom3[] = []\n const ctx = {\n pcbThickness: 1.2,\n }\n\n const addPlatedHole = (plated_hole: PCBPlatedHole) => {\n if (plated_hole.shape === \"circle\") {\n const cyGeom = cylinder({\n center: [plated_hole.x, plated_hole.y, 0],\n radius: plated_hole.hole_diameter / 2 + M,\n })\n\n boardGeom = subtract(boardGeom, cyGeom)\n\n const platedHoleGeom = platedHole(plated_hole, ctx)\n platedHoleGeoms.push(platedHoleGeom)\n } else if (plated_hole.shape === \"pill\") {\n const shouldRotate = plated_hole.hole_height! > plated_hole.hole_width!\n\n const holeWidth = shouldRotate\n ? plated_hole.hole_height!\n : plated_hole.hole_width!\n const holeHeight = shouldRotate\n ? plated_hole.hole_width!\n : plated_hole.hole_height!\n\n const holeRadius = holeHeight / 2\n const rectLength = Math.abs(holeWidth - holeHeight)\n\n const pillHole = union(\n cuboid({\n center: [plated_hole.x, plated_hole.y, 0],\n size: shouldRotate\n ? [holeHeight, rectLength, 1.5]\n : [rectLength, holeHeight, 1.5],\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 0]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.5,\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 0]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.5,\n }),\n )\n boardGeom = subtract(boardGeom, pillHole)\n\n const platedHoleGeom = platedHole(plated_hole, ctx)\n platedHoleGeoms.push(platedHoleGeom)\n }\n }\n\n for (const plated_hole of plated_holes) {\n addPlatedHole(plated_hole)\n }\n\n for (const hole of holes) {\n // @ts-expect-error\n if (hole.hole_shape === \"round\" || hole.hole_shape === \"circle\") {\n const cyGeom = cylinder({\n center: [hole.x, hole.y, 0],\n radius: hole.hole_diameter / 2 + M,\n })\n boardGeom = subtract(boardGeom, cyGeom)\n }\n }\n\n for (const pad of pads) {\n const layerSign = pad.layer === \"bottom\" ? -1 : 1\n if (pad.shape === \"rect\") {\n const padGeom = colorize(\n colors.copper,\n cuboid({\n center: [pad.x, pad.y, (layerSign * 1.2) / 2 + layerSign * M],\n size: [pad.width, pad.height, M],\n }),\n )\n padGeoms.push(padGeom)\n } else if (pad.shape === \"circle\") {\n const padGeom = colorize(\n colors.copper,\n cylinder({\n center: [pad.x, pad.y, (layerSign * 1.2) / 2 + layerSign * M],\n radius: pad.radius,\n height: M,\n }),\n )\n padGeoms.push(padGeom)\n }\n }\n\n for (const { route: mixedRoute } of traces) {\n if (mixedRoute.length < 2) continue\n\n // Group routes by continuous segments\n const routeSegments: (typeof mixedRoute)[] = []\n let currentSegment: typeof mixedRoute = [mixedRoute[0]!]\n let currentLayer =\n mixedRoute[0]!.route_type === \"wire\" ? mixedRoute[0]!.layer : \"top\"\n\n for (let i = 1; i < mixedRoute.length; i++) {\n const point = mixedRoute[i]!\n\n if (point.route_type === \"via\") {\n // Complete current segment and start a new one\n routeSegments.push(currentSegment)\n currentSegment = [point]\n } else if (point.route_type === \"wire\" && point.layer !== currentLayer) {\n // Complete current segment and start a new one on a different layer\n routeSegments.push(currentSegment)\n currentLayer = point.layer\n currentSegment = [point]\n } else {\n currentSegment.push(point)\n }\n }\n\n // Add the last segment\n routeSegments.push(currentSegment)\n\n // Render each route segment\n for (const route of routeSegments) {\n if (route.length < 2) continue\n\n const linePath = line(route.map((p) => [p.x, p.y]))\n const layerSign =\n route[0]!.route_type === \"via\"\n ? route[0]!.to_layer === \"top\"\n ? 1\n : -1\n : route[0]!.layer === \"top\"\n ? 1\n : -1\n\n let traceGeom = translate(\n [0, 0, (layerSign * 1.2) / 2],\n extrudeLinear(\n { height: M * layerSign },\n expand({ delta: 0.1, corners: \"edge\" }, linePath),\n ),\n )\n\n // Modify via subtraction to preserve trace geometry\n const viaSubtractions = pcb_vias.map((via) =>\n cylinder({\n center: [via.x, via.y, 0],\n radius: via.outer_diameter / 2,\n height: 5,\n }),\n )\n\n const holeSubtractions = plated_holes\n .filter((ph) => ph.shape === \"circle\")\n .map((ph) =>\n cylinder({\n center: [ph.x, ph.y, 0],\n radius: ph.outer_diameter / 2,\n height: 5,\n }),\n )\n\n // Subtract vias and holes without removing entire trace\n traceGeom = subtract(traceGeom, ...viaSubtractions, ...holeSubtractions)\n\n traceGeom = colorize(colors.fr4GreenSolderWithMask, traceGeom)\n\n traceGeoms.push(traceGeom)\n }\n }\n\n for (const via of pcb_vias) {\n addPlatedHole({\n x: via.x,\n y: via.y,\n hole_diameter: via.hole_diameter,\n outer_diameter: via.outer_diameter,\n shape: \"circle\",\n layers: [\"top\", \"bottom\"],\n type: \"pcb_plated_hole\",\n pcb_plated_hole_id: \"\",\n })\n }\n // Add silkscreen text\n const silkscreenGeoms: Geom3[] = []\n for (const silkscreenText of silkscreenTexts) {\n const { textOutlines, xOffset, yOffset } = createSilkscreenTextGeoms(\n silkscreenText as PcbSilkscreenText,\n )\n\n for (let outline of textOutlines) {\n // Create path from outline points with alignment offset\n\n const alignedOutline = outline.map((point) => [\n point[0] + xOffset + silkscreenText.anchor_position.x,\n point[1] + yOffset + silkscreenText.anchor_position.y,\n ]) as Vec2[]\n const textPath = line(alignedOutline)\n\n // Scale expansion delta with font size\n const fontSize = silkscreenText.font_size || 0.25\n const expansionDelta = Math.min(\n Math.max(0.01, fontSize * 0.1),\n fontSize * 0.2, // Maximum cap scales with font size\n )\n const expandedPath = expand(\n {\n delta: expansionDelta,\n corners: \"round\",\n },\n textPath,\n )\n\n // Extrude and position the text with smaller height\n let textGeom = translate(\n [0, 0, 0.6], // Position above board\n extrudeLinear(\n { height: 0.012 }, // Thinner extrusion\n expandedPath,\n ),\n )\n\n // Color white like silkscreen\n textGeom = colorize([256, 256, 256], textGeom)\n\n silkscreenGeoms.push(textGeom)\n }\n }\n\n // Colorize to a PCB green color: #05A32E\n boardGeom = colorize(colors.fr4Green, boardGeom)\n\n return [\n boardGeom,\n ...platedHoleGeoms,\n ...padGeoms,\n ...traceGeoms,\n ...silkscreenGeoms,\n ]\n}\n","import type { PCBPlatedHole } from \"@tscircuit/soup\"\nimport type { Geom3 } from \"@jscad/modeling/src/geometries/types\"\nimport { cuboid, cylinder } from \"@jscad/modeling/src/primitives\"\nimport { colorize } from \"@jscad/modeling/src/colors\"\nimport { subtract, union } from \"@jscad/modeling/src/operations/booleans\"\nimport { M, colors } from \"./constants\"\nimport type { GeomContext } from \"../GeomContext\"\n\nexport const platedHole = (\n plated_hole: PCBPlatedHole,\n ctx: GeomContext,\n): Geom3 => {\n if (!(plated_hole as PCBPlatedHole).shape) plated_hole.shape = \"circle\"\n if (plated_hole.shape === \"circle\") {\n return colorize(\n colors.copper,\n subtract(\n union(\n cylinder({\n center: [plated_hole.x, plated_hole.y, 0],\n radius: plated_hole.hole_diameter / 2,\n height: 1.2,\n }),\n cylinder({\n center: [plated_hole.x, plated_hole.y, 1.2 / 2],\n radius: plated_hole.outer_diameter / 2,\n height: M,\n }),\n cylinder({\n center: [plated_hole.x, plated_hole.y, -1.2 / 2],\n radius: plated_hole.outer_diameter / 2,\n height: M,\n }),\n ),\n cylinder({\n center: [plated_hole.x, plated_hole.y, 0],\n radius: plated_hole.hole_diameter / 2 - M,\n height: 1.5,\n }),\n ),\n )\n }\n if (plated_hole.shape === \"pill\") {\n const shouldRotate = plated_hole.hole_height! > plated_hole.hole_width!\n\n const holeWidth = shouldRotate\n ? plated_hole.hole_height!\n : plated_hole.hole_width!\n const holeHeight = shouldRotate\n ? plated_hole.hole_width!\n : plated_hole.hole_height!\n const outerHeight = shouldRotate\n ? plated_hole.outer_width || holeWidth + 0.2\n : plated_hole.outer_height || holeHeight + 0.2\n\n const holeRadius = holeHeight / 2\n const rectLength = Math.abs(holeWidth - holeHeight)\n\n const mainRect = cuboid({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y, 0]\n : [plated_hole.x, plated_hole.y, 0],\n size: shouldRotate\n ? [holeHeight, rectLength, 1.2]\n : [rectLength, holeHeight, 1.2],\n })\n\n const leftCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 0]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.2,\n })\n\n const rightCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 0]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.2,\n })\n\n const outerMainRect = cuboid({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y, 1.2 / 2]\n : [plated_hole.x, plated_hole.y, 1.2 / 2],\n size: shouldRotate\n ? [outerHeight, rectLength, M]\n : [rectLength, outerHeight, M],\n })\n\n const outerLeftCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 1.2 / 2]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n\n const outerRightCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 1.2 / 2]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n\n const bottomMainRect = cuboid({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y, -1.2 / 2]\n : [plated_hole.x, plated_hole.y, -1.2 / 2],\n size: shouldRotate\n ? [outerHeight, rectLength, M]\n : [rectLength, outerHeight, M],\n })\n\n const bottomLeftCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, -1.2 / 2]\n : [plated_hole.x - rectLength / 2, plated_hole.y, -1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n\n const bottomRightCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, -1.2 / 2]\n : [plated_hole.x + rectLength / 2, plated_hole.y, -1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n return colorize(\n colors.copper,\n subtract(\n union(\n mainRect,\n leftCap,\n rightCap,\n outerMainRect,\n outerLeftCap,\n outerRightCap,\n bottomMainRect,\n bottomLeftCap,\n bottomRightCap,\n ),\n union(\n cuboid({\n center: [plated_hole.x, plated_hole.y, 0],\n size: shouldRotate\n ? [holeHeight - M, rectLength, 1.5]\n : [rectLength, holeHeight - M, 1.5],\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 0]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 0],\n radius: holeRadius - M,\n height: 1.5,\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 0]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 0],\n radius: holeRadius - M,\n height: 1.5,\n }),\n ),\n ),\n )\n // biome-ignore lint/style/noUselessElse: <explanation>\n } else {\n throw new Error(`Unsupported plated hole shape: ${plated_hole.shape}`)\n }\n}\n","import type { RGB } from \"@jscad/modeling/src/colors\"\n\nexport const M = 0.01\n\nexport const colors = {\n copper: [0.9, 0.6, 0.2],\n fr4Green: [0x05 / 255, 0xa3 / 255, 0x2e / 255],\n fr4GreenSolderWithMask: [0x00 / 255, 0x98 / 255, 0x13 / 255],\n} satisfies Record<string, RGB>\n","import { extrudeLinear } from \"@jscad/modeling/src/operations/extrusions\"\nimport { polygon } from \"@jscad/modeling/src/primitives\"\nimport type { Geom2, Geom3 } from \"@jscad/modeling/src/geometries/types\"\nimport type { Vec2 } from \"@jscad/modeling/src/maths/types\"\nimport type { Point } from \"@tscircuit/soup\"\nimport { translate } from \"@jscad/modeling/src/operations/transforms\"\n\nconst arePointsClockwise = (points: Vec2[]): boolean => {\n let area = 0\n for (let i = 0; i < points.length; i++) {\n const j = (i + 1) % points.length\n area += points[i]![0] * points[j]![1]\n area -= points[j]![0] * points[i]![1]\n }\n const signedArea = area / 2\n return signedArea <= 0\n}\n\nexport const createBoardWithOutline = (points: Point[], depth = 1.2): Geom3 => {\n let outline: Vec2[] = points.map((point) => [point.x, point.y])\n\n if (arePointsClockwise(outline)) {\n outline = outline.reverse()\n }\n\n const shape: Geom2 = polygon({ points: outline })\n\n let board: Geom3 = extrudeLinear({ height: depth }, shape)\n\n board = translate([0, 0, -depth / 2], board)\n\n return board\n}\n","import { vectorText } from \"@jscad/modeling/src/text\"\nimport { PcbSilkscreenText } from \"circuit-json\"\n\n// Generate 2D text outlines\nexport function createSilkscreenTextGeoms(silkscreenText: PcbSilkscreenText) {\n // Generate 2D text outlines\n const textOutlines = vectorText({\n height: silkscreenText.font_size,\n input: silkscreenText.text,\n })\n // Split number 8 and small e into two parts to fix visual issues\n textOutlines.forEach((outline) => {\n if (outline.length === 29) {\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 1,\n outline.slice(0, 15),\n )\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 0,\n outline.slice(14, 29),\n )\n } else if (outline.length === 17) {\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 1,\n outline.slice(0, 10),\n )\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 0,\n outline.slice(9, 17),\n )\n }\n })\n // Calculate text bounds and center point\n const points = textOutlines.flatMap((o) => o)\n const textBounds = {\n minX: Math.min(...points.map((p) => p[0])),\n maxX: Math.max(...points.map((p) => p[0])),\n minY: Math.min(...points.map((p) => p[1])),\n maxY: Math.max(...points.map((p) => p[1])),\n }\n const centerX = (textBounds.minX + textBounds.maxX) / 2\n const centerY = (textBounds.minY + textBounds.maxY) / 2\n\n // Calculate offset based on anchor alignment\n let xOffset = -centerX\n let yOffset = -centerY\n\n // Adjust for specific alignments\n if (silkscreenText.anchor_alignment?.includes(\"right\")) {\n xOffset = -textBounds.maxX\n } else if (silkscreenText.anchor_alignment?.includes(\"left\")) {\n xOffset = -textBounds.minX\n }\n\n if (silkscreenText.anchor_alignment?.includes(\"top\")) {\n yOffset = -textBounds.maxY\n } else if (silkscreenText.anchor_alignment?.includes(\"bottom\")) {\n yOffset = -textBounds.minY\n }\n\n return { textOutlines, xOffset, yOffset }\n}\n","import { useState, useEffect } from \"react\"\nimport stlSerializer from \"@jscad/stl-serializer\"\nimport { Geom3 } from \"@jscad/modeling/src/geometries/types\"\n\nfunction blobToBase64Url(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => {\n resolve(reader.result as string)\n }\n reader.onerror = reject\n reader.readAsDataURL(blob)\n })\n}\n\ntype StlObj = { stlUrl: string; color: number[] }\n\nexport const useStlsFromGeom = (\n geom: Geom3[] | Geom3 | null,\n): {\n stls: StlObj[]\n loading: boolean\n} => {\n const [stls, setStls] = useState<StlObj[]>([])\n const [loading, setLoading] = useState(true)\n\n useEffect(() => {\n if (!geom) return\n const generateStls = async () => {\n setLoading(true)\n const geometries = Array.isArray(geom) ? geom : [geom]\n\n const stlPromises = geometries.map(async (g) => {\n const rawData = stlSerializer.serialize({ binary: true }, [g])\n const blobData = new Blob(rawData)\n const stlUrl = await blobToBase64Url(blobData)\n return { stlUrl, color: g.color! }\n })\n\n try {\n const generatedStls = await Promise.all(stlPromises)\n setStls(generatedStls)\n } catch (error) {\n console.error(\"Error generating STLs:\", error)\n setStls([])\n } finally {\n setLoading(false)\n }\n }\n\n generateStls()\n }, [geom])\n\n return { stls, loading }\n}\n","import { useLoader } from \"@react-three/fiber\"\nimport { useRef } from \"react\"\nimport * as THREE from \"three\"\nimport { MTLLoader, OBJLoader, STLLoader } from \"three-stdlib\"\n\nexport function STLModel({\n stlUrl,\n mtlUrl,\n color,\n opacity = 1,\n}: {\n stlUrl: string\n color?: any\n mtlUrl?: string\n opacity?: number\n}) {\n const geom = useLoader(STLLoader, stlUrl)\n const mesh = useRef<THREE.Mesh>()\n\n // TODO handle mtl url\n\n return (\n <mesh ref={mesh as any}>\n <primitive object={geom} attach=\"geometry\" />\n <meshStandardMaterial\n color={color}\n transparent={opacity !== 1}\n opacity={opacity}\n />\n {/* <Outlines thickness={0.05} color=\"black\" opacity={0.25} /> */}\n </mesh>\n )\n}\n","import type * as React from \"react\"\nimport type * as THREE from \"three\"\nimport { useHelper, Grid, OrbitControls } from \"@react-three/drei\"\nimport { Canvas, useFrame } from \"@react-three/fiber\"\nimport packageJson from \"../package.json\"\nimport { CubeWithLabeledSides } from \"./three-components/cube-with-labeled-sides\"\nimport { forwardRef, Suspense, useEffect, useRef } from \"react\"\n\nexport const RotationTracker = () => {\n useFrame(({ camera }) => {\n window.TSCI_MAIN_CAMERA_ROTATION = camera.rotation\n })\n\n return <></>\n}\n\nimport { Html } from \"@react-three/drei\"\n\ninterface Props {\n hoveredComponent: {\n cad_component_id: string\n name: string\n mousePosition: [number, number, number]\n } | null\n}\n\nexport const CadViewerContainer = forwardRef<\n THREE.Object3D,\n React.PropsWithChildren<Props>\n>(({ children, hoveredComponent }, ref) => {\n return (\n <div style={{ position: \"relative\", width: \"100%\", height: \"100%\" }}>\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: 120,\n height: 120,\n }}\n >\n <Canvas\n camera={{\n up: [0, 0, 1],\n position: [1, 1, 1],\n }}\n style={{ zIndex: 10 }}\n >\n <ambientLight intensity={Math.PI / 2} />\n <CubeWithLabeledSides />\n </Canvas>\n </div>\n <Canvas\n scene={{ up: [0, 0, 1] }}\n camera={{ up: [0, 0, 1], position: [5, 5, 5] }}\n >\n <RotationTracker />\n <OrbitControls autoRotate autoRotateSpeed={1} />\n <ambientLight intensity={Math.PI / 2} />\n <pointLight\n position={[-10, -10, 10]}\n decay={0}\n intensity={Math.PI / 4}\n />\n <Grid\n rotation={[Math.PI / 2, 0, 0]}\n infiniteGrid={true}\n cellSize={1}\n sectionSize={10}\n />\n <object3D ref={ref}>{children}</object3D>\n {hoveredComponent && (\n <Html\n position={hoveredComponent.mousePosition}\n style={{\n fontFamily: \"sans-serif\",\n transform: \"translate3d(50%, 50%, 0)\",\n backgroundColor: \"white\",\n padding: \"5px\",\n borderRadius: \"3px\",\n pointerEvents: \"none\",\n userSelect: \"none\",\n WebkitUserSelect: \"none\",\n MozUserSelect: \"none\",\n msUserSelect: \"none\",\n }}\n >\n {hoveredComponent.name}\n </Html>\n )}\n </Canvas>\n <div\n style={{\n position: \"absolute\",\n right: 24,\n bottom: 24,\n fontFamily: \"sans-serif\",\n color: \"white\",\n WebkitTextStroke: \"0.5px rgba(0, 0, 0, 0.5)\",\n fontSize: 11,\n }}\n >\n @{packageJson.version}\n </div>\n </div>\n )\n})\n","{\n \"name\": \"@tscircuit/3d-viewer\",\n \"version\": \"0.0.100\",\n \"main\": \"./dist/index.js\",\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"start\": \"bun run storybook\",\n \"dev:old\": \"bunx --bun vite\",\n \"build\": \"tsup ./src/index.tsx --dts --sourcemap\",\n \"prepublish\": \"npm run build\",\n \"preview\": \"vite preview\",\n \"storybook\": \"storybook dev -p 6006\",\n \"build-storybook\": \"storybook build\",\n \"vercel-build\": \"bun run build-storybook\",\n \"format\": \"biome format . --write\",\n \"format:check\": \"biome format .\"\n },\n \"dependencies\": {\n \"@jscad/modeling\": \"^2.12.2\",\n \"@jscad/regl-renderer\": \"^2.6.9\",\n \"@jscad/stl-serializer\": \"^2.1.17\",\n \"@react-three/drei\": \"^9.115.0\",\n \"@react-three/fiber\": \"^8.16.8\",\n \"@tscircuit/core\": \"^0.0.273\",\n \"@tscircuit/props\": \"^0.0.130\",\n \"@tscircuit/react-fiber\": \"^1.1.29\",\n \"@tscircuit/soup\": \"^0.0.69\",\n \"@tscircuit/soup-util\": \"^0.0.26\",\n \"@types/three\": \"^0.165.0\",\n \"jscad-electronics\": \"^0.0.23\",\n \"jscad-fiber\": \"^0.0.76\",\n \"jscad-planner\": \"^0.0.11\",\n \"react\": \"^18.3.1\",\n \"react-dom\": \"^18.3.1\",\n \"react-use-gesture\": \"^9.1.3\",\n \"three\": \"^0.165.0\",\n \"three-stdlib\": \"^2.30.3\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^1.8.3\",\n \"@chromatic-com/storybook\": \"^1.5.0\",\n \"@storybook/addon-essentials\": \"^8.4.7\",\n \"@storybook/addon-interactions\": \"^8.4.7\",\n \"@storybook/addon-links\": \"^8.4.7\",\n \"@storybook/addon-onboarding\": \"^8.4.7\",\n \"@storybook/blocks\": \"^8.4.7\",\n \"@storybook/builder-vite\": \"^8.4.7\",\n \"@storybook/react\": \"^8.4.7\",\n \"@storybook/react-vite\": \"^8.4.7\",\n \"@storybook/test\": \"^8.4.7\",\n \"@types/react\": \"^18.3.3\",\n \"@types/react-dom\": \"^18.3.0\",\n \"@vitejs/plugin-react\": \"^4.3.4\",\n \"circuit-json\": \"^0.0.116\",\n \"circuit-to-svg\": \"^0.0.91\",\n \"storybook\": \"^8.4.7\",\n \"strip-ansi\": \"^7.1.0\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.7.2\",\n \"vite\": \"^5.4.11\",\n \"vite-tsconfig-paths\": \"^4.3.2\"\n }\n}\n","import { Text } from \"@react-three/drei\"\nimport { useFrame } from \"@react-three/fiber\"\nimport { useRef } from \"react\"\nimport * as THREE from \"three\"\n\ndeclare global {\n interface Window {\n TSCI_MAIN_CAMERA_ROTATION: THREE.Euler\n }\n}\nif (typeof window !== \"undefined\") {\n window.TSCI_MAIN_CAMERA_ROTATION = new THREE.Euler(0, 0, 0)\n}\n\nfunction computePointInFront(rotationVector, distance) {\n // Create a quaternion from the rotation vector\n const quaternion = new THREE.Quaternion().setFromEuler(\n new THREE.Euler(rotationVector.x, rotationVector.y, rotationVector.z),\n )\n\n // Create a vector pointing forward (along the negative z-axis)\n const forwardVector = new THREE.Vector3(0, 0, 1)\n\n // Apply the rotation to the forward vector\n forwardVector.applyQuaternion(quaternion)\n\n // Scale the rotated vector by the distance\n const result = forwardVector.multiplyScalar(distance)\n\n return result\n}\n\nexport const CubeWithLabeledSides = ({}: any) => {\n const ref = useRef<THREE.Mesh>()\n const rotationTrackingRef = useRef({ lastRotation: new THREE.Euler() })\n useFrame((state, delta) => {\n if (!ref.current) return\n\n const mainRot = window.TSCI_MAIN_CAMERA_ROTATION\n\n // Use window.TSCI_CAMERA_ROTATION to compute the position of the camera\n const cameraPosition = computePointInFront(mainRot, 2)\n\n state.camera.position.copy(cameraPosition)\n state.camera.lookAt(0, 0, 0)\n })\n return (\n <mesh ref={ref as any} rotation={[Math.PI / 2, 0, 0]}>\n <boxGeometry args={[1, 1, 1]} />\n <meshStandardMaterial color=\"white\" />\n <Text position={[0, 0, 0.51]} fontSize={0.25} color=\"black\">\n Front\n </Text>\n <Text\n position={[0, 0, -0.51]}\n fontSize={0.25}\n color=\"black\"\n rotation={[0, Math.PI, 0]}\n >\n Back\n </Text>\n <Text\n position={[0.51, 0, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[0, Math.PI / 2, 0]}\n >\n Right\n </Text>\n <Text\n position={[-0.51, 0, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[0, -Math.PI / 2, 0]}\n >\n Left\n </Text>\n <Text\n position={[0, 0.51, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[-Math.PI / 2, 0, 0]}\n >\n Top\n </Text>\n <Text\n position={[0, -0.51, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[Math.PI / 2, 0, 0]}\n >\n Bottom\n </Text>\n <lineSegments\n args={[new THREE.EdgesGeometry(new THREE.BoxGeometry(1, 1, 1))]}\n material={\n new THREE.LineBasicMaterial({\n color: 0x000000,\n linewidth: 2,\n })\n }\n />\n </mesh>\n )\n}\n","import { Html } from \"@react-three/drei\"\nimport { GroupProps, useThree } from \"@react-three/fiber\"\nimport { useRef, useCallback } from \"react\"\nimport type { Vector3 } from \"three\"\nimport * as THREE from \"three\"\n\nconst Group = (props: GroupProps) => <group {...props} />\n\nconst ContainerWithTooltip = ({\n children,\n isHovered,\n onHover,\n position,\n}: {\n children: React.ReactNode\n position?: Vector3 | [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) => {\n const lastValidPointRef = useRef<THREE.Vector3 | null>(null)\n\n const handlePointerEnter = useCallback(\n (e: any) => {\n e.stopPropagation()\n\n try {\n // Fallback to event position if raycaster fails\n const point =\n e.point ||\n (e.intersections && e.intersections.length > 0\n ? e.intersections[0].point\n : null) ||\n (position\n ? new THREE.Vector3(...(position as [number, number, number]))\n : null)\n\n if (point) {\n lastValidPointRef.current = point\n onHover({ mousePosition: [point.x, point.y, point.z] })\n } else {\n onHover({})\n }\n } catch (error) {\n console.warn(\"Hover event error:\", error)\n onHover({})\n }\n },\n [position],\n )\n\n const handlePointerLeave = useCallback(\n (e: any) => {\n e.stopPropagation()\n lastValidPointRef.current = null\n\n // TODO REPLACE WITH onUnhover\n onHover(null)\n },\n [onHover],\n )\n\n return (\n <Group\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n >\n {children}\n </Group>\n )\n}\n\nexport default ContainerWithTooltip\n","import { useState, useEffect } from \"react\"\nimport type { Group } from \"three\"\nimport { MTLLoader, OBJLoader } from \"three-stdlib\"\n\n// Define the type for our cache\ninterface CacheItem {\n promise: Promise<any>\n result: Group | null\n}\n\ndeclare global {\n interface Window {\n TSCIRCUIT_OBJ_LOADER_CACHE: Map<string, CacheItem>\n }\n}\n\n// Ensure the global cache exists\nif (typeof window !== \"undefined\" && !window.TSCIRCUIT_OBJ_LOADER_CACHE) {\n window.TSCIRCUIT_OBJ_LOADER_CACHE = new Map<string, CacheItem>()\n}\n\nexport function useGlobalObjLoader(url: string | null): Group | null | Error {\n const [obj, setObj] = useState<Group | null | Error>(null)\n\n useEffect(() => {\n if (!url) return\n\n const cache = window.TSCIRCUIT_OBJ_LOADER_CACHE\n let hasUrlChanged = false\n\n async function loadAndParseObj() {\n try {\n const response = await fetch(url!)\n const text = await response.text()\n\n const mtlContent = text\n .match(/newmtl[\\s\\S]*?endmtl/g)\n ?.join(\"\\n\")!\n .replace(/d 0\\./g, \"d 1.\")!\n const objContent = text.replace(/newmtl[\\s\\S]*?endmtl/g, \"\")\n\n const mtlLoader = new MTLLoader()\n mtlLoader.setMaterialOptions({\n invertTrProperty: true,\n })\n const materials = mtlLoader.parse(\n mtlContent.replace(\n /Kd\\s+([\\d.]+)\\s+([\\d.]+)\\s+([\\d.]+)/g,\n \"Kd $2 $2 $2\",\n ),\n \"test.mtl\",\n )\n\n const objLoader = new OBJLoader()\n objLoader.setMaterials(materials)\n return objLoader.parse(objContent)\n } catch (error) {\n return error as Error\n }\n }\n\n function loadUrl() {\n if (cache.has(url!)) {\n const cacheItem = cache.get(url!)!\n if (cacheItem.result) {\n // If we have a result, clone it\n return Promise.resolve(cacheItem.result.clone())\n }\n // If we're still loading, return the existing promise\n return cacheItem.promise.then((result) => result.clone())\n }\n // If it's not in the cache, create a new promise and cache it\n const promise = loadAndParseObj().then((result) => {\n if (result instanceof Error) {\n // If the result is an Error, return it\n return result\n }\n cache.set(url!, { ...cache.get(url!)!, result })\n return result\n })\n cache.set(url!, { promise, result: null })\n return promise\n }\n\n loadUrl()\n .then((result) => {\n if (hasUrlChanged) return\n setObj(result)\n })\n .catch((error) => {\n console.error(error)\n })\n\n return () => {\n hasUrlChanged = true\n }\n }, [url])\n\n return obj\n}\n","import ContainerWithTooltip from \"src/ContainerWithTooltip\"\nimport { useGlobalObjLoader } from \"src/hooks/use-global-obj-loader\"\nimport type { Euler, Vector3 } from \"three\"\n\nexport function MixedStlModel({\n url,\n position,\n rotation,\n onHover,\n isHovered,\n}: {\n url: string\n position?: Vector3 | [number, number, number]\n rotation?: Euler | [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) {\n const obj = useGlobalObjLoader(url)\n\n if (!obj) {\n return (\n <ContainerWithTooltip isHovered={isHovered} onHover={onHover}>\n <mesh position={position}>\n <boxGeometry args={[0.5, 0.5, 0.5]} />\n <meshStandardMaterial transparent color=\"red\" opacity={0.25} />\n </mesh>\n </ContainerWithTooltip>\n )\n }\n\n // Check if obj is valid before rendering\n if (obj instanceof Error) {\n return (\n <ContainerWithTooltip isHovered={isHovered} onHover={onHover}>\n <mesh position={position}>\n <boxGeometry args={[0.5, 0.5, 0.5]} />\n <meshStandardMaterial transparent color=\"red\" opacity={0.5} />\n <meshBasicMaterial color=\"red\" />\n </mesh>\n </ContainerWithTooltip>\n )\n }\n return (\n <ContainerWithTooltip isHovered={isHovered} onHover={onHover}>\n <primitive rotation={rotation} position={position} object={obj} />\n </ContainerWithTooltip>\n )\n}\n","import type { JscadOperation } from \"jscad-planner\"\nimport { executeJscadOperations } from \"jscad-planner\"\nimport jscad from \"@jscad/modeling\"\nimport { convertCSGToThreeGeom } from \"jscad-fiber\"\nimport * as THREE from \"three\"\nimport { useMemo } from \"react\"\nimport ContainerWithTooltip from \"src/ContainerWithTooltip\"\n\nexport const JscadModel = ({\n jscadPlan,\n positionOffset,\n rotationOffset,\n onHover,\n isHovered,\n}: {\n jscadPlan: JscadOperation\n positionOffset?: [number, number, number]\n rotationOffset?: [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) => {\n const { threeGeom, material } = useMemo(() => {\n const jscadObject = executeJscadOperations(jscad as any, jscadPlan)\n\n const threeGeom = convertCSGToThreeGeom(jscadObject)\n\n const material = new THREE.MeshStandardMaterial({\n vertexColors: true,\n side: THREE.DoubleSide, // Ensure both sides are visible\n })\n return { threeGeom, material }\n }, [jscadPlan])\n\n useMemo(() => {\n if (isHovered) {\n const color = new THREE.Color(material.color.getHex())\n material.emissive.copy(color)\n material.emissive.setRGB(0, 0, 1)\n material.emissiveIntensity = 0.2\n } else {\n material.emissiveIntensity = 0\n }\n }, [isHovered, material])\n if (!threeGeom) return null\n\n return (\n <ContainerWithTooltip\n isHovered={isHovered}\n onHover={onHover}\n position={positionOffset}\n >\n <mesh\n geometry={threeGeom}\n material={material}\n position={positionOffset}\n rotation={rotationOffset}\n />\n </ContainerWithTooltip>\n )\n}\n","import { Footprinter3d } from \"jscad-electronics\"\nimport { createJSCADRenderer } from \"jscad-fiber\"\nimport { jscadPlanner } from \"jscad-planner\"\nimport { useMemo } from \"react\"\nimport { JscadModel } from \"./JscadModel\"\n\nconst { createJSCADRoot } = createJSCADRenderer(jscadPlanner as any)\n\nexport const FootprinterModel = ({\n positionOffset,\n footprint,\n rotationOffset,\n onHover,\n isHovered,\n}: {\n positionOffset: any\n footprint: string\n rotationOffset?: [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) => {\n const jscadOperations = useMemo(() => {\n if (!footprint) return null\n const jscadOperations: any[] = []\n const root = createJSCADRoot(jscadOperations)\n root.render(<Footprinter3d footprint={footprint} />)\n return jscadOperations\n }, [footprint])\n\n if (!jscadOperations) return null\n\n return (\n <>\n {jscadOperations.map((operation, index) => (\n <JscadModel\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n key={index}\n positionOffset={positionOffset}\n rotationOffset={rotationOffset}\n jscadPlan={operation}\n onHover={onHover}\n isHovered={isHovered}\n />\n ))}\n </>\n )\n}\n","export const tuple = <T extends any[]>(...args: T): T => args\n","import type { AnyCircuitElement, CadComponent } from \"circuit-json\"\nimport { useConvertChildrenToSoup } from \"./hooks/use-convert-children-to-soup\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { useMemo, useState } from \"react\"\nimport { createBoardGeomFromSoup } from \"./soup-to-3d\"\nimport { useStlsFromGeom } from \"./hooks/use-stls-from-geom\"\nimport { STLModel } from \"./three-components/STLModel\"\nimport { CadViewerContainer } from \"./CadViewerContainer\"\nimport { MixedStlModel } from \"./three-components/MixedStlModel\"\nimport { Euler } from \"three\"\nimport { JscadModel } from \"./three-components/JscadModel\"\nimport { Footprinter3d } from \"jscad-electronics\"\nimport { FootprinterModel } from \"./three-components/FootprinterModel\"\nimport { tuple } from \"./utils/tuple\"\n\nexport const AnyCadComponent = ({\n cad_component,\n onHover = () => {},\n isHovered = false,\n}: {\n cad_component: CadComponent\n onHover?: (e: any) => void\n isHovered?: boolean\n}) => {\n const url = cad_component.model_obj_url ?? cad_component.model_stl_url\n const rotationOffset = cad_component.rotation\n ? tuple(\n (cad_component.rotation.x * Math.PI) / 180,\n (cad_component.rotation.y * Math.PI) / 180,\n (cad_component.rotation.z * Math.PI) / 180,\n )\n : undefined\n\n if (url) {\n return (\n <MixedStlModel\n key={cad_component.cad_component_id}\n url={url}\n position={\n cad_component.position\n ? [\n cad_component.position.x,\n cad_component.position.y,\n cad_component.position.z,\n ]\n : undefined\n }\n rotation={rotationOffset}\n onHover={onHover}\n isHovered={isHovered}\n />\n )\n }\n\n if (cad_component.model_jscad) {\n return (\n <JscadModel\n key={cad_component.cad_component_id}\n jscadPlan={cad_component.model_jscad as any}\n rotationOffset={rotationOffset}\n onHover={onHover}\n isHovered={isHovered}\n />\n )\n }\n\n if (cad_component.footprinter_string) {\n return (\n <FootprinterModel\n positionOffset={\n cad_component.position\n ? [\n cad_component.position.x,\n cad_component.position.y,\n cad_component.position.z,\n ]\n : undefined\n }\n rotationOffset={rotationOffset}\n footprint={cad_component.footprinter_string}\n onHover={onHover}\n isHovered={isHovered}\n />\n )\n }\n}\n","import React from \"react\"\n\ninterface Props {\n children: React.ReactNode\n fallback: (props: { error: Error }) => any\n}\n\ninterface State {\n hasError: boolean\n error: Error | null\n}\n\nexport class ThreeErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props)\n this.state = { hasError: false, error: null }\n }\n\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error }\n }\n\n override render() {\n if (this.state.hasError && this.state.error) {\n return this.props.fallback({ error: this.state.error })\n }\n\n return this.props.children\n }\n}\n","import { Text } from \"@react-three/drei\"\nimport type { CadComponent } from \"circuit-json\"\n\nexport const Error3d = ({\n error,\n cad_component,\n}: { error: any; cad_component?: CadComponent }) => {\n let position = [0, 0, 0]\n if (cad_component?.position) {\n position = [\n cad_component.position.x,\n cad_component.position.y,\n cad_component.position.z,\n ]\n // make sure the position doesn't have any NaN values\n position = position.map((p) => (Number.isNaN(p) ? 0 : p))\n }\n return (\n <group\n // @ts-expect-error\n position={position}\n >\n <mesh\n renderOrder={-99999}\n rotation={[Math.PI / 4, Math.PI / 4, 0]}\n ref={(mesh) => {\n if (mesh) {\n mesh.renderOrder = 999999\n }\n }}\n >\n <boxGeometry args={[0.5, 0.5, 0.5]} />\n <meshStandardMaterial\n depthTest={false}\n transparent\n color=\"red\"\n opacity={0.5}\n />\n </mesh>\n <Text\n scale={[0.1, 0.1, 0.1]}\n color=\"red\" // default\n anchorX=\"center\" // default\n anchorY=\"middle\" // default\n depthOffset={-99999}\n >\n {error.toString().slice(0, 50)}...\n </Text>\n </group>\n ) as any\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,0BAAuD;AACvD,mBAA0D;AAOnD,SAAS,cACd,UAAU,CAAC,GAIX;AACA,QAAM,QAAQ,UAAU,OAAO;AAC/B,QAAM,WAAO,sBAAQ,MAAM,SAAS,cAAc,GAAG,GAAG,CAAC,CAAC;AAC1D,QAAM,SAAS,OAAO,aAAsB;AAC1C,UAAM,OAAO,YAAY,Q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A,EACrC,GAAG,CAAC,IAAI,CAAC;AAET,QAAM,EAAE,MAAM,WAAW,QAAQ,IAAI,gBAAgB,SAAS;AAE9D,QAAM,qBAAiB,sBAAG,IAAI,EAAE,cAAc,KAAK;AAEnD,SACE,+CAAC,sBAAmB,KAAU,kBAC3B;AAAA,cAAU,IAAI,CAAC,EAAE,QAAQ,MAAM,GAAG,UACjC;AAAA,MAAC;AAAA;AAAA,QAEC;AAAA,QACA;AAAA,QACA,SAAS,UAAU,IAAI,OAAO;AAAA;AAAA,MAHzB;AAAA,IAIP,CACD;AAAA,IACA,eAAe,IAAI,CAAC,kBACnB;AAAA,MAAC;AAAA;AAAA,QAEC,UAAU,CAAC,EAAE,MAAM,MACjB,8CAAC,WAAQ,eAA8B,OAAc;AAAA,QAGvD;AAAA,UAAC;AAAA;AAAA,YAEC,SAAS,CAAC,MAAM;AAEd,kBAAI,CAAC,GAAG;AACN,oCAAoB,IAAI;AAAA,cAC1B;AACA,kBAAI,CAAC,EAAE,cAAe;AAEtB,oBAAM,oBAAgB,sBAAG,IAAW,EAAE,iBAAiB,SAAS;AAAA,gBAC9D,qBAAqB,cAAc;AAAA,cACrC,CAAC,GAAG;AACJ,kCAAoB;AAAA,gBAClB,kBAAkB,cAAc;AAAA,gBAChC,MAAM,iBAAiB;AAAA,gBACvB,eAAe,EAAE;AAAA,cACnB,CAAC;AAAA,YACH;AAAA,YACA;AAAA,YACA,WACE,kBAAkB,qBAClB,cAAc;AAAA;AAAA,UApBX,cAAc;AAAA,QAsBrB;AAAA;AAAA,MA5BK,cAAc;AAAA,IA6BrB,CACD;AAAA,KACH;AAEJ,CAAC;","names":["import_react","import_soup_util","import_react","import_transforms","import_primitives","import_colors","import_booleans","import_extrusions","import_primitives","import_react","stlSerializer","import_react","import_three_stdlib","import_drei","import_fiber","import_fiber","import_react","import_jsx_runtime","import_react","import_drei","import_jsx_runtime","import_react","THREE","import_jsx_runtime","import_react","import_three_stdlib","import_jsx_runtime","THREE","import_react","import_jsx_runtime","jscad","threeGeom","material","import_jscad_fiber","import_jscad_planner","import_react","import_jsx_runtime","jscadOperations","import_jsx_runtime","import_react","React","import_drei","import_jsx_runtime","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/hooks/exporter/gltf.ts","../src/hooks/use-convert-children-to-soup.ts","../src/CadViewer.tsx","../src/soup-to-3d/index.ts","../src/geoms/plated-hole.ts","../src/geoms/constants.ts","../src/geoms/create-board-with-outline.ts","../src/geoms/create-geoms-for-silkscreen-text.ts","../src/hooks/use-stls-from-geom.ts","../src/three-components/STLModel.tsx","../src/CadViewerContainer.tsx","../package.json","../src/three-components/cube-with-labeled-sides.tsx","../src/ContainerWithTooltip.tsx","../src/hooks/use-global-obj-loader.ts","../src/three-components/MixedStlModel.tsx","../src/three-components/JscadModel.tsx","../src/three-components/FootprinterModel.tsx","../src/utils/tuple.ts","../src/AnyCadComponent.tsx","../src/three-components/ThreeErrorBoundary.tsx","../src/three-components/Error3d.tsx"],"sourcesContent":["export * from \"./hooks/index.ts\"\nexport { CadViewer } from \"./CadViewer.tsx\"\n","import type * as React from \"react\"\nimport type * as THREE from \"three\"\nimport { GLTFExporter, type GLTFExporterOptions } from \"three-stdlib\"\nimport { useEffect, useState, useMemo, useCallback } from \"react\"\n\ntype Options = Omit<\n GLTFExporterOptions,\n \"animations\" | \"includeCustomExtensions\"\n>\n\nexport function useSaveGltfAs(\n options = {} as Options & { filename?: string },\n): [\n ref3D: React.ForwardedRef<THREE.Object3D>,\n saveAs: (filename?: string) => Promise<void>,\n] {\n const parse = useParser(options)\n const link = useMemo(() => document.createElement(\"a\"), [])\n const saveAs = async (filename?: string) => {\n const name = filename ?? options.filename ?? \"\"\n if (options.binary == null) options.binary = name.endsWith(\".glb\")\n const url = await parse(instance!)\n link.download = name\n link.href = url\n link.dispatchEvent(new MouseEvent(\"click\"))\n URL.revokeObjectURL(url)\n }\n\n useEffect(\n () => () => {\n link.remove()\n instance = null\n },\n [],\n )\n\n let instance: THREE.Object3D | null\n const ref = useCallback((obj3D: THREE.Object3D | null) => {\n instance = obj3D!\n }, [])\n\n return [ref, saveAs]\n}\n\nexport function useExportGltfUrl(\n options = {} as Options,\n): [\n ref3D: React.ForwardedRef<THREE.Object3D>,\n url: string | undefined,\n error: ErrorEvent | undefined,\n] {\n const parse = useParser(options)\n const [url, setUrl] = useState<string>()\n const [error, setError] = useState<ErrorEvent>()\n const ref = useCallback(\n (instance: THREE.Object3D | null) =>\n parse(instance!).then(setUrl).catch(setError),\n [],\n )\n useEffect(() => () => URL.revokeObjectURL(url!), [url])\n return [ref, url, error]\n}\n\nfunction useParser(options = {} as Options) {\n const exporter = useMemo(() => new GLTFExporter(), [])\n return (instance: THREE.Object3D) => {\n const { promise, resolve, reject } = Promise.withResolvers<string>()\n exporter.parse(\n instance,\n (gltf) => {\n const type = options.binary ? \"gltf-binary\" : \"gltf+json\"\n const blob = new Blob(\n [gltf instanceof ArrayBuffer ? gltf : JSON.stringify(gltf)],\n { type: `model/${type}` },\n )\n resolve(URL.createObjectURL(blob))\n },\n reject,\n options,\n )\n return promise\n }\n}\n","import { Circuit } from \"@tscircuit/core\"\nimport { useMemo } from \"react\"\nimport type { AnyCircuitElement } from \"circuit-json\"\n\nexport const useConvertChildrenToSoup = (\n children?: any,\n defaultSoup?: AnyCircuitElement[],\n): AnyCircuitElement[] => {\n return useMemo(() => {\n if (!children) return\n const circuit = new Circuit()\n circuit.add(children)\n circuit.render()\n return circuit.getCircuitJson() as any\n }, [children])\n}\n","import type { AnySoupElement } from \"@tscircuit/soup\"\nimport type * as React from \"react\"\nimport type * as THREE from \"three\"\nimport { useConvertChildrenToSoup } from \"./hooks/use-convert-children-to-soup\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { useEffect, useMemo, useState, forwardRef } from \"react\"\nimport { createBoardGeomFromSoup } from \"./soup-to-3d\"\nimport { useStlsFromGeom } from \"./hooks/use-stls-from-geom\"\nimport { STLModel } from \"./three-components/STLModel\"\nimport { CadViewerContainer } from \"./CadViewerContainer\"\nimport { MixedStlModel } from \"./three-components/MixedStlModel\"\nimport { Euler } from \"three\"\nimport { JscadModel } from \"./three-components/JscadModel\"\nimport { Footprinter3d } from \"jscad-electronics\"\nimport { FootprinterModel } from \"./three-components/FootprinterModel\"\nimport { tuple } from \"./utils/tuple\"\nimport { AnyCadComponent } from \"./AnyCadComponent\"\nimport { Text } from \"@react-three/drei\"\nimport { ThreeErrorBoundary } from \"./three-components/ThreeErrorBoundary\"\nimport { Error3d } from \"./three-components/Error3d\"\n\ninterface Props {\n soup?: AnySoupElement[]\n}\n\nexport const CadViewer = forwardRef<\n THREE.Object3D,\n React.PropsWithChildren<Props>\n>(({ soup, children }, ref) => {\n const [hoveredComponent, setHoveredComponent] = useState<null | {\n cad_component_id: string\n name: string\n mousePosition: [number, number, number]\n }>(null)\n soup ??= useConvertChildrenToSoup(children, soup) as any\n\n if (!soup) return null\n\n const boardGeom = useMemo(() => {\n if (!soup.some((e) => e.type === \"pcb_board\")) return null\n return createBoardGeomFromSoup(soup)\n }, [soup])\n\n const { stls: boardStls, loading } = useStlsFromGeom(boardGeom)\n\n const cad_components = su(soup).cad_component.list()\n\n return (\n <CadViewerContainer ref={ref} hoveredComponent={hoveredComponent}>\n {boardStls.map(({ stlUrl, color }, index) => (\n <STLModel\n key={stlUrl}\n stlUrl={stlUrl}\n color={color}\n opacity={index === 0 ? 0.95 : 1}\n />\n ))}\n {cad_components.map((cad_component) => (\n <ThreeErrorBoundary\n key={cad_component.cad_component_id}\n fallback={({ error }) => (\n <Error3d cad_component={cad_component} error={error} />\n )}\n >\n <AnyCadComponent\n key={cad_component.cad_component_id}\n onHover={(e) => {\n // TODO this should be done by onUnhover\n if (!e) {\n setHoveredComponent(null)\n }\n if (!e.mousePosition) return\n\n const componentName = su(soup as any).source_component.getUsing({\n source_component_id: cad_component.source_component_id,\n })?.name\n setHoveredComponent({\n cad_component_id: cad_component.cad_component_id,\n name: componentName ?? \"<unknown>\",\n mousePosition: e.mousePosition,\n })\n }}\n cad_component={cad_component}\n isHovered={\n hoveredComponent?.cad_component_id ===\n cad_component.cad_component_id\n }\n />\n </ThreeErrorBoundary>\n ))}\n </CadViewerContainer>\n )\n})\n","import type { Geom3 } from \"@jscad/modeling/src/geometries/types\"\nimport type { AnySoupElement, PCBPlatedHole } from \"@tscircuit/soup\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { translate } from \"@jscad/modeling/src/operations/transforms\"\nimport { cuboid, cylinder, line } from \"@jscad/modeling/src/primitives\"\nimport { colorize } from \"@jscad/modeling/src/colors\"\nimport { subtract, union } from \"@jscad/modeling/src/operations/booleans\"\nimport { platedHole } from \"../geoms/plated-hole\"\nimport { M, colors } from \"../geoms/constants\"\nimport { extrudeLinear } from \"@jscad/modeling/src/operations/extrusions\"\nimport { expand } from \"@jscad/modeling/src/operations/expansions\"\nimport { createBoardWithOutline } from \"src/geoms/create-board-with-outline\"\nimport { Vec2 } from \"@jscad/modeling/src/maths/types\"\nimport { createSilkscreenTextGeoms } from \"src/geoms/create-geoms-for-silkscreen-text\"\nimport { PcbSilkscreenText } from \"circuit-json\"\nexport const createBoardGeomFromSoup = (soup: AnySoupElement[]): Geom3[] => {\n const board = su(soup).pcb_board.list()[0]\n if (!board) {\n throw new Error(\"No pcb_board found\")\n }\n const plated_holes = su(soup).pcb_plated_hole.list()\n const holes = su(soup).pcb_hole.list()\n const pads = su(soup).pcb_smtpad.list()\n const traces = su(soup).pcb_trace.list()\n const pcb_vias = su(soup).pcb_via.list()\n const silkscreenTexts = su(soup).pcb_silkscreen_text.list()\n\n // PCB Board\n let boardGeom: Geom3\n if (board.outline && board.outline.length > 0)\n boardGeom = createBoardWithOutline(board.outline, 1.2)\n else boardGeom = cuboid({ size: [board.width, board.height, 1.2] })\n\n const platedHoleGeoms: Geom3[] = []\n const holeGeoms: Geom3[] = []\n const padGeoms: Geom3[] = []\n const traceGeoms: Geom3[] = []\n const ctx = {\n pcbThickness: 1.2,\n }\n\n const addPlatedHole = (plated_hole: PCBPlatedHole) => {\n if (plated_hole.shape === \"circle\") {\n const cyGeom = cylinder({\n center: [plated_hole.x, plated_hole.y, 0],\n radius: plated_hole.hole_diameter / 2 + M,\n })\n\n boardGeom = subtract(boardGeom, cyGeom)\n\n const platedHoleGeom = platedHole(plated_hole, ctx)\n platedHoleGeoms.push(platedHoleGeom)\n } else if (plated_hole.shape === \"pill\") {\n const shouldRotate = plated_hole.hole_height! > plated_hole.hole_width!\n\n const holeWidth = shouldRotate\n ? plated_hole.hole_height!\n : plated_hole.hole_width!\n const holeHeight = shouldRotate\n ? plated_hole.hole_width!\n : plated_hole.hole_height!\n\n const holeRadius = holeHeight / 2\n const rectLength = Math.abs(holeWidth - holeHeight)\n\n const pillHole = union(\n cuboid({\n center: [plated_hole.x, plated_hole.y, 0],\n size: shouldRotate\n ? [holeHeight, rectLength, 1.5]\n : [rectLength, holeHeight, 1.5],\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 0]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.5,\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 0]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.5,\n }),\n )\n boardGeom = subtract(boardGeom, pillHole)\n\n const platedHoleGeom = platedHole(plated_hole, ctx)\n platedHoleGeoms.push(platedHoleGeom)\n }\n }\n\n for (const plated_hole of plated_holes) {\n addPlatedHole(plated_hole)\n }\n\n for (const hole of holes) {\n // @ts-expect-error\n if (hole.hole_shape === \"round\" || hole.hole_shape === \"circle\") {\n const cyGeom = cylinder({\n center: [hole.x, hole.y, 0],\n radius: hole.hole_diameter / 2 + M,\n })\n boardGeom = subtract(boardGeom, cyGeom)\n }\n }\n\n for (const pad of pads) {\n const layerSign = pad.layer === \"bottom\" ? -1 : 1\n if (pad.shape === \"rect\") {\n const padGeom = colorize(\n colors.copper,\n cuboid({\n center: [pad.x, pad.y, (layerSign * 1.2) / 2 + layerSign * M],\n size: [pad.width, pad.height, M],\n }),\n )\n padGeoms.push(padGeom)\n } else if (pad.shape === \"circle\") {\n const padGeom = colorize(\n colors.copper,\n cylinder({\n center: [pad.x, pad.y, (layerSign * 1.2) / 2 + layerSign * M],\n radius: pad.radius,\n height: M,\n }),\n )\n padGeoms.push(padGeom)\n }\n }\n\n for (const { route: mixedRoute } of traces) {\n if (mixedRoute.length < 2) continue\n\n // Group routes by continuous segments\n const routeSegments: (typeof mixedRoute)[] = []\n let currentSegment: typeof mixedRoute = [mixedRoute[0]!]\n let currentLayer =\n mixedRoute[0]!.route_type === \"wire\" ? mixedRoute[0]!.layer : \"top\"\n\n for (let i = 1; i < mixedRoute.length; i++) {\n const point = mixedRoute[i]!\n\n if (point.route_type === \"via\") {\n // Complete current segment and start a new one\n routeSegments.push(currentSegment)\n currentSegment = [point]\n } else if (point.route_type === \"wire\" && point.layer !== currentLayer) {\n // Complete current segment and start a new one on a different layer\n routeSegments.push(currentSegment)\n currentLayer = point.layer\n currentSegment = [point]\n } else {\n currentSegment.push(point)\n }\n }\n\n // Add the last segment\n routeSegments.push(currentSegment)\n\n // Render each route segment\n for (const route of routeSegments) {\n if (route.length < 2) continue\n\n const linePath = line(route.map((p) => [p.x, p.y]))\n const layerSign =\n route[0]!.route_type === \"via\"\n ? route[0]!.to_layer === \"top\"\n ? 1\n : -1\n : route[0]!.layer === \"top\"\n ? 1\n : -1\n\n let traceGeom = translate(\n [0, 0, (layerSign * 1.2) / 2],\n extrudeLinear(\n { height: M * layerSign },\n expand({ delta: 0.1, corners: \"edge\" }, linePath),\n ),\n )\n\n // Modify via subtraction to preserve trace geometry\n const viaSubtractions = pcb_vias.map((via) =>\n cylinder({\n center: [via.x, via.y, 0],\n radius: via.outer_diameter / 2,\n height: 5,\n }),\n )\n\n const holeSubtractions = plated_holes\n .filter((ph) => ph.shape === \"circle\")\n .map((ph) =>\n cylinder({\n center: [ph.x, ph.y, 0],\n radius: ph.outer_diameter / 2,\n height: 5,\n }),\n )\n\n // Subtract vias and holes without removing entire trace\n traceGeom = subtract(traceGeom, ...viaSubtractions, ...holeSubtractions)\n\n traceGeom = colorize(colors.fr4GreenSolderWithMask, traceGeom)\n\n traceGeoms.push(traceGeom)\n }\n }\n\n for (const via of pcb_vias) {\n addPlatedHole({\n x: via.x,\n y: via.y,\n hole_diameter: via.hole_diameter,\n outer_diameter: via.outer_diameter,\n shape: \"circle\",\n layers: [\"top\", \"bottom\"],\n type: \"pcb_plated_hole\",\n pcb_plated_hole_id: \"\",\n })\n }\n // Add silkscreen text\n const silkscreenGeoms: Geom3[] = []\n for (const silkscreenText of silkscreenTexts) {\n const { textOutlines, xOffset, yOffset } = createSilkscreenTextGeoms(\n silkscreenText as PcbSilkscreenText,\n )\n\n for (let outline of textOutlines) {\n // Create path from outline points with alignment offset\n\n const alignedOutline = outline.map((point) => [\n point[0] + xOffset + silkscreenText.anchor_position.x,\n point[1] + yOffset + silkscreenText.anchor_position.y,\n ]) as Vec2[]\n const textPath = line(alignedOutline)\n\n // Scale expansion delta with font size\n const fontSize = silkscreenText.font_size || 0.25\n const expansionDelta = Math.min(\n Math.max(0.01, fontSize * 0.1),\n fontSize * 0.2, // Maximum cap scales with font size\n )\n const expandedPath = expand(\n {\n delta: expansionDelta,\n corners: \"round\",\n },\n textPath,\n )\n\n // Extrude and position the text with smaller height\n let textGeom = translate(\n [0, 0, 0.6], // Position above board\n extrudeLinear(\n { height: 0.012 }, // Thinner extrusion\n expandedPath,\n ),\n )\n\n // Color white like silkscreen\n textGeom = colorize([256, 256, 256], textGeom)\n\n silkscreenGeoms.push(textGeom)\n }\n }\n\n // Colorize to a PCB green color: #05A32E\n boardGeom = colorize(colors.fr4Green, boardGeom)\n\n return [\n boardGeom,\n ...platedHoleGeoms,\n ...padGeoms,\n ...traceGeoms,\n ...silkscreenGeoms,\n ]\n}\n","import type { PCBPlatedHole } from \"@tscircuit/soup\"\nimport type { Geom3 } from \"@jscad/modeling/src/geometries/types\"\nimport { cuboid, cylinder } from \"@jscad/modeling/src/primitives\"\nimport { colorize } from \"@jscad/modeling/src/colors\"\nimport { subtract, union } from \"@jscad/modeling/src/operations/booleans\"\nimport { M, colors } from \"./constants\"\nimport type { GeomContext } from \"../GeomContext\"\n\nexport const platedHole = (\n plated_hole: PCBPlatedHole,\n ctx: GeomContext,\n): Geom3 => {\n if (!(plated_hole as PCBPlatedHole).shape) plated_hole.shape = \"circle\"\n if (plated_hole.shape === \"circle\") {\n return colorize(\n colors.copper,\n subtract(\n union(\n cylinder({\n center: [plated_hole.x, plated_hole.y, 0],\n radius: plated_hole.hole_diameter / 2,\n height: 1.2,\n }),\n cylinder({\n center: [plated_hole.x, plated_hole.y, 1.2 / 2],\n radius: plated_hole.outer_diameter / 2,\n height: M,\n }),\n cylinder({\n center: [plated_hole.x, plated_hole.y, -1.2 / 2],\n radius: plated_hole.outer_diameter / 2,\n height: M,\n }),\n ),\n cylinder({\n center: [plated_hole.x, plated_hole.y, 0],\n radius: plated_hole.hole_diameter / 2 - M,\n height: 1.5,\n }),\n ),\n )\n }\n if (plated_hole.shape === \"pill\") {\n const shouldRotate = plated_hole.hole_height! > plated_hole.hole_width!\n\n const holeWidth = shouldRotate\n ? plated_hole.hole_height!\n : plated_hole.hole_width!\n const holeHeight = shouldRotate\n ? plated_hole.hole_width!\n : plated_hole.hole_height!\n const outerHeight = shouldRotate\n ? plated_hole.outer_width || holeWidth + 0.2\n : plated_hole.outer_height || holeHeight + 0.2\n\n const holeRadius = holeHeight / 2\n const rectLength = Math.abs(holeWidth - holeHeight)\n\n const mainRect = cuboid({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y, 0]\n : [plated_hole.x, plated_hole.y, 0],\n size: shouldRotate\n ? [holeHeight, rectLength, 1.2]\n : [rectLength, holeHeight, 1.2],\n })\n\n const leftCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 0]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.2,\n })\n\n const rightCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 0]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 0],\n radius: holeRadius,\n height: 1.2,\n })\n\n const outerMainRect = cuboid({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y, 1.2 / 2]\n : [plated_hole.x, plated_hole.y, 1.2 / 2],\n size: shouldRotate\n ? [outerHeight, rectLength, M]\n : [rectLength, outerHeight, M],\n })\n\n const outerLeftCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 1.2 / 2]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n\n const outerRightCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 1.2 / 2]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n\n const bottomMainRect = cuboid({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y, -1.2 / 2]\n : [plated_hole.x, plated_hole.y, -1.2 / 2],\n size: shouldRotate\n ? [outerHeight, rectLength, M]\n : [rectLength, outerHeight, M],\n })\n\n const bottomLeftCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, -1.2 / 2]\n : [plated_hole.x - rectLength / 2, plated_hole.y, -1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n\n const bottomRightCap = cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, -1.2 / 2]\n : [plated_hole.x + rectLength / 2, plated_hole.y, -1.2 / 2],\n radius: outerHeight / 2,\n height: M,\n })\n return colorize(\n colors.copper,\n subtract(\n union(\n mainRect,\n leftCap,\n rightCap,\n outerMainRect,\n outerLeftCap,\n outerRightCap,\n bottomMainRect,\n bottomLeftCap,\n bottomRightCap,\n ),\n union(\n cuboid({\n center: [plated_hole.x, plated_hole.y, 0],\n size: shouldRotate\n ? [holeHeight - M, rectLength, 1.5]\n : [rectLength, holeHeight - M, 1.5],\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y - rectLength / 2, 0]\n : [plated_hole.x - rectLength / 2, plated_hole.y, 0],\n radius: holeRadius - M,\n height: 1.5,\n }),\n cylinder({\n center: shouldRotate\n ? [plated_hole.x, plated_hole.y + rectLength / 2, 0]\n : [plated_hole.x + rectLength / 2, plated_hole.y, 0],\n radius: holeRadius - M,\n height: 1.5,\n }),\n ),\n ),\n )\n // biome-ignore lint/style/noUselessElse: <explanation>\n } else {\n throw new Error(`Unsupported plated hole shape: ${plated_hole.shape}`)\n }\n}\n","import type { RGB } from \"@jscad/modeling/src/colors\"\n\nexport const M = 0.01\n\nexport const colors = {\n copper: [0.9, 0.6, 0.2],\n fr4Green: [0x05 / 255, 0xa3 / 255, 0x2e / 255],\n fr4GreenSolderWithMask: [0x00 / 255, 0x98 / 255, 0x13 / 255],\n} satisfies Record<string, RGB>\n","import { extrudeLinear } from \"@jscad/modeling/src/operations/extrusions\"\nimport { polygon } from \"@jscad/modeling/src/primitives\"\nimport type { Geom2, Geom3 } from \"@jscad/modeling/src/geometries/types\"\nimport type { Vec2 } from \"@jscad/modeling/src/maths/types\"\nimport type { Point } from \"@tscircuit/soup\"\nimport { translate } from \"@jscad/modeling/src/operations/transforms\"\n\nconst arePointsClockwise = (points: Vec2[]): boolean => {\n let area = 0\n for (let i = 0; i < points.length; i++) {\n const j = (i + 1) % points.length\n area += points[i]![0] * points[j]![1]\n area -= points[j]![0] * points[i]![1]\n }\n const signedArea = area / 2\n return signedArea <= 0\n}\n\nexport const createBoardWithOutline = (points: Point[], depth = 1.2): Geom3 => {\n let outline: Vec2[] = points.map((point) => [point.x, point.y])\n\n if (arePointsClockwise(outline)) {\n outline = outline.reverse()\n }\n\n const shape: Geom2 = polygon({ points: outline })\n\n let board: Geom3 = extrudeLinear({ height: depth }, shape)\n\n board = translate([0, 0, -depth / 2], board)\n\n return board\n}\n","import { vectorText } from \"@jscad/modeling/src/text\"\nimport { PcbSilkscreenText } from \"circuit-json\"\n\n// Generate 2D text outlines\nexport function createSilkscreenTextGeoms(silkscreenText: PcbSilkscreenText) {\n // Generate 2D text outlines\n const textOutlines = vectorText({\n height: silkscreenText.font_size,\n input: silkscreenText.text,\n })\n // Split number 8 and small e into two parts to fix visual issues\n textOutlines.forEach((outline) => {\n if (outline.length === 29) {\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 1,\n outline.slice(0, 15),\n )\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 0,\n outline.slice(14, 29),\n )\n } else if (outline.length === 17) {\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 1,\n outline.slice(0, 10),\n )\n textOutlines.splice(\n textOutlines.indexOf(outline),\n 0,\n outline.slice(9, 17),\n )\n }\n })\n // Calculate text bounds and center point\n const points = textOutlines.flatMap((o) => o)\n const textBounds = {\n minX: Math.min(...points.map((p) => p[0])),\n maxX: Math.max(...points.map((p) => p[0])),\n minY: Math.min(...points.map((p) => p[1])),\n maxY: Math.max(...points.map((p) => p[1])),\n }\n const centerX = (textBounds.minX + textBounds.maxX) / 2\n const centerY = (textBounds.minY + textBounds.maxY) / 2\n\n // Calculate offset based on anchor alignment\n let xOffset = -centerX\n let yOffset = -centerY\n\n // Adjust for specific alignments\n if (silkscreenText.anchor_alignment?.includes(\"right\")) {\n xOffset = -textBounds.maxX\n } else if (silkscreenText.anchor_alignment?.includes(\"left\")) {\n xOffset = -textBounds.minX\n }\n\n if (silkscreenText.anchor_alignment?.includes(\"top\")) {\n yOffset = -textBounds.maxY\n } else if (silkscreenText.anchor_alignment?.includes(\"bottom\")) {\n yOffset = -textBounds.minY\n }\n\n return { textOutlines, xOffset, yOffset }\n}\n","import { useState, useEffect } from \"react\"\nimport stlSerializer from \"@jscad/stl-serializer\"\nimport { Geom3 } from \"@jscad/modeling/src/geometries/types\"\n\nfunction blobToBase64Url(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => {\n resolve(reader.result as string)\n }\n reader.onerror = reject\n reader.readAsDataURL(blob)\n })\n}\n\ntype StlObj = { stlUrl: string; color: number[] }\n\nexport const useStlsFromGeom = (\n geom: Geom3[] | Geom3 | null,\n): {\n stls: StlObj[]\n loading: boolean\n} => {\n const [stls, setStls] = useState<StlObj[]>([])\n const [loading, setLoading] = useState(true)\n\n useEffect(() => {\n if (!geom) return\n const generateStls = async () => {\n setLoading(true)\n const geometries = Array.isArray(geom) ? geom : [geom]\n\n const stlPromises = geometries.map(async (g) => {\n const rawData = stlSerializer.serialize({ binary: true }, [g])\n const blobData = new Blob(rawData)\n const stlUrl = await blobToBase64Url(blobData)\n return { stlUrl, color: g.color! }\n })\n\n try {\n const generatedStls = await Promise.all(stlPromises)\n setStls(generatedStls)\n } catch (error) {\n console.error(\"Error generating STLs:\", error)\n setStls([])\n } finally {\n setLoading(false)\n }\n }\n\n generateStls()\n }, [geom])\n\n return { stls, loading }\n}\n","import { useLoader } from \"@react-three/fiber\"\nimport { useRef } from \"react\"\nimport * as THREE from \"three\"\nimport { MTLLoader, OBJLoader, STLLoader } from \"three-stdlib\"\n\nexport function STLModel({\n stlUrl,\n mtlUrl,\n color,\n opacity = 1,\n}: {\n stlUrl: string\n color?: any\n mtlUrl?: string\n opacity?: number\n}) {\n const geom = useLoader(STLLoader, stlUrl)\n const mesh = useRef<THREE.Mesh>()\n\n // TODO handle mtl url\n\n return (\n <mesh ref={mesh as any}>\n <primitive object={geom} attach=\"geometry\" />\n <meshStandardMaterial\n color={color}\n transparent={opacity !== 1}\n opacity={opacity}\n />\n {/* <Outlines thickness={0.05} color=\"black\" opacity={0.25} /> */}\n </mesh>\n )\n}\n","import type * as React from \"react\"\nimport type * as THREE from \"three\"\nimport { useHelper, Grid, OrbitControls } from \"@react-three/drei\"\nimport { Canvas, useFrame } from \"@react-three/fiber\"\nimport packageJson from \"../package.json\"\nimport { CubeWithLabeledSides } from \"./three-components/cube-with-labeled-sides\"\nimport { forwardRef, Suspense, useEffect, useRef } from \"react\"\n\nexport const RotationTracker = () => {\n useFrame(({ camera }) => {\n window.TSCI_MAIN_CAMERA_ROTATION = camera.rotation\n })\n\n return <></>\n}\n\nimport { Html } from \"@react-three/drei\"\n\ninterface Props {\n hoveredComponent: {\n cad_component_id: string\n name: string\n mousePosition: [number, number, number]\n } | null\n}\n\nexport const CadViewerContainer = forwardRef<\n THREE.Object3D,\n React.PropsWithChildren<Props>\n>(({ children, hoveredComponent }, ref) => {\n return (\n <div style={{ position: \"relative\", width: \"100%\", height: \"100%\" }}>\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: 120,\n height: 120,\n }}\n >\n <Canvas\n camera={{\n up: [0, 0, 1],\n position: [1, 1, 1],\n }}\n style={{ zIndex: 10 }}\n >\n <ambientLight intensity={Math.PI / 2} />\n <CubeWithLabeledSides />\n </Canvas>\n </div>\n <Canvas\n scene={{ up: [0, 0, 1] }}\n camera={{ up: [0, 0, 1], position: [5, 5, 5] }}\n >\n <RotationTracker />\n <OrbitControls autoRotate autoRotateSpeed={1} />\n <ambientLight intensity={Math.PI / 2} />\n <pointLight\n position={[-10, -10, 10]}\n decay={0}\n intensity={Math.PI / 4}\n />\n <Grid\n rotation={[Math.PI / 2, 0, 0]}\n infiniteGrid={true}\n cellSize={1}\n sectionSize={10}\n />\n <object3D ref={ref}>{children}</object3D>\n {hoveredComponent && (\n <Html\n position={hoveredComponent.mousePosition}\n style={{\n fontFamily: \"sans-serif\",\n transform: \"translate3d(50%, 50%, 0)\",\n backgroundColor: \"white\",\n padding: \"5px\",\n borderRadius: \"3px\",\n pointerEvents: \"none\",\n userSelect: \"none\",\n WebkitUserSelect: \"none\",\n MozUserSelect: \"none\",\n msUserSelect: \"none\",\n }}\n >\n {hoveredComponent.name}\n </Html>\n )}\n </Canvas>\n <div\n style={{\n position: \"absolute\",\n right: 24,\n bottom: 24,\n fontFamily: \"sans-serif\",\n color: \"white\",\n WebkitTextStroke: \"0.5px rgba(0, 0, 0, 0.5)\",\n fontSize: 11,\n }}\n >\n @{packageJson.version}\n </div>\n </div>\n )\n})\n","{\n \"name\": \"@tscircuit/3d-viewer\",\n \"version\": \"0.0.101\",\n \"main\": \"./dist/index.js\",\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"start\": \"bun run storybook\",\n \"dev:old\": \"bunx --bun vite\",\n \"build\": \"tsup ./src/index.tsx --dts --sourcemap\",\n \"prepublish\": \"npm run build\",\n \"preview\": \"vite preview\",\n \"storybook\": \"storybook dev -p 6006\",\n \"build-storybook\": \"storybook build\",\n \"vercel-build\": \"bun run build-storybook\",\n \"format\": \"biome format . --write\",\n \"format:check\": \"biome format .\"\n },\n \"dependencies\": {\n \"@jscad/modeling\": \"^2.12.2\",\n \"@jscad/regl-renderer\": \"^2.6.9\",\n \"@jscad/stl-serializer\": \"^2.1.17\",\n \"@react-three/drei\": \"^9.115.0\",\n \"@react-three/fiber\": \"^8.16.8\",\n \"@tscircuit/core\": \"^0.0.274\",\n \"@tscircuit/props\": \"^0.0.130\",\n \"@tscircuit/react-fiber\": \"^1.1.29\",\n \"@tscircuit/soup\": \"^0.0.69\",\n \"@tscircuit/soup-util\": \"^0.0.26\",\n \"@types/three\": \"^0.165.0\",\n \"jscad-electronics\": \"^0.0.23\",\n \"jscad-fiber\": \"^0.0.76\",\n \"jscad-planner\": \"^0.0.11\",\n \"react\": \"^18.3.1\",\n \"react-dom\": \"^18.3.1\",\n \"react-use-gesture\": \"^9.1.3\",\n \"three\": \"^0.165.0\",\n \"three-stdlib\": \"^2.30.3\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^1.8.3\",\n \"@chromatic-com/storybook\": \"^1.5.0\",\n \"@storybook/addon-essentials\": \"^8.4.7\",\n \"@storybook/addon-interactions\": \"^8.4.7\",\n \"@storybook/addon-links\": \"^8.4.7\",\n \"@storybook/addon-onboarding\": \"^8.4.7\",\n \"@storybook/blocks\": \"^8.4.7\",\n \"@storybook/builder-vite\": \"^8.4.7\",\n \"@storybook/react\": \"^8.4.7\",\n \"@storybook/react-vite\": \"^8.4.7\",\n \"@storybook/test\": \"^8.4.7\",\n \"@types/react\": \"^18.3.3\",\n \"@types/react-dom\": \"^18.3.0\",\n \"@vitejs/plugin-react\": \"^4.3.4\",\n \"circuit-json\": \"^0.0.116\",\n \"circuit-to-svg\": \"^0.0.91\",\n \"storybook\": \"^8.4.7\",\n \"strip-ansi\": \"^7.1.0\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.7.2\",\n \"vite\": \"^5.4.11\",\n \"vite-tsconfig-paths\": \"^4.3.2\"\n }\n}\n","import { Text } from \"@react-three/drei\"\nimport { useFrame } from \"@react-three/fiber\"\nimport { useRef } from \"react\"\nimport * as THREE from \"three\"\n\ndeclare global {\n interface Window {\n TSCI_MAIN_CAMERA_ROTATION: THREE.Euler\n }\n}\nif (typeof window !== \"undefined\") {\n window.TSCI_MAIN_CAMERA_ROTATION = new THREE.Euler(0, 0, 0)\n}\n\nfunction computePointInFront(rotationVector, distance) {\n // Create a quaternion from the rotation vector\n const quaternion = new THREE.Quaternion().setFromEuler(\n new THREE.Euler(rotationVector.x, rotationVector.y, rotationVector.z),\n )\n\n // Create a vector pointing forward (along the negative z-axis)\n const forwardVector = new THREE.Vector3(0, 0, 1)\n\n // Apply the rotation to the forward vector\n forwardVector.applyQuaternion(quaternion)\n\n // Scale the rotated vector by the distance\n const result = forwardVector.multiplyScalar(distance)\n\n return result\n}\n\nexport const CubeWithLabeledSides = ({}: any) => {\n const ref = useRef<THREE.Mesh>()\n const rotationTrackingRef = useRef({ lastRotation: new THREE.Euler() })\n useFrame((state, delta) => {\n if (!ref.current) return\n\n const mainRot = window.TSCI_MAIN_CAMERA_ROTATION\n\n // Use window.TSCI_CAMERA_ROTATION to compute the position of the camera\n const cameraPosition = computePointInFront(mainRot, 2)\n\n state.camera.position.copy(cameraPosition)\n state.camera.lookAt(0, 0, 0)\n })\n return (\n <mesh ref={ref as any} rotation={[Math.PI / 2, 0, 0]}>\n <boxGeometry args={[1, 1, 1]} />\n <meshStandardMaterial color=\"white\" />\n <Text position={[0, 0, 0.51]} fontSize={0.25} color=\"black\">\n Front\n </Text>\n <Text\n position={[0, 0, -0.51]}\n fontSize={0.25}\n color=\"black\"\n rotation={[0, Math.PI, 0]}\n >\n Back\n </Text>\n <Text\n position={[0.51, 0, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[0, Math.PI / 2, 0]}\n >\n Right\n </Text>\n <Text\n position={[-0.51, 0, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[0, -Math.PI / 2, 0]}\n >\n Left\n </Text>\n <Text\n position={[0, 0.51, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[-Math.PI / 2, 0, 0]}\n >\n Top\n </Text>\n <Text\n position={[0, -0.51, 0]}\n fontSize={0.25}\n color=\"black\"\n rotation={[Math.PI / 2, 0, 0]}\n >\n Bottom\n </Text>\n <lineSegments\n args={[new THREE.EdgesGeometry(new THREE.BoxGeometry(1, 1, 1))]}\n material={\n new THREE.LineBasicMaterial({\n color: 0x000000,\n linewidth: 2,\n })\n }\n />\n </mesh>\n )\n}\n","import { Html } from \"@react-three/drei\"\nimport { GroupProps, useThree } from \"@react-three/fiber\"\nimport { useRef, useCallback } from \"react\"\nimport type { Vector3 } from \"three\"\nimport * as THREE from \"three\"\n\nconst Group = (props: GroupProps) => <group {...props} />\n\nconst ContainerWithTooltip = ({\n children,\n isHovered,\n onHover,\n position,\n}: {\n children: React.ReactNode\n position?: Vector3 | [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) => {\n const lastValidPointRef = useRef<THREE.Vector3 | null>(null)\n\n const handlePointerEnter = useCallback(\n (e: any) => {\n e.stopPropagation()\n\n try {\n // Fallback to event position if raycaster fails\n const point =\n e.point ||\n (e.intersections && e.intersections.length > 0\n ? e.intersections[0].point\n : null) ||\n (position\n ? new THREE.Vector3(...(position as [number, number, number]))\n : null)\n\n if (point) {\n lastValidPointRef.current = point\n onHover({ mousePosition: [point.x, point.y, point.z] })\n } else {\n onHover({})\n }\n } catch (error) {\n console.warn(\"Hover event error:\", error)\n onHover({})\n }\n },\n [position],\n )\n\n const handlePointerLeave = useCallback(\n (e: any) => {\n e.stopPropagation()\n lastValidPointRef.current = null\n\n // TODO REPLACE WITH onUnhover\n onHover(null)\n },\n [onHover],\n )\n\n return (\n <Group\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n >\n {children}\n </Group>\n )\n}\n\nexport default ContainerWithTooltip\n","import { useState, useEffect } from \"react\"\nimport type { Group } from \"three\"\nimport { MTLLoader, OBJLoader } from \"three-stdlib\"\n\n// Define the type for our cache\ninterface CacheItem {\n promise: Promise<any>\n result: Group | null\n}\n\ndeclare global {\n interface Window {\n TSCIRCUIT_OBJ_LOADER_CACHE: Map<string, CacheItem>\n }\n}\n\n// Ensure the global cache exists\nif (typeof window !== \"undefined\" && !window.TSCIRCUIT_OBJ_LOADER_CACHE) {\n window.TSCIRCUIT_OBJ_LOADER_CACHE = new Map<string, CacheItem>()\n}\n\nexport function useGlobalObjLoader(url: string | null): Group | null | Error {\n const [obj, setObj] = useState<Group | null | Error>(null)\n\n useEffect(() => {\n if (!url) return\n\n const cache = window.TSCIRCUIT_OBJ_LOADER_CACHE\n let hasUrlChanged = false\n\n async function loadAndParseObj() {\n try {\n const response = await fetch(url!)\n const text = await response.text()\n\n const mtlContent = text\n .match(/newmtl[\\s\\S]*?endmtl/g)\n ?.join(\"\\n\")!\n .replace(/d 0\\./g, \"d 1.\")!\n const objContent = text.replace(/newmtl[\\s\\S]*?endmtl/g, \"\")\n\n const mtlLoader = new MTLLoader()\n mtlLoader.setMaterialOptions({\n invertTrProperty: true,\n })\n const materials = mtlLoader.parse(\n mtlContent.replace(\n /Kd\\s+([\\d.]+)\\s+([\\d.]+)\\s+([\\d.]+)/g,\n \"Kd $2 $2 $2\",\n ),\n \"test.mtl\",\n )\n\n const objLoader = new OBJLoader()\n objLoader.setMaterials(materials)\n return objLoader.parse(objContent)\n } catch (error) {\n return error as Error\n }\n }\n\n function loadUrl() {\n if (cache.has(url!)) {\n const cacheItem = cache.get(url!)!\n if (cacheItem.result) {\n // If we have a result, clone it\n return Promise.resolve(cacheItem.result.clone())\n }\n // If we're still loading, return the existing promise\n return cacheItem.promise.then((result) => result.clone())\n }\n // If it's not in the cache, create a new promise and cache it\n const promise = loadAndParseObj().then((result) => {\n if (result instanceof Error) {\n // If the result is an Error, return it\n return result\n }\n cache.set(url!, { ...cache.get(url!)!, result })\n return result\n })\n cache.set(url!, { promise, result: null })\n return promise\n }\n\n loadUrl()\n .then((result) => {\n if (hasUrlChanged) return\n setObj(result)\n })\n .catch((error) => {\n console.error(error)\n })\n\n return () => {\n hasUrlChanged = true\n }\n }, [url])\n\n return obj\n}\n","import ContainerWithTooltip from \"src/ContainerWithTooltip\"\nimport { useGlobalObjLoader } from \"src/hooks/use-global-obj-loader\"\nimport type { Euler, Vector3 } from \"three\"\n\nexport function MixedStlModel({\n url,\n position,\n rotation,\n onHover,\n isHovered,\n}: {\n url: string\n position?: Vector3 | [number, number, number]\n rotation?: Euler | [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) {\n const obj = useGlobalObjLoader(url)\n\n if (!obj) {\n return (\n <ContainerWithTooltip isHovered={isHovered} onHover={onHover}>\n <mesh position={position}>\n <boxGeometry args={[0.5, 0.5, 0.5]} />\n <meshStandardMaterial transparent color=\"red\" opacity={0.25} />\n </mesh>\n </ContainerWithTooltip>\n )\n }\n\n // Check if obj is valid before rendering\n if (obj instanceof Error) {\n return (\n <ContainerWithTooltip isHovered={isHovered} onHover={onHover}>\n <mesh position={position}>\n <boxGeometry args={[0.5, 0.5, 0.5]} />\n <meshStandardMaterial transparent color=\"red\" opacity={0.5} />\n <meshBasicMaterial color=\"red\" />\n </mesh>\n </ContainerWithTooltip>\n )\n }\n return (\n <ContainerWithTooltip isHovered={isHovered} onHover={onHover}>\n <primitive rotation={rotation} position={position} object={obj} />\n </ContainerWithTooltip>\n )\n}\n","import type { JscadOperation } from \"jscad-planner\"\nimport { executeJscadOperations } from \"jscad-planner\"\nimport jscad from \"@jscad/modeling\"\nimport { convertCSGToThreeGeom } from \"jscad-fiber\"\nimport * as THREE from \"three\"\nimport { useMemo } from \"react\"\nimport ContainerWithTooltip from \"src/ContainerWithTooltip\"\n\nexport const JscadModel = ({\n jscadPlan,\n positionOffset,\n rotationOffset,\n onHover,\n isHovered,\n}: {\n jscadPlan: JscadOperation\n positionOffset?: [number, number, number]\n rotationOffset?: [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) => {\n const { threeGeom, material } = useMemo(() => {\n const jscadObject = executeJscadOperations(jscad as any, jscadPlan)\n\n const threeGeom = convertCSGToThreeGeom(jscadObject)\n\n const material = new THREE.MeshStandardMaterial({\n vertexColors: true,\n side: THREE.DoubleSide, // Ensure both sides are visible\n })\n return { threeGeom, material }\n }, [jscadPlan])\n\n useMemo(() => {\n if (isHovered) {\n const color = new THREE.Color(material.color.getHex())\n material.emissive.copy(color)\n material.emissive.setRGB(0, 0, 1)\n material.emissiveIntensity = 0.2\n } else {\n material.emissiveIntensity = 0\n }\n }, [isHovered, material])\n if (!threeGeom) return null\n\n return (\n <ContainerWithTooltip\n isHovered={isHovered}\n onHover={onHover}\n position={positionOffset}\n >\n <mesh\n geometry={threeGeom}\n material={material}\n position={positionOffset}\n rotation={rotationOffset}\n />\n </ContainerWithTooltip>\n )\n}\n","import { Footprinter3d } from \"jscad-electronics\"\nimport { createJSCADRenderer } from \"jscad-fiber\"\nimport { jscadPlanner } from \"jscad-planner\"\nimport { useMemo } from \"react\"\nimport { JscadModel } from \"./JscadModel\"\n\nconst { createJSCADRoot } = createJSCADRenderer(jscadPlanner as any)\n\nexport const FootprinterModel = ({\n positionOffset,\n footprint,\n rotationOffset,\n onHover,\n isHovered,\n}: {\n positionOffset: any\n footprint: string\n rotationOffset?: [number, number, number]\n onHover: (e: any) => void\n isHovered: boolean\n}) => {\n const jscadOperations = useMemo(() => {\n if (!footprint) return null\n const jscadOperations: any[] = []\n const root = createJSCADRoot(jscadOperations)\n root.render(<Footprinter3d footprint={footprint} />)\n return jscadOperations\n }, [footprint])\n\n if (!jscadOperations) return null\n\n return (\n <>\n {jscadOperations.map((operation, index) => (\n <JscadModel\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n key={index}\n positionOffset={positionOffset}\n rotationOffset={rotationOffset}\n jscadPlan={operation}\n onHover={onHover}\n isHovered={isHovered}\n />\n ))}\n </>\n )\n}\n","export const tuple = <T extends any[]>(...args: T): T => args\n","import type { AnyCircuitElement, CadComponent } from \"circuit-json\"\nimport { useConvertChildrenToSoup } from \"./hooks/use-convert-children-to-soup\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { useMemo, useState } from \"react\"\nimport { createBoardGeomFromSoup } from \"./soup-to-3d\"\nimport { useStlsFromGeom } from \"./hooks/use-stls-from-geom\"\nimport { STLModel } from \"./three-components/STLModel\"\nimport { CadViewerContainer } from \"./CadViewerContainer\"\nimport { MixedStlModel } from \"./three-components/MixedStlModel\"\nimport { Euler } from \"three\"\nimport { JscadModel } from \"./three-components/JscadModel\"\nimport { Footprinter3d } from \"jscad-electronics\"\nimport { FootprinterModel } from \"./three-components/FootprinterModel\"\nimport { tuple } from \"./utils/tuple\"\n\nexport const AnyCadComponent = ({\n cad_component,\n onHover = () => {},\n isHovered = false,\n}: {\n cad_component: CadComponent\n onHover?: (e: any) => void\n isHovered?: boolean\n}) => {\n const url = cad_component.model_obj_url ?? cad_component.model_stl_url\n const rotationOffset = cad_component.rotation\n ? tuple(\n (cad_component.rotation.x * Math.PI) / 180,\n (cad_component.rotation.y * Math.PI) / 180,\n (cad_component.rotation.z * Math.PI) / 180,\n )\n : undefined\n\n if (url) {\n return (\n <MixedStlModel\n key={cad_component.cad_component_id}\n url={url}\n position={\n cad_component.position\n ? [\n cad_component.position.x,\n cad_component.position.y,\n cad_component.position.z,\n ]\n : undefined\n }\n rotation={rotationOffset}\n onHover={onHover}\n isHovered={isHovered}\n />\n )\n }\n\n if (cad_component.model_jscad) {\n return (\n <JscadModel\n key={cad_component.cad_component_id}\n jscadPlan={cad_component.model_jscad as any}\n rotationOffset={rotationOffset}\n onHover={onHover}\n isHovered={isHovered}\n />\n )\n }\n\n if (cad_component.footprinter_string) {\n return (\n <FootprinterModel\n positionOffset={\n cad_component.position\n ? [\n cad_component.position.x,\n cad_component.position.y,\n cad_component.position.z,\n ]\n : undefined\n }\n rotationOffset={rotationOffset}\n footprint={cad_component.footprinter_string}\n onHover={onHover}\n isHovered={isHovered}\n />\n )\n }\n}\n","import React from \"react\"\n\ninterface Props {\n children: React.ReactNode\n fallback: (props: { error: Error }) => any\n}\n\ninterface State {\n hasError: boolean\n error: Error | null\n}\n\nexport class ThreeErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props)\n this.state = { hasError: false, error: null }\n }\n\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error }\n }\n\n override render() {\n if (this.state.hasError && this.state.error) {\n return this.props.fallback({ error: this.state.error })\n }\n\n return this.props.children\n }\n}\n","import { Text } from \"@react-three/drei\"\nimport type { CadComponent } from \"circuit-json\"\n\nexport const Error3d = ({\n error,\n cad_component,\n}: { error: any; cad_component?: CadComponent }) => {\n let position = [0, 0, 0]\n if (cad_component?.position) {\n position = [\n cad_component.position.x,\n cad_component.position.y,\n cad_component.position.z,\n ]\n // make sure the position doesn't have any NaN values\n position = position.map((p) => (Number.isNaN(p) ? 0 : p))\n }\n return (\n <group\n // @ts-expect-error\n position={position}\n >\n <mesh\n renderOrder={-99999}\n rotation={[Math.PI / 4, Math.PI / 4, 0]}\n ref={(mesh) => {\n if (mesh) {\n mesh.renderOrder = 999999\n }\n }}\n >\n <boxGeometry args={[0.5, 0.5, 0.5]} />\n <meshStandardMaterial\n depthTest={false}\n transparent\n color=\"red\"\n opacity={0.5}\n />\n </mesh>\n <Text\n scale={[0.1, 0.1, 0.1]}\n color=\"red\" // default\n anchorX=\"center\" // default\n anchorY=\"middle\" // default\n depthOffset={-99999}\n >\n {error.toString().slice(0, 50)}...\n </Text>\n </group>\n ) as any\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,0BAAuD;AACvD,mBAA0D;AAOnD,SAAS,cACd,UAAU,CAAC,GAIX;AACA,QAAM,QAAQ,UAAU,OAAO;AAC/B,QAAM,WAAO,sBAAQ,MAAM,SAAS,cAAc,GAAG,GAAG,CAAC,CAAC;AAC1D,QAAM,SAAS,OAAO,aAAsB;AAC1C,UAAM,OAAO,YAAY,QAAQ,YAAY;AAC7C,QAAI,QAAQ,UAAU,KAAM,SAAQ,SAAS,KAAK,SAAS,MAAM;AACjE,UAAM,MAAM,MAAM,MAAM,QAAS;AACjC,SAAK,WAAW;AAChB,SAAK,OAAO;AACZ,SAAK,cAAc,IAAI,WAAW,OAAO,CAAC;AAC1C,QAAI,gBAAgB,GAAG;AAAA,EACzB;AAEA;AAAA,IACE,MAAM,MAAM;AACV,WAAK,OAAO;AACZ,iBAAW;AAAA,IACb;AAAA,IACA,CAAC;AAAA,EACH;AAEA,MAAI;AACJ,QAAM,UAAM,0BAAY,CAAC,UAAiC;AACxD,eAAW;AAAA,EACb,GAAG,CAAC,CAAC;AAEL,SAAO,CAAC,KAAK,MAAM;AACrB;AAEO,SAAS,iBACd,UAAU,CAAC,GAKX;AACA,QAAM,QAAQ,UAAU,OAAO;AAC/B,QAAM,CAAC,KAAK,MAAM,QAAI,uBAAiB;AACvC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAqB;AAC/C,QAAM,UAAM;AAAA,IACV,CAAC,aACC,MA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AAW,EAAE,iBAAiB,SAAS;AAAA,gBAC9D,qBAAqB,cAAc;AAAA,cACrC,CAAC,GAAG;AACJ,kCAAoB;AAAA,gBAClB,kBAAkB,cAAc;AAAA,gBAChC,MAAM,iBAAiB;AAAA,gBACvB,eAAe,EAAE;AAAA,cACnB,CAAC;AAAA,YACH;AAAA,YACA;AAAA,YACA,WACE,kBAAkB,qBAClB,cAAc;AAAA;AAAA,UApBX,cAAc;AAAA,QAsBrB;AAAA;AAAA,MA5BK,cAAc;AAAA,IA6BrB,CACD;AAAA,KACH;AAEJ,CAAC;","names":["import_react","import_soup_util","import_react","import_transforms","import_primitives","import_colors","import_booleans","import_extrusions","import_primitives","import_react","stlSerializer","import_react","import_three_stdlib","import_drei","import_fiber","import_fiber","import_react","import_jsx_runtime","import_react","import_drei","import_jsx_runtime","import_react","THREE","import_jsx_runtime","import_react","import_three_stdlib","import_jsx_runtime","THREE","import_react","import_jsx_runtime","jscad","threeGeom","material","import_jscad_fiber","import_jscad_planner","import_react","import_jsx_runtime","jscadOperations","import_jsx_runtime","import_react","React","import_drei","import_jsx_runtime","import_jsx_runtime"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.102",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@jscad/stl-serializer": "^2.1.17",
|
|
24
24
|
"@react-three/drei": "^9.115.0",
|
|
25
25
|
"@react-three/fiber": "^8.16.8",
|
|
26
|
-
"@tscircuit/core": "^0.0.
|
|
26
|
+
"@tscircuit/core": "^0.0.274",
|
|
27
27
|
"@tscircuit/props": "^0.0.130",
|
|
28
28
|
"@tscircuit/react-fiber": "^1.1.29",
|
|
29
29
|
"@tscircuit/soup": "^0.0.69",
|