@tscircuit/3d-viewer 0.0.444 → 0.0.446
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 +143 -32
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -14643,6 +14643,7 @@ function GltfModel({
|
|
|
14643
14643
|
}) {
|
|
14644
14644
|
const { renderer, rootObject } = useThree();
|
|
14645
14645
|
const [model, setModel] = useState3(null);
|
|
14646
|
+
const [loadError, setLoadError] = useState3(null);
|
|
14646
14647
|
useEffect5(() => {
|
|
14647
14648
|
if (!gltfUrl) return;
|
|
14648
14649
|
const loader = new GLTFLoader();
|
|
@@ -14654,8 +14655,10 @@ function GltfModel({
|
|
|
14654
14655
|
},
|
|
14655
14656
|
void 0,
|
|
14656
14657
|
(error) => {
|
|
14657
|
-
if (isMounted)
|
|
14658
|
-
|
|
14658
|
+
if (!isMounted) return;
|
|
14659
|
+
console.error(`An error happened loading ${gltfUrl}`, error);
|
|
14660
|
+
const err = error instanceof Error ? error : new Error(`Failed to load glTF model from ${gltfUrl}`);
|
|
14661
|
+
setLoadError(err);
|
|
14659
14662
|
}
|
|
14660
14663
|
);
|
|
14661
14664
|
return () => {
|
|
@@ -14734,6 +14737,9 @@ function GltfModel({
|
|
|
14734
14737
|
}
|
|
14735
14738
|
});
|
|
14736
14739
|
}, [isHovered, model]);
|
|
14740
|
+
if (loadError) {
|
|
14741
|
+
throw loadError;
|
|
14742
|
+
}
|
|
14737
14743
|
if (!model) return null;
|
|
14738
14744
|
return /* @__PURE__ */ jsx4(
|
|
14739
14745
|
ContainerWithTooltip_default,
|
|
@@ -27095,38 +27101,65 @@ var LQFP = ({
|
|
|
27095
27101
|
)
|
|
27096
27102
|
] });
|
|
27097
27103
|
};
|
|
27098
|
-
var getCcwSot723Coords2 = (pn) => {
|
|
27099
|
-
if (pn === 1) {
|
|
27100
|
-
return { x: 0, y: 0 };
|
|
27101
|
-
} else if (pn === 2) {
|
|
27102
|
-
return { x: 1, y: -0.4 };
|
|
27103
|
-
} else {
|
|
27104
|
-
return { x: 1, y: 0.4 };
|
|
27105
|
-
}
|
|
27106
|
-
};
|
|
27107
27104
|
var SOT723 = () => {
|
|
27108
|
-
const bodyWidth = 0.
|
|
27105
|
+
const bodyWidth = 0.85;
|
|
27109
27106
|
const bodyLength10 = 1.2;
|
|
27110
|
-
const bodyHeight = 0.
|
|
27111
|
-
const
|
|
27112
|
-
const
|
|
27113
|
-
const
|
|
27114
|
-
const
|
|
27107
|
+
const bodyHeight = 0.38;
|
|
27108
|
+
const straightHeight = bodyHeight * 0.55;
|
|
27109
|
+
const taperOffset = 0.1;
|
|
27110
|
+
const padLength = 0.3;
|
|
27111
|
+
const padThickness = 0.1;
|
|
27112
|
+
const leftPadWidth = 0.2;
|
|
27113
|
+
const rightPadWidth = 0.25;
|
|
27114
|
+
const rightPadCenterX = 0.55;
|
|
27115
|
+
const rightPadCenterY = 0;
|
|
27116
|
+
const leftTopPadCenterX = -0.55;
|
|
27117
|
+
const leftTopPadCenterY = 0.4;
|
|
27118
|
+
const leftBottomPadCenterX = -0.55;
|
|
27119
|
+
const leftBottomPadCenterY = -0.4;
|
|
27115
27120
|
return /* @__PURE__ */ jsxs(Fragment22, { children: [
|
|
27116
|
-
/* @__PURE__ */ jsx5(
|
|
27117
|
-
|
|
27118
|
-
const { x, y } = getCcwSot723Coords2(pn);
|
|
27119
|
-
return /* @__PURE__ */ jsx5(Translate, { center: [x, y, 0.05], children: /* @__PURE__ */ jsx5(
|
|
27121
|
+
/* @__PURE__ */ jsx5(Colorize, { color: "#222", children: /* @__PURE__ */ jsxs(Union, { children: [
|
|
27122
|
+
/* @__PURE__ */ jsx5(
|
|
27120
27123
|
Cuboid,
|
|
27121
27124
|
{
|
|
27122
|
-
size: [
|
|
27123
|
-
|
|
27124
|
-
pn === 1 ? centerLeadWidth : leadWidth,
|
|
27125
|
-
leadHeight
|
|
27126
|
-
]
|
|
27125
|
+
size: [bodyWidth, bodyLength10, straightHeight],
|
|
27126
|
+
center: [0, 0, straightHeight / 2]
|
|
27127
27127
|
}
|
|
27128
|
-
)
|
|
27129
|
-
|
|
27128
|
+
),
|
|
27129
|
+
/* @__PURE__ */ jsxs(Hull, { children: [
|
|
27130
|
+
/* @__PURE__ */ jsx5(Translate, { z: straightHeight, children: /* @__PURE__ */ jsx5(Cuboid, { size: [bodyWidth, bodyLength10, 0.01] }) }),
|
|
27131
|
+
/* @__PURE__ */ jsx5(Translate, { z: bodyHeight, children: /* @__PURE__ */ jsx5(
|
|
27132
|
+
Cuboid,
|
|
27133
|
+
{
|
|
27134
|
+
size: [bodyWidth - taperOffset, bodyLength10 - taperOffset, 0.01]
|
|
27135
|
+
}
|
|
27136
|
+
) })
|
|
27137
|
+
] })
|
|
27138
|
+
] }) }),
|
|
27139
|
+
/* @__PURE__ */ jsx5(
|
|
27140
|
+
Cuboid,
|
|
27141
|
+
{
|
|
27142
|
+
color: "#ccc",
|
|
27143
|
+
size: [padLength, rightPadWidth, padThickness],
|
|
27144
|
+
center: [rightPadCenterX, rightPadCenterY, padThickness / 2]
|
|
27145
|
+
}
|
|
27146
|
+
),
|
|
27147
|
+
/* @__PURE__ */ jsx5(
|
|
27148
|
+
Cuboid,
|
|
27149
|
+
{
|
|
27150
|
+
color: "#ccc",
|
|
27151
|
+
size: [padLength, leftPadWidth, padThickness],
|
|
27152
|
+
center: [leftTopPadCenterX, leftTopPadCenterY, padThickness / 2]
|
|
27153
|
+
}
|
|
27154
|
+
),
|
|
27155
|
+
/* @__PURE__ */ jsx5(
|
|
27156
|
+
Cuboid,
|
|
27157
|
+
{
|
|
27158
|
+
color: "#ccc",
|
|
27159
|
+
size: [padLength, leftPadWidth, padThickness],
|
|
27160
|
+
center: [leftBottomPadCenterX, leftBottomPadCenterY, padThickness / 2]
|
|
27161
|
+
}
|
|
27162
|
+
)
|
|
27130
27163
|
] });
|
|
27131
27164
|
};
|
|
27132
27165
|
var DFN = ({
|
|
@@ -27464,6 +27497,79 @@ var MS012 = ({
|
|
|
27464
27497
|
)
|
|
27465
27498
|
] });
|
|
27466
27499
|
};
|
|
27500
|
+
var TO220 = () => {
|
|
27501
|
+
const fullLength10 = 20;
|
|
27502
|
+
const bodyLength10 = 9.9;
|
|
27503
|
+
const bodyHeight = 4.5;
|
|
27504
|
+
const zOffset = 1;
|
|
27505
|
+
const padWidth = 9.9;
|
|
27506
|
+
const padLength = 6.5;
|
|
27507
|
+
const padThickness = 1.3;
|
|
27508
|
+
const padHoleDiameter = 3;
|
|
27509
|
+
const prongWidth = 0.81;
|
|
27510
|
+
const prongLength = 16;
|
|
27511
|
+
const prongHeight = 0.5;
|
|
27512
|
+
const prongPitch = 2.7;
|
|
27513
|
+
const bodyWidth = padWidth;
|
|
27514
|
+
const bodyFrontX = fullLength10 - bodyLength10 / 2;
|
|
27515
|
+
const bodyBackX = fullLength10 + bodyLength10 / 2;
|
|
27516
|
+
const prongCenterX = bodyFrontX - prongLength / 2;
|
|
27517
|
+
const padCenterX = bodyBackX + padLength / 2;
|
|
27518
|
+
return /* @__PURE__ */ jsx5(Translate, { center: [0, 0, zOffset], children: /* @__PURE__ */ jsxs(Fragment22, { children: [
|
|
27519
|
+
/* @__PURE__ */ jsxs(Rotate, { rotation: [0, 55, -55], children: [
|
|
27520
|
+
/* @__PURE__ */ jsxs(Subtract, { children: [
|
|
27521
|
+
/* @__PURE__ */ jsx5(
|
|
27522
|
+
Cuboid,
|
|
27523
|
+
{
|
|
27524
|
+
color: "#ccc",
|
|
27525
|
+
size: [padLength + 0.1, padWidth, padThickness],
|
|
27526
|
+
center: [padCenterX, 0, padThickness - 2]
|
|
27527
|
+
}
|
|
27528
|
+
),
|
|
27529
|
+
/* @__PURE__ */ jsx5(
|
|
27530
|
+
Cylinder,
|
|
27531
|
+
{
|
|
27532
|
+
color: "black",
|
|
27533
|
+
center: [padCenterX, 0, padThickness - 2],
|
|
27534
|
+
radius: padHoleDiameter / 2,
|
|
27535
|
+
height: padThickness * 1.2
|
|
27536
|
+
}
|
|
27537
|
+
)
|
|
27538
|
+
] }),
|
|
27539
|
+
/* @__PURE__ */ jsx5(Colorize, { color: "#222", children: /* @__PURE__ */ jsx5(
|
|
27540
|
+
ChipBody,
|
|
27541
|
+
{
|
|
27542
|
+
width: bodyWidth,
|
|
27543
|
+
length: bodyLength10,
|
|
27544
|
+
height: bodyHeight,
|
|
27545
|
+
center: { x: fullLength10, y: 0, z: -2.4 },
|
|
27546
|
+
includeNotch: false,
|
|
27547
|
+
straightHeightRatio: 0.3,
|
|
27548
|
+
taperRatio: 0.04,
|
|
27549
|
+
heightAboveSurface: 1
|
|
27550
|
+
}
|
|
27551
|
+
) })
|
|
27552
|
+
] }),
|
|
27553
|
+
/* @__PURE__ */ jsx5(Rotate, { rotation: [0, 55, 55], children: Array.from({ length: 3 }).map((_, i) => {
|
|
27554
|
+
const x = prongCenterX;
|
|
27555
|
+
const y = (i - 1) * prongPitch;
|
|
27556
|
+
const z135 = -prongHeight - 0.6;
|
|
27557
|
+
return /* @__PURE__ */ jsxs(Colorize, { color: "gold", children: [
|
|
27558
|
+
/* @__PURE__ */ jsxs(Hull, { children: [
|
|
27559
|
+
/* @__PURE__ */ jsx5(Translate, { center: [bodyFrontX - bodyHeight / 2 + 0.1, y, z135], children: /* @__PURE__ */ jsx5(Cuboid, { size: [bodyHeight, prongWidth + 1, prongHeight] }) }),
|
|
27560
|
+
/* @__PURE__ */ jsx5(
|
|
27561
|
+
Translate,
|
|
27562
|
+
{
|
|
27563
|
+
center: [bodyFrontX - bodyHeight / 2 - 1 + 0.1, y, z135],
|
|
27564
|
+
children: /* @__PURE__ */ jsx5(Cuboid, { size: [bodyHeight, prongWidth, prongHeight] })
|
|
27565
|
+
}
|
|
27566
|
+
)
|
|
27567
|
+
] }),
|
|
27568
|
+
/* @__PURE__ */ jsx5(Translate, { center: [x, y, z135], children: /* @__PURE__ */ jsx5(Cuboid, { size: [prongLength + 0.1, prongWidth, prongHeight] }) })
|
|
27569
|
+
] }, `prong-${i}`);
|
|
27570
|
+
}) })
|
|
27571
|
+
] }) });
|
|
27572
|
+
};
|
|
27467
27573
|
var Footprinter3d = ({ footprint }) => {
|
|
27468
27574
|
const fpJson = fp.string(footprint).json();
|
|
27469
27575
|
switch (fpJson.fn) {
|
|
@@ -27645,6 +27751,8 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
27645
27751
|
);
|
|
27646
27752
|
case "sot723":
|
|
27647
27753
|
return /* @__PURE__ */ jsx5(SOT723, {});
|
|
27754
|
+
case "to220":
|
|
27755
|
+
return /* @__PURE__ */ jsx5(TO220, {});
|
|
27648
27756
|
}
|
|
27649
27757
|
const colorMatch = footprint.match(/_color\(([^)]+)\)/);
|
|
27650
27758
|
const color = colorMatch ? colorMatch[1] : void 0;
|
|
@@ -27708,7 +27816,7 @@ function renderNode(node, colorCtx, renderCtx) {
|
|
|
27708
27816
|
}
|
|
27709
27817
|
if (type === Translate) {
|
|
27710
27818
|
const off = toVec3(
|
|
27711
|
-
props?.offset ?? { x: props?.x, y: props?.y, z: props?.z }
|
|
27819
|
+
props?.offset ?? props?.center ?? { x: props?.x, y: props?.y, z: props?.z }
|
|
27712
27820
|
);
|
|
27713
27821
|
const geoms = (children ?? []).flatMap(
|
|
27714
27822
|
(c) => renderNode(c, colorCtx, renderCtx)
|
|
@@ -28318,7 +28426,7 @@ import * as THREE15 from "three";
|
|
|
28318
28426
|
// package.json
|
|
28319
28427
|
var package_default = {
|
|
28320
28428
|
name: "@tscircuit/3d-viewer",
|
|
28321
|
-
version: "0.0.
|
|
28429
|
+
version: "0.0.445",
|
|
28322
28430
|
main: "./dist/index.js",
|
|
28323
28431
|
module: "./dist/index.js",
|
|
28324
28432
|
type: "module",
|
|
@@ -28383,7 +28491,7 @@ var package_default = {
|
|
|
28383
28491
|
"circuit-json": "0.0.320",
|
|
28384
28492
|
"circuit-to-svg": "^0.0.179",
|
|
28385
28493
|
debug: "^4.4.0",
|
|
28386
|
-
"jscad-electronics": "^0.0.
|
|
28494
|
+
"jscad-electronics": "^0.0.91",
|
|
28387
28495
|
"jscad-planner": "^0.0.13",
|
|
28388
28496
|
jsdom: "^26.0.0",
|
|
28389
28497
|
"manifold-3d": "^3.2.1",
|
|
@@ -34134,8 +34242,11 @@ function createGeometryMeshes(geoms) {
|
|
|
34134
34242
|
new THREE27.MeshStandardMaterial({
|
|
34135
34243
|
color: comp.color,
|
|
34136
34244
|
side: THREE27.DoubleSide,
|
|
34137
|
-
flatShading: true
|
|
34245
|
+
flatShading: true,
|
|
34138
34246
|
// Consistent with board
|
|
34247
|
+
polygonOffset: true,
|
|
34248
|
+
polygonOffsetFactor: -1,
|
|
34249
|
+
polygonOffsetUnits: -1
|
|
34139
34250
|
})
|
|
34140
34251
|
);
|
|
34141
34252
|
mesh.name = comp.key;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.446",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"circuit-json": "0.0.320",
|
|
66
66
|
"circuit-to-svg": "^0.0.179",
|
|
67
67
|
"debug": "^4.4.0",
|
|
68
|
-
"jscad-electronics": "^0.0.
|
|
68
|
+
"jscad-electronics": "^0.0.91",
|
|
69
69
|
"jscad-planner": "^0.0.13",
|
|
70
70
|
"jsdom": "^26.0.0",
|
|
71
71
|
"manifold-3d": "^3.2.1",
|