@tscircuit/3d-viewer 0.0.306 → 0.0.308
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 +109 -44
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13980,7 +13980,7 @@ var require_browser = __commonJS({
|
|
|
13980
13980
|
});
|
|
13981
13981
|
|
|
13982
13982
|
// src/CadViewer.tsx
|
|
13983
|
-
import { useState as useState11, useRef as useRef8, useEffect as useEffect8 } from "react";
|
|
13983
|
+
import { useState as useState11, useCallback as useCallback6, useRef as useRef8, useEffect as useEffect8 } from "react";
|
|
13984
13984
|
|
|
13985
13985
|
// src/CadViewerJscad.tsx
|
|
13986
13986
|
import { su as su4 } from "@tscircuit/soup-util";
|
|
@@ -17286,7 +17286,7 @@ import {
|
|
|
17286
17286
|
// package.json
|
|
17287
17287
|
var package_default = {
|
|
17288
17288
|
name: "@tscircuit/3d-viewer",
|
|
17289
|
-
version: "0.0.
|
|
17289
|
+
version: "0.0.307",
|
|
17290
17290
|
main: "./dist/index.js",
|
|
17291
17291
|
module: "./dist/index.js",
|
|
17292
17292
|
type: "module",
|
|
@@ -17318,7 +17318,7 @@ var package_default = {
|
|
|
17318
17318
|
"@react-three/drei": "^9.121.4",
|
|
17319
17319
|
"@react-three/fiber": "^8.17.14",
|
|
17320
17320
|
"@tscircuit/core": "^0.0.580",
|
|
17321
|
-
"@tscircuit/props": "^0.0.
|
|
17321
|
+
"@tscircuit/props": "^0.0.269",
|
|
17322
17322
|
"@tscircuit/soup-util": "^0.0.41",
|
|
17323
17323
|
"jscad-electronics": "^0.0.29",
|
|
17324
17324
|
"jscad-fiber": "^0.0.79",
|
|
@@ -17475,7 +17475,8 @@ var CadViewerContainer = forwardRef(
|
|
|
17475
17475
|
initialCameraPosition = [5, 5, 5],
|
|
17476
17476
|
autoRotateDisabled,
|
|
17477
17477
|
clickToInteractEnabled = false,
|
|
17478
|
-
boardDimensions
|
|
17478
|
+
boardDimensions,
|
|
17479
|
+
onUserInteraction
|
|
17479
17480
|
}, ref) => {
|
|
17480
17481
|
const [isInteractionEnabled, setIsInteractionEnabled] = useState3(
|
|
17481
17482
|
!clickToInteractEnabled
|
|
@@ -17526,7 +17527,8 @@ var CadViewerContainer = forwardRef(
|
|
|
17526
17527
|
OrbitControls,
|
|
17527
17528
|
{
|
|
17528
17529
|
autoRotate: !autoRotateDisabled,
|
|
17529
|
-
autoRotateSpeed: 1
|
|
17530
|
+
autoRotateSpeed: 1,
|
|
17531
|
+
onStart: onUserInteraction
|
|
17530
17532
|
}
|
|
17531
17533
|
),
|
|
17532
17534
|
/* @__PURE__ */ jsx7("ambientLight", { intensity: Math.PI / 2 }),
|
|
@@ -18981,7 +18983,14 @@ var ThreeErrorBoundary = class extends React.Component {
|
|
|
18981
18983
|
// src/CadViewerJscad.tsx
|
|
18982
18984
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
18983
18985
|
var CadViewerJscad = forwardRef2(
|
|
18984
|
-
({
|
|
18986
|
+
({
|
|
18987
|
+
soup,
|
|
18988
|
+
circuitJson,
|
|
18989
|
+
children,
|
|
18990
|
+
autoRotateDisabled,
|
|
18991
|
+
clickToInteractEnabled,
|
|
18992
|
+
onUserInteraction
|
|
18993
|
+
}, ref) => {
|
|
18985
18994
|
const childrenSoup = useConvertChildrenToSoup(children);
|
|
18986
18995
|
const internalCircuitJson = useMemo6(() => {
|
|
18987
18996
|
const cj = soup ?? circuitJson;
|
|
@@ -19028,6 +19037,7 @@ var CadViewerJscad = forwardRef2(
|
|
|
19028
19037
|
initialCameraPosition,
|
|
19029
19038
|
clickToInteractEnabled,
|
|
19030
19039
|
boardDimensions,
|
|
19040
|
+
onUserInteraction,
|
|
19031
19041
|
children: [
|
|
19032
19042
|
boardStls.map(({ stlUrl, color }, index) => /* @__PURE__ */ jsx10(
|
|
19033
19043
|
STLModel,
|
|
@@ -20097,6 +20107,7 @@ var CadViewerManifold = ({
|
|
|
20097
20107
|
circuitJson: circuitJsonProp,
|
|
20098
20108
|
autoRotateDisabled,
|
|
20099
20109
|
clickToInteractEnabled,
|
|
20110
|
+
onUserInteraction,
|
|
20100
20111
|
children
|
|
20101
20112
|
}) => {
|
|
20102
20113
|
const childrenCircuitJson = useConvertChildrenToSoup(children);
|
|
@@ -20208,6 +20219,7 @@ var CadViewerManifold = ({
|
|
|
20208
20219
|
autoRotateDisabled,
|
|
20209
20220
|
clickToInteractEnabled,
|
|
20210
20221
|
boardDimensions,
|
|
20222
|
+
onUserInteraction,
|
|
20211
20223
|
children: [
|
|
20212
20224
|
geometryMeshes.map((mesh, index) => /* @__PURE__ */ jsx11("primitive", { object: mesh }, `${mesh.name}-${index}`)),
|
|
20213
20225
|
textureMeshes.map((mesh, index) => /* @__PURE__ */ jsx11("primitive", { object: mesh }, `${mesh.name}-${index}`)),
|
|
@@ -20338,6 +20350,8 @@ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
|
20338
20350
|
var CadViewer = (props) => {
|
|
20339
20351
|
const [engine, setEngine] = useState11("manifold");
|
|
20340
20352
|
const containerRef = useRef8(null);
|
|
20353
|
+
const [autoRotate, setAutoRotate] = useState11(true);
|
|
20354
|
+
const [autoRotateUserToggled, setAutoRotateUserToggled] = useState11(false);
|
|
20341
20355
|
const {
|
|
20342
20356
|
menuVisible,
|
|
20343
20357
|
menuPos,
|
|
@@ -20345,6 +20359,15 @@ var CadViewer = (props) => {
|
|
|
20345
20359
|
contextMenuEventHandlers,
|
|
20346
20360
|
setMenuVisible
|
|
20347
20361
|
} = useContextMenu({ containerRef });
|
|
20362
|
+
const handleUserInteraction = useCallback6(() => {
|
|
20363
|
+
if (!autoRotateUserToggled) {
|
|
20364
|
+
setAutoRotate(false);
|
|
20365
|
+
}
|
|
20366
|
+
}, [autoRotateUserToggled]);
|
|
20367
|
+
const toggleAutoRotate = useCallback6(() => {
|
|
20368
|
+
setAutoRotate((prev) => !prev);
|
|
20369
|
+
setAutoRotateUserToggled(true);
|
|
20370
|
+
}, []);
|
|
20348
20371
|
const handleMenuClick = (newEngine) => {
|
|
20349
20372
|
setEngine(newEngine);
|
|
20350
20373
|
setMenuVisible(false);
|
|
@@ -20366,7 +20389,21 @@ var CadViewer = (props) => {
|
|
|
20366
20389
|
style: { width: "100%", height: "100%", position: "relative" },
|
|
20367
20390
|
...contextMenuEventHandlers,
|
|
20368
20391
|
children: [
|
|
20369
|
-
engine === "jscad" ? /* @__PURE__ */ jsx12(
|
|
20392
|
+
engine === "jscad" ? /* @__PURE__ */ jsx12(
|
|
20393
|
+
CadViewerJscad,
|
|
20394
|
+
{
|
|
20395
|
+
...props,
|
|
20396
|
+
autoRotateDisabled: props.autoRotateDisabled || !autoRotate,
|
|
20397
|
+
onUserInteraction: handleUserInteraction
|
|
20398
|
+
}
|
|
20399
|
+
) : /* @__PURE__ */ jsx12(
|
|
20400
|
+
CadViewerManifold_default,
|
|
20401
|
+
{
|
|
20402
|
+
...props,
|
|
20403
|
+
autoRotateDisabled: props.autoRotateDisabled || !autoRotate,
|
|
20404
|
+
onUserInteraction: handleUserInteraction
|
|
20405
|
+
}
|
|
20406
|
+
),
|
|
20370
20407
|
/* @__PURE__ */ jsxs9(
|
|
20371
20408
|
"div",
|
|
20372
20409
|
{
|
|
@@ -20388,7 +20425,7 @@ var CadViewer = (props) => {
|
|
|
20388
20425
|
]
|
|
20389
20426
|
}
|
|
20390
20427
|
),
|
|
20391
|
-
menuVisible && /* @__PURE__ */
|
|
20428
|
+
menuVisible && /* @__PURE__ */ jsxs9(
|
|
20392
20429
|
"div",
|
|
20393
20430
|
{
|
|
20394
20431
|
ref: menuRef,
|
|
@@ -20408,42 +20445,70 @@ var CadViewer = (props) => {
|
|
|
20408
20445
|
fontWeight: 500,
|
|
20409
20446
|
transition: "opacity 0.1s"
|
|
20410
20447
|
},
|
|
20411
|
-
children:
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
|
|
20419
|
-
|
|
20420
|
-
|
|
20421
|
-
|
|
20422
|
-
|
|
20423
|
-
|
|
20424
|
-
|
|
20425
|
-
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
|
|
20430
|
-
|
|
20431
|
-
|
|
20432
|
-
|
|
20433
|
-
|
|
20434
|
-
|
|
20435
|
-
|
|
20436
|
-
|
|
20437
|
-
|
|
20438
|
-
|
|
20439
|
-
|
|
20440
|
-
|
|
20441
|
-
|
|
20442
|
-
|
|
20443
|
-
|
|
20444
|
-
|
|
20445
|
-
|
|
20446
|
-
|
|
20448
|
+
children: [
|
|
20449
|
+
/* @__PURE__ */ jsxs9(
|
|
20450
|
+
"div",
|
|
20451
|
+
{
|
|
20452
|
+
style: {
|
|
20453
|
+
padding: "12px 18px",
|
|
20454
|
+
cursor: "pointer",
|
|
20455
|
+
display: "flex",
|
|
20456
|
+
alignItems: "center",
|
|
20457
|
+
gap: 10,
|
|
20458
|
+
color: "#f5f6fa",
|
|
20459
|
+
fontWeight: 500,
|
|
20460
|
+
borderRadius: 6,
|
|
20461
|
+
transition: "background 0.1s"
|
|
20462
|
+
},
|
|
20463
|
+
onClick: () => handleMenuClick(engine === "jscad" ? "manifold" : "jscad"),
|
|
20464
|
+
onMouseOver: (e) => e.currentTarget.style.background = "#2d313a",
|
|
20465
|
+
onMouseOut: (e) => e.currentTarget.style.background = "transparent",
|
|
20466
|
+
children: [
|
|
20467
|
+
"Switch to ",
|
|
20468
|
+
engine === "jscad" ? "Manifold" : "JSCAD",
|
|
20469
|
+
" Engine",
|
|
20470
|
+
/* @__PURE__ */ jsx12(
|
|
20471
|
+
"span",
|
|
20472
|
+
{
|
|
20473
|
+
style: {
|
|
20474
|
+
fontSize: 12,
|
|
20475
|
+
marginLeft: "auto",
|
|
20476
|
+
opacity: 0.5,
|
|
20477
|
+
fontWeight: 400
|
|
20478
|
+
},
|
|
20479
|
+
children: engine === "jscad" ? "experimental" : "default"
|
|
20480
|
+
}
|
|
20481
|
+
)
|
|
20482
|
+
]
|
|
20483
|
+
}
|
|
20484
|
+
),
|
|
20485
|
+
/* @__PURE__ */ jsxs9(
|
|
20486
|
+
"div",
|
|
20487
|
+
{
|
|
20488
|
+
style: {
|
|
20489
|
+
padding: "12px 18px",
|
|
20490
|
+
cursor: "pointer",
|
|
20491
|
+
display: "flex",
|
|
20492
|
+
alignItems: "center",
|
|
20493
|
+
gap: 10,
|
|
20494
|
+
color: "#f5f6fa",
|
|
20495
|
+
fontWeight: 500,
|
|
20496
|
+
borderRadius: 6,
|
|
20497
|
+
transition: "background 0.1s"
|
|
20498
|
+
},
|
|
20499
|
+
onClick: () => {
|
|
20500
|
+
toggleAutoRotate();
|
|
20501
|
+
setMenuVisible(false);
|
|
20502
|
+
},
|
|
20503
|
+
onMouseOver: (e) => e.currentTarget.style.background = "#2d313a",
|
|
20504
|
+
onMouseOut: (e) => e.currentTarget.style.background = "transparent",
|
|
20505
|
+
children: [
|
|
20506
|
+
/* @__PURE__ */ jsx12("span", { style: { marginRight: 8 }, children: autoRotate ? "\u2714" : "" }),
|
|
20507
|
+
"Auto rotate"
|
|
20508
|
+
]
|
|
20509
|
+
}
|
|
20510
|
+
)
|
|
20511
|
+
]
|
|
20447
20512
|
}
|
|
20448
20513
|
)
|
|
20449
20514
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.308",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@react-three/drei": "^9.121.4",
|
|
33
33
|
"@react-three/fiber": "^8.17.14",
|
|
34
34
|
"@tscircuit/core": "^0.0.580",
|
|
35
|
-
"@tscircuit/props": "^0.0.
|
|
35
|
+
"@tscircuit/props": "^0.0.269",
|
|
36
36
|
"@tscircuit/soup-util": "^0.0.41",
|
|
37
37
|
"jscad-electronics": "^0.0.29",
|
|
38
38
|
"jscad-fiber": "^0.0.79",
|