@tscircuit/3d-viewer 0.0.460 → 0.0.462
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.d.ts +2 -0
- package/dist/index.js +79 -51
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -75,6 +75,8 @@ interface ManifoldGeoms {
|
|
|
75
75
|
interface ManifoldTextures {
|
|
76
76
|
topTrace?: THREE.CanvasTexture | null;
|
|
77
77
|
bottomTrace?: THREE.CanvasTexture | null;
|
|
78
|
+
topTraceWithMask?: THREE.CanvasTexture | null;
|
|
79
|
+
bottomTraceWithMask?: THREE.CanvasTexture | null;
|
|
78
80
|
topSilkscreen?: THREE.CanvasTexture | null;
|
|
79
81
|
bottomSilkscreen?: THREE.CanvasTexture | null;
|
|
80
82
|
topSoldermask?: THREE.CanvasTexture | null;
|
package/dist/index.js
CHANGED
|
@@ -28509,7 +28509,7 @@ import * as THREE15 from "three";
|
|
|
28509
28509
|
// package.json
|
|
28510
28510
|
var package_default = {
|
|
28511
28511
|
name: "@tscircuit/3d-viewer",
|
|
28512
|
-
version: "0.0.
|
|
28512
|
+
version: "0.0.461",
|
|
28513
28513
|
main: "./dist/index.js",
|
|
28514
28514
|
module: "./dist/index.js",
|
|
28515
28515
|
type: "module",
|
|
@@ -29716,22 +29716,29 @@ var BOARD_SURFACE_OFFSET = {
|
|
|
29716
29716
|
};
|
|
29717
29717
|
var colors = {
|
|
29718
29718
|
copper: [0.9, 0.6, 0.2],
|
|
29719
|
-
|
|
29720
|
-
|
|
29721
|
-
|
|
29722
|
-
|
|
29719
|
+
fr4Tan: [0.6, 0.43, 0.28],
|
|
29720
|
+
fr4SolderMaskGreen: [0.02, 0.1, 0.04],
|
|
29721
|
+
fr4TracesWithMaskGreen: [0, 0.5, 0.25],
|
|
29722
|
+
fr4TracesWithoutMaskTan: [0.6, 0.43, 0.28],
|
|
29723
|
+
fr1Tan: [0.8, 0.4, 0.2],
|
|
29724
|
+
fr1TracesWithMaskCopper: [0.9, 0.6, 0.2],
|
|
29725
|
+
fr1SolderMaskGreen: [0.02, 0.1, 0.04]
|
|
29723
29726
|
};
|
|
29724
29727
|
var MANIFOLD_Z_OFFSET = 1e-3;
|
|
29725
29728
|
var SMOOTH_CIRCLE_SEGMENTS = 32;
|
|
29726
29729
|
var DEFAULT_SMT_PAD_THICKNESS = 0.035;
|
|
29727
29730
|
var TRACE_TEXTURE_RESOLUTION = 50;
|
|
29728
29731
|
var boardMaterialColors = {
|
|
29729
|
-
fr1: colors.
|
|
29730
|
-
fr4: colors.
|
|
29732
|
+
fr1: colors.fr1Tan,
|
|
29733
|
+
fr4: colors.fr4Tan
|
|
29731
29734
|
};
|
|
29732
29735
|
var tracesMaterialColors = {
|
|
29733
|
-
fr1: colors.
|
|
29734
|
-
fr4: colors.
|
|
29736
|
+
fr1: colors.fr1TracesWithMaskCopper,
|
|
29737
|
+
fr4: colors.fr4TracesWithoutMaskTan
|
|
29738
|
+
};
|
|
29739
|
+
var soldermaskColors = {
|
|
29740
|
+
fr1: colors.fr1SolderMaskGreen,
|
|
29741
|
+
fr4: colors.fr4SolderMaskGreen
|
|
29735
29742
|
};
|
|
29736
29743
|
|
|
29737
29744
|
// src/geoms/create-board-with-outline.ts
|
|
@@ -29800,7 +29807,7 @@ var createSimplifiedBoardGeom = (circuitJson) => {
|
|
|
29800
29807
|
center: [boardOrPanel.center.x, boardOrPanel.center.y, 0]
|
|
29801
29808
|
});
|
|
29802
29809
|
}
|
|
29803
|
-
const material = boardMaterialColors["material" in boardOrPanel ? boardOrPanel.material ?? "fr4" : "fr4"] ?? colors.
|
|
29810
|
+
const material = boardMaterialColors["material" in boardOrPanel ? boardOrPanel.material ?? "fr4" : "fr4"] ?? colors.fr4Tan;
|
|
29804
29811
|
return [(0, import_colors.colorize)(material, boardGeom)];
|
|
29805
29812
|
};
|
|
29806
29813
|
var createBoardGeomFromCircuitJson = (circuitJson, opts = {}) => {
|
|
@@ -31357,7 +31364,7 @@ var BoardGeomBuilder = class {
|
|
|
31357
31364
|
pourGeom = (0, import_booleans6.intersect)(this.boardClipGeom, pourGeom);
|
|
31358
31365
|
}
|
|
31359
31366
|
const covered = pour.covered_with_solder_mask !== false;
|
|
31360
|
-
const pourMaterialColor = covered ? tracesMaterialColors[this.board.material] ?? colors.
|
|
31367
|
+
const pourMaterialColor = covered ? tracesMaterialColors[this.board.material] ?? colors.fr4TracesWithoutMaskTan : colors.copper;
|
|
31361
31368
|
const coloredPourGeom = (0, import_colors7.colorize)(pourMaterialColor, pourGeom);
|
|
31362
31369
|
this.copperPourGeoms.push(coloredPourGeom);
|
|
31363
31370
|
}
|
|
@@ -31675,7 +31682,7 @@ var BoardGeomBuilder = class {
|
|
|
31675
31682
|
});
|
|
31676
31683
|
traceGeom = (0, import_booleans6.subtract)(traceGeom, cuttingCylinder);
|
|
31677
31684
|
}
|
|
31678
|
-
const tracesMaterialColor = tracesMaterialColors[this.board.material] ?? colors.
|
|
31685
|
+
const tracesMaterialColor = tracesMaterialColors[this.board.material] ?? colors.fr4TracesWithoutMaskTan;
|
|
31679
31686
|
if (this.boardClipGeom) {
|
|
31680
31687
|
traceGeom = (0, import_booleans6.intersect)(this.boardClipGeom, traceGeom);
|
|
31681
31688
|
}
|
|
@@ -31800,7 +31807,7 @@ var BoardGeomBuilder = class {
|
|
|
31800
31807
|
}
|
|
31801
31808
|
finalize() {
|
|
31802
31809
|
if (!this.boardGeom) return;
|
|
31803
|
-
const boardMaterialColor = boardMaterialColors[this.board.material] ?? colors.
|
|
31810
|
+
const boardMaterialColor = boardMaterialColors[this.board.material] ?? colors.fr4Tan;
|
|
31804
31811
|
this.boardGeom = (0, import_colors7.colorize)(boardMaterialColor, this.boardGeom);
|
|
31805
31812
|
this.finalGeoms = [
|
|
31806
31813
|
this.boardGeom,
|
|
@@ -32605,7 +32612,7 @@ function processCopperPoursForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
32605
32612
|
pourOp = clipped;
|
|
32606
32613
|
}
|
|
32607
32614
|
const covered = pour.covered_with_solder_mask !== false;
|
|
32608
|
-
const pourColorArr = covered ? tracesMaterialColors[boardMaterial] ?? colors.
|
|
32615
|
+
const pourColorArr = covered ? tracesMaterialColors[boardMaterial] ?? colors.fr4TracesWithoutMaskTan : colors.copper;
|
|
32609
32616
|
const pourColor = new THREE19.Color(...pourColorArr);
|
|
32610
32617
|
const threeGeom = manifoldMeshToThreeGeometry(pourOp.getMesh());
|
|
32611
32618
|
copperPourGeoms.push({
|
|
@@ -34142,8 +34149,7 @@ function createSoldermaskTextureForLayer({
|
|
|
34142
34149
|
rawRadius
|
|
34143
34150
|
) * traceTextureResolution;
|
|
34144
34151
|
const ccwRotation = pad2.ccw_rotation || 0;
|
|
34145
|
-
const
|
|
34146
|
-
const rotation2 = layer === "bottom" ? -rotationRadians : rotationRadians;
|
|
34152
|
+
const rotation2 = -ccwRotation * (Math.PI / 180);
|
|
34147
34153
|
ctx.save();
|
|
34148
34154
|
ctx.translate(canvasX, canvasY);
|
|
34149
34155
|
ctx.rotate(rotation2);
|
|
@@ -34179,10 +34185,8 @@ function createSoldermaskTextureForLayer({
|
|
|
34179
34185
|
const width10 = (hole.outer_width ?? hole.outer_diameter ?? hole.hole_width) * traceTextureResolution;
|
|
34180
34186
|
const height10 = (hole.outer_height ?? hole.outer_diameter ?? hole.hole_height) * traceTextureResolution;
|
|
34181
34187
|
const radius = Math.min(width10, height10) / 2;
|
|
34182
|
-
|
|
34183
|
-
|
|
34184
|
-
rotation2 = -rotation2;
|
|
34185
|
-
}
|
|
34188
|
+
const ccwRotationDeg = hole.ccw_rotation || 0;
|
|
34189
|
+
const rotation2 = -ccwRotationDeg;
|
|
34186
34190
|
if (rotation2) {
|
|
34187
34191
|
ctx.save();
|
|
34188
34192
|
ctx.translate(canvasX, canvasY);
|
|
@@ -34207,10 +34211,8 @@ function createSoldermaskTextureForLayer({
|
|
|
34207
34211
|
const height10 = (hole.outer_height ?? hole.outer_diameter ?? hole.hole_height) * traceTextureResolution;
|
|
34208
34212
|
const radiusX = width10 / 2;
|
|
34209
34213
|
const radiusY = height10 / 2;
|
|
34210
|
-
|
|
34211
|
-
|
|
34212
|
-
rotation2 = -rotation2;
|
|
34213
|
-
}
|
|
34214
|
+
const ccwRotationDeg = hole.ccw_rotation || 0;
|
|
34215
|
+
const rotation2 = -ccwRotationDeg;
|
|
34214
34216
|
if (rotation2) {
|
|
34215
34217
|
ctx.save();
|
|
34216
34218
|
ctx.translate(canvasX, canvasY);
|
|
@@ -34234,10 +34236,8 @@ function createSoldermaskTextureForLayer({
|
|
|
34234
34236
|
const width10 = (hole.outer_width ?? hole.outer_diameter ?? hole.hole_width) * traceTextureResolution;
|
|
34235
34237
|
const height10 = (hole.outer_height ?? hole.outer_diameter ?? hole.hole_height) * traceTextureResolution;
|
|
34236
34238
|
const radius = Math.min(width10, height10) / 2;
|
|
34237
|
-
|
|
34238
|
-
|
|
34239
|
-
rotation2 = -rotation2;
|
|
34240
|
-
}
|
|
34239
|
+
const ccwRotationDeg = hole.ccw_rotation || 0;
|
|
34240
|
+
const rotation2 = -ccwRotationDeg;
|
|
34241
34241
|
if (rotation2) {
|
|
34242
34242
|
ctx.save();
|
|
34243
34243
|
ctx.translate(adjustedCanvasX, adjustedCanvasY);
|
|
@@ -34262,10 +34262,8 @@ function createSoldermaskTextureForLayer({
|
|
|
34262
34262
|
const height10 = (hole.outer_height ?? hole.outer_diameter ?? hole.hole_height) * traceTextureResolution;
|
|
34263
34263
|
const radiusX = width10 / 2;
|
|
34264
34264
|
const radiusY = height10 / 2;
|
|
34265
|
-
|
|
34266
|
-
|
|
34267
|
-
rotation2 = -rotation2;
|
|
34268
|
-
}
|
|
34265
|
+
const ccwRotationDeg = hole.ccw_rotation || 0;
|
|
34266
|
+
const rotation2 = -ccwRotationDeg;
|
|
34269
34267
|
if (rotation2) {
|
|
34270
34268
|
ctx.save();
|
|
34271
34269
|
ctx.translate(adjustedCanvasX, adjustedCanvasY);
|
|
@@ -34330,10 +34328,8 @@ function createSoldermaskTextureForLayer({
|
|
|
34330
34328
|
hole.rect_pad_height ?? hole.hole_height ?? 0,
|
|
34331
34329
|
rawRadius
|
|
34332
34330
|
) * traceTextureResolution;
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
rotation2 = -rotation2;
|
|
34336
|
-
}
|
|
34331
|
+
const ccwRotationDeg = hole.ccw_rotation || 0;
|
|
34332
|
+
const rotation2 = -ccwRotationDeg;
|
|
34337
34333
|
if (rotation2) {
|
|
34338
34334
|
ctx.save();
|
|
34339
34335
|
ctx.translate(canvasX, canvasY);
|
|
@@ -34377,10 +34373,8 @@ function createSoldermaskTextureForLayer({
|
|
|
34377
34373
|
const width10 = hole.hole_width * traceTextureResolution;
|
|
34378
34374
|
const height10 = hole.hole_height * traceTextureResolution;
|
|
34379
34375
|
const radius = Math.min(width10, height10) / 2;
|
|
34380
|
-
|
|
34381
|
-
|
|
34382
|
-
rotation2 = -rotation2;
|
|
34383
|
-
}
|
|
34376
|
+
const ccwRotationDeg = hole.ccw_rotation || 0;
|
|
34377
|
+
const rotation2 = -ccwRotationDeg * (Math.PI / 180);
|
|
34384
34378
|
if (rotation2) {
|
|
34385
34379
|
ctx.save();
|
|
34386
34380
|
ctx.translate(canvasX, canvasY);
|
|
@@ -34444,7 +34438,7 @@ function createSoldermaskTextureForLayer({
|
|
|
34444
34438
|
if (cutout.rotation) {
|
|
34445
34439
|
ctx.save();
|
|
34446
34440
|
ctx.translate(canvasX, canvasY);
|
|
34447
|
-
const rotation2 =
|
|
34441
|
+
const rotation2 = -cutout.rotation * (Math.PI / 180);
|
|
34448
34442
|
ctx.rotate(rotation2);
|
|
34449
34443
|
if (borderRadius > 0) {
|
|
34450
34444
|
ctx.beginPath();
|
|
@@ -34816,7 +34810,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
34816
34810
|
if (boardManifold) {
|
|
34817
34811
|
const boardThreeMesh = boardManifold.getMesh();
|
|
34818
34812
|
const finalBoardGeom = manifoldMeshToThreeGeometry(boardThreeMesh);
|
|
34819
|
-
const matColorArray = boardMaterialColors[boardData.material] ?? colors.
|
|
34813
|
+
const matColorArray = boardMaterialColors[boardData.material] ?? colors.fr4Tan;
|
|
34820
34814
|
currentGeoms.board = {
|
|
34821
34815
|
geometry: finalBoardGeom,
|
|
34822
34816
|
color: new THREE26.Color(
|
|
@@ -34849,20 +34843,36 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
34849
34843
|
);
|
|
34850
34844
|
currentGeoms.copperPours = copperPourGeoms;
|
|
34851
34845
|
setGeoms(currentGeoms);
|
|
34852
|
-
const
|
|
34853
|
-
const
|
|
34846
|
+
const traceColorWithoutMaskArr = colors.fr4TracesWithoutMaskTan;
|
|
34847
|
+
const traceColorWithoutMask = `rgb(${Math.round(traceColorWithoutMaskArr[0] * 255)}, ${Math.round(traceColorWithoutMaskArr[1] * 255)}, ${Math.round(traceColorWithoutMaskArr[2] * 255)})`;
|
|
34854
34848
|
currentTextures.topTrace = createTraceTextureForLayer({
|
|
34855
34849
|
layer: "top",
|
|
34856
34850
|
circuitJson,
|
|
34857
34851
|
boardData,
|
|
34858
|
-
traceColor,
|
|
34852
|
+
traceColor: traceColorWithoutMask,
|
|
34859
34853
|
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34860
34854
|
});
|
|
34861
34855
|
currentTextures.bottomTrace = createTraceTextureForLayer({
|
|
34862
34856
|
layer: "bottom",
|
|
34863
34857
|
circuitJson,
|
|
34864
34858
|
boardData,
|
|
34865
|
-
traceColor,
|
|
34859
|
+
traceColor: traceColorWithoutMask,
|
|
34860
|
+
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34861
|
+
});
|
|
34862
|
+
const traceColorWithMaskArr = colors.fr4TracesWithMaskGreen;
|
|
34863
|
+
const traceColorWithMask = `rgb(${Math.round(traceColorWithMaskArr[0] * 255)}, ${Math.round(traceColorWithMaskArr[1] * 255)}, ${Math.round(traceColorWithMaskArr[2] * 255)})`;
|
|
34864
|
+
currentTextures.topTraceWithMask = createTraceTextureForLayer({
|
|
34865
|
+
layer: "top",
|
|
34866
|
+
circuitJson,
|
|
34867
|
+
boardData,
|
|
34868
|
+
traceColor: traceColorWithMask,
|
|
34869
|
+
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34870
|
+
});
|
|
34871
|
+
currentTextures.bottomTraceWithMask = createTraceTextureForLayer({
|
|
34872
|
+
layer: "bottom",
|
|
34873
|
+
circuitJson,
|
|
34874
|
+
boardData,
|
|
34875
|
+
traceColor: traceColorWithMask,
|
|
34866
34876
|
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34867
34877
|
});
|
|
34868
34878
|
const silkscreenColor = "rgb(255,255,255)";
|
|
@@ -34880,7 +34890,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
34880
34890
|
silkscreenColor,
|
|
34881
34891
|
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34882
34892
|
});
|
|
34883
|
-
const soldermaskColorArr =
|
|
34893
|
+
const soldermaskColorArr = soldermaskColors[boardData.material] ?? colors.fr4SolderMaskGreen;
|
|
34884
34894
|
const soldermaskColor = `rgb(${Math.round(soldermaskColorArr[0] * 255)}, ${Math.round(soldermaskColorArr[1] * 255)}, ${Math.round(soldermaskColorArr[2] * 255)})`;
|
|
34885
34895
|
currentTextures.topSoldermask = createSoldermaskTextureForLayer({
|
|
34886
34896
|
layer: "top",
|
|
@@ -35039,6 +35049,13 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
35039
35049
|
"trace"
|
|
35040
35050
|
);
|
|
35041
35051
|
if (topTraceMesh) meshes.push(topTraceMesh);
|
|
35052
|
+
const topTraceWithMaskMesh = createTexturePlane(
|
|
35053
|
+
textures.topTraceWithMask,
|
|
35054
|
+
pcbThickness / 2 + BOARD_SURFACE_OFFSET.traces,
|
|
35055
|
+
false,
|
|
35056
|
+
"trace-with-mask"
|
|
35057
|
+
);
|
|
35058
|
+
if (topTraceWithMaskMesh) meshes.push(topTraceWithMaskMesh);
|
|
35042
35059
|
const topSilkscreenMesh = createTexturePlane(
|
|
35043
35060
|
textures.topSilkscreen,
|
|
35044
35061
|
pcbThickness / 2 + 0.017,
|
|
@@ -35055,6 +35072,13 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
35055
35072
|
"trace"
|
|
35056
35073
|
);
|
|
35057
35074
|
if (bottomTraceMesh) meshes.push(bottomTraceMesh);
|
|
35075
|
+
const bottomTraceWithMaskMesh = createTexturePlane(
|
|
35076
|
+
textures.bottomTraceWithMask,
|
|
35077
|
+
-pcbThickness / 2 - BOARD_SURFACE_OFFSET.traces,
|
|
35078
|
+
true,
|
|
35079
|
+
"trace-with-mask"
|
|
35080
|
+
);
|
|
35081
|
+
if (bottomTraceWithMaskMesh) meshes.push(bottomTraceWithMaskMesh);
|
|
35058
35082
|
const bottomSilkscreenMesh = createTexturePlane(
|
|
35059
35083
|
textures.bottomSilkscreen,
|
|
35060
35084
|
-pcbThickness / 2 - 0.017,
|
|
@@ -35118,10 +35142,14 @@ var BoardMeshes = ({
|
|
|
35118
35142
|
});
|
|
35119
35143
|
textureMeshes.forEach((mesh) => {
|
|
35120
35144
|
let shouldShow = true;
|
|
35121
|
-
if (mesh.name.includes("top-trace")) {
|
|
35122
|
-
shouldShow = visibility.topCopper;
|
|
35123
|
-
} else if (mesh.name.includes("
|
|
35124
|
-
shouldShow = visibility.
|
|
35145
|
+
if (mesh.name.includes("top-trace-texture-plane") && !mesh.name.includes("with-mask")) {
|
|
35146
|
+
shouldShow = visibility.topCopper && !visibility.topMask;
|
|
35147
|
+
} else if (mesh.name.includes("top-trace-with-mask")) {
|
|
35148
|
+
shouldShow = visibility.topCopper && visibility.topMask;
|
|
35149
|
+
} else if (mesh.name.includes("bottom-trace-texture-plane") && !mesh.name.includes("with-mask")) {
|
|
35150
|
+
shouldShow = visibility.bottomCopper && !visibility.bottomMask;
|
|
35151
|
+
} else if (mesh.name.includes("bottom-trace-with-mask")) {
|
|
35152
|
+
shouldShow = visibility.bottomCopper && visibility.bottomMask;
|
|
35125
35153
|
} else if (mesh.name.includes("top-silkscreen")) {
|
|
35126
35154
|
shouldShow = visibility.topSilkscreen;
|
|
35127
35155
|
} else if (mesh.name.includes("bottom-silkscreen")) {
|