@tscircuit/3d-viewer 0.0.633 → 0.0.634
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 +84 -39
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -22051,7 +22051,7 @@ import * as THREE30 from "three";
|
|
|
22051
22051
|
// package.json
|
|
22052
22052
|
var package_default = {
|
|
22053
22053
|
name: "@tscircuit/3d-viewer",
|
|
22054
|
-
version: "0.0.
|
|
22054
|
+
version: "0.0.633",
|
|
22055
22055
|
repository: {
|
|
22056
22056
|
type: "git",
|
|
22057
22057
|
url: "https://github.com/tscircuit/3d-viewer"
|
|
@@ -22119,8 +22119,8 @@ var package_default = {
|
|
|
22119
22119
|
"@tscircuit/alphabet": "^0.0.25",
|
|
22120
22120
|
"@tscircuit/circuit-json-util": "^0.0.119",
|
|
22121
22121
|
"@tscircuit/copper-pour-solver": "^0.0.29",
|
|
22122
|
-
"@tscircuit/core": "^0.0.
|
|
22123
|
-
"@tscircuit/props": "^0.0.
|
|
22122
|
+
"@tscircuit/core": "^0.0.2195",
|
|
22123
|
+
"@tscircuit/props": "^0.0.707",
|
|
22124
22124
|
"@tscircuit/solver-utils": "^0.0.4",
|
|
22125
22125
|
"@types/debug": "^4.1.13",
|
|
22126
22126
|
"@types/jsdom": "^21.1.7",
|
|
@@ -24039,46 +24039,45 @@ var createPillPrism = (width, height, depth) => {
|
|
|
24039
24039
|
});
|
|
24040
24040
|
return (0, import_booleans.union)(rect, firstCap, secondCap);
|
|
24041
24041
|
};
|
|
24042
|
-
var createHoleWithPolygonPadHoleGeom = (hole,
|
|
24042
|
+
var createHoleWithPolygonPadHoleGeom = (hole, depth, options = {}) => {
|
|
24043
24043
|
const holeShape = hole.hole_shape || "circle";
|
|
24044
24044
|
const sizeDelta = options.sizeDelta ?? 0;
|
|
24045
24045
|
const offsetX = hole.hole_offset_x || 0;
|
|
24046
24046
|
const offsetY = hole.hole_offset_y || 0;
|
|
24047
|
-
|
|
24048
|
-
hole.x + offsetX,
|
|
24049
|
-
hole.y + offsetY,
|
|
24050
|
-
0
|
|
24051
|
-
];
|
|
24047
|
+
let drill;
|
|
24052
24048
|
if (holeShape === "circle") {
|
|
24053
24049
|
const diameter = Math.max((hole.hole_diameter ?? 0) + sizeDelta, M);
|
|
24054
|
-
const radius =
|
|
24055
|
-
|
|
24056
|
-
}
|
|
24057
|
-
|
|
24058
|
-
|
|
24059
|
-
|
|
24060
|
-
|
|
24061
|
-
|
|
24062
|
-
|
|
24063
|
-
|
|
24064
|
-
|
|
24065
|
-
|
|
24066
|
-
|
|
24067
|
-
|
|
24068
|
-
|
|
24069
|
-
|
|
24070
|
-
|
|
24071
|
-
|
|
24072
|
-
|
|
24073
|
-
|
|
24050
|
+
const radius = diameter / 2;
|
|
24051
|
+
drill = (0, import_primitives3.cylinder)({ center: [0, 0, 0], radius, height: depth });
|
|
24052
|
+
} else {
|
|
24053
|
+
const baseWidth = hole.hole_width ?? hole.hole_diameter;
|
|
24054
|
+
const baseHeight = hole.hole_height ?? hole.hole_diameter;
|
|
24055
|
+
if (!baseWidth || !baseHeight) {
|
|
24056
|
+
return null;
|
|
24057
|
+
}
|
|
24058
|
+
const shapeWidth = Math.max(baseWidth + sizeDelta, M);
|
|
24059
|
+
const shapeHeight = Math.max(baseHeight + sizeDelta, M);
|
|
24060
|
+
if (holeShape === "oval") {
|
|
24061
|
+
drill = createEllipsePrism(shapeWidth, shapeHeight, depth);
|
|
24062
|
+
} else if (holeShape === "pill" || holeShape === "rotated_pill") {
|
|
24063
|
+
drill = createPillPrism(shapeWidth, shapeHeight, depth);
|
|
24064
|
+
} else {
|
|
24065
|
+
const fallbackDiameter = Math.max(
|
|
24066
|
+
(hole.hole_diameter ?? baseWidth) + sizeDelta,
|
|
24067
|
+
M
|
|
24068
|
+
);
|
|
24069
|
+
drill = (0, import_primitives3.cylinder)({
|
|
24070
|
+
center: [0, 0, 0],
|
|
24071
|
+
radius: fallbackDiameter / 2,
|
|
24072
|
+
height: depth
|
|
24073
|
+
});
|
|
24074
24074
|
}
|
|
24075
|
-
return (0, import_transforms2.translate)(center, pill);
|
|
24076
24075
|
}
|
|
24077
|
-
|
|
24078
|
-
|
|
24079
|
-
|
|
24080
|
-
|
|
24081
|
-
return (0,
|
|
24076
|
+
drill = (0, import_transforms2.translate)([offsetX, offsetY, 0], drill);
|
|
24077
|
+
if (hole.ccw_rotation) {
|
|
24078
|
+
drill = (0, import_transforms2.rotateZ)(hole.ccw_rotation * Math.PI / 180, drill);
|
|
24079
|
+
}
|
|
24080
|
+
return (0, import_transforms2.translate)([hole.x, hole.y, 0], drill);
|
|
24082
24081
|
};
|
|
24083
24082
|
|
|
24084
24083
|
// src/geoms/plated-hole.ts
|
|
@@ -24567,7 +24566,13 @@ var platedHole = (plated_hole, ctx, options = {}) => {
|
|
|
24567
24566
|
const centerZ = 0;
|
|
24568
24567
|
const createPolygonPad = (thickness, zCenter) => {
|
|
24569
24568
|
const safeThickness = Math.max(thickness, M);
|
|
24570
|
-
|
|
24569
|
+
let extruded = (0, import_extrusions3.extrudeLinear)({ height: safeThickness }, polygon2d);
|
|
24570
|
+
if (plated_hole.ccw_rotation) {
|
|
24571
|
+
extruded = (0, import_transforms4.rotate)(
|
|
24572
|
+
[0, 0, plated_hole.ccw_rotation * Math.PI / 180],
|
|
24573
|
+
extruded
|
|
24574
|
+
);
|
|
24575
|
+
}
|
|
24571
24576
|
return (0, import_transforms4.translate)(
|
|
24572
24577
|
[plated_hole.x, plated_hole.y, zCenter - safeThickness / 2],
|
|
24573
24578
|
extruded
|
|
@@ -25655,6 +25660,7 @@ function clearViaHolesFromSurface({
|
|
|
25655
25660
|
}
|
|
25656
25661
|
|
|
25657
25662
|
// src/textures/create-combined-board-textures.ts
|
|
25663
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer12 } from "circuit-to-canvas";
|
|
25658
25664
|
import * as THREE46 from "three";
|
|
25659
25665
|
|
|
25660
25666
|
// src/utils/pad-texture.ts
|
|
@@ -27163,7 +27169,8 @@ var createCombinedTexture = ({
|
|
|
27163
27169
|
boardData,
|
|
27164
27170
|
traceTextureResolution,
|
|
27165
27171
|
layer,
|
|
27166
|
-
openViaHoles
|
|
27172
|
+
openViaHoles,
|
|
27173
|
+
drillElements
|
|
27167
27174
|
}) => {
|
|
27168
27175
|
const hasImage = textures.some((texture) => texture?.image);
|
|
27169
27176
|
if (!hasImage) return null;
|
|
@@ -27185,6 +27192,30 @@ var createCombinedTexture = ({
|
|
|
27185
27192
|
const image = texture.image;
|
|
27186
27193
|
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
|
|
27187
27194
|
}
|
|
27195
|
+
if (drillElements.length > 0) {
|
|
27196
|
+
const apertureMask = document.createElement("canvas");
|
|
27197
|
+
apertureMask.width = canvasWidth;
|
|
27198
|
+
apertureMask.height = canvasHeight;
|
|
27199
|
+
const maskCtx = apertureMask.getContext("2d");
|
|
27200
|
+
if (maskCtx) {
|
|
27201
|
+
maskCtx.fillStyle = "black";
|
|
27202
|
+
maskCtx.fillRect(0, 0, canvasWidth, canvasHeight);
|
|
27203
|
+
if (layer === "bottom") {
|
|
27204
|
+
maskCtx.translate(0, canvasHeight);
|
|
27205
|
+
maskCtx.scale(1, -1);
|
|
27206
|
+
}
|
|
27207
|
+
const drawer = new CircuitToCanvasDrawer12(maskCtx);
|
|
27208
|
+
drawer.setCameraBounds(boardOutlineBounds);
|
|
27209
|
+
drawer.drawElements(drillElements, {
|
|
27210
|
+
layers: [layer === "top" ? "top_copper" : "bottom_copper"],
|
|
27211
|
+
clearDrillHoles: true
|
|
27212
|
+
});
|
|
27213
|
+
ctx.save();
|
|
27214
|
+
ctx.globalCompositeOperation = "destination-in";
|
|
27215
|
+
ctx.drawImage(apertureMask, 0, 0, canvasWidth, canvasHeight);
|
|
27216
|
+
ctx.restore();
|
|
27217
|
+
}
|
|
27218
|
+
}
|
|
27188
27219
|
clearViaHolesFromSurface({
|
|
27189
27220
|
ctx,
|
|
27190
27221
|
vias: openViaHoles,
|
|
@@ -27254,6 +27285,9 @@ function createCombinedBoardTextures({
|
|
|
27254
27285
|
const silkscreenColor = "rgb(255,255,255)";
|
|
27255
27286
|
const copperColor = toRgb3(colors.copper);
|
|
27256
27287
|
const showBoardBody = visibility?.boardBody ?? true;
|
|
27288
|
+
const drillElements = circuitJson.filter(
|
|
27289
|
+
(element) => element.type === "pcb_hole" || element.type === "pcb_plated_hole" || element.type === "pcb_cutout"
|
|
27290
|
+
);
|
|
27257
27291
|
const openViaHoles = getViaHolesAtExposedPads(
|
|
27258
27292
|
circuitJson,
|
|
27259
27293
|
boardData,
|
|
@@ -27348,6 +27382,7 @@ function createCombinedBoardTextures({
|
|
|
27348
27382
|
}) : null;
|
|
27349
27383
|
const boardTexture = createCombinedTexture({
|
|
27350
27384
|
openViaHoles,
|
|
27385
|
+
drillElements,
|
|
27351
27386
|
textures: [
|
|
27352
27387
|
copperPourTexture,
|
|
27353
27388
|
traceTexture,
|
|
@@ -30463,12 +30498,17 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
30463
30498
|
if (!Array.isArray(padOutline) || padOutline.length < 3) {
|
|
30464
30499
|
return;
|
|
30465
30500
|
}
|
|
30466
|
-
|
|
30501
|
+
let boardHoleOp = createHoleOpForPolygonPad({
|
|
30467
30502
|
ph,
|
|
30468
30503
|
depth: pcbThickness * 1.2,
|
|
30469
30504
|
sizeDelta: 2 * M
|
|
30470
30505
|
});
|
|
30471
30506
|
if (!boardHoleOp) return;
|
|
30507
|
+
if (ph.ccw_rotation) {
|
|
30508
|
+
const rotatedOp = boardHoleOp.rotate([0, 0, ph.ccw_rotation]);
|
|
30509
|
+
manifoldInstancesForCleanup.push(rotatedOp);
|
|
30510
|
+
boardHoleOp = rotatedOp;
|
|
30511
|
+
}
|
|
30472
30512
|
const translatedBoardHole = boardHoleOp.translate([ph.x, ph.y, 0]);
|
|
30473
30513
|
manifoldInstancesForCleanup.push(translatedBoardHole);
|
|
30474
30514
|
platedHoleBoardDrills.push(translatedBoardHole);
|
|
@@ -30494,8 +30534,13 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
30494
30534
|
}) || barrelOp;
|
|
30495
30535
|
const copperUnion = Manifold.union([mainFill, barrelOp]);
|
|
30496
30536
|
manifoldInstancesForCleanup.push(copperUnion);
|
|
30497
|
-
|
|
30537
|
+
let finalCopper = copperUnion.subtract(holeCutOp);
|
|
30498
30538
|
manifoldInstancesForCleanup.push(finalCopper);
|
|
30539
|
+
if (ph.ccw_rotation) {
|
|
30540
|
+
const rotatedOp = finalCopper.rotate([0, 0, ph.ccw_rotation]);
|
|
30541
|
+
manifoldInstancesForCleanup.push(rotatedOp);
|
|
30542
|
+
finalCopper = rotatedOp;
|
|
30543
|
+
}
|
|
30499
30544
|
const translatedCopper = finalCopper.translate([ph.x, ph.y, 0]);
|
|
30500
30545
|
manifoldInstancesForCleanup.push(translatedCopper);
|
|
30501
30546
|
let finalCopperOp = translatedCopper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.634",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tscircuit/3d-viewer"
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"@tscircuit/alphabet": "^0.0.25",
|
|
69
69
|
"@tscircuit/circuit-json-util": "^0.0.119",
|
|
70
70
|
"@tscircuit/copper-pour-solver": "^0.0.29",
|
|
71
|
-
"@tscircuit/core": "^0.0.
|
|
72
|
-
"@tscircuit/props": "^0.0.
|
|
71
|
+
"@tscircuit/core": "^0.0.2195",
|
|
72
|
+
"@tscircuit/props": "^0.0.707",
|
|
73
73
|
"@tscircuit/solver-utils": "^0.0.4",
|
|
74
74
|
"@types/debug": "^4.1.13",
|
|
75
75
|
"@types/jsdom": "^21.1.7",
|