@tscircuit/3d-viewer 0.0.590 → 0.0.591
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 +7 -0
- package/dist/index.js +83 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -64,7 +64,14 @@ interface LayerVisibilityState {
|
|
|
64
64
|
pcbNotes: boolean;
|
|
65
65
|
backgroundStart: boolean;
|
|
66
66
|
backgroundEnd: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Three-state display for the single assembled enclosure CAD entity. This is
|
|
69
|
+
* viewer state, not Circuit JSON: hidden to work unobstructed, translucent to
|
|
70
|
+
* check openings against the board, opaque to inspect the print itself.
|
|
71
|
+
*/
|
|
72
|
+
enclosure: EnclosureVisibility;
|
|
67
73
|
}
|
|
74
|
+
type EnclosureVisibility = "hidden" | "translucent" | "opaque";
|
|
68
75
|
|
|
69
76
|
interface CombinedBoardTextures {
|
|
70
77
|
topBoard?: THREE.CanvasTexture | null;
|
package/dist/index.js
CHANGED
|
@@ -14452,6 +14452,12 @@ import {
|
|
|
14452
14452
|
useMemo
|
|
14453
14453
|
} from "react";
|
|
14454
14454
|
import { jsx } from "react/jsx-runtime";
|
|
14455
|
+
var ENCLOSURE_VISIBILITY_CYCLE = [
|
|
14456
|
+
"translucent",
|
|
14457
|
+
"opaque",
|
|
14458
|
+
"hidden"
|
|
14459
|
+
];
|
|
14460
|
+
var nextEnclosureVisibility = (current) => ENCLOSURE_VISIBILITY_CYCLE[(ENCLOSURE_VISIBILITY_CYCLE.indexOf(current) + 1) % ENCLOSURE_VISIBILITY_CYCLE.length];
|
|
14455
14461
|
var defaultVisibility = {
|
|
14456
14462
|
boardBody: true,
|
|
14457
14463
|
topCopper: true,
|
|
@@ -14472,7 +14478,8 @@ var defaultVisibility = {
|
|
|
14472
14478
|
threedAxis: false,
|
|
14473
14479
|
pcbNotes: false,
|
|
14474
14480
|
backgroundStart: true,
|
|
14475
|
-
backgroundEnd: true
|
|
14481
|
+
backgroundEnd: true,
|
|
14482
|
+
enclosure: "translucent"
|
|
14476
14483
|
};
|
|
14477
14484
|
var LayerVisibilityContext = createContext(void 0);
|
|
14478
14485
|
var LayerVisibilityProvider = ({ children }) => {
|
|
@@ -32389,6 +32396,19 @@ var getRenderedCadModelType = (modelType) => {
|
|
|
32389
32396
|
return modelType === "step" ? "glb" : modelType;
|
|
32390
32397
|
};
|
|
32391
32398
|
|
|
32399
|
+
// src/utils/is-legacy-fdm-enclosure.ts
|
|
32400
|
+
var isLegacyFdmEnclosure = (cadComponent, circuitJson) => {
|
|
32401
|
+
if (!cadComponent.model_jscad || cadComponent.model_origin_alignment !== "bottom_center_of_component") {
|
|
32402
|
+
return false;
|
|
32403
|
+
}
|
|
32404
|
+
const pcbComponent = circuitJson.find(
|
|
32405
|
+
(element) => element.type === "pcb_component" && element.pcb_component_id === cadComponent.pcb_component_id
|
|
32406
|
+
);
|
|
32407
|
+
return Boolean(
|
|
32408
|
+
pcbComponent && pcbComponent.do_not_place && pcbComponent.is_allowed_to_be_off_board && pcbComponent.obstructs_within_bounds === false
|
|
32409
|
+
);
|
|
32410
|
+
};
|
|
32411
|
+
|
|
32392
32412
|
// src/utils/resolve-model-url.ts
|
|
32393
32413
|
var resolveModelUrl = (modelUrl, resolveStaticAsset) => {
|
|
32394
32414
|
if (!modelUrl) return void 0;
|
|
@@ -32483,6 +32503,11 @@ var AnyCadComponent = ({
|
|
|
32483
32503
|
(elm) => elm.type === "pcb_component" && elm.source_component_id === cad_component.source_component_id
|
|
32484
32504
|
);
|
|
32485
32505
|
const layer = pcbComponent?.layer ?? "top";
|
|
32506
|
+
const isEnclosure = useMemo8(
|
|
32507
|
+
() => isLegacyFdmEnclosure(cad_component, circuitJson),
|
|
32508
|
+
[cad_component, circuitJson]
|
|
32509
|
+
);
|
|
32510
|
+
const isTranslucent = isEnclosure ? visibility.enclosure === "translucent" : Boolean(cad_component.show_as_translucent_model);
|
|
32486
32511
|
const sourceModelType = getCadModelType(cad_component);
|
|
32487
32512
|
const renderedModelType = getRenderedCadModelType(sourceModelType);
|
|
32488
32513
|
const gltfModelType = cad_component.model_glb_url ? "glb" : "gltf";
|
|
@@ -32518,7 +32543,7 @@ var AnyCadComponent = ({
|
|
|
32518
32543
|
onHover: handleHover,
|
|
32519
32544
|
onUnhover: handleUnhover,
|
|
32520
32545
|
isHovered,
|
|
32521
|
-
isTranslucent
|
|
32546
|
+
isTranslucent
|
|
32522
32547
|
},
|
|
32523
32548
|
`${cad_component.cad_component_id}-gltf-${gltfUrl}`
|
|
32524
32549
|
)
|
|
@@ -32543,7 +32568,7 @@ var AnyCadComponent = ({
|
|
|
32543
32568
|
onHover: handleHover,
|
|
32544
32569
|
onUnhover: handleUnhover,
|
|
32545
32570
|
isHovered,
|
|
32546
|
-
isTranslucent
|
|
32571
|
+
isTranslucent
|
|
32547
32572
|
},
|
|
32548
32573
|
`${cad_component.cad_component_id}-mixed-${url}`
|
|
32549
32574
|
)
|
|
@@ -32568,7 +32593,7 @@ var AnyCadComponent = ({
|
|
|
32568
32593
|
onHover: handleHover,
|
|
32569
32594
|
onUnhover: handleUnhover,
|
|
32570
32595
|
isHovered,
|
|
32571
|
-
isTranslucent
|
|
32596
|
+
isTranslucent
|
|
32572
32597
|
},
|
|
32573
32598
|
`${cad_component.cad_component_id}-step-${stepUrl}`
|
|
32574
32599
|
)
|
|
@@ -32580,7 +32605,7 @@ var AnyCadComponent = ({
|
|
|
32580
32605
|
cad_component.cad_component_id,
|
|
32581
32606
|
cad_component.footprinter_string,
|
|
32582
32607
|
cad_component.model_jscad,
|
|
32583
|
-
|
|
32608
|
+
isTranslucent,
|
|
32584
32609
|
gltfUrl,
|
|
32585
32610
|
gltfModelType,
|
|
32586
32611
|
handleHover,
|
|
@@ -32642,7 +32667,7 @@ var AnyCadComponent = ({
|
|
|
32642
32667
|
onHover: handleHover,
|
|
32643
32668
|
onUnhover: handleUnhover,
|
|
32644
32669
|
isHovered,
|
|
32645
|
-
isTranslucent
|
|
32670
|
+
isTranslucent
|
|
32646
32671
|
},
|
|
32647
32672
|
cad_component.cad_component_id
|
|
32648
32673
|
);
|
|
@@ -32657,21 +32682,17 @@ var AnyCadComponent = ({
|
|
|
32657
32682
|
onHover: handleHover,
|
|
32658
32683
|
onUnhover: handleUnhover,
|
|
32659
32684
|
isHovered,
|
|
32660
|
-
isTranslucent
|
|
32685
|
+
isTranslucent
|
|
32661
32686
|
}
|
|
32662
32687
|
);
|
|
32663
32688
|
}
|
|
32664
|
-
if (
|
|
32665
|
-
if (
|
|
32666
|
-
|
|
32667
|
-
|
|
32689
|
+
if (isEnclosure) {
|
|
32690
|
+
if (visibility.enclosure === "hidden") return null;
|
|
32691
|
+
} else if (cad_component.show_as_translucent_model) {
|
|
32692
|
+
if (!visibility.translucentModels) return null;
|
|
32668
32693
|
} else {
|
|
32669
|
-
if (isThroughHole && !visibility.throughHoleModels)
|
|
32670
|
-
|
|
32671
|
-
}
|
|
32672
|
-
if (!isThroughHole && !visibility.smtModels) {
|
|
32673
|
-
return null;
|
|
32674
|
-
}
|
|
32694
|
+
if (isThroughHole && !visibility.throughHoleModels) return null;
|
|
32695
|
+
if (!isThroughHole && !visibility.smtModels) return null;
|
|
32675
32696
|
}
|
|
32676
32697
|
return /* @__PURE__ */ jsxs2(Fragment4, { children: [
|
|
32677
32698
|
modelComponent,
|
|
@@ -32704,7 +32725,7 @@ import * as THREE23 from "three";
|
|
|
32704
32725
|
// package.json
|
|
32705
32726
|
var package_default = {
|
|
32706
32727
|
name: "@tscircuit/3d-viewer",
|
|
32707
|
-
version: "0.0.
|
|
32728
|
+
version: "0.0.590",
|
|
32708
32729
|
main: "./dist/index.js",
|
|
32709
32730
|
module: "./dist/index.js",
|
|
32710
32731
|
type: "module",
|
|
@@ -46668,6 +46689,21 @@ var ChevronRightIcon = ({ isOpen }) => /* @__PURE__ */ jsx32(
|
|
|
46668
46689
|
children: /* @__PURE__ */ jsx32("path", { d: "m9 18 6-6-6-6" })
|
|
46669
46690
|
}
|
|
46670
46691
|
);
|
|
46692
|
+
var CheckMinusIcon = () => /* @__PURE__ */ jsx32(
|
|
46693
|
+
"svg",
|
|
46694
|
+
{
|
|
46695
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
46696
|
+
width: "14",
|
|
46697
|
+
height: "14",
|
|
46698
|
+
viewBox: "0 0 24 24",
|
|
46699
|
+
fill: "none",
|
|
46700
|
+
stroke: "currentColor",
|
|
46701
|
+
strokeWidth: "2",
|
|
46702
|
+
strokeLinecap: "round",
|
|
46703
|
+
strokeLinejoin: "round",
|
|
46704
|
+
children: /* @__PURE__ */ jsx32("path", { d: "M5 12h14" })
|
|
46705
|
+
}
|
|
46706
|
+
);
|
|
46671
46707
|
var DotIcon = () => /* @__PURE__ */ jsx32(
|
|
46672
46708
|
"svg",
|
|
46673
46709
|
{
|
|
@@ -47060,6 +47096,35 @@ var AppearanceMenu = () => {
|
|
|
47060
47096
|
/* @__PURE__ */ jsx33("span", { style: { display: "flex", alignItems: "center" }, children: "Through-Hole Components" })
|
|
47061
47097
|
]
|
|
47062
47098
|
}
|
|
47099
|
+
),
|
|
47100
|
+
/* @__PURE__ */ jsx33(Separator2, { style: separatorStyles }),
|
|
47101
|
+
/* @__PURE__ */ jsxs7(
|
|
47102
|
+
Item22,
|
|
47103
|
+
{
|
|
47104
|
+
style: {
|
|
47105
|
+
...itemStyles,
|
|
47106
|
+
backgroundColor: hoveredItem === "enclosure" ? "#404040" : "transparent"
|
|
47107
|
+
},
|
|
47108
|
+
onSelect: (e) => e.preventDefault(),
|
|
47109
|
+
onPointerDown: (e) => {
|
|
47110
|
+
e.preventDefault();
|
|
47111
|
+
setLayerVisibility(
|
|
47112
|
+
"enclosure",
|
|
47113
|
+
nextEnclosureVisibility(visibility.enclosure)
|
|
47114
|
+
);
|
|
47115
|
+
},
|
|
47116
|
+
onMouseEnter: () => setHoveredItem("enclosure"),
|
|
47117
|
+
onMouseLeave: () => setHoveredItem(null),
|
|
47118
|
+
onTouchStart: () => setHoveredItem("enclosure"),
|
|
47119
|
+
title: `Enclosure: ${visibility.enclosure}`,
|
|
47120
|
+
children: [
|
|
47121
|
+
/* @__PURE__ */ jsxs7("span", { style: iconContainerStyles, children: [
|
|
47122
|
+
visibility.enclosure === "opaque" && /* @__PURE__ */ jsx33(CheckIcon, {}),
|
|
47123
|
+
visibility.enclosure === "translucent" && /* @__PURE__ */ jsx33(CheckMinusIcon, {})
|
|
47124
|
+
] }),
|
|
47125
|
+
/* @__PURE__ */ jsx33("span", { style: { display: "flex", alignItems: "center" }, children: "Enclosure" })
|
|
47126
|
+
]
|
|
47127
|
+
}
|
|
47063
47128
|
)
|
|
47064
47129
|
]
|
|
47065
47130
|
}
|