@tscircuit/3d-viewer 0.0.353 → 0.0.355
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 +67 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25583,7 +25583,7 @@ import * as THREE10 from "three";
|
|
|
25583
25583
|
// package.json
|
|
25584
25584
|
var package_default = {
|
|
25585
25585
|
name: "@tscircuit/3d-viewer",
|
|
25586
|
-
version: "0.0.
|
|
25586
|
+
version: "0.0.354",
|
|
25587
25587
|
main: "./dist/index.js",
|
|
25588
25588
|
module: "./dist/index.js",
|
|
25589
25589
|
type: "module",
|
|
@@ -28903,13 +28903,17 @@ var CadViewerManifold = ({
|
|
|
28903
28903
|
);
|
|
28904
28904
|
}
|
|
28905
28905
|
};
|
|
28906
|
-
|
|
28906
|
+
const existingManifold = window.ManifoldModule ?? window.MANIFOLD ?? window.MANIFOLD_MODULE;
|
|
28907
|
+
if (existingManifold) {
|
|
28908
|
+
window.ManifoldModule = existingManifold;
|
|
28907
28909
|
initManifold(window.ManifoldModule);
|
|
28908
28910
|
return;
|
|
28909
28911
|
}
|
|
28910
28912
|
const eventName = "manifoldLoaded";
|
|
28911
28913
|
const handleLoad = () => {
|
|
28912
|
-
|
|
28914
|
+
const loadedManifold = window.ManifoldModule ?? window.MANIFOLD ?? window.MANIFOLD_MODULE;
|
|
28915
|
+
if (loadedManifold) {
|
|
28916
|
+
window.ManifoldModule = loadedManifold;
|
|
28913
28917
|
initManifold(window.ManifoldModule);
|
|
28914
28918
|
} else {
|
|
28915
28919
|
const errText = "ManifoldModule not found on window after script load.";
|
|
@@ -29059,11 +29063,23 @@ var useContextMenu = ({ containerRef }) => {
|
|
|
29059
29063
|
});
|
|
29060
29064
|
const menuRef = useRef8(null);
|
|
29061
29065
|
const interactionOriginPosRef = useRef8(null);
|
|
29066
|
+
const longPressTimeoutRef = useRef8(null);
|
|
29067
|
+
const ignoreNextContextMenuRef = useRef8(false);
|
|
29068
|
+
const clearLongPressTimeout = () => {
|
|
29069
|
+
if (longPressTimeoutRef.current !== null) {
|
|
29070
|
+
clearTimeout(longPressTimeoutRef.current);
|
|
29071
|
+
longPressTimeoutRef.current = null;
|
|
29072
|
+
}
|
|
29073
|
+
};
|
|
29062
29074
|
const handleContextMenu = useCallback6(
|
|
29063
29075
|
(e) => {
|
|
29064
29076
|
e.preventDefault();
|
|
29065
29077
|
const eventX = typeof e.clientX === "number" ? e.clientX : 0;
|
|
29066
29078
|
const eventY = typeof e.clientY === "number" ? e.clientY : 0;
|
|
29079
|
+
if (ignoreNextContextMenuRef.current) {
|
|
29080
|
+
ignoreNextContextMenuRef.current = false;
|
|
29081
|
+
return;
|
|
29082
|
+
}
|
|
29067
29083
|
if (!interactionOriginPosRef.current) {
|
|
29068
29084
|
return;
|
|
29069
29085
|
}
|
|
@@ -29081,18 +29097,39 @@ var useContextMenu = ({ containerRef }) => {
|
|
|
29081
29097
|
},
|
|
29082
29098
|
[setMenuPos, setMenuVisible]
|
|
29083
29099
|
);
|
|
29084
|
-
const handleTouchStart = useCallback6(
|
|
29085
|
-
|
|
29086
|
-
|
|
29087
|
-
|
|
29088
|
-
|
|
29100
|
+
const handleTouchStart = useCallback6(
|
|
29101
|
+
(e) => {
|
|
29102
|
+
if (e.touches.length === 1) {
|
|
29103
|
+
const touch = e.touches[0];
|
|
29104
|
+
if (touch) {
|
|
29105
|
+
interactionOriginPosRef.current = {
|
|
29106
|
+
x: touch.clientX,
|
|
29107
|
+
y: touch.clientY
|
|
29108
|
+
};
|
|
29109
|
+
clearLongPressTimeout();
|
|
29110
|
+
longPressTimeoutRef.current = window.setTimeout(() => {
|
|
29111
|
+
if (!interactionOriginPosRef.current) return;
|
|
29112
|
+
if (containerRef.current) {
|
|
29113
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
29114
|
+
setMenuPos({
|
|
29115
|
+
x: rect.left + rect.width / 2,
|
|
29116
|
+
y: rect.top + rect.height / 2
|
|
29117
|
+
});
|
|
29118
|
+
setMenuVisible(true);
|
|
29119
|
+
ignoreNextContextMenuRef.current = true;
|
|
29120
|
+
}
|
|
29121
|
+
interactionOriginPosRef.current = null;
|
|
29122
|
+
}, 600);
|
|
29123
|
+
} else {
|
|
29124
|
+
interactionOriginPosRef.current = null;
|
|
29125
|
+
}
|
|
29089
29126
|
} else {
|
|
29090
29127
|
interactionOriginPosRef.current = null;
|
|
29128
|
+
clearLongPressTimeout();
|
|
29091
29129
|
}
|
|
29092
|
-
}
|
|
29093
|
-
|
|
29094
|
-
|
|
29095
|
-
}, []);
|
|
29130
|
+
},
|
|
29131
|
+
[containerRef]
|
|
29132
|
+
);
|
|
29096
29133
|
const handleTouchMove = useCallback6((e) => {
|
|
29097
29134
|
if (!interactionOriginPosRef.current || e.touches.length !== 1) {
|
|
29098
29135
|
return;
|
|
@@ -29104,12 +29141,15 @@ var useContextMenu = ({ containerRef }) => {
|
|
|
29104
29141
|
const swipeThreshold = 10;
|
|
29105
29142
|
if (dx > swipeThreshold || dy > swipeThreshold) {
|
|
29106
29143
|
interactionOriginPosRef.current = null;
|
|
29144
|
+
clearLongPressTimeout();
|
|
29107
29145
|
}
|
|
29108
29146
|
} else {
|
|
29109
29147
|
interactionOriginPosRef.current = null;
|
|
29148
|
+
clearLongPressTimeout();
|
|
29110
29149
|
}
|
|
29111
29150
|
}, []);
|
|
29112
29151
|
const handleTouchEnd = useCallback6(() => {
|
|
29152
|
+
clearLongPressTimeout();
|
|
29113
29153
|
setTimeout(() => {
|
|
29114
29154
|
if (interactionOriginPosRef.current) {
|
|
29115
29155
|
interactionOriginPosRef.current = null;
|
|
@@ -29125,7 +29165,11 @@ var useContextMenu = ({ containerRef }) => {
|
|
|
29125
29165
|
useEffect21(() => {
|
|
29126
29166
|
if (menuVisible) {
|
|
29127
29167
|
document.addEventListener("mousedown", handleClickAway);
|
|
29128
|
-
|
|
29168
|
+
document.addEventListener("touchstart", handleClickAway);
|
|
29169
|
+
return () => {
|
|
29170
|
+
document.removeEventListener("mousedown", handleClickAway);
|
|
29171
|
+
document.removeEventListener("touchstart", handleClickAway);
|
|
29172
|
+
};
|
|
29129
29173
|
}
|
|
29130
29174
|
}, [menuVisible, handleClickAway]);
|
|
29131
29175
|
const contextMenuEventHandlers = {
|
|
@@ -29224,7 +29268,16 @@ var CadViewer = (props) => {
|
|
|
29224
29268
|
"div",
|
|
29225
29269
|
{
|
|
29226
29270
|
ref: containerRef,
|
|
29227
|
-
style: {
|
|
29271
|
+
style: {
|
|
29272
|
+
width: "100%",
|
|
29273
|
+
height: "100%",
|
|
29274
|
+
position: "relative",
|
|
29275
|
+
userSelect: "none",
|
|
29276
|
+
MozUserSelect: "none",
|
|
29277
|
+
msUserSelect: "none",
|
|
29278
|
+
WebkitUserSelect: "none",
|
|
29279
|
+
WebkitTouchCallout: "none"
|
|
29280
|
+
},
|
|
29228
29281
|
...contextMenuEventHandlers,
|
|
29229
29282
|
children: [
|
|
29230
29283
|
engine === "jscad" ? /* @__PURE__ */ jsx14(
|