@tscircuit/3d-viewer 0.0.500 → 0.0.501
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 +30 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14300,6 +14300,22 @@ var useLayerVisibility = () => {
|
|
|
14300
14300
|
return context;
|
|
14301
14301
|
};
|
|
14302
14302
|
|
|
14303
|
+
// src/hooks/usePcbThickness.ts
|
|
14304
|
+
import { useMemo as useMemo2 } from "react";
|
|
14305
|
+
import { su } from "@tscircuit/circuit-json-util";
|
|
14306
|
+
var DEFAULT_PCB_THICKNESS = 1.2;
|
|
14307
|
+
function usePcbThickness(circuitJson) {
|
|
14308
|
+
return useMemo2(() => {
|
|
14309
|
+
if (!circuitJson) return DEFAULT_PCB_THICKNESS;
|
|
14310
|
+
try {
|
|
14311
|
+
const board = su(circuitJson).pcb_board.list()[0];
|
|
14312
|
+
return board?.thickness ?? DEFAULT_PCB_THICKNESS;
|
|
14313
|
+
} catch (e) {
|
|
14314
|
+
return DEFAULT_PCB_THICKNESS;
|
|
14315
|
+
}
|
|
14316
|
+
}, [circuitJson]);
|
|
14317
|
+
}
|
|
14318
|
+
|
|
14303
14319
|
// src/react-three/Html.tsx
|
|
14304
14320
|
import { useRef, useEffect as useEffect2, useState as useState2 } from "react";
|
|
14305
14321
|
import ReactDOM from "react-dom";
|
|
@@ -29750,7 +29766,7 @@ function getJscadModelForFootprint(footprint, jscad3) {
|
|
|
29750
29766
|
|
|
29751
29767
|
// src/three-components/FootprinterModel.tsx
|
|
29752
29768
|
var jscadModeling = __toESM(require_src(), 1);
|
|
29753
|
-
import { useMemo as
|
|
29769
|
+
import { useMemo as useMemo4, useEffect as useEffect5 } from "react";
|
|
29754
29770
|
import * as THREE3 from "three";
|
|
29755
29771
|
|
|
29756
29772
|
// src/ContainerWithTooltip.tsx
|
|
@@ -29762,7 +29778,7 @@ import {
|
|
|
29762
29778
|
useContext as useContext3,
|
|
29763
29779
|
useState as useState3,
|
|
29764
29780
|
useCallback as useCallback2,
|
|
29765
|
-
useMemo as
|
|
29781
|
+
useMemo as useMemo3,
|
|
29766
29782
|
useEffect as useEffect3,
|
|
29767
29783
|
useRef as useRef2
|
|
29768
29784
|
} from "react";
|
|
@@ -29779,8 +29795,8 @@ var useHover = () => {
|
|
|
29779
29795
|
var HoverProvider = ({ children }) => {
|
|
29780
29796
|
const { camera, renderer } = useThree();
|
|
29781
29797
|
const [hoverables, setHoverables] = useState3([]);
|
|
29782
|
-
const raycaster =
|
|
29783
|
-
const mouse =
|
|
29798
|
+
const raycaster = useMemo3(() => new THREE2.Raycaster(), []);
|
|
29799
|
+
const mouse = useMemo3(() => new THREE2.Vector2(), []);
|
|
29784
29800
|
const hoverablesRef = useRef2(hoverables);
|
|
29785
29801
|
hoverablesRef.current = hoverables;
|
|
29786
29802
|
const hoveredObjectRef = useRef2(null);
|
|
@@ -29873,7 +29889,7 @@ var HoverProvider = ({ children }) => {
|
|
|
29873
29889
|
domElement.removeEventListener("mousemove", onMouseMove);
|
|
29874
29890
|
};
|
|
29875
29891
|
}, [renderer, onMouseMove]);
|
|
29876
|
-
const contextValue =
|
|
29892
|
+
const contextValue = useMemo3(
|
|
29877
29893
|
() => ({
|
|
29878
29894
|
addHoverable,
|
|
29879
29895
|
removeHoverable
|
|
@@ -29922,7 +29938,7 @@ var FootprinterModel = ({
|
|
|
29922
29938
|
isTranslucent = false
|
|
29923
29939
|
}) => {
|
|
29924
29940
|
const { rootObject } = useThree();
|
|
29925
|
-
const group =
|
|
29941
|
+
const group = useMemo4(() => {
|
|
29926
29942
|
if (!footprint) return null;
|
|
29927
29943
|
const { geometries } = getJscadModelForFootprint(footprint, jscadModeling);
|
|
29928
29944
|
const group2 = new THREE3.Group();
|
|
@@ -30169,7 +30185,7 @@ function GltfModel({
|
|
|
30169
30185
|
var import_jscad_planner = __toESM(require_dist(), 1);
|
|
30170
30186
|
var import_modeling = __toESM(require_src(), 1);
|
|
30171
30187
|
import * as THREE6 from "three";
|
|
30172
|
-
import { useMemo as
|
|
30188
|
+
import { useMemo as useMemo6, useEffect as useEffect7 } from "react";
|
|
30173
30189
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
30174
30190
|
var JscadModel = ({
|
|
30175
30191
|
jscadPlan,
|
|
@@ -30182,7 +30198,7 @@ var JscadModel = ({
|
|
|
30182
30198
|
isTranslucent = false
|
|
30183
30199
|
}) => {
|
|
30184
30200
|
const { rootObject } = useThree();
|
|
30185
|
-
const { threeGeom, material } =
|
|
30201
|
+
const { threeGeom, material } = useMemo6(() => {
|
|
30186
30202
|
const jscadObject = (0, import_jscad_planner.executeJscadOperations)(import_modeling.default, jscadPlan);
|
|
30187
30203
|
if (!jscadObject || !jscadObject.polygons && !jscadObject.sides) {
|
|
30188
30204
|
return { threeGeom: null, material: null };
|
|
@@ -30197,7 +30213,7 @@ var JscadModel = ({
|
|
|
30197
30213
|
});
|
|
30198
30214
|
return { threeGeom: threeGeom2, material: material2 };
|
|
30199
30215
|
}, [jscadPlan, isTranslucent]);
|
|
30200
|
-
const mesh =
|
|
30216
|
+
const mesh = useMemo6(() => {
|
|
30201
30217
|
if (!threeGeom) return null;
|
|
30202
30218
|
return new THREE6.Mesh(threeGeom, material);
|
|
30203
30219
|
}, [threeGeom, material]);
|
|
@@ -30223,7 +30239,7 @@ var JscadModel = ({
|
|
|
30223
30239
|
rotationOffset?.[2],
|
|
30224
30240
|
scale3
|
|
30225
30241
|
]);
|
|
30226
|
-
|
|
30242
|
+
useMemo6(() => {
|
|
30227
30243
|
if (!material) return;
|
|
30228
30244
|
if (isHovered) {
|
|
30229
30245
|
const color = new THREE6.Color(material.color.getHex());
|
|
@@ -30351,7 +30367,7 @@ function useGlobalObjLoader(url) {
|
|
|
30351
30367
|
}
|
|
30352
30368
|
|
|
30353
30369
|
// src/three-components/MixedStlModel.tsx
|
|
30354
|
-
import { useEffect as useEffect9, useMemo as
|
|
30370
|
+
import { useEffect as useEffect9, useMemo as useMemo7 } from "react";
|
|
30355
30371
|
import * as THREE7 from "three";
|
|
30356
30372
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
30357
30373
|
function MixedStlModel({
|
|
@@ -30366,7 +30382,7 @@ function MixedStlModel({
|
|
|
30366
30382
|
}) {
|
|
30367
30383
|
const obj = useGlobalObjLoader(url);
|
|
30368
30384
|
const { rootObject } = useThree();
|
|
30369
|
-
const model =
|
|
30385
|
+
const model = useMemo7(() => {
|
|
30370
30386
|
if (obj && !(obj instanceof Error)) {
|
|
30371
30387
|
obj.traverse((child) => {
|
|
30372
30388
|
if (child instanceof THREE7.Mesh && child.material) {
|
|
@@ -30649,22 +30665,6 @@ var StepModel = ({
|
|
|
30649
30665
|
// src/utils/tuple.ts
|
|
30650
30666
|
var tuple = (...args) => args;
|
|
30651
30667
|
|
|
30652
|
-
// src/hooks/usePcbThickness.ts
|
|
30653
|
-
import { useMemo as useMemo7 } from "react";
|
|
30654
|
-
import { su } from "@tscircuit/circuit-json-util";
|
|
30655
|
-
var DEFAULT_PCB_THICKNESS = 1.2;
|
|
30656
|
-
function usePcbThickness(circuitJson) {
|
|
30657
|
-
return useMemo7(() => {
|
|
30658
|
-
if (!circuitJson) return DEFAULT_PCB_THICKNESS;
|
|
30659
|
-
try {
|
|
30660
|
-
const board = su(circuitJson).pcb_board.list()[0];
|
|
30661
|
-
return board?.thickness ?? DEFAULT_PCB_THICKNESS;
|
|
30662
|
-
} catch (e) {
|
|
30663
|
-
return DEFAULT_PCB_THICKNESS;
|
|
30664
|
-
}
|
|
30665
|
-
}, [circuitJson]);
|
|
30666
|
-
}
|
|
30667
|
-
|
|
30668
30668
|
// src/AnyCadComponent.tsx
|
|
30669
30669
|
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
30670
30670
|
var AnyCadComponent = ({
|
|
@@ -30713,7 +30713,7 @@ var AnyCadComponent = ({
|
|
|
30713
30713
|
cad_component2.rotation.z * Math.PI / 180
|
|
30714
30714
|
) : tuple(0, 0, 0);
|
|
30715
30715
|
if (layer === "bottom") {
|
|
30716
|
-
return tuple(baseRotation[0] + Math.PI, baseRotation[1], baseRotation[2]);
|
|
30716
|
+
return tuple(baseRotation[0] + Math.PI, baseRotation[1], -baseRotation[2]);
|
|
30717
30717
|
}
|
|
30718
30718
|
return baseRotation;
|
|
30719
30719
|
}, [cad_component2.rotation, layer]);
|
|
@@ -30848,7 +30848,7 @@ import * as THREE16 from "three";
|
|
|
30848
30848
|
// package.json
|
|
30849
30849
|
var package_default = {
|
|
30850
30850
|
name: "@tscircuit/3d-viewer",
|
|
30851
|
-
version: "0.0.
|
|
30851
|
+
version: "0.0.500",
|
|
30852
30852
|
main: "./dist/index.js",
|
|
30853
30853
|
module: "./dist/index.js",
|
|
30854
30854
|
type: "module",
|