@tscircuit/3d-viewer 0.0.274 → 0.0.276

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.
Files changed (2) hide show
  1. package/dist/index.js +112 -65
  2. 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 useState10, useRef as useRef8, useEffect as useEffect8 } from "react";
13983
+ import { useState as useState11, 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";
@@ -17282,7 +17282,7 @@ import {
17282
17282
  // package.json
17283
17283
  var package_default = {
17284
17284
  name: "@tscircuit/3d-viewer",
17285
- version: "0.0.273",
17285
+ version: "0.0.275",
17286
17286
  main: "./dist/index.js",
17287
17287
  module: "./dist/index.js",
17288
17288
  type: "module",
@@ -17314,7 +17314,7 @@ var package_default = {
17314
17314
  "@react-three/drei": "^9.121.4",
17315
17315
  "@react-three/fiber": "^8.17.14",
17316
17316
  "@tscircuit/core": "^0.0.454",
17317
- "@tscircuit/props": "^0.0.231",
17317
+ "@tscircuit/props": "^0.0.233",
17318
17318
  "@tscircuit/soup-util": "^0.0.41",
17319
17319
  "jscad-electronics": "^0.0.29",
17320
17320
  "jscad-fiber": "^0.0.79",
@@ -18820,12 +18820,28 @@ var useBoardGeomBuilder = (circuitJson) => {
18820
18820
  };
18821
18821
 
18822
18822
  // src/three-components/Error3d.tsx
18823
- import { Text as Text2 } from "@react-three/drei";
18824
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
18823
+ import { Html as Html2, Text as Text2 } from "@react-three/drei";
18824
+ import { useState as useState6, useCallback as useCallback3 } from "react";
18825
+ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
18825
18826
  var Error3d = ({
18826
18827
  error,
18827
18828
  cad_component
18828
18829
  }) => {
18830
+ const [isHovered, setIsHovered] = useState6(false);
18831
+ const [hoverPosition, setHoverPosition] = useState6(null);
18832
+ const handleHover = useCallback3((e) => {
18833
+ if (e?.mousePosition) {
18834
+ setIsHovered(true);
18835
+ setHoverPosition(e.mousePosition);
18836
+ } else {
18837
+ setIsHovered(false);
18838
+ setHoverPosition(null);
18839
+ }
18840
+ }, []);
18841
+ const handleUnhover = useCallback3(() => {
18842
+ setIsHovered(false);
18843
+ setHoverPosition(null);
18844
+ }, []);
18829
18845
  let position = [0, 0, 0];
18830
18846
  if (cad_component?.position) {
18831
18847
  position = [
@@ -18835,52 +18851,83 @@ var Error3d = ({
18835
18851
  ];
18836
18852
  position = position.map((p) => Number.isNaN(p) ? 0 : p);
18837
18853
  }
18838
- return /* @__PURE__ */ jsxs5(
18839
- "group",
18840
- {
18841
- position,
18842
- children: [
18843
- /* @__PURE__ */ jsxs5(
18844
- "mesh",
18854
+ return /* @__PURE__ */ jsxs5(Fragment4, { children: [
18855
+ /* @__PURE__ */ jsx8(
18856
+ ContainerWithTooltip_default,
18857
+ {
18858
+ isHovered,
18859
+ onHover: handleHover,
18860
+ onUnhover: handleUnhover,
18861
+ position,
18862
+ children: /* @__PURE__ */ jsxs5(
18863
+ "group",
18845
18864
  {
18846
- renderOrder: -99999,
18847
- rotation: [Math.PI / 4, Math.PI / 4, 0],
18848
- ref: (mesh) => {
18849
- if (mesh) {
18850
- mesh.renderOrder = 999999;
18851
- }
18852
- },
18865
+ position,
18853
18866
  children: [
18854
- /* @__PURE__ */ jsx8("boxGeometry", { args: [0.5, 0.5, 0.5] }),
18855
- /* @__PURE__ */ jsx8(
18856
- "meshStandardMaterial",
18867
+ /* @__PURE__ */ jsxs5(
18868
+ "mesh",
18869
+ {
18870
+ renderOrder: -99999,
18871
+ rotation: [Math.PI / 4, Math.PI / 4, 0],
18872
+ ref: (mesh) => {
18873
+ if (mesh) {
18874
+ mesh.renderOrder = 999999;
18875
+ }
18876
+ },
18877
+ children: [
18878
+ /* @__PURE__ */ jsx8("boxGeometry", { args: [0.5, 0.5, 0.5] }),
18879
+ /* @__PURE__ */ jsx8(
18880
+ "meshStandardMaterial",
18881
+ {
18882
+ depthTest: false,
18883
+ transparent: true,
18884
+ color: "red",
18885
+ opacity: 0.5
18886
+ }
18887
+ )
18888
+ ]
18889
+ }
18890
+ ),
18891
+ /* @__PURE__ */ jsxs5(
18892
+ Text2,
18857
18893
  {
18858
- depthTest: false,
18859
- transparent: true,
18894
+ scale: [0.1, 0.1, 0.1],
18860
18895
  color: "red",
18861
- opacity: 0.5
18896
+ anchorX: "center",
18897
+ anchorY: "middle",
18898
+ depthOffset: -99999,
18899
+ children: [
18900
+ error.toString().slice(0, 50),
18901
+ "..."
18902
+ ]
18862
18903
  }
18863
18904
  )
18864
18905
  ]
18865
18906
  }
18866
- ),
18867
- /* @__PURE__ */ jsxs5(
18868
- Text2,
18869
- {
18870
- scale: [0.1, 0.1, 0.1],
18871
- color: "red",
18872
- anchorX: "center",
18873
- anchorY: "middle",
18874
- depthOffset: -99999,
18875
- children: [
18876
- error.toString().slice(0, 50),
18877
- "..."
18878
- ]
18879
- }
18880
18907
  )
18881
- ]
18882
- }
18883
- );
18908
+ }
18909
+ ),
18910
+ isHovered && hoverPosition ? /* @__PURE__ */ jsx8(
18911
+ Html2,
18912
+ {
18913
+ position: hoverPosition,
18914
+ style: {
18915
+ fontFamily: "sans-serif",
18916
+ transform: "translate3d(50%, 50%, 0)",
18917
+ backgroundColor: "white",
18918
+ padding: "6px",
18919
+ borderRadius: "4px",
18920
+ color: "red",
18921
+ pointerEvents: "none",
18922
+ userSelect: "none",
18923
+ WebkitUserSelect: "none",
18924
+ MozUserSelect: "none",
18925
+ msUserSelect: "none"
18926
+ },
18927
+ children: error.toString()
18928
+ }
18929
+ ) : null
18930
+ ] });
18884
18931
  };
18885
18932
 
18886
18933
  // src/three-components/STLModel.tsx
@@ -19011,10 +19058,10 @@ var CadViewerJscad = forwardRef2(
19011
19058
  // src/CadViewerManifold.tsx
19012
19059
  import { su as su13 } from "@tscircuit/soup-util";
19013
19060
  import ManifoldModule from "manifold-3d";
19014
- import { useEffect as useEffect6, useMemo as useMemo8, useState as useState8 } from "react";
19061
+ import { useEffect as useEffect6, useMemo as useMemo8, useState as useState9 } from "react";
19015
19062
 
19016
19063
  // src/hooks/useManifoldBoardBuilder.ts
19017
- import { useState as useState7, useEffect as useEffect5, useMemo as useMemo7, useRef as useRef6 } from "react";
19064
+ import { useState as useState8, useEffect as useEffect5, useMemo as useMemo7, useRef as useRef6 } from "react";
19018
19065
  import { su as su12 } from "@tscircuit/soup-util";
19019
19066
  import * as THREE10 from "three";
19020
19067
 
@@ -19675,11 +19722,11 @@ function processCutoutsForManifold(Manifold, CrossSection, circuitJson, pcbThick
19675
19722
 
19676
19723
  // src/hooks/useManifoldBoardBuilder.ts
19677
19724
  var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
19678
- const [geoms, setGeoms] = useState7(null);
19679
- const [textures, setTextures] = useState7(null);
19680
- const [pcbThickness, setPcbThickness] = useState7(null);
19681
- const [error, setError] = useState7(null);
19682
- const [isLoading, setIsLoading] = useState7(true);
19725
+ const [geoms, setGeoms] = useState8(null);
19726
+ const [textures, setTextures] = useState8(null);
19727
+ const [pcbThickness, setPcbThickness] = useState8(null);
19728
+ const [error, setError] = useState8(null);
19729
+ const [isLoading, setIsLoading] = useState8(true);
19683
19730
  const manifoldInstancesForCleanup = useRef6([]);
19684
19731
  const boardData = useMemo7(() => {
19685
19732
  if (!circuitJson) return null;
@@ -19946,8 +19993,8 @@ var CadViewerManifold = ({
19946
19993
  autoRotateDisabled,
19947
19994
  clickToInteractEnabled
19948
19995
  }) => {
19949
- const [manifoldJSModule, setManifoldJSModule] = useState8(null);
19950
- const [manifoldLoadingError, setManifoldLoadingError] = useState8(null);
19996
+ const [manifoldJSModule, setManifoldJSModule] = useState9(null);
19997
+ const [manifoldLoadingError, setManifoldLoadingError] = useState9(null);
19951
19998
  useEffect6(() => {
19952
19999
  const manifoldConfig = {
19953
20000
  locateFile: (path, scriptDirectory) => path === "manifold.wasm" ? "/manifold.wasm" : scriptDirectory + path
@@ -20062,16 +20109,16 @@ var CadViewerManifold = ({
20062
20109
  var CadViewerManifold_default = CadViewerManifold;
20063
20110
 
20064
20111
  // src/hooks/useContextMenu.ts
20065
- import { useState as useState9, useCallback as useCallback4, useRef as useRef7, useEffect as useEffect7 } from "react";
20112
+ import { useState as useState10, useCallback as useCallback5, useRef as useRef7, useEffect as useEffect7 } from "react";
20066
20113
  var useContextMenu = ({ containerRef }) => {
20067
- const [menuVisible, setMenuVisible] = useState9(false);
20068
- const [menuPos, setMenuPos] = useState9({
20114
+ const [menuVisible, setMenuVisible] = useState10(false);
20115
+ const [menuPos, setMenuPos] = useState10({
20069
20116
  x: 0,
20070
20117
  y: 0
20071
20118
  });
20072
20119
  const menuRef = useRef7(null);
20073
20120
  const interactionOriginPosRef = useRef7(null);
20074
- const handleContextMenu = useCallback4(
20121
+ const handleContextMenu = useCallback5(
20075
20122
  (e) => {
20076
20123
  e.preventDefault();
20077
20124
  const eventX = typeof e.clientX === "number" ? e.clientX : 0;
@@ -20093,7 +20140,7 @@ var useContextMenu = ({ containerRef }) => {
20093
20140
  },
20094
20141
  [setMenuPos, setMenuVisible]
20095
20142
  );
20096
- const handleTouchStart = useCallback4((e) => {
20143
+ const handleTouchStart = useCallback5((e) => {
20097
20144
  if (e.touches.length === 1) {
20098
20145
  const touch = e.touches[0];
20099
20146
  if (touch) {
@@ -20105,7 +20152,7 @@ var useContextMenu = ({ containerRef }) => {
20105
20152
  interactionOriginPosRef.current = null;
20106
20153
  }
20107
20154
  }, []);
20108
- const handleTouchMove = useCallback4((e) => {
20155
+ const handleTouchMove = useCallback5((e) => {
20109
20156
  if (!interactionOriginPosRef.current || e.touches.length !== 1) {
20110
20157
  return;
20111
20158
  }
@@ -20121,14 +20168,14 @@ var useContextMenu = ({ containerRef }) => {
20121
20168
  interactionOriginPosRef.current = null;
20122
20169
  }
20123
20170
  }, []);
20124
- const handleTouchEnd = useCallback4(() => {
20171
+ const handleTouchEnd = useCallback5(() => {
20125
20172
  setTimeout(() => {
20126
20173
  if (interactionOriginPosRef.current) {
20127
20174
  interactionOriginPosRef.current = null;
20128
20175
  }
20129
20176
  }, 0);
20130
20177
  }, []);
20131
- const handleClickAway = useCallback4((e) => {
20178
+ const handleClickAway = useCallback5((e) => {
20132
20179
  const target = e.target;
20133
20180
  if (menuRef.current && !menuRef.current.contains(target)) {
20134
20181
  setMenuVisible(false);
@@ -20166,7 +20213,7 @@ var useContextMenu = ({ containerRef }) => {
20166
20213
  // src/CadViewer.tsx
20167
20214
  import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
20168
20215
  var CadViewer = (props) => {
20169
- const [engine, setEngine] = useState10("jscad");
20216
+ const [engine, setEngine] = useState11("jscad");
20170
20217
  const containerRef = useRef8(null);
20171
20218
  const {
20172
20219
  menuVisible,
@@ -20545,7 +20592,7 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
20545
20592
  }
20546
20593
 
20547
20594
  // src/hooks/exporter/gltf.ts
20548
- import { useEffect as useEffect9, useState as useState11, useMemo as useMemo9, useCallback as useCallback6 } from "react";
20595
+ import { useEffect as useEffect9, useState as useState12, useMemo as useMemo9, useCallback as useCallback7 } from "react";
20549
20596
  function useSaveGltfAs(options = {}) {
20550
20597
  const parse = useParser(options);
20551
20598
  const link = useMemo9(() => document.createElement("a"), []);
@@ -20566,16 +20613,16 @@ function useSaveGltfAs(options = {}) {
20566
20613
  []
20567
20614
  );
20568
20615
  let instance;
20569
- const ref = useCallback6((obj3D) => {
20616
+ const ref = useCallback7((obj3D) => {
20570
20617
  instance = obj3D;
20571
20618
  }, []);
20572
20619
  return [ref, saveAs];
20573
20620
  }
20574
20621
  function useExportGltfUrl(options = {}) {
20575
20622
  const parse = useParser(options);
20576
- const [url, setUrl] = useState11();
20577
- const [error, setError] = useState11();
20578
- const ref = useCallback6(
20623
+ const [url, setUrl] = useState12();
20624
+ const [error, setError] = useState12();
20625
+ const ref = useCallback7(
20579
20626
  (instance) => parse(instance).then(setUrl).catch(setError),
20580
20627
  []
20581
20628
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.274",
3
+ "version": "0.0.276",
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.454",
35
- "@tscircuit/props": "^0.0.231",
35
+ "@tscircuit/props": "^0.0.233",
36
36
  "@tscircuit/soup-util": "^0.0.41",
37
37
  "jscad-electronics": "^0.0.29",
38
38
  "jscad-fiber": "^0.0.79",