@tscircuit/3d-viewer 0.0.632 → 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 +86 -49
- package/package.json +4 -4
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"
|
|
@@ -22092,7 +22092,7 @@ var package_default = {
|
|
|
22092
22092
|
"@jscad/stl-serializer": "^2.1.20",
|
|
22093
22093
|
"@tscircuit/cableprinter": "^0.0.6",
|
|
22094
22094
|
"circuit-json": "^0.0.525",
|
|
22095
|
-
"circuit-to-canvas": "^0.0.
|
|
22095
|
+
"circuit-to-canvas": "^0.0.139",
|
|
22096
22096
|
"jscad-electronics": "^0.0.213",
|
|
22097
22097
|
"react-hot-toast": "^2.6.0",
|
|
22098
22098
|
three: "^0.165.0",
|
|
@@ -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
|
|
@@ -25933,7 +25939,6 @@ var toRgb = (colorArr) => {
|
|
|
25933
25939
|
b * 255
|
|
25934
25940
|
)})`;
|
|
25935
25941
|
};
|
|
25936
|
-
var COPPER_POUR_OPACITY_COMPENSATION_PASSES = 8;
|
|
25937
25942
|
function createCopperPourTextureForLayer({
|
|
25938
25943
|
layer,
|
|
25939
25944
|
circuitJson,
|
|
@@ -26027,18 +26032,11 @@ function createCopperPourTextureForLayer({
|
|
|
26027
26032
|
});
|
|
26028
26033
|
drawer.drawElements(elementsToDraw, {
|
|
26029
26034
|
layers: [pcbRenderLayer],
|
|
26035
|
+
copperPourOpacity: 1,
|
|
26030
26036
|
drawSoldermask: false,
|
|
26031
26037
|
drawSoldermaskTop: false,
|
|
26032
26038
|
drawSoldermaskBottom: false
|
|
26033
26039
|
});
|
|
26034
|
-
for (let i = 1; i < COPPER_POUR_OPACITY_COMPENSATION_PASSES; i += 1) {
|
|
26035
|
-
drawer.drawElements(elementsToDraw, {
|
|
26036
|
-
layers: [pcbRenderLayer],
|
|
26037
|
-
drawSoldermask: false,
|
|
26038
|
-
drawSoldermaskTop: false,
|
|
26039
|
-
drawSoldermaskBottom: false
|
|
26040
|
-
});
|
|
26041
|
-
}
|
|
26042
26040
|
};
|
|
26043
26041
|
const coveredPours = poursOnLayer.filter(
|
|
26044
26042
|
(p) => p.covered_with_solder_mask !== false
|
|
@@ -27171,7 +27169,8 @@ var createCombinedTexture = ({
|
|
|
27171
27169
|
boardData,
|
|
27172
27170
|
traceTextureResolution,
|
|
27173
27171
|
layer,
|
|
27174
|
-
openViaHoles
|
|
27172
|
+
openViaHoles,
|
|
27173
|
+
drillElements
|
|
27175
27174
|
}) => {
|
|
27176
27175
|
const hasImage = textures.some((texture) => texture?.image);
|
|
27177
27176
|
if (!hasImage) return null;
|
|
@@ -27193,6 +27192,30 @@ var createCombinedTexture = ({
|
|
|
27193
27192
|
const image = texture.image;
|
|
27194
27193
|
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
|
|
27195
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
|
+
}
|
|
27196
27219
|
clearViaHolesFromSurface({
|
|
27197
27220
|
ctx,
|
|
27198
27221
|
vias: openViaHoles,
|
|
@@ -27262,6 +27285,9 @@ function createCombinedBoardTextures({
|
|
|
27262
27285
|
const silkscreenColor = "rgb(255,255,255)";
|
|
27263
27286
|
const copperColor = toRgb3(colors.copper);
|
|
27264
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
|
+
);
|
|
27265
27291
|
const openViaHoles = getViaHolesAtExposedPads(
|
|
27266
27292
|
circuitJson,
|
|
27267
27293
|
boardData,
|
|
@@ -27356,6 +27382,7 @@ function createCombinedBoardTextures({
|
|
|
27356
27382
|
}) : null;
|
|
27357
27383
|
const boardTexture = createCombinedTexture({
|
|
27358
27384
|
openViaHoles,
|
|
27385
|
+
drillElements,
|
|
27359
27386
|
textures: [
|
|
27360
27387
|
copperPourTexture,
|
|
27361
27388
|
traceTexture,
|
|
@@ -30471,12 +30498,17 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
30471
30498
|
if (!Array.isArray(padOutline) || padOutline.length < 3) {
|
|
30472
30499
|
return;
|
|
30473
30500
|
}
|
|
30474
|
-
|
|
30501
|
+
let boardHoleOp = createHoleOpForPolygonPad({
|
|
30475
30502
|
ph,
|
|
30476
30503
|
depth: pcbThickness * 1.2,
|
|
30477
30504
|
sizeDelta: 2 * M
|
|
30478
30505
|
});
|
|
30479
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
|
+
}
|
|
30480
30512
|
const translatedBoardHole = boardHoleOp.translate([ph.x, ph.y, 0]);
|
|
30481
30513
|
manifoldInstancesForCleanup.push(translatedBoardHole);
|
|
30482
30514
|
platedHoleBoardDrills.push(translatedBoardHole);
|
|
@@ -30502,8 +30534,13 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
30502
30534
|
}) || barrelOp;
|
|
30503
30535
|
const copperUnion = Manifold.union([mainFill, barrelOp]);
|
|
30504
30536
|
manifoldInstancesForCleanup.push(copperUnion);
|
|
30505
|
-
|
|
30537
|
+
let finalCopper = copperUnion.subtract(holeCutOp);
|
|
30506
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
|
+
}
|
|
30507
30544
|
const translatedCopper = finalCopper.translate([ph.x, ph.y, 0]);
|
|
30508
30545
|
manifoldInstancesForCleanup.push(translatedCopper);
|
|
30509
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"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@jscad/stl-serializer": "^2.1.20",
|
|
42
42
|
"@tscircuit/cableprinter": "^0.0.6",
|
|
43
43
|
"circuit-json": "^0.0.525",
|
|
44
|
-
"circuit-to-canvas": "^0.0.
|
|
44
|
+
"circuit-to-canvas": "^0.0.139",
|
|
45
45
|
"jscad-electronics": "^0.0.213",
|
|
46
46
|
"react-hot-toast": "^2.6.0",
|
|
47
47
|
"three": "^0.165.0",
|
|
@@ -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",
|