@tscircuit/3d-viewer 0.0.461 → 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 +65 -24
- 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({
|
|
@@ -34803,7 +34810,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
34803
34810
|
if (boardManifold) {
|
|
34804
34811
|
const boardThreeMesh = boardManifold.getMesh();
|
|
34805
34812
|
const finalBoardGeom = manifoldMeshToThreeGeometry(boardThreeMesh);
|
|
34806
|
-
const matColorArray = boardMaterialColors[boardData.material] ?? colors.
|
|
34813
|
+
const matColorArray = boardMaterialColors[boardData.material] ?? colors.fr4Tan;
|
|
34807
34814
|
currentGeoms.board = {
|
|
34808
34815
|
geometry: finalBoardGeom,
|
|
34809
34816
|
color: new THREE26.Color(
|
|
@@ -34836,20 +34843,36 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
34836
34843
|
);
|
|
34837
34844
|
currentGeoms.copperPours = copperPourGeoms;
|
|
34838
34845
|
setGeoms(currentGeoms);
|
|
34839
|
-
const
|
|
34840
|
-
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)})`;
|
|
34841
34848
|
currentTextures.topTrace = createTraceTextureForLayer({
|
|
34842
34849
|
layer: "top",
|
|
34843
34850
|
circuitJson,
|
|
34844
34851
|
boardData,
|
|
34845
|
-
traceColor,
|
|
34852
|
+
traceColor: traceColorWithoutMask,
|
|
34846
34853
|
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34847
34854
|
});
|
|
34848
34855
|
currentTextures.bottomTrace = createTraceTextureForLayer({
|
|
34849
34856
|
layer: "bottom",
|
|
34850
34857
|
circuitJson,
|
|
34851
34858
|
boardData,
|
|
34852
|
-
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,
|
|
34853
34876
|
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34854
34877
|
});
|
|
34855
34878
|
const silkscreenColor = "rgb(255,255,255)";
|
|
@@ -34867,7 +34890,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
34867
34890
|
silkscreenColor,
|
|
34868
34891
|
traceTextureResolution: TRACE_TEXTURE_RESOLUTION
|
|
34869
34892
|
});
|
|
34870
|
-
const soldermaskColorArr =
|
|
34893
|
+
const soldermaskColorArr = soldermaskColors[boardData.material] ?? colors.fr4SolderMaskGreen;
|
|
34871
34894
|
const soldermaskColor = `rgb(${Math.round(soldermaskColorArr[0] * 255)}, ${Math.round(soldermaskColorArr[1] * 255)}, ${Math.round(soldermaskColorArr[2] * 255)})`;
|
|
34872
34895
|
currentTextures.topSoldermask = createSoldermaskTextureForLayer({
|
|
34873
34896
|
layer: "top",
|
|
@@ -35026,6 +35049,13 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
35026
35049
|
"trace"
|
|
35027
35050
|
);
|
|
35028
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);
|
|
35029
35059
|
const topSilkscreenMesh = createTexturePlane(
|
|
35030
35060
|
textures.topSilkscreen,
|
|
35031
35061
|
pcbThickness / 2 + 0.017,
|
|
@@ -35042,6 +35072,13 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
35042
35072
|
"trace"
|
|
35043
35073
|
);
|
|
35044
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);
|
|
35045
35082
|
const bottomSilkscreenMesh = createTexturePlane(
|
|
35046
35083
|
textures.bottomSilkscreen,
|
|
35047
35084
|
-pcbThickness / 2 - 0.017,
|
|
@@ -35105,10 +35142,14 @@ var BoardMeshes = ({
|
|
|
35105
35142
|
});
|
|
35106
35143
|
textureMeshes.forEach((mesh) => {
|
|
35107
35144
|
let shouldShow = true;
|
|
35108
|
-
if (mesh.name.includes("top-trace")) {
|
|
35109
|
-
shouldShow = visibility.topCopper;
|
|
35110
|
-
} else if (mesh.name.includes("
|
|
35111
|
-
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;
|
|
35112
35153
|
} else if (mesh.name.includes("top-silkscreen")) {
|
|
35113
35154
|
shouldShow = visibility.topSilkscreen;
|
|
35114
35155
|
} else if (mesh.name.includes("bottom-silkscreen")) {
|