@tscircuit/3d-viewer 0.0.582 → 0.0.584
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 +1360 -627
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14432,12 +14432,12 @@ var require_browser = __commonJS({
|
|
|
14432
14432
|
});
|
|
14433
14433
|
|
|
14434
14434
|
// src/CadViewer.tsx
|
|
14435
|
-
import { useCallback as useCallback24, useEffect as
|
|
14436
|
-
import * as
|
|
14435
|
+
import { useCallback as useCallback24, useEffect as useEffect49, useRef as useRef29, useState as useState39 } from "react";
|
|
14436
|
+
import * as THREE48 from "three";
|
|
14437
14437
|
|
|
14438
14438
|
// src/CadViewerJscad.tsx
|
|
14439
14439
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
14440
|
-
import { forwardRef as forwardRef3, useMemo as
|
|
14440
|
+
import { forwardRef as forwardRef3, useMemo as useMemo22 } from "react";
|
|
14441
14441
|
|
|
14442
14442
|
// src/AnyCadComponent.tsx
|
|
14443
14443
|
import { su as su2 } from "@tscircuit/circuit-json-util";
|
|
@@ -32704,13 +32704,13 @@ var AnyCadComponent = ({
|
|
|
32704
32704
|
};
|
|
32705
32705
|
|
|
32706
32706
|
// src/CadViewerContainer.tsx
|
|
32707
|
-
import { forwardRef as forwardRef2, useEffect as
|
|
32708
|
-
import * as
|
|
32707
|
+
import { forwardRef as forwardRef2, useEffect as useEffect20, useMemo as useMemo16, useState as useState11 } from "react";
|
|
32708
|
+
import * as THREE23 from "three";
|
|
32709
32709
|
|
|
32710
32710
|
// package.json
|
|
32711
32711
|
var package_default = {
|
|
32712
32712
|
name: "@tscircuit/3d-viewer",
|
|
32713
|
-
version: "0.0.
|
|
32713
|
+
version: "0.0.583",
|
|
32714
32714
|
main: "./dist/index.js",
|
|
32715
32715
|
module: "./dist/index.js",
|
|
32716
32716
|
type: "module",
|
|
@@ -32801,6 +32801,7 @@ var AppearanceProvider = ({
|
|
|
32801
32801
|
children
|
|
32802
32802
|
}) => {
|
|
32803
32803
|
const [darkBackgroundEnabled, setDarkBackgroundEnabled] = useState8(false);
|
|
32804
|
+
const [gridEnabled, setGridEnabled] = useState8(false);
|
|
32804
32805
|
const [lightingEnabled, setLightingEnabled] = useState8(
|
|
32805
32806
|
readStoredLightingEnabled
|
|
32806
32807
|
);
|
|
@@ -32814,10 +32815,12 @@ var AppearanceProvider = ({
|
|
|
32814
32815
|
() => ({
|
|
32815
32816
|
darkBackgroundEnabled,
|
|
32816
32817
|
setDarkBackgroundEnabled,
|
|
32818
|
+
gridEnabled,
|
|
32819
|
+
setGridEnabled,
|
|
32817
32820
|
lightingEnabled,
|
|
32818
32821
|
setLightingEnabled
|
|
32819
32822
|
}),
|
|
32820
|
-
[darkBackgroundEnabled, lightingEnabled]
|
|
32823
|
+
[darkBackgroundEnabled, gridEnabled, lightingEnabled]
|
|
32821
32824
|
);
|
|
32822
32825
|
return /* @__PURE__ */ jsx11(AppearanceContext.Provider, { value, children });
|
|
32823
32826
|
};
|
|
@@ -33385,9 +33388,101 @@ var Canvas = forwardRef(
|
|
|
33385
33388
|
}
|
|
33386
33389
|
);
|
|
33387
33390
|
|
|
33388
|
-
// src/react-three/
|
|
33391
|
+
// src/react-three/Grid.tsx
|
|
33389
33392
|
import { useEffect as useEffect15, useMemo as useMemo12 } from "react";
|
|
33390
33393
|
import * as THREE17 from "three";
|
|
33394
|
+
var vertexShader = `
|
|
33395
|
+
varying vec3 worldPosition;
|
|
33396
|
+
void main() {
|
|
33397
|
+
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
33398
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
33399
|
+
}
|
|
33400
|
+
`;
|
|
33401
|
+
var fragmentShader = `
|
|
33402
|
+
varying vec3 worldPosition;
|
|
33403
|
+
uniform float cellSize;
|
|
33404
|
+
uniform float sectionSize;
|
|
33405
|
+
uniform vec3 gridColor;
|
|
33406
|
+
uniform vec3 sectionColor;
|
|
33407
|
+
uniform float fadeDistance;
|
|
33408
|
+
uniform float fadeStrength;
|
|
33409
|
+
|
|
33410
|
+
float getGrid(float size) {
|
|
33411
|
+
vec2 r = worldPosition.xy / size;
|
|
33412
|
+
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
|
33413
|
+
float line = min(grid.x, grid.y);
|
|
33414
|
+
return 1.0 - min(line * 1.5, 1.0);
|
|
33415
|
+
}
|
|
33416
|
+
|
|
33417
|
+
void main() {
|
|
33418
|
+
float g1 = getGrid(cellSize);
|
|
33419
|
+
float g2 = getGrid(sectionSize);
|
|
33420
|
+
|
|
33421
|
+
float d = distance(worldPosition.xy, cameraPosition.xy);
|
|
33422
|
+
float a = 1.0 - smoothstep(fadeDistance, fadeDistance * fadeStrength, d);
|
|
33423
|
+
|
|
33424
|
+
vec3 color = mix(gridColor, sectionColor, g2);
|
|
33425
|
+
|
|
33426
|
+
gl_FragColor = vec4(color, max(g1, g2) * a);
|
|
33427
|
+
if (gl_FragColor.a <= 0.0) discard;
|
|
33428
|
+
}
|
|
33429
|
+
`;
|
|
33430
|
+
var Grid = ({
|
|
33431
|
+
rotation,
|
|
33432
|
+
infiniteGrid,
|
|
33433
|
+
cellSize = 1,
|
|
33434
|
+
sectionSize = 10
|
|
33435
|
+
}) => {
|
|
33436
|
+
const { scene, camera } = useThree();
|
|
33437
|
+
const size4 = 1e3;
|
|
33438
|
+
const gridMesh = useMemo12(() => {
|
|
33439
|
+
const geometry = new THREE17.PlaneGeometry(size4, size4);
|
|
33440
|
+
geometry.rotateX(-Math.PI / 2);
|
|
33441
|
+
const material = new THREE17.ShaderMaterial({
|
|
33442
|
+
vertexShader,
|
|
33443
|
+
fragmentShader,
|
|
33444
|
+
uniforms: {
|
|
33445
|
+
cellSize: { value: cellSize },
|
|
33446
|
+
sectionSize: { value: sectionSize },
|
|
33447
|
+
gridColor: { value: new THREE17.Color(15658734) },
|
|
33448
|
+
sectionColor: { value: new THREE17.Color(13421823) },
|
|
33449
|
+
fadeDistance: { value: 100 },
|
|
33450
|
+
// Fade out based on sectionSize
|
|
33451
|
+
fadeStrength: { value: 1.5 }
|
|
33452
|
+
},
|
|
33453
|
+
transparent: true,
|
|
33454
|
+
side: THREE17.DoubleSide
|
|
33455
|
+
});
|
|
33456
|
+
const mesh = new THREE17.Mesh(geometry, material);
|
|
33457
|
+
if (rotation) {
|
|
33458
|
+
mesh.rotation.fromArray(rotation);
|
|
33459
|
+
}
|
|
33460
|
+
return mesh;
|
|
33461
|
+
}, [size4, cellSize, sectionSize, rotation]);
|
|
33462
|
+
useFrame(() => {
|
|
33463
|
+
if (infiniteGrid) {
|
|
33464
|
+
gridMesh.position.set(camera.position.x, camera.position.y, 0);
|
|
33465
|
+
}
|
|
33466
|
+
});
|
|
33467
|
+
useEffect15(() => {
|
|
33468
|
+
if (!scene || !gridMesh) return;
|
|
33469
|
+
scene.add(gridMesh);
|
|
33470
|
+
return () => {
|
|
33471
|
+
scene.remove(gridMesh);
|
|
33472
|
+
gridMesh.geometry.dispose();
|
|
33473
|
+
if (Array.isArray(gridMesh.material)) {
|
|
33474
|
+
gridMesh.material.forEach((m) => m.dispose());
|
|
33475
|
+
} else {
|
|
33476
|
+
gridMesh.material.dispose();
|
|
33477
|
+
}
|
|
33478
|
+
};
|
|
33479
|
+
}, [scene, gridMesh]);
|
|
33480
|
+
return null;
|
|
33481
|
+
};
|
|
33482
|
+
|
|
33483
|
+
// src/react-three/Lights.tsx
|
|
33484
|
+
import { useEffect as useEffect16, useMemo as useMemo13 } from "react";
|
|
33485
|
+
import * as THREE18 from "three";
|
|
33391
33486
|
var UNDERSIDE_LIGHT_FACTOR = 0.75;
|
|
33392
33487
|
var Lights = ({
|
|
33393
33488
|
boardDimensions,
|
|
@@ -33396,8 +33491,8 @@ var Lights = ({
|
|
|
33396
33491
|
shadowsEnabled = false
|
|
33397
33492
|
}) => {
|
|
33398
33493
|
const { scene } = useThree();
|
|
33399
|
-
const lightRig =
|
|
33400
|
-
const rig = new
|
|
33494
|
+
const lightRig = useMemo13(() => {
|
|
33495
|
+
const rig = new THREE18.Group();
|
|
33401
33496
|
rig.name = "cad-viewer-light-rig";
|
|
33402
33497
|
const centerX = boardCenter?.x ?? 0;
|
|
33403
33498
|
const centerY = boardCenter?.y ?? 0;
|
|
@@ -33409,14 +33504,14 @@ var Lights = ({
|
|
|
33409
33504
|
const shadowHalfSize = largestBoardDimension * 0.8;
|
|
33410
33505
|
const lightDistance = largestBoardDimension;
|
|
33411
33506
|
const keyLightDistance = largestBoardDimension * 1.7;
|
|
33412
|
-
const ambientLight = new
|
|
33507
|
+
const ambientLight = new THREE18.AmbientLight(16186360, 0.22);
|
|
33413
33508
|
ambientLight.name = "cad-viewer-soft-ambient";
|
|
33414
33509
|
rig.add(ambientLight);
|
|
33415
|
-
const hemisphereLight = new
|
|
33510
|
+
const hemisphereLight = new THREE18.HemisphereLight(15004141, 1581597, 0.2);
|
|
33416
33511
|
hemisphereLight.name = "cad-viewer-hemisphere";
|
|
33417
33512
|
rig.add(hemisphereLight);
|
|
33418
33513
|
const addDirectionalLight = (name, color, intensity, position, castShadow = false) => {
|
|
33419
|
-
const light = new
|
|
33514
|
+
const light = new THREE18.DirectionalLight(color, intensity);
|
|
33420
33515
|
light.name = name;
|
|
33421
33516
|
light.position.set(
|
|
33422
33517
|
centerX + position[0],
|
|
@@ -33490,17 +33585,17 @@ var Lights = ({
|
|
|
33490
33585
|
);
|
|
33491
33586
|
return rig;
|
|
33492
33587
|
}, [boardCenter, boardDimensions, shadowsEnabled]);
|
|
33493
|
-
|
|
33588
|
+
useEffect16(() => {
|
|
33494
33589
|
const previousBackground = scene.background;
|
|
33495
33590
|
const previousEnvironment = scene.environment;
|
|
33496
|
-
scene.background = darkBackgroundEnabled ? new
|
|
33591
|
+
scene.background = darkBackgroundEnabled ? new THREE18.Color(1053456) : null;
|
|
33497
33592
|
scene.environment = null;
|
|
33498
33593
|
return () => {
|
|
33499
33594
|
scene.background = previousBackground;
|
|
33500
33595
|
scene.environment = previousEnvironment;
|
|
33501
33596
|
};
|
|
33502
33597
|
}, [darkBackgroundEnabled, scene]);
|
|
33503
|
-
|
|
33598
|
+
useEffect16(() => {
|
|
33504
33599
|
if (!scene) return;
|
|
33505
33600
|
scene.add(lightRig);
|
|
33506
33601
|
return () => {
|
|
@@ -33511,8 +33606,8 @@ var Lights = ({
|
|
|
33511
33606
|
};
|
|
33512
33607
|
|
|
33513
33608
|
// src/react-three/OrbitControls.tsx
|
|
33514
|
-
import { useEffect as
|
|
33515
|
-
import * as
|
|
33609
|
+
import { useEffect as useEffect17, useMemo as useMemo14 } from "react";
|
|
33610
|
+
import * as THREE19 from "three";
|
|
33516
33611
|
import { OrbitControls as ThreeOrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
33517
33612
|
var OrbitControls = ({
|
|
33518
33613
|
autoRotate,
|
|
@@ -33527,15 +33622,15 @@ var OrbitControls = ({
|
|
|
33527
33622
|
onControlsChange
|
|
33528
33623
|
}) => {
|
|
33529
33624
|
const { camera, renderer } = useThree();
|
|
33530
|
-
const controls =
|
|
33625
|
+
const controls = useMemo14(() => {
|
|
33531
33626
|
if (!camera || !renderer) return null;
|
|
33532
33627
|
return new ThreeOrbitControls(camera, renderer.domElement);
|
|
33533
33628
|
}, [camera, renderer]);
|
|
33534
|
-
|
|
33629
|
+
useEffect17(() => {
|
|
33535
33630
|
onControlsChange?.(controls ?? null);
|
|
33536
33631
|
return () => onControlsChange?.(null);
|
|
33537
33632
|
}, [controls, onControlsChange]);
|
|
33538
|
-
|
|
33633
|
+
useEffect17(() => {
|
|
33539
33634
|
if (!controls) return;
|
|
33540
33635
|
const handleChange = () => {
|
|
33541
33636
|
onControlsChange?.(controls);
|
|
@@ -33545,7 +33640,7 @@ var OrbitControls = ({
|
|
|
33545
33640
|
controls.removeEventListener("change", handleChange);
|
|
33546
33641
|
};
|
|
33547
33642
|
}, [controls, onControlsChange]);
|
|
33548
|
-
|
|
33643
|
+
useEffect17(() => {
|
|
33549
33644
|
if (!controls) return;
|
|
33550
33645
|
controls.autoRotate = autoRotate || false;
|
|
33551
33646
|
controls.autoRotateSpeed = autoRotateSpeed || 1;
|
|
@@ -33556,9 +33651,9 @@ var OrbitControls = ({
|
|
|
33556
33651
|
if (dampingFactor !== void 0) controls.dampingFactor = dampingFactor;
|
|
33557
33652
|
controls.zoomToCursor = true;
|
|
33558
33653
|
controls.mouseButtons = {
|
|
33559
|
-
LEFT:
|
|
33654
|
+
LEFT: THREE19.MOUSE.ROTATE,
|
|
33560
33655
|
// Left click to rotate
|
|
33561
|
-
MIDDLE:
|
|
33656
|
+
MIDDLE: THREE19.MOUSE.PAN,
|
|
33562
33657
|
// Middle click to pan
|
|
33563
33658
|
RIGHT: null
|
|
33564
33659
|
// Right-click always disabled - only context menu
|
|
@@ -33578,14 +33673,14 @@ var OrbitControls = ({
|
|
|
33578
33673
|
dampingFactor,
|
|
33579
33674
|
target
|
|
33580
33675
|
]);
|
|
33581
|
-
|
|
33676
|
+
useEffect17(() => {
|
|
33582
33677
|
if (!controls || !onStart) return;
|
|
33583
33678
|
controls.addEventListener("start", onStart);
|
|
33584
33679
|
return () => {
|
|
33585
33680
|
controls.removeEventListener("start", onStart);
|
|
33586
33681
|
};
|
|
33587
33682
|
}, [controls, onStart]);
|
|
33588
|
-
|
|
33683
|
+
useEffect17(() => {
|
|
33589
33684
|
if (!controls) return;
|
|
33590
33685
|
return () => {
|
|
33591
33686
|
controls.dispose();
|
|
@@ -33597,16 +33692,95 @@ var OrbitControls = ({
|
|
|
33597
33692
|
return null;
|
|
33598
33693
|
};
|
|
33599
33694
|
|
|
33695
|
+
// src/reference-objects/reference-object.ts
|
|
33696
|
+
var REFERENCE_OBJECT_CLEARANCE_MM = 10;
|
|
33697
|
+
var REFERENCE_OBJECT_SPECS = {
|
|
33698
|
+
banana: {
|
|
33699
|
+
type: "banana",
|
|
33700
|
+
label: "Show Banana",
|
|
33701
|
+
// USDA describes a medium banana as 7 to 7 7/8 inches long. The 190 mm
|
|
33702
|
+
// envelope is near the midpoint of that range.
|
|
33703
|
+
width: 190,
|
|
33704
|
+
height: 60,
|
|
33705
|
+
depth: 34,
|
|
33706
|
+
zCenter: 17
|
|
33707
|
+
},
|
|
33708
|
+
"credit-card": {
|
|
33709
|
+
type: "credit-card",
|
|
33710
|
+
label: "Show Credit Card",
|
|
33711
|
+
// ISO/IEC 7810 ID-1 dimensions.
|
|
33712
|
+
width: 85.6,
|
|
33713
|
+
height: 53.98,
|
|
33714
|
+
depth: 0.76,
|
|
33715
|
+
zCenter: 0
|
|
33716
|
+
},
|
|
33717
|
+
"14in-macbook": {
|
|
33718
|
+
type: "14in-macbook",
|
|
33719
|
+
label: "Show 14in Macbook",
|
|
33720
|
+
// Current 14-inch MacBook Pro exterior dimensions.
|
|
33721
|
+
width: 312.6,
|
|
33722
|
+
height: 221.2,
|
|
33723
|
+
depth: 15.5,
|
|
33724
|
+
zCenter: 0
|
|
33725
|
+
}
|
|
33726
|
+
};
|
|
33727
|
+
var REFERENCE_OBJECT_OPTIONS = Object.values(REFERENCE_OBJECT_SPECS);
|
|
33728
|
+
var safeDimension = (dimension) => Number.isFinite(dimension) ? Math.max(dimension ?? 0, 0) : 0;
|
|
33729
|
+
var safeCoordinate = (coordinate) => Number.isFinite(coordinate) ? coordinate ?? 0 : 0;
|
|
33730
|
+
var getReferenceObjectPosition = (type, boardDimensions, boardCenter) => {
|
|
33731
|
+
const spec = REFERENCE_OBJECT_SPECS[type];
|
|
33732
|
+
const boardWidth = safeDimension(boardDimensions?.width);
|
|
33733
|
+
const centerX = safeCoordinate(boardCenter?.x);
|
|
33734
|
+
const centerY = safeCoordinate(boardCenter?.y);
|
|
33735
|
+
return {
|
|
33736
|
+
x: centerX + boardWidth / 2 + REFERENCE_OBJECT_CLEARANCE_MM + spec.width / 2,
|
|
33737
|
+
y: centerY,
|
|
33738
|
+
z: 0
|
|
33739
|
+
};
|
|
33740
|
+
};
|
|
33741
|
+
var getComparisonBounds = (type, boardDimensions, boardCenter) => {
|
|
33742
|
+
const spec = REFERENCE_OBJECT_SPECS[type];
|
|
33743
|
+
const boardWidth = safeDimension(boardDimensions?.width);
|
|
33744
|
+
const boardHeight = safeDimension(boardDimensions?.height);
|
|
33745
|
+
const centerX = safeCoordinate(boardCenter?.x);
|
|
33746
|
+
const centerY = safeCoordinate(boardCenter?.y);
|
|
33747
|
+
const referencePosition = getReferenceObjectPosition(
|
|
33748
|
+
type,
|
|
33749
|
+
boardDimensions,
|
|
33750
|
+
boardCenter
|
|
33751
|
+
);
|
|
33752
|
+
return {
|
|
33753
|
+
minX: Math.min(
|
|
33754
|
+
centerX - boardWidth / 2,
|
|
33755
|
+
referencePosition.x - spec.width / 2
|
|
33756
|
+
),
|
|
33757
|
+
maxX: Math.max(
|
|
33758
|
+
centerX + boardWidth / 2,
|
|
33759
|
+
referencePosition.x + spec.width / 2
|
|
33760
|
+
),
|
|
33761
|
+
minY: Math.min(
|
|
33762
|
+
centerY - boardHeight / 2,
|
|
33763
|
+
referencePosition.y - spec.height / 2
|
|
33764
|
+
),
|
|
33765
|
+
maxY: Math.max(
|
|
33766
|
+
centerY + boardHeight / 2,
|
|
33767
|
+
referencePosition.y + spec.height / 2
|
|
33768
|
+
),
|
|
33769
|
+
minZ: Math.min(0, referencePosition.z + spec.zCenter - spec.depth / 2),
|
|
33770
|
+
maxZ: Math.max(0, referencePosition.z + spec.zCenter + spec.depth / 2)
|
|
33771
|
+
};
|
|
33772
|
+
};
|
|
33773
|
+
|
|
33600
33774
|
// src/three-components/OrientationCubeCanvas.tsx
|
|
33601
|
-
import { useEffect as
|
|
33602
|
-
import * as
|
|
33775
|
+
import { useEffect as useEffect18, useRef as useRef7 } from "react";
|
|
33776
|
+
import * as THREE20 from "three";
|
|
33603
33777
|
import { Text as TroikaText } from "troika-three-text";
|
|
33604
33778
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
33605
33779
|
function computePointInFront(rotationVector, distance5) {
|
|
33606
|
-
const quaternion = new
|
|
33607
|
-
new
|
|
33780
|
+
const quaternion = new THREE20.Quaternion().setFromEuler(
|
|
33781
|
+
new THREE20.Euler(rotationVector.x, rotationVector.y, rotationVector.z)
|
|
33608
33782
|
);
|
|
33609
|
-
const forwardVector = new
|
|
33783
|
+
const forwardVector = new THREE20.Vector3(0, 0, 1);
|
|
33610
33784
|
forwardVector.applyQuaternion(quaternion);
|
|
33611
33785
|
const result = forwardVector.multiplyScalar(distance5);
|
|
33612
33786
|
return result;
|
|
@@ -33614,36 +33788,36 @@ function computePointInFront(rotationVector, distance5) {
|
|
|
33614
33788
|
var OrientationCubeCanvas = () => {
|
|
33615
33789
|
const { mainCameraRef } = useCameraController();
|
|
33616
33790
|
const containerRef = useRef7(null);
|
|
33617
|
-
|
|
33791
|
+
useEffect18(() => {
|
|
33618
33792
|
if (!containerRef.current) return;
|
|
33619
33793
|
const container = containerRef.current;
|
|
33620
33794
|
const canvas = document.createElement("canvas");
|
|
33621
33795
|
container.appendChild(canvas);
|
|
33622
|
-
const renderer = new
|
|
33796
|
+
const renderer = new THREE20.WebGLRenderer({
|
|
33623
33797
|
canvas,
|
|
33624
33798
|
antialias: true,
|
|
33625
33799
|
alpha: true
|
|
33626
33800
|
});
|
|
33627
33801
|
renderer.setSize(120, 120);
|
|
33628
33802
|
renderer.setPixelRatio(window.devicePixelRatio);
|
|
33629
|
-
const scene = new
|
|
33630
|
-
const camera = new
|
|
33803
|
+
const scene = new THREE20.Scene();
|
|
33804
|
+
const camera = new THREE20.PerspectiveCamera(75, 1, 0.1, 1e3);
|
|
33631
33805
|
camera.up.set(0, 0, 1);
|
|
33632
|
-
const ambientLight = new
|
|
33806
|
+
const ambientLight = new THREE20.AmbientLight(16777215, Math.PI / 2);
|
|
33633
33807
|
scene.add(ambientLight);
|
|
33634
|
-
const group = new
|
|
33808
|
+
const group = new THREE20.Group();
|
|
33635
33809
|
group.rotation.fromArray([Math.PI / 2, 0, 0]);
|
|
33636
33810
|
const cubeSize = 1;
|
|
33637
|
-
const box = new
|
|
33638
|
-
new
|
|
33639
|
-
new
|
|
33811
|
+
const box = new THREE20.Mesh(
|
|
33812
|
+
new THREE20.BoxGeometry(cubeSize, cubeSize, cubeSize),
|
|
33813
|
+
new THREE20.MeshStandardMaterial({ color: "white" })
|
|
33640
33814
|
);
|
|
33641
33815
|
group.add(box);
|
|
33642
|
-
const edges = new
|
|
33643
|
-
new
|
|
33644
|
-
new
|
|
33816
|
+
const edges = new THREE20.LineSegments(
|
|
33817
|
+
new THREE20.EdgesGeometry(
|
|
33818
|
+
new THREE20.BoxGeometry(cubeSize, cubeSize, cubeSize)
|
|
33645
33819
|
),
|
|
33646
|
-
new
|
|
33820
|
+
new THREE20.LineBasicMaterial({ color: 0, linewidth: 2 })
|
|
33647
33821
|
);
|
|
33648
33822
|
group.add(edges);
|
|
33649
33823
|
scene.add(group);
|
|
@@ -33698,7 +33872,7 @@ var OrientationCubeCanvas = () => {
|
|
|
33698
33872
|
const animate = () => {
|
|
33699
33873
|
if (mainCameraRef.current) {
|
|
33700
33874
|
const cameraPosition = computePointInFront(
|
|
33701
|
-
mainCameraRef.current.rotation ?? new
|
|
33875
|
+
mainCameraRef.current.rotation ?? new THREE20.Euler(0, 0, 0),
|
|
33702
33876
|
2
|
|
33703
33877
|
);
|
|
33704
33878
|
if (!cameraPosition.equals(camera.position)) {
|
|
@@ -33746,6 +33920,421 @@ var OrientationCubeCanvas = () => {
|
|
|
33746
33920
|
);
|
|
33747
33921
|
};
|
|
33748
33922
|
|
|
33923
|
+
// src/three-components/reference-object.tsx
|
|
33924
|
+
import { useEffect as useEffect19, useMemo as useMemo15 } from "react";
|
|
33925
|
+
|
|
33926
|
+
// src/reference-objects/create-reference-object.ts
|
|
33927
|
+
import * as THREE21 from "three";
|
|
33928
|
+
var createRoundedRectangleShape = (width10, height10, radius) => {
|
|
33929
|
+
const halfWidth = width10 / 2;
|
|
33930
|
+
const halfHeight = height10 / 2;
|
|
33931
|
+
const safeRadius = Math.min(radius, halfWidth, halfHeight);
|
|
33932
|
+
const shape = new THREE21.Shape();
|
|
33933
|
+
shape.moveTo(-halfWidth + safeRadius, -halfHeight);
|
|
33934
|
+
shape.lineTo(halfWidth - safeRadius, -halfHeight);
|
|
33935
|
+
shape.quadraticCurveTo(
|
|
33936
|
+
halfWidth,
|
|
33937
|
+
-halfHeight,
|
|
33938
|
+
halfWidth,
|
|
33939
|
+
-halfHeight + safeRadius
|
|
33940
|
+
);
|
|
33941
|
+
shape.lineTo(halfWidth, halfHeight - safeRadius);
|
|
33942
|
+
shape.quadraticCurveTo(
|
|
33943
|
+
halfWidth,
|
|
33944
|
+
halfHeight,
|
|
33945
|
+
halfWidth - safeRadius,
|
|
33946
|
+
halfHeight
|
|
33947
|
+
);
|
|
33948
|
+
shape.lineTo(-halfWidth + safeRadius, halfHeight);
|
|
33949
|
+
shape.quadraticCurveTo(
|
|
33950
|
+
-halfWidth,
|
|
33951
|
+
halfHeight,
|
|
33952
|
+
-halfWidth,
|
|
33953
|
+
halfHeight - safeRadius
|
|
33954
|
+
);
|
|
33955
|
+
shape.lineTo(-halfWidth, -halfHeight + safeRadius);
|
|
33956
|
+
shape.quadraticCurveTo(
|
|
33957
|
+
-halfWidth,
|
|
33958
|
+
-halfHeight,
|
|
33959
|
+
-halfWidth + safeRadius,
|
|
33960
|
+
-halfHeight
|
|
33961
|
+
);
|
|
33962
|
+
return shape;
|
|
33963
|
+
};
|
|
33964
|
+
var createRoundedPrismGeometry = (width10, height10, depth, radius) => {
|
|
33965
|
+
return createPrismGeometryFromShape(
|
|
33966
|
+
createRoundedRectangleShape(width10, height10, radius),
|
|
33967
|
+
depth
|
|
33968
|
+
);
|
|
33969
|
+
};
|
|
33970
|
+
var createPrismGeometryFromShape = (shape, depth) => {
|
|
33971
|
+
const geometry = new THREE21.ExtrudeGeometry(shape, {
|
|
33972
|
+
depth,
|
|
33973
|
+
bevelEnabled: false,
|
|
33974
|
+
curveSegments: 24
|
|
33975
|
+
});
|
|
33976
|
+
geometry.translate(0, 0, -depth / 2);
|
|
33977
|
+
geometry.computeVertexNormals();
|
|
33978
|
+
return geometry;
|
|
33979
|
+
};
|
|
33980
|
+
var normalizeObjectToSpec = (object, type) => {
|
|
33981
|
+
const spec = REFERENCE_OBJECT_SPECS[type];
|
|
33982
|
+
object.updateMatrixWorld(true);
|
|
33983
|
+
const initialBounds = new THREE21.Box3().setFromObject(object);
|
|
33984
|
+
const initialSize = initialBounds.getSize(new THREE21.Vector3());
|
|
33985
|
+
object.scale.set(
|
|
33986
|
+
spec.width / initialSize.x,
|
|
33987
|
+
spec.height / initialSize.y,
|
|
33988
|
+
spec.depth / initialSize.z
|
|
33989
|
+
);
|
|
33990
|
+
object.updateMatrixWorld(true);
|
|
33991
|
+
const scaledBounds = new THREE21.Box3().setFromObject(object);
|
|
33992
|
+
const scaledCenter = scaledBounds.getCenter(new THREE21.Vector3());
|
|
33993
|
+
object.position.set(
|
|
33994
|
+
-scaledCenter.x,
|
|
33995
|
+
-scaledCenter.y,
|
|
33996
|
+
spec.zCenter - scaledCenter.z
|
|
33997
|
+
);
|
|
33998
|
+
object.updateMatrixWorld(true);
|
|
33999
|
+
};
|
|
34000
|
+
var createBananaGeometry = () => {
|
|
34001
|
+
const curve = new THREE21.CatmullRomCurve3([
|
|
34002
|
+
new THREE21.Vector3(-82, 18, 16),
|
|
34003
|
+
new THREE21.Vector3(-67, 7, 15),
|
|
34004
|
+
new THREE21.Vector3(-43, -9, 14),
|
|
34005
|
+
new THREE21.Vector3(-15, -18, 14),
|
|
34006
|
+
new THREE21.Vector3(16, -18, 14),
|
|
34007
|
+
new THREE21.Vector3(47, -8, 14.5),
|
|
34008
|
+
new THREE21.Vector3(72, 8, 16),
|
|
34009
|
+
new THREE21.Vector3(84, 19, 17)
|
|
34010
|
+
]);
|
|
34011
|
+
const tubularSegments = 84;
|
|
34012
|
+
const radialSegments = 30;
|
|
34013
|
+
const frames = curve.computeFrenetFrames(tubularSegments, false);
|
|
34014
|
+
const positions = [];
|
|
34015
|
+
const normals = [];
|
|
34016
|
+
const colors2 = [];
|
|
34017
|
+
const uvs = [];
|
|
34018
|
+
const indices = [];
|
|
34019
|
+
const ripeYellow = new THREE21.Color(16766023);
|
|
34020
|
+
const stemGreen = new THREE21.Color(12038965);
|
|
34021
|
+
for (let segment = 0; segment <= tubularSegments; segment++) {
|
|
34022
|
+
const t = segment / tubularSegments;
|
|
34023
|
+
const point = curve.getPointAt(t);
|
|
34024
|
+
const normal = frames.normals[segment];
|
|
34025
|
+
const binormal = frames.binormals[segment];
|
|
34026
|
+
const taper = Math.sin(Math.PI * t) ** 0.48;
|
|
34027
|
+
const radius = 3.4 + 12.4 * taper;
|
|
34028
|
+
const stemBlend = Math.max(0, (t - 0.82) / 0.18) * 0.38;
|
|
34029
|
+
const ringColor = ripeYellow.clone().lerp(stemGreen, stemBlend);
|
|
34030
|
+
for (let side = 0; side <= radialSegments; side++) {
|
|
34031
|
+
const angle = side / radialSegments * Math.PI * 2;
|
|
34032
|
+
const sin = Math.sin(angle);
|
|
34033
|
+
const cos = Math.cos(angle);
|
|
34034
|
+
const ridgeScale = 1 + Math.cos(angle * 5 + 0.35) * 0.035;
|
|
34035
|
+
const radialNormal = new THREE21.Vector3().addScaledVector(normal, cos).addScaledVector(binormal, sin * 0.9).normalize();
|
|
34036
|
+
const vertex = point.clone().addScaledVector(normal, cos * radius * ridgeScale).addScaledVector(binormal, sin * radius * 0.9 * ridgeScale);
|
|
34037
|
+
positions.push(vertex.x, vertex.y, vertex.z);
|
|
34038
|
+
normals.push(radialNormal.x, radialNormal.y, radialNormal.z);
|
|
34039
|
+
colors2.push(ringColor.r, ringColor.g, ringColor.b);
|
|
34040
|
+
uvs.push(t, side / radialSegments);
|
|
34041
|
+
}
|
|
34042
|
+
}
|
|
34043
|
+
for (let segment = 1; segment <= tubularSegments; segment++) {
|
|
34044
|
+
for (let side = 1; side <= radialSegments; side++) {
|
|
34045
|
+
const rowSize = radialSegments + 1;
|
|
34046
|
+
const a = rowSize * (segment - 1) + (side - 1);
|
|
34047
|
+
const b = rowSize * segment + (side - 1);
|
|
34048
|
+
const c = rowSize * segment + side;
|
|
34049
|
+
const d = rowSize * (segment - 1) + side;
|
|
34050
|
+
indices.push(a, d, b, b, d, c);
|
|
34051
|
+
}
|
|
34052
|
+
}
|
|
34053
|
+
const geometry = new THREE21.BufferGeometry();
|
|
34054
|
+
geometry.setIndex(indices);
|
|
34055
|
+
geometry.setAttribute(
|
|
34056
|
+
"position",
|
|
34057
|
+
new THREE21.Float32BufferAttribute(positions, 3)
|
|
34058
|
+
);
|
|
34059
|
+
geometry.setAttribute("normal", new THREE21.Float32BufferAttribute(normals, 3));
|
|
34060
|
+
geometry.setAttribute("color", new THREE21.Float32BufferAttribute(colors2, 3));
|
|
34061
|
+
geometry.setAttribute("uv", new THREE21.Float32BufferAttribute(uvs, 2));
|
|
34062
|
+
geometry.computeBoundingBox();
|
|
34063
|
+
geometry.computeBoundingSphere();
|
|
34064
|
+
return { geometry, curve };
|
|
34065
|
+
};
|
|
34066
|
+
var createBanana = () => {
|
|
34067
|
+
const group = new THREE21.Group();
|
|
34068
|
+
const banana = new THREE21.Group();
|
|
34069
|
+
const { geometry, curve } = createBananaGeometry();
|
|
34070
|
+
const peel = new THREE21.Mesh(
|
|
34071
|
+
geometry,
|
|
34072
|
+
new THREE21.MeshStandardMaterial({
|
|
34073
|
+
color: 16777215,
|
|
34074
|
+
roughness: 0.72,
|
|
34075
|
+
metalness: 0,
|
|
34076
|
+
vertexColors: true
|
|
34077
|
+
})
|
|
34078
|
+
);
|
|
34079
|
+
peel.name = "banana-peel";
|
|
34080
|
+
banana.add(peel);
|
|
34081
|
+
const blossomTip = new THREE21.Mesh(
|
|
34082
|
+
new THREE21.SphereGeometry(3.4, 20, 12),
|
|
34083
|
+
new THREE21.MeshStandardMaterial({
|
|
34084
|
+
color: 6242844,
|
|
34085
|
+
roughness: 0.92
|
|
34086
|
+
})
|
|
34087
|
+
);
|
|
34088
|
+
blossomTip.position.copy(curve.getPointAt(0));
|
|
34089
|
+
blossomTip.scale.set(1.15, 0.78, 0.78);
|
|
34090
|
+
blossomTip.name = "banana-blossom-tip";
|
|
34091
|
+
banana.add(blossomTip);
|
|
34092
|
+
const stemLength = 11;
|
|
34093
|
+
const stemTangent = curve.getTangentAt(1).normalize();
|
|
34094
|
+
const stem = new THREE21.Mesh(
|
|
34095
|
+
new THREE21.CylinderGeometry(2.5, 4.1, stemLength, 18),
|
|
34096
|
+
new THREE21.MeshStandardMaterial({
|
|
34097
|
+
color: 8483625,
|
|
34098
|
+
roughness: 0.82
|
|
34099
|
+
})
|
|
34100
|
+
);
|
|
34101
|
+
stem.quaternion.setFromUnitVectors(new THREE21.Vector3(0, 1, 0), stemTangent);
|
|
34102
|
+
stem.position.copy(curve.getPointAt(1)).addScaledVector(stemTangent, stemLength / 2);
|
|
34103
|
+
stem.name = "banana-stem";
|
|
34104
|
+
banana.add(stem);
|
|
34105
|
+
const stemTip = new THREE21.Mesh(
|
|
34106
|
+
new THREE21.SphereGeometry(2.55, 18, 10),
|
|
34107
|
+
new THREE21.MeshStandardMaterial({
|
|
34108
|
+
color: 5981470,
|
|
34109
|
+
roughness: 0.9
|
|
34110
|
+
})
|
|
34111
|
+
);
|
|
34112
|
+
stemTip.position.copy(curve.getPointAt(1)).addScaledVector(stemTangent, stemLength);
|
|
34113
|
+
stemTip.name = "banana-stem-tip";
|
|
34114
|
+
banana.add(stemTip);
|
|
34115
|
+
normalizeObjectToSpec(banana, "banana");
|
|
34116
|
+
group.add(banana);
|
|
34117
|
+
return group;
|
|
34118
|
+
};
|
|
34119
|
+
var createMacbookLidGeometry = (width10, height10, depth, radius, indentRadius) => {
|
|
34120
|
+
const lidShape = createRoundedRectangleShape(width10, height10, radius);
|
|
34121
|
+
const indent = new THREE21.Path();
|
|
34122
|
+
indent.absarc(0, 0, indentRadius, 0, Math.PI * 2, true);
|
|
34123
|
+
lidShape.holes.push(indent);
|
|
34124
|
+
return createPrismGeometryFromShape(lidShape, depth);
|
|
34125
|
+
};
|
|
34126
|
+
var createMacbookIndent = (topZ, radius) => {
|
|
34127
|
+
const indentDepth = 0.35;
|
|
34128
|
+
const diskDepth = 0.25;
|
|
34129
|
+
const disk = new THREE21.Mesh(
|
|
34130
|
+
new THREE21.CylinderGeometry(radius - 0.15, radius - 0.15, diskDepth, 48),
|
|
34131
|
+
new THREE21.MeshStandardMaterial({
|
|
34132
|
+
color: 10199202,
|
|
34133
|
+
roughness: 0.48,
|
|
34134
|
+
metalness: 0.28
|
|
34135
|
+
})
|
|
34136
|
+
);
|
|
34137
|
+
disk.rotation.x = Math.PI / 2;
|
|
34138
|
+
disk.position.z = topZ - indentDepth - diskDepth / 2;
|
|
34139
|
+
disk.name = "macbook-lid-indent";
|
|
34140
|
+
return disk;
|
|
34141
|
+
};
|
|
34142
|
+
var createCreditCard = () => {
|
|
34143
|
+
const spec = REFERENCE_OBJECT_SPECS["credit-card"];
|
|
34144
|
+
const group = new THREE21.Group();
|
|
34145
|
+
const body = new THREE21.Mesh(
|
|
34146
|
+
createRoundedPrismGeometry(spec.width, spec.height, spec.depth, 3.18),
|
|
34147
|
+
new THREE21.MeshStandardMaterial({
|
|
34148
|
+
color: 2383272,
|
|
34149
|
+
roughness: 0.38,
|
|
34150
|
+
metalness: 0.08
|
|
34151
|
+
})
|
|
34152
|
+
);
|
|
34153
|
+
body.name = "credit-card-body";
|
|
34154
|
+
group.add(body);
|
|
34155
|
+
const surfaceZ = spec.depth / 2 + 0.08;
|
|
34156
|
+
const chip = new THREE21.Mesh(
|
|
34157
|
+
createRoundedPrismGeometry(12, 9, 0.14, 1.2),
|
|
34158
|
+
new THREE21.MeshStandardMaterial({
|
|
34159
|
+
color: 14003525,
|
|
34160
|
+
roughness: 0.3,
|
|
34161
|
+
metalness: 0.62
|
|
34162
|
+
})
|
|
34163
|
+
);
|
|
34164
|
+
chip.position.set(-21, 3, surfaceZ);
|
|
34165
|
+
chip.name = "credit-card-chip";
|
|
34166
|
+
group.add(chip);
|
|
34167
|
+
const stripeMaterial = new THREE21.MeshStandardMaterial({
|
|
34168
|
+
color: 15331061,
|
|
34169
|
+
roughness: 0.45,
|
|
34170
|
+
metalness: 0.05
|
|
34171
|
+
});
|
|
34172
|
+
for (let index2 = 0; index2 < 4; index2++) {
|
|
34173
|
+
const stripe = new THREE21.Mesh(
|
|
34174
|
+
new THREE21.BoxGeometry(index2 === 3 ? 8 : 12, 0.8, 0.1),
|
|
34175
|
+
stripeMaterial
|
|
34176
|
+
);
|
|
34177
|
+
stripe.position.set(-20 + index2 * 14, -14, surfaceZ + 0.08);
|
|
34178
|
+
stripe.name = "credit-card-detail";
|
|
34179
|
+
group.add(stripe);
|
|
34180
|
+
}
|
|
34181
|
+
return group;
|
|
34182
|
+
};
|
|
34183
|
+
var createMacbook = () => {
|
|
34184
|
+
const spec = REFERENCE_OBJECT_SPECS["14in-macbook"];
|
|
34185
|
+
const group = new THREE21.Group();
|
|
34186
|
+
const aluminumMaterial = new THREE21.MeshStandardMaterial({
|
|
34187
|
+
color: 12896201,
|
|
34188
|
+
roughness: 0.3,
|
|
34189
|
+
metalness: 0.38
|
|
34190
|
+
});
|
|
34191
|
+
const body = new THREE21.Mesh(
|
|
34192
|
+
createRoundedPrismGeometry(spec.width, spec.height, 13.5, 9),
|
|
34193
|
+
aluminumMaterial
|
|
34194
|
+
);
|
|
34195
|
+
body.position.z = -1;
|
|
34196
|
+
body.name = "macbook-body";
|
|
34197
|
+
group.add(body);
|
|
34198
|
+
const lidDepth = 2;
|
|
34199
|
+
const lidCenterZ = 6.75;
|
|
34200
|
+
const lidTopZ = lidCenterZ + lidDepth / 2;
|
|
34201
|
+
const indentRadius = 12;
|
|
34202
|
+
const lid = new THREE21.Mesh(
|
|
34203
|
+
createMacbookLidGeometry(
|
|
34204
|
+
spec.width - 1.8,
|
|
34205
|
+
spec.height - 1.8,
|
|
34206
|
+
lidDepth,
|
|
34207
|
+
8.2,
|
|
34208
|
+
indentRadius
|
|
34209
|
+
),
|
|
34210
|
+
aluminumMaterial.clone()
|
|
34211
|
+
);
|
|
34212
|
+
lid.position.z = lidCenterZ;
|
|
34213
|
+
lid.name = "macbook-lid";
|
|
34214
|
+
group.add(lid);
|
|
34215
|
+
const hinge = new THREE21.Mesh(
|
|
34216
|
+
new THREE21.BoxGeometry(spec.width - 42, 3.2, 1.2),
|
|
34217
|
+
new THREE21.MeshStandardMaterial({
|
|
34218
|
+
color: 3158838,
|
|
34219
|
+
roughness: 0.55,
|
|
34220
|
+
metalness: 0.45
|
|
34221
|
+
})
|
|
34222
|
+
);
|
|
34223
|
+
hinge.position.set(0, spec.height / 2 - 2.4, 6.15);
|
|
34224
|
+
hinge.name = "macbook-hinge";
|
|
34225
|
+
group.add(hinge);
|
|
34226
|
+
group.add(createMacbookIndent(lidTopZ, indentRadius));
|
|
34227
|
+
const frontNotch = new THREE21.Mesh(
|
|
34228
|
+
new THREE21.BoxGeometry(54, 1.2, 0.8),
|
|
34229
|
+
new THREE21.MeshStandardMaterial({
|
|
34230
|
+
color: 6712174,
|
|
34231
|
+
roughness: 0.45,
|
|
34232
|
+
metalness: 0.5
|
|
34233
|
+
})
|
|
34234
|
+
);
|
|
34235
|
+
frontNotch.position.set(0, -spec.height / 2 + 0.5, 2.5);
|
|
34236
|
+
frontNotch.name = "macbook-front-notch";
|
|
34237
|
+
group.add(frontNotch);
|
|
34238
|
+
return group;
|
|
34239
|
+
};
|
|
34240
|
+
var createReferenceObject = (type) => {
|
|
34241
|
+
const group = type === "banana" ? createBanana() : type === "credit-card" ? createCreditCard() : createMacbook();
|
|
34242
|
+
group.name = `reference-object-${type}`;
|
|
34243
|
+
group.userData.isReferenceObject = true;
|
|
34244
|
+
group.userData.referenceObjectType = type;
|
|
34245
|
+
configureObjectShadows(group);
|
|
34246
|
+
return group;
|
|
34247
|
+
};
|
|
34248
|
+
var disposeReferenceObject = (object) => {
|
|
34249
|
+
const geometries = /* @__PURE__ */ new Set();
|
|
34250
|
+
const materials = /* @__PURE__ */ new Set();
|
|
34251
|
+
object.traverse((child) => {
|
|
34252
|
+
if (!(child instanceof THREE21.Mesh)) return;
|
|
34253
|
+
geometries.add(child.geometry);
|
|
34254
|
+
const childMaterials = Array.isArray(child.material) ? child.material : [child.material];
|
|
34255
|
+
for (const material of childMaterials) materials.add(material);
|
|
34256
|
+
});
|
|
34257
|
+
for (const geometry of geometries) geometry.dispose();
|
|
34258
|
+
for (const material of materials) material.dispose();
|
|
34259
|
+
};
|
|
34260
|
+
|
|
34261
|
+
// src/reference-objects/fit-camera-to-bounds.ts
|
|
34262
|
+
import * as THREE22 from "three";
|
|
34263
|
+
var fitCameraToBounds = (camera, controls, bounds, padding = 1.18) => {
|
|
34264
|
+
const width10 = Math.max(bounds.maxX - bounds.minX, 0);
|
|
34265
|
+
const height10 = Math.max(bounds.maxY - bounds.minY, 0);
|
|
34266
|
+
const depth = Math.max(bounds.maxZ - bounds.minZ, 0);
|
|
34267
|
+
const center = new THREE22.Vector3(
|
|
34268
|
+
(bounds.minX + bounds.maxX) / 2,
|
|
34269
|
+
(bounds.minY + bounds.maxY) / 2,
|
|
34270
|
+
(bounds.minZ + bounds.maxZ) / 2
|
|
34271
|
+
);
|
|
34272
|
+
const radius = Math.max(Math.hypot(width10, height10, depth) / 2, 1);
|
|
34273
|
+
const previousTarget = controls?.target ?? new THREE22.Vector3();
|
|
34274
|
+
const direction = new THREE22.Vector3(0, -0.75, 0.9).normalize();
|
|
34275
|
+
let distance5 = Math.max(camera.position.distanceTo(previousTarget), 5);
|
|
34276
|
+
if (camera instanceof THREE22.PerspectiveCamera) {
|
|
34277
|
+
const verticalFov = THREE22.MathUtils.degToRad(camera.fov);
|
|
34278
|
+
const horizontalFov = 2 * Math.atan(Math.tan(verticalFov / 2) * camera.aspect);
|
|
34279
|
+
const limitingFov = Math.min(verticalFov, horizontalFov);
|
|
34280
|
+
distance5 = radius * padding / Math.sin(limitingFov / 2);
|
|
34281
|
+
camera.far = Math.max(camera.far, distance5 + radius * padding * 3);
|
|
34282
|
+
camera.updateProjectionMatrix();
|
|
34283
|
+
} else if (camera instanceof THREE22.OrthographicCamera) {
|
|
34284
|
+
const halfViewWidth = Math.abs(camera.right - camera.left) / 2;
|
|
34285
|
+
const halfViewHeight = Math.abs(camera.top - camera.bottom) / 2;
|
|
34286
|
+
camera.zoom = Math.min(
|
|
34287
|
+
halfViewWidth / (radius * padding),
|
|
34288
|
+
halfViewHeight / (radius * padding)
|
|
34289
|
+
);
|
|
34290
|
+
distance5 = Math.max(distance5, radius * padding * 2);
|
|
34291
|
+
camera.updateProjectionMatrix();
|
|
34292
|
+
}
|
|
34293
|
+
camera.position.copy(center).addScaledVector(direction, distance5);
|
|
34294
|
+
camera.lookAt(center);
|
|
34295
|
+
camera.updateMatrixWorld();
|
|
34296
|
+
if (controls) {
|
|
34297
|
+
controls.target.copy(center);
|
|
34298
|
+
controls.update();
|
|
34299
|
+
}
|
|
34300
|
+
return { center, radius, distance: distance5 };
|
|
34301
|
+
};
|
|
34302
|
+
|
|
34303
|
+
// src/three-components/reference-object.tsx
|
|
34304
|
+
var ReferenceObject = ({
|
|
34305
|
+
type,
|
|
34306
|
+
boardDimensions,
|
|
34307
|
+
boardCenter
|
|
34308
|
+
}) => {
|
|
34309
|
+
const { scene } = useThree();
|
|
34310
|
+
const object = useMemo15(() => {
|
|
34311
|
+
const nextObject = createReferenceObject(type);
|
|
34312
|
+
const position = getReferenceObjectPosition(
|
|
34313
|
+
type,
|
|
34314
|
+
boardDimensions,
|
|
34315
|
+
boardCenter
|
|
34316
|
+
);
|
|
34317
|
+
nextObject.position.set(position.x, position.y, position.z);
|
|
34318
|
+
return nextObject;
|
|
34319
|
+
}, [type, boardDimensions, boardCenter]);
|
|
34320
|
+
useEffect19(() => {
|
|
34321
|
+
scene.add(object);
|
|
34322
|
+
return () => {
|
|
34323
|
+
scene.remove(object);
|
|
34324
|
+
disposeReferenceObject(object);
|
|
34325
|
+
};
|
|
34326
|
+
}, [scene, object]);
|
|
34327
|
+
return null;
|
|
34328
|
+
};
|
|
34329
|
+
var FitCameraToComparison = ({ bounds }) => {
|
|
34330
|
+
const { camera } = useThree();
|
|
34331
|
+
const { controlsRef } = useCameraController();
|
|
34332
|
+
useEffect19(() => {
|
|
34333
|
+
fitCameraToBounds(camera, controlsRef.current, bounds);
|
|
34334
|
+
}, [bounds, camera, controlsRef]);
|
|
34335
|
+
return null;
|
|
34336
|
+
};
|
|
34337
|
+
|
|
33749
34338
|
// src/CadViewerContainer.tsx
|
|
33750
34339
|
import { jsx as jsx15, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
33751
34340
|
var RotationTracker = () => {
|
|
@@ -33766,6 +34355,7 @@ var CadViewerContainer = forwardRef2(
|
|
|
33766
34355
|
clickToInteractEnabled = false,
|
|
33767
34356
|
boardDimensions,
|
|
33768
34357
|
boardCenter,
|
|
34358
|
+
referenceObject,
|
|
33769
34359
|
onUserInteraction,
|
|
33770
34360
|
onCameraControllerReady
|
|
33771
34361
|
}, ref) => {
|
|
@@ -33773,27 +34363,44 @@ var CadViewerContainer = forwardRef2(
|
|
|
33773
34363
|
!clickToInteractEnabled
|
|
33774
34364
|
);
|
|
33775
34365
|
const { mainCameraRef, handleControlsChange, controller } = useCameraController();
|
|
33776
|
-
const { darkBackgroundEnabled, lightingEnabled } = useAppearance();
|
|
34366
|
+
const { darkBackgroundEnabled, gridEnabled, lightingEnabled } = useAppearance();
|
|
33777
34367
|
const {
|
|
33778
34368
|
handleCameraCreated,
|
|
33779
34369
|
handleControlsChange: handleSessionControlsChange
|
|
33780
34370
|
} = useCameraSession();
|
|
33781
|
-
|
|
34371
|
+
useEffect20(() => {
|
|
33782
34372
|
if (onCameraControllerReady) {
|
|
33783
34373
|
onCameraControllerReady(controller);
|
|
33784
34374
|
}
|
|
33785
34375
|
}, [controller, onCameraControllerReady]);
|
|
33786
|
-
const
|
|
34376
|
+
const comparisonBounds = useMemo16(() => {
|
|
34377
|
+
if (!referenceObject) return void 0;
|
|
34378
|
+
return getComparisonBounds(referenceObject, boardDimensions, boardCenter);
|
|
34379
|
+
}, [referenceObject, boardDimensions, boardCenter]);
|
|
34380
|
+
const gridSectionSize = useMemo16(() => {
|
|
34381
|
+
if (!boardDimensions) return 10;
|
|
34382
|
+
const width10 = boardDimensions.width ?? 0;
|
|
34383
|
+
const height10 = boardDimensions.height ?? 0;
|
|
34384
|
+
return Math.max(Math.max(width10, height10) * 1.5, 10);
|
|
34385
|
+
}, [boardDimensions]);
|
|
34386
|
+
const orbitTarget = useMemo16(() => {
|
|
34387
|
+
if (comparisonBounds) {
|
|
34388
|
+
return [
|
|
34389
|
+
(comparisonBounds.minX + comparisonBounds.maxX) / 2,
|
|
34390
|
+
(comparisonBounds.minY + comparisonBounds.maxY) / 2,
|
|
34391
|
+
(comparisonBounds.minZ + comparisonBounds.maxZ) / 2
|
|
34392
|
+
];
|
|
34393
|
+
}
|
|
33787
34394
|
if (!boardCenter) return void 0;
|
|
33788
34395
|
return [boardCenter.x, boardCenter.y, 0];
|
|
33789
|
-
}, [boardCenter]);
|
|
34396
|
+
}, [boardCenter, comparisonBounds]);
|
|
33790
34397
|
return /* @__PURE__ */ jsxs3("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
|
|
33791
34398
|
/* @__PURE__ */ jsx15(OrientationCubeCanvas, {}),
|
|
33792
34399
|
/* @__PURE__ */ jsxs3(
|
|
33793
34400
|
Canvas,
|
|
33794
34401
|
{
|
|
33795
34402
|
ref,
|
|
33796
|
-
scene: { up: new
|
|
34403
|
+
scene: { up: new THREE23.Vector3(0, 0, 1) },
|
|
33797
34404
|
camera: { up: [0, 0, 1], position: initialCameraPosition },
|
|
33798
34405
|
onCreated: ({ camera }) => {
|
|
33799
34406
|
mainCameraRef.current = camera;
|
|
@@ -33829,6 +34436,24 @@ var CadViewerContainer = forwardRef2(
|
|
|
33829
34436
|
shadowsEnabled: lightingEnabled
|
|
33830
34437
|
}
|
|
33831
34438
|
),
|
|
34439
|
+
referenceObject && /* @__PURE__ */ jsx15(
|
|
34440
|
+
ReferenceObject,
|
|
34441
|
+
{
|
|
34442
|
+
type: referenceObject,
|
|
34443
|
+
boardDimensions,
|
|
34444
|
+
boardCenter
|
|
34445
|
+
}
|
|
34446
|
+
),
|
|
34447
|
+
comparisonBounds && /* @__PURE__ */ jsx15(FitCameraToComparison, { bounds: comparisonBounds }),
|
|
34448
|
+
gridEnabled && /* @__PURE__ */ jsx15(
|
|
34449
|
+
Grid,
|
|
34450
|
+
{
|
|
34451
|
+
rotation: [Math.PI / 2, 0, 0],
|
|
34452
|
+
infiniteGrid: true,
|
|
34453
|
+
cellSize: 3,
|
|
34454
|
+
sectionSize: gridSectionSize
|
|
34455
|
+
}
|
|
34456
|
+
),
|
|
33832
34457
|
children
|
|
33833
34458
|
]
|
|
33834
34459
|
}
|
|
@@ -33893,9 +34518,9 @@ var CadViewerContainer = forwardRef2(
|
|
|
33893
34518
|
|
|
33894
34519
|
// src/hooks/use-convert-children-to-soup.ts
|
|
33895
34520
|
import { Circuit } from "@tscircuit/core";
|
|
33896
|
-
import { useMemo as
|
|
34521
|
+
import { useMemo as useMemo17 } from "react";
|
|
33897
34522
|
var useConvertChildrenToCircuitJson = (children) => {
|
|
33898
|
-
return
|
|
34523
|
+
return useMemo17(() => {
|
|
33899
34524
|
if (!children) return [];
|
|
33900
34525
|
const circuit = new Circuit();
|
|
33901
34526
|
circuit.add(children);
|
|
@@ -33905,12 +34530,12 @@ var useConvertChildrenToCircuitJson = (children) => {
|
|
|
33905
34530
|
};
|
|
33906
34531
|
|
|
33907
34532
|
// src/hooks/use-stls-from-geom.ts
|
|
33908
|
-
import { useState as useState12, useEffect as
|
|
34533
|
+
import { useState as useState12, useEffect as useEffect21 } from "react";
|
|
33909
34534
|
import stlSerializer from "@jscad/stl-serializer";
|
|
33910
34535
|
var useStlsFromGeom = (geom) => {
|
|
33911
34536
|
const [stls, setStls] = useState12([]);
|
|
33912
34537
|
const [loading, setLoading] = useState12(true);
|
|
33913
|
-
|
|
34538
|
+
useEffect21(() => {
|
|
33914
34539
|
if (!geom) return;
|
|
33915
34540
|
const generateStls = async () => {
|
|
33916
34541
|
setLoading(true);
|
|
@@ -33939,7 +34564,7 @@ var useStlsFromGeom = (geom) => {
|
|
|
33939
34564
|
};
|
|
33940
34565
|
|
|
33941
34566
|
// src/hooks/useBoardGeomBuilder.ts
|
|
33942
|
-
import { useState as useState13, useEffect as
|
|
34567
|
+
import { useState as useState13, useEffect as useEffect22, useRef as useRef8 } from "react";
|
|
33943
34568
|
|
|
33944
34569
|
// src/soup-to-3d/index.ts
|
|
33945
34570
|
var import_primitives2 = __toESM(require_primitives(), 1);
|
|
@@ -35253,7 +35878,7 @@ var BoardGeomBuilder = class {
|
|
|
35253
35878
|
var useBoardGeomBuilder = (circuitJson) => {
|
|
35254
35879
|
const [boardGeom, setBoardGeom] = useState13(null);
|
|
35255
35880
|
const isProcessingRef = useRef8(false);
|
|
35256
|
-
|
|
35881
|
+
useEffect22(() => {
|
|
35257
35882
|
let isCancelled = false;
|
|
35258
35883
|
if (!circuitJson) {
|
|
35259
35884
|
setBoardGeom(null);
|
|
@@ -35299,10 +35924,10 @@ var useBoardGeomBuilder = (circuitJson) => {
|
|
|
35299
35924
|
};
|
|
35300
35925
|
|
|
35301
35926
|
// src/three-components/Error3d.tsx
|
|
35302
|
-
import { useState as useState14, useCallback as useCallback8, useEffect as
|
|
35927
|
+
import { useState as useState14, useCallback as useCallback8, useEffect as useEffect24, useMemo as useMemo19 } from "react";
|
|
35303
35928
|
|
|
35304
35929
|
// src/react-three/Text.tsx
|
|
35305
|
-
import { useEffect as
|
|
35930
|
+
import { useEffect as useEffect23, useMemo as useMemo18 } from "react";
|
|
35306
35931
|
import { Text as TroikaText2 } from "troika-three-text";
|
|
35307
35932
|
var Text = ({
|
|
35308
35933
|
children,
|
|
@@ -35317,7 +35942,7 @@ var Text = ({
|
|
|
35317
35942
|
depthOffset
|
|
35318
35943
|
}) => {
|
|
35319
35944
|
const { rootObject } = useThree();
|
|
35320
|
-
const mesh =
|
|
35945
|
+
const mesh = useMemo18(() => {
|
|
35321
35946
|
const textMesh = new TroikaText2();
|
|
35322
35947
|
textMesh.text = children;
|
|
35323
35948
|
if (position) textMesh.position.fromArray(position);
|
|
@@ -35342,7 +35967,7 @@ var Text = ({
|
|
|
35342
35967
|
anchorY,
|
|
35343
35968
|
depthOffset
|
|
35344
35969
|
]);
|
|
35345
|
-
|
|
35970
|
+
useEffect23(() => {
|
|
35346
35971
|
const parentObject = parent || rootObject;
|
|
35347
35972
|
if (!parentObject || !mesh) return;
|
|
35348
35973
|
parentObject.add(mesh);
|
|
@@ -35355,7 +35980,7 @@ var Text = ({
|
|
|
35355
35980
|
};
|
|
35356
35981
|
|
|
35357
35982
|
// src/three-components/Error3d.tsx
|
|
35358
|
-
import * as
|
|
35983
|
+
import * as THREE24 from "three";
|
|
35359
35984
|
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
35360
35985
|
var Error3d = ({
|
|
35361
35986
|
error,
|
|
@@ -35377,7 +36002,7 @@ var Error3d = ({
|
|
|
35377
36002
|
setIsHovered(false);
|
|
35378
36003
|
setHoverPosition(null);
|
|
35379
36004
|
}, []);
|
|
35380
|
-
const position =
|
|
36005
|
+
const position = useMemo19(() => {
|
|
35381
36006
|
if (cad_component?.position) {
|
|
35382
36007
|
const p = [
|
|
35383
36008
|
cad_component.position.x,
|
|
@@ -35388,12 +36013,12 @@ var Error3d = ({
|
|
|
35388
36013
|
}
|
|
35389
36014
|
return [0, 0, 0];
|
|
35390
36015
|
}, [cad_component]);
|
|
35391
|
-
const group =
|
|
35392
|
-
const g = new
|
|
36016
|
+
const group = useMemo19(() => {
|
|
36017
|
+
const g = new THREE24.Group();
|
|
35393
36018
|
g.position.fromArray(position);
|
|
35394
36019
|
return g;
|
|
35395
36020
|
}, [position]);
|
|
35396
|
-
|
|
36021
|
+
useEffect24(() => {
|
|
35397
36022
|
if (!rootObject) return;
|
|
35398
36023
|
rootObject.add(group);
|
|
35399
36024
|
return () => {
|
|
@@ -35448,10 +36073,10 @@ var Error3d = ({
|
|
|
35448
36073
|
] });
|
|
35449
36074
|
};
|
|
35450
36075
|
var ErrorBox = ({ parent }) => {
|
|
35451
|
-
const mesh =
|
|
35452
|
-
const m = new
|
|
35453
|
-
new
|
|
35454
|
-
new
|
|
36076
|
+
const mesh = useMemo19(() => {
|
|
36077
|
+
const m = new THREE24.Mesh(
|
|
36078
|
+
new THREE24.BoxGeometry(0.5, 0.5, 0.5),
|
|
36079
|
+
new THREE24.MeshStandardMaterial({
|
|
35455
36080
|
depthTest: false,
|
|
35456
36081
|
transparent: true,
|
|
35457
36082
|
color: "red",
|
|
@@ -35462,7 +36087,7 @@ var ErrorBox = ({ parent }) => {
|
|
|
35462
36087
|
m.rotation.fromArray([Math.PI / 4, Math.PI / 4, 0]);
|
|
35463
36088
|
return m;
|
|
35464
36089
|
}, []);
|
|
35465
|
-
|
|
36090
|
+
useEffect24(() => {
|
|
35466
36091
|
parent.add(mesh);
|
|
35467
36092
|
return () => {
|
|
35468
36093
|
parent.remove(mesh);
|
|
@@ -35471,114 +36096,12 @@ var ErrorBox = ({ parent }) => {
|
|
|
35471
36096
|
return null;
|
|
35472
36097
|
};
|
|
35473
36098
|
|
|
35474
|
-
// src/three-components/STLModel.tsx
|
|
35475
|
-
import { useState as useState15, useEffect as useEffect23, useMemo as useMemo18 } from "react";
|
|
35476
|
-
import * as THREE22 from "three";
|
|
35477
|
-
import { STLLoader } from "three-stdlib";
|
|
35478
|
-
function STLModel({
|
|
35479
|
-
stlUrl,
|
|
35480
|
-
stlData,
|
|
35481
|
-
mtlUrl,
|
|
35482
|
-
color,
|
|
35483
|
-
opacity = 1,
|
|
35484
|
-
layerType
|
|
35485
|
-
}) {
|
|
35486
|
-
const { rootObject } = useThree();
|
|
35487
|
-
const [geom, setGeom] = useState15(null);
|
|
35488
|
-
useEffect23(() => {
|
|
35489
|
-
const loader = new STLLoader();
|
|
35490
|
-
if (stlData) {
|
|
35491
|
-
try {
|
|
35492
|
-
const geometry = loader.parse(stlData);
|
|
35493
|
-
setGeom(geometry);
|
|
35494
|
-
} catch (e) {
|
|
35495
|
-
console.error("Failed to parse STL data", e);
|
|
35496
|
-
setGeom(null);
|
|
35497
|
-
}
|
|
35498
|
-
return;
|
|
35499
|
-
}
|
|
35500
|
-
if (stlUrl) {
|
|
35501
|
-
loader.load(stlUrl, (geometry) => {
|
|
35502
|
-
setGeom(geometry);
|
|
35503
|
-
});
|
|
35504
|
-
}
|
|
35505
|
-
}, [stlUrl, stlData]);
|
|
35506
|
-
const mesh = useMemo18(() => {
|
|
35507
|
-
if (!geom) return null;
|
|
35508
|
-
const isBoardLayer = layerType === "board";
|
|
35509
|
-
const material = new THREE22.MeshStandardMaterial({
|
|
35510
|
-
color: Array.isArray(color) ? new THREE22.Color(color[0], color[1], color[2]) : color,
|
|
35511
|
-
transparent: opacity !== 1,
|
|
35512
|
-
opacity,
|
|
35513
|
-
polygonOffset: isBoardLayer,
|
|
35514
|
-
polygonOffsetFactor: isBoardLayer ? 6 : 0,
|
|
35515
|
-
polygonOffsetUnits: isBoardLayer ? 6 : 0
|
|
35516
|
-
});
|
|
35517
|
-
const createdMesh = new THREE22.Mesh(geom, material);
|
|
35518
|
-
createdMesh.renderOrder = isBoardLayer ? -1 : 1;
|
|
35519
|
-
configureObjectShadows(createdMesh, {
|
|
35520
|
-
castShadow: !isBoardLayer && opacity === 1,
|
|
35521
|
-
receiveShadow: true
|
|
35522
|
-
});
|
|
35523
|
-
return createdMesh;
|
|
35524
|
-
}, [geom, color, opacity, layerType]);
|
|
35525
|
-
useEffect23(() => {
|
|
35526
|
-
if (!rootObject || !mesh) return;
|
|
35527
|
-
rootObject.add(mesh);
|
|
35528
|
-
return () => {
|
|
35529
|
-
rootObject.remove(mesh);
|
|
35530
|
-
mesh.geometry.dispose();
|
|
35531
|
-
if (Array.isArray(mesh.material)) {
|
|
35532
|
-
mesh.material.forEach((m) => m.dispose());
|
|
35533
|
-
} else {
|
|
35534
|
-
mesh.material.dispose();
|
|
35535
|
-
}
|
|
35536
|
-
};
|
|
35537
|
-
}, [rootObject, mesh]);
|
|
35538
|
-
return null;
|
|
35539
|
-
}
|
|
35540
|
-
|
|
35541
|
-
// src/three-components/VisibleSTLModel.tsx
|
|
35542
|
-
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
35543
|
-
function VisibleSTLModel({
|
|
35544
|
-
stlData,
|
|
35545
|
-
color,
|
|
35546
|
-
opacity = 1,
|
|
35547
|
-
layerType
|
|
35548
|
-
}) {
|
|
35549
|
-
const { visibility } = useLayerVisibility();
|
|
35550
|
-
let shouldShow = true;
|
|
35551
|
-
if (layerType === "board") {
|
|
35552
|
-
shouldShow = visibility.boardBody;
|
|
35553
|
-
} else if (layerType === "top-copper") {
|
|
35554
|
-
shouldShow = visibility.topCopper;
|
|
35555
|
-
} else if (layerType === "bottom-copper") {
|
|
35556
|
-
shouldShow = visibility.bottomCopper;
|
|
35557
|
-
} else if (layerType === "top-silkscreen") {
|
|
35558
|
-
shouldShow = visibility.topSilkscreen;
|
|
35559
|
-
} else if (layerType === "bottom-silkscreen") {
|
|
35560
|
-
shouldShow = visibility.bottomSilkscreen;
|
|
35561
|
-
}
|
|
35562
|
-
if (!shouldShow) {
|
|
35563
|
-
return null;
|
|
35564
|
-
}
|
|
35565
|
-
return /* @__PURE__ */ jsx17(
|
|
35566
|
-
STLModel,
|
|
35567
|
-
{
|
|
35568
|
-
stlData,
|
|
35569
|
-
color,
|
|
35570
|
-
opacity,
|
|
35571
|
-
layerType
|
|
35572
|
-
}
|
|
35573
|
-
);
|
|
35574
|
-
}
|
|
35575
|
-
|
|
35576
36099
|
// src/three-components/JscadBoardTextures.tsx
|
|
35577
36100
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
35578
|
-
import { useEffect as
|
|
36101
|
+
import { useEffect as useEffect25, useMemo as useMemo20 } from "react";
|
|
35579
36102
|
|
|
35580
36103
|
// src/textures/create-combined-board-textures.ts
|
|
35581
|
-
import * as
|
|
36104
|
+
import * as THREE36 from "three";
|
|
35582
36105
|
|
|
35583
36106
|
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
35584
36107
|
var getBoundsFromPoints = (points) => {
|
|
@@ -35633,7 +36156,7 @@ function calculateOutlineBounds(boardData) {
|
|
|
35633
36156
|
// src/utils/pad-texture.ts
|
|
35634
36157
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
35635
36158
|
import { CircuitToCanvasDrawer } from "circuit-to-canvas";
|
|
35636
|
-
import * as
|
|
36159
|
+
import * as THREE25 from "three";
|
|
35637
36160
|
function createPadTextureForLayer({
|
|
35638
36161
|
layer,
|
|
35639
36162
|
circuitJson,
|
|
@@ -35711,10 +36234,10 @@ function createPadTextureForLayer({
|
|
|
35711
36234
|
drawSoldermaskTop: false,
|
|
35712
36235
|
drawSoldermaskBottom: false
|
|
35713
36236
|
});
|
|
35714
|
-
const texture = new
|
|
36237
|
+
const texture = new THREE25.CanvasTexture(canvas);
|
|
35715
36238
|
texture.generateMipmaps = true;
|
|
35716
|
-
texture.minFilter =
|
|
35717
|
-
texture.magFilter =
|
|
36239
|
+
texture.minFilter = THREE25.LinearMipmapLinearFilter;
|
|
36240
|
+
texture.magFilter = THREE25.LinearFilter;
|
|
35718
36241
|
texture.anisotropy = 16;
|
|
35719
36242
|
texture.needsUpdate = true;
|
|
35720
36243
|
return texture;
|
|
@@ -35722,7 +36245,7 @@ function createPadTextureForLayer({
|
|
|
35722
36245
|
|
|
35723
36246
|
// src/utils/panel-outline-texture.ts
|
|
35724
36247
|
import { su as su6 } from "@tscircuit/circuit-json-util";
|
|
35725
|
-
import * as
|
|
36248
|
+
import * as THREE26 from "three";
|
|
35726
36249
|
var resolvePanelIdForTexture = (circuitJson) => {
|
|
35727
36250
|
const panels = circuitJson.filter(
|
|
35728
36251
|
(e) => e.type === "pcb_panel"
|
|
@@ -35790,17 +36313,17 @@ function createPanelOutlineTextureForLayer({
|
|
|
35790
36313
|
);
|
|
35791
36314
|
}
|
|
35792
36315
|
});
|
|
35793
|
-
const texture = new
|
|
36316
|
+
const texture = new THREE26.CanvasTexture(canvas);
|
|
35794
36317
|
texture.generateMipmaps = true;
|
|
35795
|
-
texture.minFilter =
|
|
35796
|
-
texture.magFilter =
|
|
36318
|
+
texture.minFilter = THREE26.LinearMipmapLinearFilter;
|
|
36319
|
+
texture.magFilter = THREE26.LinearFilter;
|
|
35797
36320
|
texture.anisotropy = 16;
|
|
35798
36321
|
texture.needsUpdate = true;
|
|
35799
36322
|
return texture;
|
|
35800
36323
|
}
|
|
35801
36324
|
|
|
35802
36325
|
// src/utils/trace-texture.ts
|
|
35803
|
-
import * as
|
|
36326
|
+
import * as THREE27 from "three";
|
|
35804
36327
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
|
|
35805
36328
|
import { getElementRenderLayers, su as su7 } from "@tscircuit/circuit-json-util";
|
|
35806
36329
|
|
|
@@ -35918,10 +36441,10 @@ function createTraceTextureForLayer({
|
|
|
35918
36441
|
drawSoldermaskTop: false,
|
|
35919
36442
|
drawSoldermaskBottom: false
|
|
35920
36443
|
});
|
|
35921
|
-
const texture = new
|
|
36444
|
+
const texture = new THREE27.CanvasTexture(canvas);
|
|
35922
36445
|
texture.generateMipmaps = true;
|
|
35923
|
-
texture.minFilter =
|
|
35924
|
-
texture.magFilter =
|
|
36446
|
+
texture.minFilter = THREE27.LinearMipmapLinearFilter;
|
|
36447
|
+
texture.magFilter = THREE27.LinearFilter;
|
|
35925
36448
|
texture.anisotropy = 16;
|
|
35926
36449
|
texture.needsUpdate = true;
|
|
35927
36450
|
return texture;
|
|
@@ -35929,7 +36452,7 @@ function createTraceTextureForLayer({
|
|
|
35929
36452
|
|
|
35930
36453
|
// src/textures/create-copper-pour-texture-for-layer.ts
|
|
35931
36454
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
|
|
35932
|
-
import * as
|
|
36455
|
+
import * as THREE28 from "three";
|
|
35933
36456
|
var toRgb = (colorArr) => {
|
|
35934
36457
|
const [r = 0, g = 0, b = 0] = colorArr;
|
|
35935
36458
|
return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
|
|
@@ -36051,17 +36574,17 @@ function createCopperPourTextureForLayer({
|
|
|
36051
36574
|
if (!onlyCoveredBySoldermask) {
|
|
36052
36575
|
setColorAndDraw(uncoveredPours, uncoveredColor);
|
|
36053
36576
|
}
|
|
36054
|
-
const texture = new
|
|
36577
|
+
const texture = new THREE28.CanvasTexture(canvas);
|
|
36055
36578
|
texture.generateMipmaps = true;
|
|
36056
|
-
texture.minFilter =
|
|
36057
|
-
texture.magFilter =
|
|
36579
|
+
texture.minFilter = THREE28.LinearMipmapLinearFilter;
|
|
36580
|
+
texture.magFilter = THREE28.LinearFilter;
|
|
36058
36581
|
texture.anisotropy = 16;
|
|
36059
36582
|
texture.needsUpdate = true;
|
|
36060
36583
|
return texture;
|
|
36061
36584
|
}
|
|
36062
36585
|
|
|
36063
36586
|
// src/textures/create-copper-text-texture-for-layer.ts
|
|
36064
|
-
import * as
|
|
36587
|
+
import * as THREE29 from "three";
|
|
36065
36588
|
|
|
36066
36589
|
// src/textures/copper-text/copper-text-drawing.ts
|
|
36067
36590
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
|
|
@@ -36172,17 +36695,17 @@ function createCopperTextTextureForLayer({
|
|
|
36172
36695
|
elements,
|
|
36173
36696
|
copperColor
|
|
36174
36697
|
});
|
|
36175
|
-
const texture = new
|
|
36698
|
+
const texture = new THREE29.CanvasTexture(canvas);
|
|
36176
36699
|
texture.generateMipmaps = true;
|
|
36177
|
-
texture.minFilter =
|
|
36178
|
-
texture.magFilter =
|
|
36700
|
+
texture.minFilter = THREE29.LinearMipmapLinearFilter;
|
|
36701
|
+
texture.magFilter = THREE29.LinearFilter;
|
|
36179
36702
|
texture.anisotropy = 16;
|
|
36180
36703
|
texture.needsUpdate = true;
|
|
36181
36704
|
return texture;
|
|
36182
36705
|
}
|
|
36183
36706
|
|
|
36184
36707
|
// src/textures/create-fabrication-note-texture-for-layer.ts
|
|
36185
|
-
import * as
|
|
36708
|
+
import * as THREE30 from "three";
|
|
36186
36709
|
|
|
36187
36710
|
// src/textures/fabrication-note/fabrication-note-drawing.ts
|
|
36188
36711
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
|
|
@@ -36410,17 +36933,17 @@ function createFabricationNoteTextureForLayer({
|
|
|
36410
36933
|
bounds,
|
|
36411
36934
|
elements
|
|
36412
36935
|
});
|
|
36413
|
-
const texture = new
|
|
36936
|
+
const texture = new THREE30.CanvasTexture(canvas);
|
|
36414
36937
|
texture.generateMipmaps = true;
|
|
36415
|
-
texture.minFilter =
|
|
36416
|
-
texture.magFilter =
|
|
36938
|
+
texture.minFilter = THREE30.LinearMipmapLinearFilter;
|
|
36939
|
+
texture.magFilter = THREE30.LinearFilter;
|
|
36417
36940
|
texture.anisotropy = 16;
|
|
36418
36941
|
texture.needsUpdate = true;
|
|
36419
36942
|
return texture;
|
|
36420
36943
|
}
|
|
36421
36944
|
|
|
36422
36945
|
// src/textures/create-keepout-texture-for-layer.ts
|
|
36423
|
-
import * as
|
|
36946
|
+
import * as THREE31 from "three";
|
|
36424
36947
|
|
|
36425
36948
|
// src/textures/keepout/keepout-drawing.ts
|
|
36426
36949
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
|
|
@@ -36495,17 +37018,17 @@ function createKeepoutTextureForLayer({
|
|
|
36495
37018
|
elements,
|
|
36496
37019
|
keepoutColor
|
|
36497
37020
|
});
|
|
36498
|
-
const texture = new
|
|
37021
|
+
const texture = new THREE31.CanvasTexture(canvas);
|
|
36499
37022
|
texture.generateMipmaps = true;
|
|
36500
|
-
texture.minFilter =
|
|
36501
|
-
texture.magFilter =
|
|
37023
|
+
texture.minFilter = THREE31.LinearMipmapLinearFilter;
|
|
37024
|
+
texture.magFilter = THREE31.LinearFilter;
|
|
36502
37025
|
texture.anisotropy = 16;
|
|
36503
37026
|
texture.needsUpdate = true;
|
|
36504
37027
|
return texture;
|
|
36505
37028
|
}
|
|
36506
37029
|
|
|
36507
37030
|
// src/textures/create-pcb-note-texture-for-layer.ts
|
|
36508
|
-
import * as
|
|
37031
|
+
import * as THREE32 from "three";
|
|
36509
37032
|
|
|
36510
37033
|
// src/textures/pcb-note/pcb-note-drawing.ts
|
|
36511
37034
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
|
|
@@ -36656,17 +37179,17 @@ function createPcbNoteTextureForLayer({
|
|
|
36656
37179
|
bounds,
|
|
36657
37180
|
elements
|
|
36658
37181
|
});
|
|
36659
|
-
const texture = new
|
|
37182
|
+
const texture = new THREE32.CanvasTexture(canvas);
|
|
36660
37183
|
texture.generateMipmaps = true;
|
|
36661
|
-
texture.minFilter =
|
|
36662
|
-
texture.magFilter =
|
|
37184
|
+
texture.minFilter = THREE32.LinearMipmapLinearFilter;
|
|
37185
|
+
texture.magFilter = THREE32.LinearFilter;
|
|
36663
37186
|
texture.anisotropy = 16;
|
|
36664
37187
|
texture.needsUpdate = true;
|
|
36665
37188
|
return texture;
|
|
36666
37189
|
}
|
|
36667
37190
|
|
|
36668
37191
|
// src/textures/create-silkscreen-texture-for-layer.ts
|
|
36669
|
-
import * as
|
|
37192
|
+
import * as THREE33 from "three";
|
|
36670
37193
|
|
|
36671
37194
|
// src/textures/silkscreen/silkscreen-drawing.ts
|
|
36672
37195
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
|
|
@@ -36775,17 +37298,17 @@ function createSilkscreenTextureForLayer({
|
|
|
36775
37298
|
elements,
|
|
36776
37299
|
silkscreenColor
|
|
36777
37300
|
});
|
|
36778
|
-
const texture = new
|
|
37301
|
+
const texture = new THREE33.CanvasTexture(canvas);
|
|
36779
37302
|
texture.generateMipmaps = true;
|
|
36780
|
-
texture.minFilter =
|
|
36781
|
-
texture.magFilter =
|
|
37303
|
+
texture.minFilter = THREE33.LinearMipmapLinearFilter;
|
|
37304
|
+
texture.magFilter = THREE33.LinearFilter;
|
|
36782
37305
|
texture.anisotropy = 16;
|
|
36783
37306
|
texture.needsUpdate = true;
|
|
36784
37307
|
return texture;
|
|
36785
37308
|
}
|
|
36786
37309
|
|
|
36787
37310
|
// src/textures/create-soldermask-texture-for-layer.ts
|
|
36788
|
-
import * as
|
|
37311
|
+
import * as THREE34 from "three";
|
|
36789
37312
|
|
|
36790
37313
|
// src/textures/soldermask/soldermask-drawing.ts
|
|
36791
37314
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer9 } from "circuit-to-canvas";
|
|
@@ -36920,17 +37443,17 @@ function createSoldermaskTextureForLayer({
|
|
|
36920
37443
|
elements,
|
|
36921
37444
|
boardMaterial: boardData.material
|
|
36922
37445
|
});
|
|
36923
|
-
const texture = new
|
|
37446
|
+
const texture = new THREE34.CanvasTexture(canvas);
|
|
36924
37447
|
texture.generateMipmaps = true;
|
|
36925
|
-
texture.minFilter =
|
|
36926
|
-
texture.magFilter =
|
|
37448
|
+
texture.minFilter = THREE34.LinearMipmapLinearFilter;
|
|
37449
|
+
texture.magFilter = THREE34.LinearFilter;
|
|
36927
37450
|
texture.anisotropy = 16;
|
|
36928
37451
|
texture.needsUpdate = true;
|
|
36929
37452
|
return texture;
|
|
36930
37453
|
}
|
|
36931
37454
|
|
|
36932
37455
|
// src/textures/create-through-hole-texture-for-layer.ts
|
|
36933
|
-
import * as
|
|
37456
|
+
import * as THREE35 from "three";
|
|
36934
37457
|
|
|
36935
37458
|
// src/textures/through-hole/through-hole-drawing.ts
|
|
36936
37459
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer10 } from "circuit-to-canvas";
|
|
@@ -37023,10 +37546,10 @@ function createThroughHoleTextureForLayer({
|
|
|
37023
37546
|
elements,
|
|
37024
37547
|
copperColor
|
|
37025
37548
|
});
|
|
37026
|
-
const texture = new
|
|
37549
|
+
const texture = new THREE35.CanvasTexture(canvas);
|
|
37027
37550
|
texture.generateMipmaps = true;
|
|
37028
|
-
texture.minFilter =
|
|
37029
|
-
texture.magFilter =
|
|
37551
|
+
texture.minFilter = THREE35.LinearMipmapLinearFilter;
|
|
37552
|
+
texture.magFilter = THREE35.LinearFilter;
|
|
37030
37553
|
texture.anisotropy = 16;
|
|
37031
37554
|
texture.needsUpdate = true;
|
|
37032
37555
|
return texture;
|
|
@@ -37114,10 +37637,10 @@ var createCombinedTexture = ({
|
|
|
37114
37637
|
applySoldermaskSurfaceFilter(ctx, canvasWidth, canvasHeight, {
|
|
37115
37638
|
includeReflection: layer === "top"
|
|
37116
37639
|
});
|
|
37117
|
-
const combinedTexture = new
|
|
37640
|
+
const combinedTexture = new THREE36.CanvasTexture(canvas);
|
|
37118
37641
|
combinedTexture.generateMipmaps = false;
|
|
37119
|
-
combinedTexture.minFilter =
|
|
37120
|
-
combinedTexture.magFilter =
|
|
37642
|
+
combinedTexture.minFilter = THREE36.LinearFilter;
|
|
37643
|
+
combinedTexture.magFilter = THREE36.LinearFilter;
|
|
37121
37644
|
combinedTexture.premultiplyAlpha = true;
|
|
37122
37645
|
combinedTexture.anisotropy = 16;
|
|
37123
37646
|
combinedTexture.needsUpdate = true;
|
|
@@ -37142,11 +37665,11 @@ var createMaskedCopperMask = ({
|
|
|
37142
37665
|
if (!texture?.image) continue;
|
|
37143
37666
|
ctx.drawImage(texture.image, 0, 0, width10, height10);
|
|
37144
37667
|
}
|
|
37145
|
-
const maskTexture = new
|
|
37146
|
-
maskTexture.colorSpace =
|
|
37668
|
+
const maskTexture = new THREE36.CanvasTexture(canvas);
|
|
37669
|
+
maskTexture.colorSpace = THREE36.NoColorSpace;
|
|
37147
37670
|
maskTexture.generateMipmaps = false;
|
|
37148
|
-
maskTexture.minFilter =
|
|
37149
|
-
maskTexture.magFilter =
|
|
37671
|
+
maskTexture.minFilter = THREE36.LinearFilter;
|
|
37672
|
+
maskTexture.magFilter = THREE36.LinearFilter;
|
|
37150
37673
|
maskTexture.premultiplyAlpha = false;
|
|
37151
37674
|
maskTexture.needsUpdate = true;
|
|
37152
37675
|
return maskTexture;
|
|
@@ -37284,7 +37807,7 @@ function createCombinedBoardTextures({
|
|
|
37284
37807
|
}
|
|
37285
37808
|
|
|
37286
37809
|
// src/textures/create-three-texture-meshes.ts
|
|
37287
|
-
import * as
|
|
37810
|
+
import * as THREE38 from "three";
|
|
37288
37811
|
|
|
37289
37812
|
// src/board-surface-textures.ts
|
|
37290
37813
|
var REALISTIC_BOARD_SURFACE_MATERIAL = {
|
|
@@ -37307,7 +37830,7 @@ var PAD_COPPER_TEXTURE_MATERIAL = {
|
|
|
37307
37830
|
};
|
|
37308
37831
|
|
|
37309
37832
|
// src/utils/create-board-relief-textures.ts
|
|
37310
|
-
import * as
|
|
37833
|
+
import * as THREE37 from "three";
|
|
37311
37834
|
var PLAIN_SOLDERMASK_HEIGHT = 0.22;
|
|
37312
37835
|
var MASKED_COPPER_HEIGHT = 0.7;
|
|
37313
37836
|
var EXPOSED_COPPER_HEIGHT = 0.86;
|
|
@@ -37396,13 +37919,13 @@ var getBoardSurfaceProfile = (r, g, b, hasMaskedCopper) => {
|
|
|
37396
37919
|
};
|
|
37397
37920
|
};
|
|
37398
37921
|
var createDataTexture = (canvas) => {
|
|
37399
|
-
const texture = new
|
|
37400
|
-
texture.colorSpace =
|
|
37922
|
+
const texture = new THREE37.CanvasTexture(canvas);
|
|
37923
|
+
texture.colorSpace = THREE37.NoColorSpace;
|
|
37401
37924
|
texture.generateMipmaps = false;
|
|
37402
|
-
texture.minFilter =
|
|
37403
|
-
texture.magFilter =
|
|
37404
|
-
texture.wrapS =
|
|
37405
|
-
texture.wrapT =
|
|
37925
|
+
texture.minFilter = THREE37.LinearFilter;
|
|
37926
|
+
texture.magFilter = THREE37.LinearFilter;
|
|
37927
|
+
texture.wrapS = THREE37.ClampToEdgeWrapping;
|
|
37928
|
+
texture.wrapT = THREE37.ClampToEdgeWrapping;
|
|
37406
37929
|
texture.needsUpdate = true;
|
|
37407
37930
|
return texture;
|
|
37408
37931
|
};
|
|
@@ -37509,7 +38032,7 @@ var createBoardReliefTextures = (texture, maskedCopperMask) => {
|
|
|
37509
38032
|
for (let x = 0; x < sourceCanvas.width; x++) {
|
|
37510
38033
|
const dx = (getHeight4(x + 1, y) - getHeight4(x - 1, y)) * 4;
|
|
37511
38034
|
const dy = (getHeight4(x, y + 1) - getHeight4(x, y - 1)) * 4;
|
|
37512
|
-
const normal = new
|
|
38035
|
+
const normal = new THREE37.Vector3(-dx, -dy, 1).normalize();
|
|
37513
38036
|
const i = (y * sourceCanvas.width + x) * 4;
|
|
37514
38037
|
normalData[i] = (normal.x * 0.5 + 0.5) * 255;
|
|
37515
38038
|
normalData[i + 1] = (normal.y * 0.5 + 0.5) * 255;
|
|
@@ -37539,16 +38062,16 @@ function createTexturePlane(config, boardData) {
|
|
|
37539
38062
|
} = config;
|
|
37540
38063
|
if (!texture) return null;
|
|
37541
38064
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
37542
|
-
const planeGeom = new
|
|
38065
|
+
const planeGeom = new THREE38.PlaneGeometry(
|
|
37543
38066
|
boardOutlineBounds.width,
|
|
37544
38067
|
boardOutlineBounds.height
|
|
37545
38068
|
);
|
|
37546
|
-
texture.colorSpace =
|
|
38069
|
+
texture.colorSpace = THREE38.SRGBColorSpace;
|
|
37547
38070
|
const sharedMaterialOptions = {
|
|
37548
38071
|
map: texture,
|
|
37549
38072
|
transparent: true,
|
|
37550
38073
|
alphaTest: 0.08,
|
|
37551
|
-
side:
|
|
38074
|
+
side: THREE38.FrontSide,
|
|
37552
38075
|
depthWrite: true,
|
|
37553
38076
|
polygonOffset: usePolygonOffset,
|
|
37554
38077
|
polygonOffsetFactor: usePolygonOffset ? -4 : 0,
|
|
@@ -37557,12 +38080,12 @@ function createTexturePlane(config, boardData) {
|
|
|
37557
38080
|
opacity: isFaux ? FAUX_BOARD_OPACITY : 1
|
|
37558
38081
|
};
|
|
37559
38082
|
const reliefTextures = createBoardReliefTextures(texture, maskedCopperMask);
|
|
37560
|
-
const material = new
|
|
38083
|
+
const material = new THREE38.MeshPhysicalMaterial({
|
|
37561
38084
|
...sharedMaterialOptions,
|
|
37562
38085
|
bumpMap: reliefTextures?.bumpMap ?? null,
|
|
37563
38086
|
bumpScale: REALISTIC_BOARD_SURFACE_MATERIAL.bumpScale,
|
|
37564
38087
|
normalMap: reliefTextures?.normalMap ?? null,
|
|
37565
|
-
normalScale: new
|
|
38088
|
+
normalScale: new THREE38.Vector2(
|
|
37566
38089
|
REALISTIC_BOARD_SURFACE_MATERIAL.normalScale,
|
|
37567
38090
|
REALISTIC_BOARD_SURFACE_MATERIAL.normalScale
|
|
37568
38091
|
),
|
|
@@ -37576,7 +38099,7 @@ function createTexturePlane(config, boardData) {
|
|
|
37576
38099
|
clearcoatRoughness: REALISTIC_BOARD_SURFACE_MATERIAL.clearcoatRoughness,
|
|
37577
38100
|
envMapIntensity: 0.18
|
|
37578
38101
|
});
|
|
37579
|
-
const mesh = new
|
|
38102
|
+
const mesh = new THREE38.Mesh(planeGeom, material);
|
|
37580
38103
|
mesh.position.set(
|
|
37581
38104
|
boardOutlineBounds.centerX,
|
|
37582
38105
|
boardOutlineBounds.centerY,
|
|
@@ -37624,7 +38147,7 @@ function createTextureMeshes(textures, boardData, pcbThickness, isFaux = false)
|
|
|
37624
38147
|
}
|
|
37625
38148
|
|
|
37626
38149
|
// src/three-components/JscadBoardTextures.tsx
|
|
37627
|
-
import * as
|
|
38150
|
+
import * as THREE39 from "three";
|
|
37628
38151
|
|
|
37629
38152
|
// src/utils/layer-texture-resolution.ts
|
|
37630
38153
|
var DEFAULT_MAX_TEXTURE_PIXELS = 4e6;
|
|
@@ -37661,7 +38184,7 @@ function JscadBoardTextures({
|
|
|
37661
38184
|
}) {
|
|
37662
38185
|
const { rootObject } = useThree();
|
|
37663
38186
|
const { visibility } = useLayerVisibility();
|
|
37664
|
-
const boardData =
|
|
38187
|
+
const boardData = useMemo20(() => {
|
|
37665
38188
|
const panels = circuitJson.filter(
|
|
37666
38189
|
(e) => e.type === "pcb_panel"
|
|
37667
38190
|
);
|
|
@@ -37687,11 +38210,11 @@ function JscadBoardTextures({
|
|
|
37687
38210
|
);
|
|
37688
38211
|
return boardsNotInPanel.length > 0 ? boardsNotInPanel[0] : null;
|
|
37689
38212
|
}, [circuitJson]);
|
|
37690
|
-
const traceTextureResolution =
|
|
38213
|
+
const traceTextureResolution = useMemo20(() => {
|
|
37691
38214
|
if (!boardData) return TRACE_TEXTURE_RESOLUTION;
|
|
37692
38215
|
return getLayerTextureResolution(boardData, TRACE_TEXTURE_RESOLUTION);
|
|
37693
38216
|
}, [boardData]);
|
|
37694
|
-
const textures =
|
|
38217
|
+
const textures = useMemo20(() => {
|
|
37695
38218
|
if (!boardData?.width || !boardData.height) return null;
|
|
37696
38219
|
return createCombinedBoardTextures({
|
|
37697
38220
|
circuitJson,
|
|
@@ -37700,7 +38223,7 @@ function JscadBoardTextures({
|
|
|
37700
38223
|
visibility
|
|
37701
38224
|
});
|
|
37702
38225
|
}, [circuitJson, boardData, traceTextureResolution, visibility]);
|
|
37703
|
-
|
|
38226
|
+
useEffect25(() => {
|
|
37704
38227
|
if (!rootObject || !boardData || !textures) return;
|
|
37705
38228
|
const meshes = [];
|
|
37706
38229
|
const disposeTextureMaterial = (material) => {
|
|
@@ -37720,7 +38243,7 @@ function JscadBoardTextures({
|
|
|
37720
38243
|
const typedMaterial = material;
|
|
37721
38244
|
for (const prop of textureProps) {
|
|
37722
38245
|
const texture = typedMaterial[prop];
|
|
37723
|
-
if (texture && texture instanceof
|
|
38246
|
+
if (texture && texture instanceof THREE39.Texture) {
|
|
37724
38247
|
texture.dispose();
|
|
37725
38248
|
typedMaterial[prop] = null;
|
|
37726
38249
|
}
|
|
@@ -37739,16 +38262,16 @@ function JscadBoardTextures({
|
|
|
37739
38262
|
}) => {
|
|
37740
38263
|
if (!texture) return null;
|
|
37741
38264
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
37742
|
-
const planeGeom = new
|
|
38265
|
+
const planeGeom = new THREE39.PlaneGeometry(
|
|
37743
38266
|
boardOutlineBounds.width,
|
|
37744
38267
|
boardOutlineBounds.height
|
|
37745
38268
|
);
|
|
37746
|
-
texture.colorSpace =
|
|
38269
|
+
texture.colorSpace = THREE39.SRGBColorSpace;
|
|
37747
38270
|
const sharedMaterialOptions = {
|
|
37748
38271
|
map: texture,
|
|
37749
38272
|
transparent: true,
|
|
37750
38273
|
alphaTest: 0.08,
|
|
37751
|
-
side:
|
|
38274
|
+
side: THREE39.FrontSide,
|
|
37752
38275
|
depthWrite,
|
|
37753
38276
|
polygonOffset: usePolygonOffset,
|
|
37754
38277
|
polygonOffsetFactor: usePolygonOffset ? -4 : 0,
|
|
@@ -37759,12 +38282,12 @@ function JscadBoardTextures({
|
|
|
37759
38282
|
texture,
|
|
37760
38283
|
maskedCopperMask
|
|
37761
38284
|
);
|
|
37762
|
-
const material = new
|
|
38285
|
+
const material = new THREE39.MeshPhysicalMaterial({
|
|
37763
38286
|
...sharedMaterialOptions,
|
|
37764
38287
|
bumpMap: reliefTextures?.bumpMap ?? null,
|
|
37765
38288
|
bumpScale: REALISTIC_BOARD_SURFACE_MATERIAL.bumpScale,
|
|
37766
38289
|
normalMap: reliefTextures?.normalMap ?? null,
|
|
37767
|
-
normalScale: new
|
|
38290
|
+
normalScale: new THREE39.Vector2(
|
|
37768
38291
|
REALISTIC_BOARD_SURFACE_MATERIAL.normalScale,
|
|
37769
38292
|
REALISTIC_BOARD_SURFACE_MATERIAL.normalScale
|
|
37770
38293
|
),
|
|
@@ -37776,7 +38299,7 @@ function JscadBoardTextures({
|
|
|
37776
38299
|
clearcoatRoughness: REALISTIC_BOARD_SURFACE_MATERIAL.clearcoatRoughness,
|
|
37777
38300
|
envMapIntensity: 0.18
|
|
37778
38301
|
});
|
|
37779
|
-
const mesh = new
|
|
38302
|
+
const mesh = new THREE39.Mesh(planeGeom, material);
|
|
37780
38303
|
mesh.position.set(
|
|
37781
38304
|
boardOutlineBounds.centerX,
|
|
37782
38305
|
boardOutlineBounds.centerY,
|
|
@@ -37826,7 +38349,7 @@ function JscadBoardTextures({
|
|
|
37826
38349
|
for (const material of mesh.material) {
|
|
37827
38350
|
disposeTextureMaterial(material);
|
|
37828
38351
|
}
|
|
37829
|
-
} else if (mesh.material instanceof
|
|
38352
|
+
} else if (mesh.material instanceof THREE39.Material) {
|
|
37830
38353
|
disposeTextureMaterial(mesh.material);
|
|
37831
38354
|
}
|
|
37832
38355
|
}
|
|
@@ -37837,6 +38360,108 @@ function JscadBoardTextures({
|
|
|
37837
38360
|
return null;
|
|
37838
38361
|
}
|
|
37839
38362
|
|
|
38363
|
+
// src/three-components/STLModel.tsx
|
|
38364
|
+
import { useState as useState15, useEffect as useEffect26, useMemo as useMemo21 } from "react";
|
|
38365
|
+
import * as THREE40 from "three";
|
|
38366
|
+
import { STLLoader } from "three-stdlib";
|
|
38367
|
+
function STLModel({
|
|
38368
|
+
stlUrl,
|
|
38369
|
+
stlData,
|
|
38370
|
+
mtlUrl,
|
|
38371
|
+
color,
|
|
38372
|
+
opacity = 1,
|
|
38373
|
+
layerType
|
|
38374
|
+
}) {
|
|
38375
|
+
const { rootObject } = useThree();
|
|
38376
|
+
const [geom, setGeom] = useState15(null);
|
|
38377
|
+
useEffect26(() => {
|
|
38378
|
+
const loader = new STLLoader();
|
|
38379
|
+
if (stlData) {
|
|
38380
|
+
try {
|
|
38381
|
+
const geometry = loader.parse(stlData);
|
|
38382
|
+
setGeom(geometry);
|
|
38383
|
+
} catch (e) {
|
|
38384
|
+
console.error("Failed to parse STL data", e);
|
|
38385
|
+
setGeom(null);
|
|
38386
|
+
}
|
|
38387
|
+
return;
|
|
38388
|
+
}
|
|
38389
|
+
if (stlUrl) {
|
|
38390
|
+
loader.load(stlUrl, (geometry) => {
|
|
38391
|
+
setGeom(geometry);
|
|
38392
|
+
});
|
|
38393
|
+
}
|
|
38394
|
+
}, [stlUrl, stlData]);
|
|
38395
|
+
const mesh = useMemo21(() => {
|
|
38396
|
+
if (!geom) return null;
|
|
38397
|
+
const isBoardLayer = layerType === "board";
|
|
38398
|
+
const material = new THREE40.MeshStandardMaterial({
|
|
38399
|
+
color: Array.isArray(color) ? new THREE40.Color(color[0], color[1], color[2]) : color,
|
|
38400
|
+
transparent: opacity !== 1,
|
|
38401
|
+
opacity,
|
|
38402
|
+
polygonOffset: isBoardLayer,
|
|
38403
|
+
polygonOffsetFactor: isBoardLayer ? 6 : 0,
|
|
38404
|
+
polygonOffsetUnits: isBoardLayer ? 6 : 0
|
|
38405
|
+
});
|
|
38406
|
+
const createdMesh = new THREE40.Mesh(geom, material);
|
|
38407
|
+
createdMesh.renderOrder = isBoardLayer ? -1 : 1;
|
|
38408
|
+
configureObjectShadows(createdMesh, {
|
|
38409
|
+
castShadow: !isBoardLayer && opacity === 1,
|
|
38410
|
+
receiveShadow: true
|
|
38411
|
+
});
|
|
38412
|
+
return createdMesh;
|
|
38413
|
+
}, [geom, color, opacity, layerType]);
|
|
38414
|
+
useEffect26(() => {
|
|
38415
|
+
if (!rootObject || !mesh) return;
|
|
38416
|
+
rootObject.add(mesh);
|
|
38417
|
+
return () => {
|
|
38418
|
+
rootObject.remove(mesh);
|
|
38419
|
+
mesh.geometry.dispose();
|
|
38420
|
+
if (Array.isArray(mesh.material)) {
|
|
38421
|
+
mesh.material.forEach((m) => m.dispose());
|
|
38422
|
+
} else {
|
|
38423
|
+
mesh.material.dispose();
|
|
38424
|
+
}
|
|
38425
|
+
};
|
|
38426
|
+
}, [rootObject, mesh]);
|
|
38427
|
+
return null;
|
|
38428
|
+
}
|
|
38429
|
+
|
|
38430
|
+
// src/three-components/VisibleSTLModel.tsx
|
|
38431
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
38432
|
+
function VisibleSTLModel({
|
|
38433
|
+
stlData,
|
|
38434
|
+
color,
|
|
38435
|
+
opacity = 1,
|
|
38436
|
+
layerType
|
|
38437
|
+
}) {
|
|
38438
|
+
const { visibility } = useLayerVisibility();
|
|
38439
|
+
let shouldShow = true;
|
|
38440
|
+
if (layerType === "board") {
|
|
38441
|
+
shouldShow = visibility.boardBody;
|
|
38442
|
+
} else if (layerType === "top-copper") {
|
|
38443
|
+
shouldShow = visibility.topCopper;
|
|
38444
|
+
} else if (layerType === "bottom-copper") {
|
|
38445
|
+
shouldShow = visibility.bottomCopper;
|
|
38446
|
+
} else if (layerType === "top-silkscreen") {
|
|
38447
|
+
shouldShow = visibility.topSilkscreen;
|
|
38448
|
+
} else if (layerType === "bottom-silkscreen") {
|
|
38449
|
+
shouldShow = visibility.bottomSilkscreen;
|
|
38450
|
+
}
|
|
38451
|
+
if (!shouldShow) {
|
|
38452
|
+
return null;
|
|
38453
|
+
}
|
|
38454
|
+
return /* @__PURE__ */ jsx17(
|
|
38455
|
+
STLModel,
|
|
38456
|
+
{
|
|
38457
|
+
stlData,
|
|
38458
|
+
color,
|
|
38459
|
+
opacity,
|
|
38460
|
+
layerType
|
|
38461
|
+
}
|
|
38462
|
+
);
|
|
38463
|
+
}
|
|
38464
|
+
|
|
37840
38465
|
// src/utils/preprocess-circuit-json.ts
|
|
37841
38466
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
37842
38467
|
|
|
@@ -37935,16 +38560,17 @@ var CadViewerJscad = forwardRef3(
|
|
|
37935
38560
|
clickToInteractEnabled,
|
|
37936
38561
|
onUserInteraction,
|
|
37937
38562
|
onCameraControllerReady,
|
|
37938
|
-
resolveStaticAsset
|
|
38563
|
+
resolveStaticAsset,
|
|
38564
|
+
referenceObject
|
|
37939
38565
|
}, ref) => {
|
|
37940
38566
|
const childrenSoup = useConvertChildrenToCircuitJson(children);
|
|
37941
|
-
const internalCircuitJson =
|
|
38567
|
+
const internalCircuitJson = useMemo22(() => {
|
|
37942
38568
|
return addFauxBoardIfNeeded(
|
|
37943
38569
|
circuitJson ?? childrenSoup
|
|
37944
38570
|
);
|
|
37945
38571
|
}, [circuitJson, childrenSoup]);
|
|
37946
38572
|
const boardGeom = useBoardGeomBuilder(internalCircuitJson);
|
|
37947
|
-
const initialCameraPosition =
|
|
38573
|
+
const initialCameraPosition = useMemo22(() => {
|
|
37948
38574
|
if (!internalCircuitJson) return [5, -5, 5];
|
|
37949
38575
|
try {
|
|
37950
38576
|
const board = su11(internalCircuitJson).pcb_board.list()[0];
|
|
@@ -37970,7 +38596,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
37970
38596
|
return [5, -5, 5];
|
|
37971
38597
|
}
|
|
37972
38598
|
}, [internalCircuitJson]);
|
|
37973
|
-
const isFauxBoard =
|
|
38599
|
+
const isFauxBoard = useMemo22(() => {
|
|
37974
38600
|
if (!internalCircuitJson) return false;
|
|
37975
38601
|
try {
|
|
37976
38602
|
const board = su11(internalCircuitJson).pcb_board.list()[0];
|
|
@@ -37979,23 +38605,25 @@ var CadViewerJscad = forwardRef3(
|
|
|
37979
38605
|
return false;
|
|
37980
38606
|
}
|
|
37981
38607
|
}, [internalCircuitJson]);
|
|
37982
|
-
const boardDimensions =
|
|
38608
|
+
const boardDimensions = useMemo22(() => {
|
|
37983
38609
|
if (!internalCircuitJson) return void 0;
|
|
37984
38610
|
try {
|
|
37985
38611
|
const board = su11(internalCircuitJson).pcb_board.list()[0];
|
|
37986
38612
|
if (!board) return void 0;
|
|
37987
|
-
|
|
38613
|
+
const bounds = calculateOutlineBounds(board);
|
|
38614
|
+
return { width: bounds.width, height: bounds.height };
|
|
37988
38615
|
} catch (e) {
|
|
37989
38616
|
console.error(e);
|
|
37990
38617
|
return void 0;
|
|
37991
38618
|
}
|
|
37992
38619
|
}, [internalCircuitJson]);
|
|
37993
|
-
const boardCenter =
|
|
38620
|
+
const boardCenter = useMemo22(() => {
|
|
37994
38621
|
if (!internalCircuitJson) return void 0;
|
|
37995
38622
|
try {
|
|
37996
38623
|
const board = su11(internalCircuitJson).pcb_board.list()[0];
|
|
37997
|
-
if (!board
|
|
37998
|
-
|
|
38624
|
+
if (!board) return void 0;
|
|
38625
|
+
const bounds = calculateOutlineBounds(board);
|
|
38626
|
+
return { x: bounds.centerX, y: bounds.centerY };
|
|
37999
38627
|
} catch (e) {
|
|
38000
38628
|
console.error(e);
|
|
38001
38629
|
return void 0;
|
|
@@ -38013,6 +38641,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
38013
38641
|
clickToInteractEnabled,
|
|
38014
38642
|
boardDimensions,
|
|
38015
38643
|
boardCenter,
|
|
38644
|
+
referenceObject,
|
|
38016
38645
|
onUserInteraction,
|
|
38017
38646
|
onCameraControllerReady,
|
|
38018
38647
|
children: [
|
|
@@ -38058,13 +38687,13 @@ var CadViewerJscad = forwardRef3(
|
|
|
38058
38687
|
|
|
38059
38688
|
// src/CadViewerManifold.tsx
|
|
38060
38689
|
import { su as su17 } from "@tscircuit/circuit-json-util";
|
|
38061
|
-
import { useEffect as
|
|
38062
|
-
import * as
|
|
38690
|
+
import { useEffect as useEffect28, useMemo as useMemo24, useState as useState17 } from "react";
|
|
38691
|
+
import * as THREE47 from "three";
|
|
38063
38692
|
|
|
38064
38693
|
// src/hooks/useManifoldBoardBuilder.ts
|
|
38065
38694
|
import { su as su16 } from "@tscircuit/circuit-json-util";
|
|
38066
|
-
import { useEffect as
|
|
38067
|
-
import * as
|
|
38695
|
+
import { useEffect as useEffect27, useMemo as useMemo23, useRef as useRef9, useState as useState16 } from "react";
|
|
38696
|
+
import * as THREE44 from "three";
|
|
38068
38697
|
|
|
38069
38698
|
// src/utils/manifold/create-manifold-board.ts
|
|
38070
38699
|
var arePointsClockwise2 = (points) => {
|
|
@@ -38413,17 +39042,17 @@ function processNonPlatedHolesForManifold(Manifold, CrossSection, circuitJson, p
|
|
|
38413
39042
|
|
|
38414
39043
|
// src/utils/manifold/process-plated-holes.ts
|
|
38415
39044
|
import { su as su14 } from "@tscircuit/circuit-json-util";
|
|
38416
|
-
import * as
|
|
39045
|
+
import * as THREE42 from "three";
|
|
38417
39046
|
|
|
38418
39047
|
// src/utils/manifold-mesh-to-three-geometry.ts
|
|
38419
|
-
import * as
|
|
39048
|
+
import * as THREE41 from "three";
|
|
38420
39049
|
function manifoldMeshToThreeGeometry(manifoldMesh) {
|
|
38421
|
-
const geometry = new
|
|
39050
|
+
const geometry = new THREE41.BufferGeometry();
|
|
38422
39051
|
geometry.setAttribute(
|
|
38423
39052
|
"position",
|
|
38424
|
-
new
|
|
39053
|
+
new THREE41.Float32BufferAttribute(manifoldMesh.vertProperties, 3)
|
|
38425
39054
|
);
|
|
38426
|
-
geometry.setIndex(new
|
|
39055
|
+
geometry.setIndex(new THREE41.Uint32BufferAttribute(manifoldMesh.triVerts, 1));
|
|
38427
39056
|
if (manifoldMesh.runIndex && manifoldMesh.runIndex.length > 1 && manifoldMesh.runOriginalID) {
|
|
38428
39057
|
for (let i = 0; i < manifoldMesh.runIndex.length - 1; i++) {
|
|
38429
39058
|
const start = manifoldMesh.runIndex[i];
|
|
@@ -38457,7 +39086,7 @@ var createEllipsePoints = (width10, height10, segments) => {
|
|
|
38457
39086
|
}
|
|
38458
39087
|
return points;
|
|
38459
39088
|
};
|
|
38460
|
-
var COPPER_COLOR = new
|
|
39089
|
+
var COPPER_COLOR = new THREE42.Color(...colors.copper);
|
|
38461
39090
|
var PLATED_HOLE_LIP_HEIGHT = 0.05;
|
|
38462
39091
|
var PLATED_HOLE_PAD_THICKNESS = 3e-3;
|
|
38463
39092
|
var PLATED_HOLE_SURFACE_CLEARANCE = 5e-4;
|
|
@@ -39088,7 +39717,7 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
39088
39717
|
|
|
39089
39718
|
// src/utils/manifold/process-vias.ts
|
|
39090
39719
|
import { su as su15 } from "@tscircuit/circuit-json-util";
|
|
39091
|
-
import * as
|
|
39720
|
+
import * as THREE43 from "three";
|
|
39092
39721
|
|
|
39093
39722
|
// src/utils/via-geoms.ts
|
|
39094
39723
|
function createViaCopper2({
|
|
@@ -39126,7 +39755,7 @@ function createViaCopper2({
|
|
|
39126
39755
|
}
|
|
39127
39756
|
|
|
39128
39757
|
// src/utils/manifold/process-vias.ts
|
|
39129
|
-
var COPPER_COLOR2 = new
|
|
39758
|
+
var COPPER_COLOR2 = new THREE43.Color(...colors.copper);
|
|
39130
39759
|
function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
39131
39760
|
const viaBoardDrills = [];
|
|
39132
39761
|
const pcbVias = su15(circuitJson).pcb_via.list();
|
|
@@ -39184,7 +39813,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
39184
39813
|
const [error, setError] = useState16(null);
|
|
39185
39814
|
const [isLoading, setIsLoading] = useState16(true);
|
|
39186
39815
|
const manifoldInstancesForCleanup = useRef9([]);
|
|
39187
|
-
const boardData =
|
|
39816
|
+
const boardData = useMemo23(() => {
|
|
39188
39817
|
const panels = circuitJson.filter(
|
|
39189
39818
|
(e) => e.type === "pcb_panel"
|
|
39190
39819
|
);
|
|
@@ -39208,15 +39837,15 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
39208
39837
|
const boardsNotInPanel = boards.filter((b) => !b.pcb_panel_id);
|
|
39209
39838
|
return boardsNotInPanel.length > 0 ? boardsNotInPanel[0] : null;
|
|
39210
39839
|
}, [circuitJson]);
|
|
39211
|
-
const isFauxBoard =
|
|
39840
|
+
const isFauxBoard = useMemo23(() => {
|
|
39212
39841
|
const boards = su16(circuitJson).pcb_board.list();
|
|
39213
39842
|
return boards.length > 0 && boards[0].pcb_board_id === "faux-board";
|
|
39214
39843
|
}, [circuitJson]);
|
|
39215
|
-
const traceTextureResolution =
|
|
39844
|
+
const traceTextureResolution = useMemo23(() => {
|
|
39216
39845
|
if (!boardData) return TRACE_TEXTURE_RESOLUTION;
|
|
39217
39846
|
return getLayerTextureResolution(boardData, TRACE_TEXTURE_RESOLUTION);
|
|
39218
39847
|
}, [boardData]);
|
|
39219
|
-
|
|
39848
|
+
useEffect27(() => {
|
|
39220
39849
|
if (!manifoldJSModule || !boardData) {
|
|
39221
39850
|
setGeoms(null);
|
|
39222
39851
|
setPcbThickness(null);
|
|
@@ -39346,7 +39975,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
39346
39975
|
{
|
|
39347
39976
|
key: "plated-holes-union",
|
|
39348
39977
|
geometry: cutPlatedGeom,
|
|
39349
|
-
color: new
|
|
39978
|
+
color: new THREE44.Color(
|
|
39350
39979
|
colors.copper[0],
|
|
39351
39980
|
colors.copper[1],
|
|
39352
39981
|
colors.copper[2]
|
|
@@ -39376,7 +40005,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
39376
40005
|
const matColorArray = boardMaterialColors[boardData.material] ?? colors.fr4Tan;
|
|
39377
40006
|
currentGeoms.board = {
|
|
39378
40007
|
geometry: finalBoardGeom,
|
|
39379
|
-
color: new
|
|
40008
|
+
color: new THREE44.Color(
|
|
39380
40009
|
matColorArray[0],
|
|
39381
40010
|
matColorArray[1],
|
|
39382
40011
|
matColorArray[2]
|
|
@@ -39400,7 +40029,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
39400
40029
|
manifoldInstancesForCleanup.current = [];
|
|
39401
40030
|
};
|
|
39402
40031
|
}, [manifoldJSModule, circuitJson, boardData]);
|
|
39403
|
-
const textures =
|
|
40032
|
+
const textures = useMemo23(() => {
|
|
39404
40033
|
if (!boardData || !traceTextureResolution) return null;
|
|
39405
40034
|
return createCombinedBoardTextures({
|
|
39406
40035
|
circuitJson,
|
|
@@ -39421,11 +40050,11 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
39421
40050
|
};
|
|
39422
40051
|
|
|
39423
40052
|
// src/utils/manifold/create-three-geometry-meshes.ts
|
|
39424
|
-
import * as
|
|
40053
|
+
import * as THREE46 from "three";
|
|
39425
40054
|
|
|
39426
40055
|
// src/utils/create-board-material.ts
|
|
39427
|
-
import * as
|
|
39428
|
-
var DEFAULT_SIDE =
|
|
40056
|
+
import * as THREE45 from "three";
|
|
40057
|
+
var DEFAULT_SIDE = THREE45.DoubleSide;
|
|
39429
40058
|
var createBoardMaterial = ({
|
|
39430
40059
|
material,
|
|
39431
40060
|
color,
|
|
@@ -39433,7 +40062,7 @@ var createBoardMaterial = ({
|
|
|
39433
40062
|
isFaux = false
|
|
39434
40063
|
}) => {
|
|
39435
40064
|
if (material === "fr4") {
|
|
39436
|
-
return new
|
|
40065
|
+
return new THREE45.MeshPhysicalMaterial({
|
|
39437
40066
|
// A dark edge lets the green solder mask read as a finished PCB rather
|
|
39438
40067
|
// than a tan substrate with a decal placed on top.
|
|
39439
40068
|
color: 1063462,
|
|
@@ -39453,7 +40082,7 @@ var createBoardMaterial = ({
|
|
|
39453
40082
|
polygonOffsetUnits: 1
|
|
39454
40083
|
});
|
|
39455
40084
|
}
|
|
39456
|
-
return new
|
|
40085
|
+
return new THREE45.MeshStandardMaterial({
|
|
39457
40086
|
color,
|
|
39458
40087
|
side,
|
|
39459
40088
|
flatShading: true,
|
|
@@ -39472,12 +40101,12 @@ function createGeometryMeshes(geoms) {
|
|
|
39472
40101
|
const meshes = [];
|
|
39473
40102
|
if (!geoms) return meshes;
|
|
39474
40103
|
if (geoms.board?.geometry) {
|
|
39475
|
-
const mesh = new
|
|
40104
|
+
const mesh = new THREE46.Mesh(
|
|
39476
40105
|
geoms.board.geometry,
|
|
39477
40106
|
createBoardMaterial({
|
|
39478
40107
|
material: geoms.board.material,
|
|
39479
40108
|
color: geoms.board.color,
|
|
39480
|
-
side:
|
|
40109
|
+
side: THREE46.DoubleSide,
|
|
39481
40110
|
isFaux: geoms.board.isFaux
|
|
39482
40111
|
})
|
|
39483
40112
|
);
|
|
@@ -39488,11 +40117,11 @@ function createGeometryMeshes(geoms) {
|
|
|
39488
40117
|
const createMeshesFromArray = (geomArray) => {
|
|
39489
40118
|
if (geomArray) {
|
|
39490
40119
|
for (const comp of geomArray) {
|
|
39491
|
-
const mesh = new
|
|
40120
|
+
const mesh = new THREE46.Mesh(
|
|
39492
40121
|
comp.geometry,
|
|
39493
|
-
new
|
|
40122
|
+
new THREE46.MeshStandardMaterial({
|
|
39494
40123
|
color: comp.color,
|
|
39495
|
-
side:
|
|
40124
|
+
side: THREE46.DoubleSide,
|
|
39496
40125
|
flatShading: true
|
|
39497
40126
|
// Consistent with board
|
|
39498
40127
|
})
|
|
@@ -39537,14 +40166,14 @@ var BoardMeshes = ({
|
|
|
39537
40166
|
const typedMaterial = material;
|
|
39538
40167
|
for (const prop of textureProps) {
|
|
39539
40168
|
const texture = typedMaterial[prop];
|
|
39540
|
-
if (texture && texture instanceof
|
|
40169
|
+
if (texture && texture instanceof THREE47.Texture) {
|
|
39541
40170
|
texture.dispose();
|
|
39542
40171
|
}
|
|
39543
40172
|
}
|
|
39544
40173
|
material.dispose();
|
|
39545
40174
|
}
|
|
39546
40175
|
};
|
|
39547
|
-
|
|
40176
|
+
useEffect28(() => {
|
|
39548
40177
|
if (!rootObject) return;
|
|
39549
40178
|
for (const mesh of geometryMeshes) {
|
|
39550
40179
|
let shouldShow = true;
|
|
@@ -39566,7 +40195,7 @@ var BoardMeshes = ({
|
|
|
39566
40195
|
}
|
|
39567
40196
|
};
|
|
39568
40197
|
}, [rootObject, geometryMeshes, visibility]);
|
|
39569
|
-
|
|
40198
|
+
useEffect28(() => {
|
|
39570
40199
|
if (!rootObject) return;
|
|
39571
40200
|
for (const mesh of textureMeshes) {
|
|
39572
40201
|
rootObject.add(mesh);
|
|
@@ -39590,17 +40219,18 @@ var CadViewerManifold = ({
|
|
|
39590
40219
|
onUserInteraction,
|
|
39591
40220
|
children,
|
|
39592
40221
|
onCameraControllerReady,
|
|
39593
|
-
resolveStaticAsset
|
|
40222
|
+
resolveStaticAsset,
|
|
40223
|
+
referenceObject
|
|
39594
40224
|
}) => {
|
|
39595
40225
|
const childrenCircuitJson = useConvertChildrenToCircuitJson(children);
|
|
39596
|
-
const circuitJson =
|
|
40226
|
+
const circuitJson = useMemo24(() => {
|
|
39597
40227
|
const rawCircuitJson = circuitJsonProp ?? childrenCircuitJson;
|
|
39598
40228
|
return addFauxBoardIfNeeded(rawCircuitJson);
|
|
39599
40229
|
}, [circuitJsonProp, childrenCircuitJson]);
|
|
39600
40230
|
const [manifoldJSModule, setManifoldJSModule] = useState17(null);
|
|
39601
40231
|
const [manifoldLoadingError, setManifoldLoadingError] = useState17(null);
|
|
39602
40232
|
const { visibility } = useLayerVisibility();
|
|
39603
|
-
|
|
40233
|
+
useEffect28(() => {
|
|
39604
40234
|
if (window.ManifoldModule && typeof window.ManifoldModule === "object" && window.ManifoldModule.setup) {
|
|
39605
40235
|
setManifoldJSModule(window.ManifoldModule);
|
|
39606
40236
|
return;
|
|
@@ -39671,27 +40301,26 @@ try {
|
|
|
39671
40301
|
boardData,
|
|
39672
40302
|
isFauxBoard
|
|
39673
40303
|
} = useManifoldBoardBuilder(manifoldJSModule, circuitJson, visibility);
|
|
39674
|
-
const geometryMeshes =
|
|
39675
|
-
const textureMeshes =
|
|
40304
|
+
const geometryMeshes = useMemo24(() => createGeometryMeshes(geoms), [geoms]);
|
|
40305
|
+
const textureMeshes = useMemo24(
|
|
39676
40306
|
() => createTextureMeshes(textures, boardData, pcbThickness, isFauxBoard),
|
|
39677
40307
|
[textures, boardData, pcbThickness, isFauxBoard]
|
|
39678
40308
|
);
|
|
39679
|
-
const cadComponents =
|
|
40309
|
+
const cadComponents = useMemo24(
|
|
39680
40310
|
() => su17(circuitJson).cad_component.list(),
|
|
39681
40311
|
[circuitJson]
|
|
39682
40312
|
);
|
|
39683
|
-
const boardDimensions =
|
|
40313
|
+
const boardDimensions = useMemo24(() => {
|
|
39684
40314
|
if (!boardData) return void 0;
|
|
39685
|
-
const
|
|
39686
|
-
return { width:
|
|
40315
|
+
const bounds = calculateOutlineBounds(boardData);
|
|
40316
|
+
return { width: bounds.width, height: bounds.height };
|
|
39687
40317
|
}, [boardData]);
|
|
39688
|
-
const boardCenter =
|
|
40318
|
+
const boardCenter = useMemo24(() => {
|
|
39689
40319
|
if (!boardData) return void 0;
|
|
39690
|
-
const
|
|
39691
|
-
|
|
39692
|
-
return { x: center.x, y: center.y };
|
|
40320
|
+
const bounds = calculateOutlineBounds(boardData);
|
|
40321
|
+
return { x: bounds.centerX, y: bounds.centerY };
|
|
39693
40322
|
}, [boardData]);
|
|
39694
|
-
const initialCameraPosition =
|
|
40323
|
+
const initialCameraPosition = useMemo24(() => {
|
|
39695
40324
|
if (!boardData) return [5, -5, 5];
|
|
39696
40325
|
const { width: width10 = 0, height: height10 = 0 } = boardData;
|
|
39697
40326
|
const safeWidth = Math.max(width10, 1);
|
|
@@ -39754,6 +40383,7 @@ try {
|
|
|
39754
40383
|
clickToInteractEnabled,
|
|
39755
40384
|
boardDimensions,
|
|
39756
40385
|
boardCenter,
|
|
40386
|
+
referenceObject,
|
|
39757
40387
|
onUserInteraction,
|
|
39758
40388
|
onCameraControllerReady,
|
|
39759
40389
|
children: [
|
|
@@ -39785,11 +40415,8 @@ try {
|
|
|
39785
40415
|
};
|
|
39786
40416
|
var CadViewerManifold_default = CadViewerManifold;
|
|
39787
40417
|
|
|
39788
|
-
// src/components/ContextMenu.tsx
|
|
39789
|
-
import { useState as useState35 } from "react";
|
|
39790
|
-
|
|
39791
40418
|
// node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs
|
|
39792
|
-
import * as
|
|
40419
|
+
import * as React42 from "react";
|
|
39793
40420
|
|
|
39794
40421
|
// node_modules/@radix-ui/primitive/dist/index.mjs
|
|
39795
40422
|
var __defProp3 = Object.defineProperty;
|
|
@@ -39844,7 +40471,7 @@ function isFrame(element) {
|
|
|
39844
40471
|
__name(isFrame, "isFrame");
|
|
39845
40472
|
|
|
39846
40473
|
// node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
39847
|
-
import * as
|
|
40474
|
+
import * as React11 from "react";
|
|
39848
40475
|
var __defProp4 = Object.defineProperty;
|
|
39849
40476
|
var __name2 = (target, value) => __defProp4(target, "name", { value, configurable: true });
|
|
39850
40477
|
function setRef(ref, value) {
|
|
@@ -39881,28 +40508,28 @@ function composeRefs(...refs) {
|
|
|
39881
40508
|
}
|
|
39882
40509
|
__name2(composeRefs, "composeRefs");
|
|
39883
40510
|
function useComposedRefs(...refs) {
|
|
39884
|
-
return
|
|
40511
|
+
return React11.useCallback(composeRefs(...refs), refs);
|
|
39885
40512
|
}
|
|
39886
40513
|
__name2(useComposedRefs, "useComposedRefs");
|
|
39887
40514
|
|
|
39888
40515
|
// node_modules/@radix-ui/react-context/dist/index.mjs
|
|
39889
|
-
import * as
|
|
40516
|
+
import * as React12 from "react";
|
|
39890
40517
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
39891
40518
|
var __defProp5 = Object.defineProperty;
|
|
39892
40519
|
var __name3 = (target, value) => __defProp5(target, "name", { value, configurable: true });
|
|
39893
40520
|
// @__NO_SIDE_EFFECTS__
|
|
39894
40521
|
function createContext22(rootComponentName, defaultContext) {
|
|
39895
|
-
const Context =
|
|
40522
|
+
const Context = React12.createContext(defaultContext);
|
|
39896
40523
|
Context.displayName = rootComponentName + "Context";
|
|
39897
40524
|
const Provider = /* @__PURE__ */ __name3((props) => {
|
|
39898
40525
|
const { children, ...context } = props;
|
|
39899
|
-
const value =
|
|
40526
|
+
const value = React12.useMemo(() => context, Object.values(context));
|
|
39900
40527
|
return /* @__PURE__ */ jsx20(Context.Provider, { value, children });
|
|
39901
40528
|
}, "Provider");
|
|
39902
40529
|
Provider.displayName = rootComponentName + "Provider";
|
|
39903
40530
|
function useContext22(consumerName, options = {}) {
|
|
39904
40531
|
const { optional = false } = options;
|
|
39905
|
-
const context =
|
|
40532
|
+
const context = React12.useContext(Context);
|
|
39906
40533
|
if (context) return context;
|
|
39907
40534
|
if (defaultContext !== void 0) return defaultContext;
|
|
39908
40535
|
if (optional) return void 0;
|
|
@@ -39916,21 +40543,21 @@ __name3(createContext22, "createContext");
|
|
|
39916
40543
|
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
39917
40544
|
let defaultContexts = [];
|
|
39918
40545
|
function createContext32(rootComponentName, defaultContext) {
|
|
39919
|
-
const BaseContext =
|
|
40546
|
+
const BaseContext = React12.createContext(defaultContext);
|
|
39920
40547
|
BaseContext.displayName = rootComponentName + "Context";
|
|
39921
40548
|
const index2 = defaultContexts.length;
|
|
39922
40549
|
defaultContexts = [...defaultContexts, defaultContext];
|
|
39923
40550
|
const Provider = /* @__PURE__ */ __name3((props) => {
|
|
39924
40551
|
const { scope, children, ...context } = props;
|
|
39925
40552
|
const Context = scope?.[scopeName]?.[index2] || BaseContext;
|
|
39926
|
-
const value =
|
|
40553
|
+
const value = React12.useMemo(() => context, Object.values(context));
|
|
39927
40554
|
return /* @__PURE__ */ jsx20(Context.Provider, { value, children });
|
|
39928
40555
|
}, "Provider");
|
|
39929
40556
|
Provider.displayName = rootComponentName + "Provider";
|
|
39930
40557
|
function useContext22(consumerName, scope, options = {}) {
|
|
39931
40558
|
const { optional = false } = options;
|
|
39932
40559
|
const Context = scope?.[scopeName]?.[index2] || BaseContext;
|
|
39933
|
-
const context =
|
|
40560
|
+
const context = React12.useContext(Context);
|
|
39934
40561
|
if (context) return context;
|
|
39935
40562
|
if (defaultContext !== void 0) return defaultContext;
|
|
39936
40563
|
if (optional) return void 0;
|
|
@@ -39942,11 +40569,11 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
|
39942
40569
|
__name3(createContext32, "createContext");
|
|
39943
40570
|
const createScope = /* @__PURE__ */ __name3(() => {
|
|
39944
40571
|
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
39945
|
-
return
|
|
40572
|
+
return React12.createContext(defaultContext);
|
|
39946
40573
|
});
|
|
39947
40574
|
return /* @__PURE__ */ __name3(function useScope(scope) {
|
|
39948
40575
|
const contexts = scope?.[scopeName] || scopeContexts;
|
|
39949
|
-
return
|
|
40576
|
+
return React12.useMemo(
|
|
39950
40577
|
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
39951
40578
|
[scope, contexts]
|
|
39952
40579
|
);
|
|
@@ -39970,7 +40597,7 @@ function composeContextScopes(...scopes) {
|
|
|
39970
40597
|
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
39971
40598
|
return { ...nextScopes2, ...currentScope };
|
|
39972
40599
|
}, {});
|
|
39973
|
-
return
|
|
40600
|
+
return React12.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
39974
40601
|
}, "useComposedScopes");
|
|
39975
40602
|
}, "createScope");
|
|
39976
40603
|
createScope.scopeName = baseScope.scopeName;
|
|
@@ -39979,30 +40606,30 @@ function composeContextScopes(...scopes) {
|
|
|
39979
40606
|
__name3(composeContextScopes, "composeContextScopes");
|
|
39980
40607
|
|
|
39981
40608
|
// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
39982
|
-
import * as
|
|
40609
|
+
import * as React15 from "react";
|
|
39983
40610
|
|
|
39984
40611
|
// node_modules/@radix-ui/primitive/dist/internal/is-development.false.mjs
|
|
39985
40612
|
var IS_DEVELOPMENT = false;
|
|
39986
40613
|
|
|
39987
40614
|
// node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
39988
|
-
import * as
|
|
39989
|
-
var useLayoutEffect2 = globalThis?.document ?
|
|
40615
|
+
import * as React13 from "react";
|
|
40616
|
+
var useLayoutEffect2 = globalThis?.document ? React13.useLayoutEffect : () => {
|
|
39990
40617
|
};
|
|
39991
40618
|
|
|
39992
40619
|
// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
39993
40620
|
import * as React22 from "react";
|
|
39994
40621
|
|
|
39995
40622
|
// node_modules/@radix-ui/react-use-effect-event/dist/index.mjs
|
|
39996
|
-
import * as
|
|
40623
|
+
import * as React14 from "react";
|
|
39997
40624
|
var __defProp6 = Object.defineProperty;
|
|
39998
40625
|
var __name4 = (target, value) => __defProp6(target, "name", { value, configurable: true });
|
|
39999
|
-
var useReactEffectEvent =
|
|
40000
|
-
var useReactInsertionEffect =
|
|
40626
|
+
var useReactEffectEvent = React14[" useEffectEvent ".trim().toString()];
|
|
40627
|
+
var useReactInsertionEffect = React14[" useInsertionEffect ".trim().toString()];
|
|
40001
40628
|
function useEffectEvent(callback) {
|
|
40002
40629
|
if (typeof useReactEffectEvent === "function") {
|
|
40003
40630
|
return useReactEffectEvent(callback);
|
|
40004
40631
|
}
|
|
40005
|
-
const ref =
|
|
40632
|
+
const ref = React14.useRef(() => {
|
|
40006
40633
|
throw new Error("Cannot call an event handler while rendering.");
|
|
40007
40634
|
});
|
|
40008
40635
|
if (typeof useReactInsertionEffect === "function") {
|
|
@@ -40014,14 +40641,14 @@ function useEffectEvent(callback) {
|
|
|
40014
40641
|
ref.current = callback;
|
|
40015
40642
|
});
|
|
40016
40643
|
}
|
|
40017
|
-
return
|
|
40644
|
+
return React14.useMemo(() => ((...args) => ref.current?.(...args)), []);
|
|
40018
40645
|
}
|
|
40019
40646
|
__name4(useEffectEvent, "useEffectEvent");
|
|
40020
40647
|
|
|
40021
40648
|
// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
40022
40649
|
var __defProp7 = Object.defineProperty;
|
|
40023
40650
|
var __name5 = (target, value) => __defProp7(target, "name", { value, configurable: true });
|
|
40024
|
-
var useInsertionEffect =
|
|
40651
|
+
var useInsertionEffect = React15[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
40025
40652
|
function useControllableState({
|
|
40026
40653
|
prop,
|
|
40027
40654
|
defaultProp,
|
|
@@ -40036,8 +40663,8 @@ function useControllableState({
|
|
|
40036
40663
|
const isControlled = prop !== void 0;
|
|
40037
40664
|
const value = isControlled ? prop : uncontrolledProp;
|
|
40038
40665
|
if (IS_DEVELOPMENT) {
|
|
40039
|
-
const isControlledRef =
|
|
40040
|
-
|
|
40666
|
+
const isControlledRef = React15.useRef(prop !== void 0);
|
|
40667
|
+
React15.useEffect(() => {
|
|
40041
40668
|
const wasControlled = isControlledRef.current;
|
|
40042
40669
|
if (wasControlled !== isControlled) {
|
|
40043
40670
|
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
@@ -40049,7 +40676,7 @@ function useControllableState({
|
|
|
40049
40676
|
isControlledRef.current = isControlled;
|
|
40050
40677
|
}, [isControlled, caller]);
|
|
40051
40678
|
}
|
|
40052
|
-
const setValue =
|
|
40679
|
+
const setValue = React15.useCallback(
|
|
40053
40680
|
(nextValue) => {
|
|
40054
40681
|
if (isControlled) {
|
|
40055
40682
|
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
@@ -40069,13 +40696,13 @@ function useUncontrolledState({
|
|
|
40069
40696
|
defaultProp,
|
|
40070
40697
|
onChange
|
|
40071
40698
|
}) {
|
|
40072
|
-
const [value, setValue] =
|
|
40073
|
-
const prevValueRef =
|
|
40074
|
-
const onChangeRef =
|
|
40699
|
+
const [value, setValue] = React15.useState(defaultProp);
|
|
40700
|
+
const prevValueRef = React15.useRef(value);
|
|
40701
|
+
const onChangeRef = React15.useRef(onChange);
|
|
40075
40702
|
useInsertionEffect(() => {
|
|
40076
40703
|
onChangeRef.current = onChange;
|
|
40077
40704
|
}, [onChange]);
|
|
40078
|
-
|
|
40705
|
+
React15.useEffect(() => {
|
|
40079
40706
|
if (prevValueRef.current !== value) {
|
|
40080
40707
|
onChangeRef.current?.(value);
|
|
40081
40708
|
prevValueRef.current = value;
|
|
@@ -40151,16 +40778,16 @@ function useControllableStateReducer(reducer, userArgs, initialArg, init) {
|
|
|
40151
40778
|
__name5(useControllableStateReducer, "useControllableStateReducer");
|
|
40152
40779
|
|
|
40153
40780
|
// node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
40154
|
-
import * as
|
|
40781
|
+
import * as React17 from "react";
|
|
40155
40782
|
import * as ReactDOM2 from "react-dom";
|
|
40156
40783
|
|
|
40157
40784
|
// node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
40158
|
-
import * as
|
|
40785
|
+
import * as React16 from "react";
|
|
40159
40786
|
var __defProp8 = Object.defineProperty;
|
|
40160
40787
|
var __name6 = (target, value) => __defProp8(target, "name", { value, configurable: true });
|
|
40161
40788
|
// @__NO_SIDE_EFFECTS__
|
|
40162
40789
|
function createSlot(ownerName) {
|
|
40163
|
-
const Slot2 =
|
|
40790
|
+
const Slot2 = React16.forwardRef((props, forwardedRef) => {
|
|
40164
40791
|
let { children, ...slotProps } = props;
|
|
40165
40792
|
let slottableElement = null;
|
|
40166
40793
|
let hasSlottable = false;
|
|
@@ -40168,7 +40795,7 @@ function createSlot(ownerName) {
|
|
|
40168
40795
|
if (isLazyComponent(children) && typeof use === "function") {
|
|
40169
40796
|
children = use(children._payload);
|
|
40170
40797
|
}
|
|
40171
|
-
|
|
40798
|
+
React16.Children.forEach(children, (maybeSlottable) => {
|
|
40172
40799
|
if (isSlottable(maybeSlottable)) {
|
|
40173
40800
|
hasSlottable = true;
|
|
40174
40801
|
const slottable = maybeSlottable;
|
|
@@ -40183,13 +40810,13 @@ function createSlot(ownerName) {
|
|
|
40183
40810
|
}
|
|
40184
40811
|
});
|
|
40185
40812
|
if (slottableElement) {
|
|
40186
|
-
slottableElement =
|
|
40813
|
+
slottableElement = React16.cloneElement(slottableElement, void 0, newChildren);
|
|
40187
40814
|
} else if (
|
|
40188
40815
|
// A `Slottable` was found but it didn't resolve to a single element (e.g.
|
|
40189
40816
|
// it wrapped multiple elements, text, or a render-prop `child` that
|
|
40190
40817
|
// wasn't an element). Don't fall back to treating the `Slottable` wrapper
|
|
40191
40818
|
// itself as the slot target — throw a descriptive error below instead.
|
|
40192
|
-
!hasSlottable &&
|
|
40819
|
+
!hasSlottable && React16.Children.count(children) === 1 && React16.isValidElement(children)
|
|
40193
40820
|
) {
|
|
40194
40821
|
slottableElement = children;
|
|
40195
40822
|
}
|
|
@@ -40204,10 +40831,10 @@ function createSlot(ownerName) {
|
|
|
40204
40831
|
return children;
|
|
40205
40832
|
}
|
|
40206
40833
|
const mergedProps = mergeProps(slotProps, slottableElement.props ?? {});
|
|
40207
|
-
if (slottableElement.type !==
|
|
40834
|
+
if (slottableElement.type !== React16.Fragment) {
|
|
40208
40835
|
mergedProps.ref = forwardedRef ? composedRef : slottableElementRef;
|
|
40209
40836
|
}
|
|
40210
|
-
return
|
|
40837
|
+
return React16.cloneElement(slottableElement, mergedProps);
|
|
40211
40838
|
});
|
|
40212
40839
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
40213
40840
|
return Slot2;
|
|
@@ -40225,10 +40852,10 @@ __name6(createSlottable, "createSlottable");
|
|
|
40225
40852
|
var getSlottableElementFromSlottable = /* @__PURE__ */ __name6((slottable, child) => {
|
|
40226
40853
|
if ("child" in slottable.props) {
|
|
40227
40854
|
const child2 = slottable.props.child;
|
|
40228
|
-
if (!
|
|
40229
|
-
return
|
|
40855
|
+
if (!React16.isValidElement(child2)) return null;
|
|
40856
|
+
return React16.cloneElement(child2, void 0, slottable.props.children(child2.props.children));
|
|
40230
40857
|
}
|
|
40231
|
-
return
|
|
40858
|
+
return React16.isValidElement(child) ? child : null;
|
|
40232
40859
|
}, "getSlottableElementFromSlottable");
|
|
40233
40860
|
function mergeProps(slotProps, childProps) {
|
|
40234
40861
|
const overrideProps = { ...childProps };
|
|
@@ -40270,7 +40897,7 @@ function getElementRef(element) {
|
|
|
40270
40897
|
}
|
|
40271
40898
|
__name6(getElementRef, "getElementRef");
|
|
40272
40899
|
function isSlottable(child) {
|
|
40273
|
-
return
|
|
40900
|
+
return React16.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
40274
40901
|
}
|
|
40275
40902
|
__name6(isSlottable, "isSlottable");
|
|
40276
40903
|
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
@@ -40288,7 +40915,7 @@ var createSlotError = /* @__PURE__ */ __name6((ownerName) => {
|
|
|
40288
40915
|
var createSlottableError = /* @__PURE__ */ __name6((ownerName) => {
|
|
40289
40916
|
return `${ownerName} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`;
|
|
40290
40917
|
}, "createSlottableError");
|
|
40291
|
-
var use =
|
|
40918
|
+
var use = React16[" use ".trim().toString()];
|
|
40292
40919
|
|
|
40293
40920
|
// node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
40294
40921
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
@@ -40315,7 +40942,7 @@ var NODES = [
|
|
|
40315
40942
|
];
|
|
40316
40943
|
var Primitive = NODES.reduce((primitive, node) => {
|
|
40317
40944
|
const Slot2 = createSlot(`Primitive.${node}`);
|
|
40318
|
-
const Node2 =
|
|
40945
|
+
const Node2 = React17.forwardRef((props, forwardedRef) => {
|
|
40319
40946
|
const { asChild, ...primitiveProps } = props;
|
|
40320
40947
|
const Comp = asChild ? Slot2 : node;
|
|
40321
40948
|
if (typeof window !== "undefined") {
|
|
@@ -40332,10 +40959,10 @@ function dispatchDiscreteCustomEvent(target, event) {
|
|
|
40332
40959
|
__name7(dispatchDiscreteCustomEvent, "dispatchDiscreteCustomEvent");
|
|
40333
40960
|
|
|
40334
40961
|
// node_modules/@radix-ui/react-menu/dist/index.mjs
|
|
40335
|
-
import * as
|
|
40962
|
+
import * as React41 from "react";
|
|
40336
40963
|
|
|
40337
40964
|
// node_modules/@radix-ui/react-collection/dist/index.mjs
|
|
40338
|
-
import * as
|
|
40965
|
+
import * as React18 from "react";
|
|
40339
40966
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
40340
40967
|
import * as React23 from "react";
|
|
40341
40968
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
@@ -40351,14 +40978,14 @@ function createCollection(name) {
|
|
|
40351
40978
|
);
|
|
40352
40979
|
const CollectionProvider = /* @__PURE__ */ __name8((props) => {
|
|
40353
40980
|
const { scope, children } = props;
|
|
40354
|
-
const ref =
|
|
40355
|
-
const itemMap =
|
|
40981
|
+
const ref = React18.useRef(null);
|
|
40982
|
+
const itemMap = React18.useRef(/* @__PURE__ */ new Map()).current;
|
|
40356
40983
|
return /* @__PURE__ */ jsx22(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
40357
40984
|
}, "CollectionProvider");
|
|
40358
40985
|
CollectionProvider.displayName = PROVIDER_NAME;
|
|
40359
40986
|
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
40360
40987
|
const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
|
|
40361
|
-
const CollectionSlot =
|
|
40988
|
+
const CollectionSlot = React18.forwardRef(
|
|
40362
40989
|
(props, forwardedRef) => {
|
|
40363
40990
|
const { scope, children } = props;
|
|
40364
40991
|
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
@@ -40370,13 +40997,13 @@ function createCollection(name) {
|
|
|
40370
40997
|
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
40371
40998
|
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
40372
40999
|
const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
|
|
40373
|
-
const CollectionItemSlot =
|
|
41000
|
+
const CollectionItemSlot = React18.forwardRef(
|
|
40374
41001
|
(props, forwardedRef) => {
|
|
40375
41002
|
const { scope, children, ...itemData } = props;
|
|
40376
|
-
const ref =
|
|
41003
|
+
const ref = React18.useRef(null);
|
|
40377
41004
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
40378
41005
|
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
40379
|
-
|
|
41006
|
+
React18.useEffect(() => {
|
|
40380
41007
|
context.itemMap.set(ref, { ref, ...itemData });
|
|
40381
41008
|
return () => void context.itemMap.delete(ref);
|
|
40382
41009
|
});
|
|
@@ -40386,7 +41013,7 @@ function createCollection(name) {
|
|
|
40386
41013
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
40387
41014
|
function useCollection3(scope) {
|
|
40388
41015
|
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
40389
|
-
const getItems =
|
|
41016
|
+
const getItems = React18.useCallback(() => {
|
|
40390
41017
|
const collectionNode = context.collectionRef.current;
|
|
40391
41018
|
if (!collectionNode) return [];
|
|
40392
41019
|
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
@@ -40881,30 +41508,30 @@ function getChildListObserver(callback) {
|
|
|
40881
41508
|
__name8(getChildListObserver, "getChildListObserver");
|
|
40882
41509
|
|
|
40883
41510
|
// node_modules/@radix-ui/react-direction/dist/index.mjs
|
|
40884
|
-
import * as
|
|
41511
|
+
import * as React19 from "react";
|
|
40885
41512
|
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
40886
41513
|
var __defProp11 = Object.defineProperty;
|
|
40887
41514
|
var __name9 = (target, value) => __defProp11(target, "name", { value, configurable: true });
|
|
40888
|
-
var DirectionContext =
|
|
41515
|
+
var DirectionContext = React19.createContext(void 0);
|
|
40889
41516
|
function useDirection(localDir) {
|
|
40890
|
-
const globalDir =
|
|
41517
|
+
const globalDir = React19.useContext(DirectionContext);
|
|
40891
41518
|
return localDir || globalDir || "ltr";
|
|
40892
41519
|
}
|
|
40893
41520
|
__name9(useDirection, "useDirection");
|
|
40894
41521
|
|
|
40895
41522
|
// node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
|
|
40896
|
-
import * as
|
|
41523
|
+
import * as React21 from "react";
|
|
40897
41524
|
|
|
40898
41525
|
// node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs
|
|
40899
|
-
import * as
|
|
41526
|
+
import * as React20 from "react";
|
|
40900
41527
|
var __defProp12 = Object.defineProperty;
|
|
40901
41528
|
var __name10 = (target, value) => __defProp12(target, "name", { value, configurable: true });
|
|
40902
41529
|
function useCallbackRef(callback) {
|
|
40903
|
-
const callbackRef =
|
|
40904
|
-
|
|
41530
|
+
const callbackRef = React20.useRef(callback);
|
|
41531
|
+
React20.useEffect(() => {
|
|
40905
41532
|
callbackRef.current = callback;
|
|
40906
41533
|
});
|
|
40907
|
-
return
|
|
41534
|
+
return React20.useMemo(() => ((...args) => callbackRef.current?.(...args)), []);
|
|
40908
41535
|
}
|
|
40909
41536
|
__name10(useCallbackRef, "useCallbackRef");
|
|
40910
41537
|
|
|
@@ -40916,7 +41543,7 @@ var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
|
40916
41543
|
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
40917
41544
|
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
40918
41545
|
var originalBodyPointerEvents;
|
|
40919
|
-
var DismissableLayerContext =
|
|
41546
|
+
var DismissableLayerContext = React21.createContext({
|
|
40920
41547
|
layers: /* @__PURE__ */ new Set(),
|
|
40921
41548
|
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
40922
41549
|
branches: /* @__PURE__ */ new Set(),
|
|
@@ -40927,7 +41554,7 @@ var DismissableLayerContext = React20.createContext({
|
|
|
40927
41554
|
// See https://github.com/radix-ui/primitives/issues/3346
|
|
40928
41555
|
dismissableSurfaces: /* @__PURE__ */ new Set()
|
|
40929
41556
|
});
|
|
40930
|
-
var DismissableLayer = /* @__PURE__ */
|
|
41557
|
+
var DismissableLayer = /* @__PURE__ */ React21.forwardRef(
|
|
40931
41558
|
// blank line to reduce diff noise
|
|
40932
41559
|
/* @__PURE__ */ __name11(function DismissableLayer2(props, forwardedRef) {
|
|
40933
41560
|
const {
|
|
@@ -40940,10 +41567,10 @@ var DismissableLayer = /* @__PURE__ */ React20.forwardRef(
|
|
|
40940
41567
|
onDismiss,
|
|
40941
41568
|
...layerProps
|
|
40942
41569
|
} = props;
|
|
40943
|
-
const context =
|
|
40944
|
-
const [node, setNode] =
|
|
41570
|
+
const context = React21.useContext(DismissableLayerContext);
|
|
41571
|
+
const [node, setNode] = React21.useState(null);
|
|
40945
41572
|
const ownerDocument = node?.ownerDocument ?? globalThis?.document;
|
|
40946
|
-
const [, force] =
|
|
41573
|
+
const [, force] = React21.useState({});
|
|
40947
41574
|
const composedRefs = useComposedRefs(forwardedRef, setNode);
|
|
40948
41575
|
const layers = Array.from(context.layers);
|
|
40949
41576
|
const [highestLayerWithOutsidePointerEventsDisabled] = [
|
|
@@ -40953,7 +41580,7 @@ var DismissableLayer = /* @__PURE__ */ React20.forwardRef(
|
|
|
40953
41580
|
const index2 = node ? layers.indexOf(node) : -1;
|
|
40954
41581
|
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
40955
41582
|
const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
40956
|
-
const isDeferredPointerDownOutsideRef =
|
|
41583
|
+
const isDeferredPointerDownOutsideRef = React21.useRef(false);
|
|
40957
41584
|
const pointerDownOutside = usePointerDownOutside(
|
|
40958
41585
|
(event) => {
|
|
40959
41586
|
onPointerDownOutside?.(event);
|
|
@@ -40965,7 +41592,7 @@ var DismissableLayer = /* @__PURE__ */ React20.forwardRef(
|
|
|
40965
41592
|
deferPointerDownOutside,
|
|
40966
41593
|
isDeferredPointerDownOutsideRef,
|
|
40967
41594
|
dismissableSurfaces: context.dismissableSurfaces,
|
|
40968
|
-
shouldHandlePointerDownOutside:
|
|
41595
|
+
shouldHandlePointerDownOutside: React21.useCallback(
|
|
40969
41596
|
(target) => {
|
|
40970
41597
|
if (!(target instanceof Node)) {
|
|
40971
41598
|
return false;
|
|
@@ -41001,14 +41628,14 @@ var DismissableLayer = /* @__PURE__ */ React20.forwardRef(
|
|
|
41001
41628
|
onDismiss();
|
|
41002
41629
|
}
|
|
41003
41630
|
});
|
|
41004
|
-
|
|
41631
|
+
React21.useEffect(() => {
|
|
41005
41632
|
if (!isHighestLayer) {
|
|
41006
41633
|
return;
|
|
41007
41634
|
}
|
|
41008
41635
|
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
41009
41636
|
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
41010
41637
|
}, [ownerDocument, isHighestLayer, handleKeyDown]);
|
|
41011
|
-
|
|
41638
|
+
React21.useEffect(() => {
|
|
41012
41639
|
if (!node) return;
|
|
41013
41640
|
if (disableOutsidePointerEvents) {
|
|
41014
41641
|
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
@@ -41028,7 +41655,7 @@ var DismissableLayer = /* @__PURE__ */ React20.forwardRef(
|
|
|
41028
41655
|
}
|
|
41029
41656
|
};
|
|
41030
41657
|
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
41031
|
-
|
|
41658
|
+
React21.useEffect(() => {
|
|
41032
41659
|
return () => {
|
|
41033
41660
|
if (!node) return;
|
|
41034
41661
|
context.layers.delete(node);
|
|
@@ -41036,7 +41663,7 @@ var DismissableLayer = /* @__PURE__ */ React20.forwardRef(
|
|
|
41036
41663
|
dispatchUpdate();
|
|
41037
41664
|
};
|
|
41038
41665
|
}, [node, context]);
|
|
41039
|
-
|
|
41666
|
+
React21.useEffect(() => {
|
|
41040
41667
|
const handleUpdate = /* @__PURE__ */ __name11(() => force({}), "handleUpdate");
|
|
41041
41668
|
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
41042
41669
|
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
@@ -41061,9 +41688,9 @@ var DismissableLayer = /* @__PURE__ */ React20.forwardRef(
|
|
|
41061
41688
|
}, "DismissableLayer")
|
|
41062
41689
|
);
|
|
41063
41690
|
function useDismissableLayerSurface() {
|
|
41064
|
-
const context =
|
|
41065
|
-
const [node, setNode] =
|
|
41066
|
-
|
|
41691
|
+
const context = React21.useContext(DismissableLayerContext);
|
|
41692
|
+
const [node, setNode] = React21.useState(null);
|
|
41693
|
+
React21.useEffect(() => {
|
|
41067
41694
|
if (!node) {
|
|
41068
41695
|
return;
|
|
41069
41696
|
}
|
|
@@ -41085,12 +41712,12 @@ function usePointerDownOutside(onPointerDownOutside, args) {
|
|
|
41085
41712
|
shouldHandlePointerDownOutside = IS_TRUE
|
|
41086
41713
|
} = args;
|
|
41087
41714
|
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
41088
|
-
const isPointerInsideReactTreeRef =
|
|
41089
|
-
const isPointerDownOutsideRef =
|
|
41090
|
-
const interceptedOutsideInteractionEventsRef =
|
|
41091
|
-
const handleClickRef =
|
|
41715
|
+
const isPointerInsideReactTreeRef = React21.useRef(false);
|
|
41716
|
+
const isPointerDownOutsideRef = React21.useRef(false);
|
|
41717
|
+
const interceptedOutsideInteractionEventsRef = React21.useRef(/* @__PURE__ */ new Map());
|
|
41718
|
+
const handleClickRef = React21.useRef(() => {
|
|
41092
41719
|
});
|
|
41093
|
-
|
|
41720
|
+
React21.useEffect(() => {
|
|
41094
41721
|
function resetOutsideInteraction() {
|
|
41095
41722
|
isPointerDownOutsideRef.current = false;
|
|
41096
41723
|
isDeferredPointerDownOutsideRef.current = false;
|
|
@@ -41205,8 +41832,8 @@ function usePointerDownOutside(onPointerDownOutside, args) {
|
|
|
41205
41832
|
__name11(usePointerDownOutside, "usePointerDownOutside");
|
|
41206
41833
|
function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
|
|
41207
41834
|
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
41208
|
-
const isFocusInsideReactTreeRef =
|
|
41209
|
-
|
|
41835
|
+
const isFocusInsideReactTreeRef = React21.useRef(false);
|
|
41836
|
+
React21.useEffect(() => {
|
|
41210
41837
|
const handleFocus = /* @__PURE__ */ __name11((event) => {
|
|
41211
41838
|
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
41212
41839
|
const eventDetail = { originalEvent: event };
|
|
@@ -41242,7 +41869,7 @@ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
|
41242
41869
|
__name11(handleAndDispatchCustomEvent, "handleAndDispatchCustomEvent");
|
|
41243
41870
|
|
|
41244
41871
|
// node_modules/@radix-ui/react-focus-guards/dist/index.mjs
|
|
41245
|
-
import * as
|
|
41872
|
+
import * as React24 from "react";
|
|
41246
41873
|
var __defProp14 = Object.defineProperty;
|
|
41247
41874
|
var __name12 = (target, value) => __defProp14(target, "name", { value, configurable: true });
|
|
41248
41875
|
var count = 0;
|
|
@@ -41253,7 +41880,7 @@ function FocusGuards(props) {
|
|
|
41253
41880
|
}
|
|
41254
41881
|
__name12(FocusGuards, "FocusGuards");
|
|
41255
41882
|
function useFocusGuards() {
|
|
41256
|
-
|
|
41883
|
+
React24.useEffect(() => {
|
|
41257
41884
|
if (!guards) {
|
|
41258
41885
|
guards = { start: createFocusGuard(), end: createFocusGuard() };
|
|
41259
41886
|
}
|
|
@@ -41289,14 +41916,14 @@ function createFocusGuard() {
|
|
|
41289
41916
|
__name12(createFocusGuard, "createFocusGuard");
|
|
41290
41917
|
|
|
41291
41918
|
// node_modules/@radix-ui/react-focus-scope/dist/index.mjs
|
|
41292
|
-
import * as
|
|
41919
|
+
import * as React25 from "react";
|
|
41293
41920
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
41294
41921
|
var __defProp15 = Object.defineProperty;
|
|
41295
41922
|
var __name13 = (target, value) => __defProp15(target, "name", { value, configurable: true });
|
|
41296
41923
|
var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
41297
41924
|
var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
41298
41925
|
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
41299
|
-
var FocusScope = /* @__PURE__ */
|
|
41926
|
+
var FocusScope = /* @__PURE__ */ React25.forwardRef(
|
|
41300
41927
|
/* @__PURE__ */ __name13(function FocusScope2(props, forwardedRef) {
|
|
41301
41928
|
const {
|
|
41302
41929
|
loop = false,
|
|
@@ -41305,12 +41932,12 @@ var FocusScope = /* @__PURE__ */ React24.forwardRef(
|
|
|
41305
41932
|
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
41306
41933
|
...scopeProps
|
|
41307
41934
|
} = props;
|
|
41308
|
-
const [container, setContainer] =
|
|
41935
|
+
const [container, setContainer] = React25.useState(null);
|
|
41309
41936
|
const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
|
|
41310
41937
|
const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
|
|
41311
|
-
const lastFocusedElementRef =
|
|
41938
|
+
const lastFocusedElementRef = React25.useRef(null);
|
|
41312
41939
|
const composedRefs = useComposedRefs(forwardedRef, setContainer);
|
|
41313
|
-
const focusScope =
|
|
41940
|
+
const focusScope = React25.useRef({
|
|
41314
41941
|
paused: false,
|
|
41315
41942
|
pause() {
|
|
41316
41943
|
this.paused = true;
|
|
@@ -41319,7 +41946,7 @@ var FocusScope = /* @__PURE__ */ React24.forwardRef(
|
|
|
41319
41946
|
this.paused = false;
|
|
41320
41947
|
}
|
|
41321
41948
|
}).current;
|
|
41322
|
-
|
|
41949
|
+
React25.useEffect(() => {
|
|
41323
41950
|
if (trapped) {
|
|
41324
41951
|
let handleFocusIn2 = function(event) {
|
|
41325
41952
|
if (focusScope.paused || !container) return;
|
|
@@ -41358,7 +41985,7 @@ var FocusScope = /* @__PURE__ */ React24.forwardRef(
|
|
|
41358
41985
|
};
|
|
41359
41986
|
}
|
|
41360
41987
|
}, [trapped, container, focusScope.paused]);
|
|
41361
|
-
|
|
41988
|
+
React25.useEffect(() => {
|
|
41362
41989
|
if (container) {
|
|
41363
41990
|
focusScopesStack.add(focusScope);
|
|
41364
41991
|
const previouslyFocusedElement = document.activeElement;
|
|
@@ -41389,7 +42016,7 @@ var FocusScope = /* @__PURE__ */ React24.forwardRef(
|
|
|
41389
42016
|
};
|
|
41390
42017
|
}
|
|
41391
42018
|
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
41392
|
-
const handleKeyDown =
|
|
42019
|
+
const handleKeyDown = React25.useCallback(
|
|
41393
42020
|
(event) => {
|
|
41394
42021
|
if (!loop && !trapped) return;
|
|
41395
42022
|
if (focusScope.paused) return;
|
|
@@ -41512,13 +42139,13 @@ function removeLinks(items) {
|
|
|
41512
42139
|
__name13(removeLinks, "removeLinks");
|
|
41513
42140
|
|
|
41514
42141
|
// node_modules/@radix-ui/react-id/dist/index.mjs
|
|
41515
|
-
import * as
|
|
42142
|
+
import * as React26 from "react";
|
|
41516
42143
|
var __defProp16 = Object.defineProperty;
|
|
41517
42144
|
var __name14 = (target, value) => __defProp16(target, "name", { value, configurable: true });
|
|
41518
|
-
var useReactId =
|
|
42145
|
+
var useReactId = React26[" useId ".trim().toString()] || (() => void 0);
|
|
41519
42146
|
var count2 = 0;
|
|
41520
42147
|
function useId(deterministicId) {
|
|
41521
|
-
const [id, setId] =
|
|
42148
|
+
const [id, setId] = React26.useState(useReactId());
|
|
41522
42149
|
useLayoutEffect2(() => {
|
|
41523
42150
|
if (!deterministicId) setId((reactId) => reactId ?? String(count2++));
|
|
41524
42151
|
}, [deterministicId]);
|
|
@@ -41527,7 +42154,7 @@ function useId(deterministicId) {
|
|
|
41527
42154
|
__name14(useId, "useId");
|
|
41528
42155
|
|
|
41529
42156
|
// node_modules/@radix-ui/react-popper/dist/index.mjs
|
|
41530
|
-
import * as
|
|
42157
|
+
import * as React29 from "react";
|
|
41531
42158
|
|
|
41532
42159
|
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
41533
42160
|
var sides = ["top", "right", "bottom", "left"];
|
|
@@ -43122,7 +43749,7 @@ var computePosition2 = (reference, floating, options) => {
|
|
|
43122
43749
|
};
|
|
43123
43750
|
|
|
43124
43751
|
// node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
|
|
43125
|
-
import * as
|
|
43752
|
+
import * as React27 from "react";
|
|
43126
43753
|
import { useLayoutEffect as useLayoutEffect3 } from "react";
|
|
43127
43754
|
import * as ReactDOM3 from "react-dom";
|
|
43128
43755
|
var isClient = typeof document !== "undefined";
|
|
@@ -43188,7 +43815,7 @@ function roundByDPR(element, value) {
|
|
|
43188
43815
|
return Math.round(value * dpr) / dpr;
|
|
43189
43816
|
}
|
|
43190
43817
|
function useLatestRef(value) {
|
|
43191
|
-
const ref =
|
|
43818
|
+
const ref = React27.useRef(value);
|
|
43192
43819
|
index(() => {
|
|
43193
43820
|
ref.current = value;
|
|
43194
43821
|
});
|
|
@@ -43211,7 +43838,7 @@ function useFloating(options) {
|
|
|
43211
43838
|
whileElementsMounted,
|
|
43212
43839
|
open
|
|
43213
43840
|
} = options;
|
|
43214
|
-
const [data, setData] =
|
|
43841
|
+
const [data, setData] = React27.useState({
|
|
43215
43842
|
x: 0,
|
|
43216
43843
|
y: 0,
|
|
43217
43844
|
strategy,
|
|
@@ -43219,19 +43846,19 @@ function useFloating(options) {
|
|
|
43219
43846
|
middlewareData: {},
|
|
43220
43847
|
isPositioned: false
|
|
43221
43848
|
});
|
|
43222
|
-
const [latestMiddleware, setLatestMiddleware] =
|
|
43849
|
+
const [latestMiddleware, setLatestMiddleware] = React27.useState(middleware);
|
|
43223
43850
|
if (!deepEqual(latestMiddleware, middleware)) {
|
|
43224
43851
|
setLatestMiddleware(middleware);
|
|
43225
43852
|
}
|
|
43226
|
-
const [_reference, _setReference] =
|
|
43227
|
-
const [_floating, _setFloating] =
|
|
43228
|
-
const setReference =
|
|
43853
|
+
const [_reference, _setReference] = React27.useState(null);
|
|
43854
|
+
const [_floating, _setFloating] = React27.useState(null);
|
|
43855
|
+
const setReference = React27.useCallback((node) => {
|
|
43229
43856
|
if (node !== referenceRef.current) {
|
|
43230
43857
|
referenceRef.current = node;
|
|
43231
43858
|
_setReference(node);
|
|
43232
43859
|
}
|
|
43233
43860
|
}, []);
|
|
43234
|
-
const setFloating =
|
|
43861
|
+
const setFloating = React27.useCallback((node) => {
|
|
43235
43862
|
if (node !== floatingRef.current) {
|
|
43236
43863
|
floatingRef.current = node;
|
|
43237
43864
|
_setFloating(node);
|
|
@@ -43239,14 +43866,14 @@ function useFloating(options) {
|
|
|
43239
43866
|
}, []);
|
|
43240
43867
|
const referenceEl = externalReference || _reference;
|
|
43241
43868
|
const floatingEl = externalFloating || _floating;
|
|
43242
|
-
const referenceRef =
|
|
43243
|
-
const floatingRef =
|
|
43244
|
-
const dataRef =
|
|
43869
|
+
const referenceRef = React27.useRef(null);
|
|
43870
|
+
const floatingRef = React27.useRef(null);
|
|
43871
|
+
const dataRef = React27.useRef(data);
|
|
43245
43872
|
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
43246
43873
|
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
43247
43874
|
const platformRef = useLatestRef(platform2);
|
|
43248
43875
|
const openRef = useLatestRef(open);
|
|
43249
|
-
const update =
|
|
43876
|
+
const update = React27.useCallback(() => {
|
|
43250
43877
|
if (!referenceRef.current || !floatingRef.current) {
|
|
43251
43878
|
return;
|
|
43252
43879
|
}
|
|
@@ -43284,7 +43911,7 @@ function useFloating(options) {
|
|
|
43284
43911
|
}));
|
|
43285
43912
|
}
|
|
43286
43913
|
}, [open]);
|
|
43287
|
-
const isMountedRef =
|
|
43914
|
+
const isMountedRef = React27.useRef(false);
|
|
43288
43915
|
index(() => {
|
|
43289
43916
|
isMountedRef.current = true;
|
|
43290
43917
|
return () => {
|
|
@@ -43301,17 +43928,17 @@ function useFloating(options) {
|
|
|
43301
43928
|
update();
|
|
43302
43929
|
}
|
|
43303
43930
|
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
43304
|
-
const refs =
|
|
43931
|
+
const refs = React27.useMemo(() => ({
|
|
43305
43932
|
reference: referenceRef,
|
|
43306
43933
|
floating: floatingRef,
|
|
43307
43934
|
setReference,
|
|
43308
43935
|
setFloating
|
|
43309
43936
|
}), [setReference, setFloating]);
|
|
43310
|
-
const elements =
|
|
43937
|
+
const elements = React27.useMemo(() => ({
|
|
43311
43938
|
reference: referenceEl,
|
|
43312
43939
|
floating: floatingEl
|
|
43313
43940
|
}), [referenceEl, floatingEl]);
|
|
43314
|
-
const floatingStyles =
|
|
43941
|
+
const floatingStyles = React27.useMemo(() => {
|
|
43315
43942
|
const initialStyles = {
|
|
43316
43943
|
position: strategy,
|
|
43317
43944
|
left: 0,
|
|
@@ -43337,7 +43964,7 @@ function useFloating(options) {
|
|
|
43337
43964
|
top: y
|
|
43338
43965
|
};
|
|
43339
43966
|
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
43340
|
-
return
|
|
43967
|
+
return React27.useMemo(() => ({
|
|
43341
43968
|
...data,
|
|
43342
43969
|
update,
|
|
43343
43970
|
refs,
|
|
@@ -43433,11 +44060,11 @@ var arrow3 = (options, deps) => {
|
|
|
43433
44060
|
};
|
|
43434
44061
|
|
|
43435
44062
|
// node_modules/@radix-ui/react-use-size/dist/index.mjs
|
|
43436
|
-
import * as
|
|
44063
|
+
import * as React28 from "react";
|
|
43437
44064
|
var __defProp17 = Object.defineProperty;
|
|
43438
44065
|
var __name15 = (target, value) => __defProp17(target, "name", { value, configurable: true });
|
|
43439
44066
|
function useSize(element) {
|
|
43440
|
-
const [size4, setSize] =
|
|
44067
|
+
const [size4, setSize] = React28.useState(void 0);
|
|
43441
44068
|
useLayoutEffect2(() => {
|
|
43442
44069
|
if (element) {
|
|
43443
44070
|
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
@@ -43481,8 +44108,8 @@ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
|
|
43481
44108
|
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
43482
44109
|
var Popper = /* @__PURE__ */ __name16((props) => {
|
|
43483
44110
|
const { __scopePopper, children } = props;
|
|
43484
|
-
const [anchor, setAnchor] =
|
|
43485
|
-
const [placementState, setPlacementState] =
|
|
44111
|
+
const [anchor, setAnchor] = React29.useState(null);
|
|
44112
|
+
const [placementState, setPlacementState] = React29.useState(void 0);
|
|
43486
44113
|
return /* @__PURE__ */ jsx27(
|
|
43487
44114
|
PopperProvider,
|
|
43488
44115
|
{
|
|
@@ -43496,13 +44123,13 @@ var Popper = /* @__PURE__ */ __name16((props) => {
|
|
|
43496
44123
|
);
|
|
43497
44124
|
}, "Popper");
|
|
43498
44125
|
var ANCHOR_NAME = "PopperAnchor";
|
|
43499
|
-
var PopperAnchor = /* @__PURE__ */
|
|
44126
|
+
var PopperAnchor = /* @__PURE__ */ React29.forwardRef(
|
|
43500
44127
|
/* @__PURE__ */ __name16(function PopperAnchor2(props, forwardedRef) {
|
|
43501
44128
|
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
43502
44129
|
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
43503
|
-
const ref =
|
|
44130
|
+
const ref = React29.useRef(null);
|
|
43504
44131
|
const onAnchorChange = context.onAnchorChange;
|
|
43505
|
-
const callbackRef =
|
|
44132
|
+
const callbackRef = React29.useCallback(
|
|
43506
44133
|
(node) => {
|
|
43507
44134
|
ref.current = node;
|
|
43508
44135
|
if (node) {
|
|
@@ -43512,8 +44139,8 @@ var PopperAnchor = /* @__PURE__ */ React28.forwardRef(
|
|
|
43512
44139
|
[onAnchorChange]
|
|
43513
44140
|
);
|
|
43514
44141
|
const composedRefs = useComposedRefs(forwardedRef, callbackRef);
|
|
43515
|
-
const anchorRef =
|
|
43516
|
-
|
|
44142
|
+
const anchorRef = React29.useRef(null);
|
|
44143
|
+
React29.useEffect(() => {
|
|
43517
44144
|
if (!virtualRef) {
|
|
43518
44145
|
return;
|
|
43519
44146
|
}
|
|
@@ -43539,7 +44166,7 @@ var PopperAnchor = /* @__PURE__ */ React28.forwardRef(
|
|
|
43539
44166
|
);
|
|
43540
44167
|
var CONTENT_NAME = "PopperContent";
|
|
43541
44168
|
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
|
|
43542
|
-
var PopperContent = /* @__PURE__ */
|
|
44169
|
+
var PopperContent = /* @__PURE__ */ React29.forwardRef(
|
|
43543
44170
|
/* @__PURE__ */ __name16(function PopperContent2(props, forwardedRef) {
|
|
43544
44171
|
const {
|
|
43545
44172
|
__scopePopper,
|
|
@@ -43558,9 +44185,9 @@ var PopperContent = /* @__PURE__ */ React28.forwardRef(
|
|
|
43558
44185
|
...contentProps
|
|
43559
44186
|
} = props;
|
|
43560
44187
|
const context = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
43561
|
-
const [content, setContent] =
|
|
44188
|
+
const [content, setContent] = React29.useState(null);
|
|
43562
44189
|
const composedRefs = useComposedRefs(forwardedRef, setContent);
|
|
43563
|
-
const [arrow4, setArrow] =
|
|
44190
|
+
const [arrow4, setArrow] = React29.useState(null);
|
|
43564
44191
|
const arrowSize = useSize(arrow4);
|
|
43565
44192
|
const arrowWidth = arrowSize?.width ?? 0;
|
|
43566
44193
|
const arrowHeight = arrowSize?.height ?? 0;
|
|
@@ -43640,7 +44267,7 @@ var PopperContent = /* @__PURE__ */ React28.forwardRef(
|
|
|
43640
44267
|
const arrowX = middlewareData.arrow?.x;
|
|
43641
44268
|
const arrowY = middlewareData.arrow?.y;
|
|
43642
44269
|
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
43643
|
-
const [contentZIndex, setContentZIndex] =
|
|
44270
|
+
const [contentZIndex, setContentZIndex] = React29.useState();
|
|
43644
44271
|
useLayoutEffect2(() => {
|
|
43645
44272
|
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
43646
44273
|
}, [content]);
|
|
@@ -43745,15 +44372,15 @@ var Anchor = PopperAnchor;
|
|
|
43745
44372
|
var Content = PopperContent;
|
|
43746
44373
|
|
|
43747
44374
|
// node_modules/@radix-ui/react-portal/dist/index.mjs
|
|
43748
|
-
import * as
|
|
44375
|
+
import * as React30 from "react";
|
|
43749
44376
|
import * as ReactDOM4 from "react-dom";
|
|
43750
44377
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
43751
44378
|
var __defProp19 = Object.defineProperty;
|
|
43752
44379
|
var __name17 = (target, value) => __defProp19(target, "name", { value, configurable: true });
|
|
43753
|
-
var Portal = /* @__PURE__ */
|
|
44380
|
+
var Portal = /* @__PURE__ */ React30.forwardRef(
|
|
43754
44381
|
/* @__PURE__ */ __name17(function Portal2(props, forwardedRef) {
|
|
43755
44382
|
const { container: containerProp, ...portalProps } = props;
|
|
43756
|
-
const [mounted, setMounted] =
|
|
44383
|
+
const [mounted, setMounted] = React30.useState(false);
|
|
43757
44384
|
useLayoutEffect2(() => setMounted(true), []);
|
|
43758
44385
|
const container = containerProp || mounted && globalThis?.document?.body;
|
|
43759
44386
|
return container ? ReactDOM4.createPortal(/* @__PURE__ */ jsx28(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
@@ -43762,11 +44389,11 @@ var Portal = /* @__PURE__ */ React29.forwardRef(
|
|
|
43762
44389
|
|
|
43763
44390
|
// node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
43764
44391
|
import * as React210 from "react";
|
|
43765
|
-
import * as
|
|
44392
|
+
import * as React31 from "react";
|
|
43766
44393
|
var __defProp20 = Object.defineProperty;
|
|
43767
44394
|
var __name18 = (target, value) => __defProp20(target, "name", { value, configurable: true });
|
|
43768
44395
|
function useStateMachine(initialState, machine) {
|
|
43769
|
-
return
|
|
44396
|
+
return React31.useReducer((state, event) => {
|
|
43770
44397
|
const nextState = machine[state][event];
|
|
43771
44398
|
return nextState ?? state;
|
|
43772
44399
|
}, initialState);
|
|
@@ -43940,17 +44567,17 @@ function getElementRef2(element) {
|
|
|
43940
44567
|
__name18(getElementRef2, "getElementRef");
|
|
43941
44568
|
|
|
43942
44569
|
// node_modules/@radix-ui/react-roving-focus/dist/index.mjs
|
|
43943
|
-
import * as
|
|
44570
|
+
import * as React33 from "react";
|
|
43944
44571
|
|
|
43945
44572
|
// node_modules/@radix-ui/react-use-is-hydrated/dist/index.mjs
|
|
43946
44573
|
import * as React211 from "react";
|
|
43947
|
-
import * as
|
|
44574
|
+
import * as React32 from "react";
|
|
43948
44575
|
var __defProp21 = Object.defineProperty;
|
|
43949
44576
|
var __name19 = (target, value) => __defProp21(target, "name", { value, configurable: true });
|
|
43950
44577
|
var _isHydrated = false;
|
|
43951
44578
|
function useIsHydrated() {
|
|
43952
|
-
const [isHydrated, setIsHydrated] =
|
|
43953
|
-
|
|
44579
|
+
const [isHydrated, setIsHydrated] = React32.useState(_isHydrated);
|
|
44580
|
+
React32.useEffect(() => {
|
|
43954
44581
|
if (!_isHydrated) {
|
|
43955
44582
|
_isHydrated = true;
|
|
43956
44583
|
setIsHydrated(true);
|
|
@@ -43988,13 +44615,13 @@ var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContext
|
|
|
43988
44615
|
[createCollectionScope]
|
|
43989
44616
|
);
|
|
43990
44617
|
var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME);
|
|
43991
|
-
var RovingFocusGroup = /* @__PURE__ */
|
|
44618
|
+
var RovingFocusGroup = /* @__PURE__ */ React33.forwardRef(
|
|
43992
44619
|
// blank line to reduce diff noise
|
|
43993
44620
|
/* @__PURE__ */ __name20(function RovingFocusGroup2(props, forwardedRef) {
|
|
43994
44621
|
return /* @__PURE__ */ jsx29(Collection.Provider, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx29(Collection.Slot, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx29(RovingFocusGroupImpl, { ...props, ref: forwardedRef }) }) });
|
|
43995
44622
|
}, "RovingFocusGroup")
|
|
43996
44623
|
);
|
|
43997
|
-
var RovingFocusGroupImpl = /* @__PURE__ */
|
|
44624
|
+
var RovingFocusGroupImpl = /* @__PURE__ */ React33.forwardRef(/* @__PURE__ */ __name20(function RovingFocusGroupImpl2(props, forwardedRef) {
|
|
43998
44625
|
const {
|
|
43999
44626
|
__scopeRovingFocusGroup,
|
|
44000
44627
|
orientation: orientation2,
|
|
@@ -44007,7 +44634,7 @@ var RovingFocusGroupImpl = /* @__PURE__ */ React32.forwardRef(/* @__PURE__ */ __
|
|
|
44007
44634
|
preventScrollOnEntryFocus = false,
|
|
44008
44635
|
...groupProps
|
|
44009
44636
|
} = props;
|
|
44010
|
-
const ref =
|
|
44637
|
+
const ref = React33.useRef(null);
|
|
44011
44638
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
44012
44639
|
const direction = useDirection(dir);
|
|
44013
44640
|
const [currentTabStopId, setCurrentTabStopId] = useControllableState({
|
|
@@ -44016,12 +44643,12 @@ var RovingFocusGroupImpl = /* @__PURE__ */ React32.forwardRef(/* @__PURE__ */ __
|
|
|
44016
44643
|
onChange: onCurrentTabStopIdChange,
|
|
44017
44644
|
caller: GROUP_NAME
|
|
44018
44645
|
});
|
|
44019
|
-
const [isTabbingBackOut, setIsTabbingBackOut] =
|
|
44646
|
+
const [isTabbingBackOut, setIsTabbingBackOut] = React33.useState(false);
|
|
44020
44647
|
const handleEntryFocus = useCallbackRef(onEntryFocus);
|
|
44021
44648
|
const getItems = useCollection(__scopeRovingFocusGroup);
|
|
44022
|
-
const isClickFocusRef =
|
|
44023
|
-
const [focusableItemsCount, setFocusableItemsCount] =
|
|
44024
|
-
|
|
44649
|
+
const isClickFocusRef = React33.useRef(false);
|
|
44650
|
+
const [focusableItemsCount, setFocusableItemsCount] = React33.useState(0);
|
|
44651
|
+
React33.useEffect(() => {
|
|
44025
44652
|
const node = ref.current;
|
|
44026
44653
|
if (node) {
|
|
44027
44654
|
node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
@@ -44036,16 +44663,16 @@ var RovingFocusGroupImpl = /* @__PURE__ */ React32.forwardRef(/* @__PURE__ */ __
|
|
|
44036
44663
|
dir: direction,
|
|
44037
44664
|
loop,
|
|
44038
44665
|
currentTabStopId,
|
|
44039
|
-
onItemFocus:
|
|
44666
|
+
onItemFocus: React33.useCallback(
|
|
44040
44667
|
(tabStopId) => setCurrentTabStopId(tabStopId),
|
|
44041
44668
|
[setCurrentTabStopId]
|
|
44042
44669
|
),
|
|
44043
|
-
onItemShiftTab:
|
|
44044
|
-
onFocusableItemAdd:
|
|
44670
|
+
onItemShiftTab: React33.useCallback(() => setIsTabbingBackOut(true), []),
|
|
44671
|
+
onFocusableItemAdd: React33.useCallback(
|
|
44045
44672
|
() => setFocusableItemsCount((prevCount) => prevCount + 1),
|
|
44046
44673
|
[]
|
|
44047
44674
|
),
|
|
44048
|
-
onFocusableItemRemove:
|
|
44675
|
+
onFocusableItemRemove: React33.useCallback(
|
|
44049
44676
|
() => setFocusableItemsCount((prevCount) => prevCount - 1),
|
|
44050
44677
|
[]
|
|
44051
44678
|
),
|
|
@@ -44085,7 +44712,7 @@ var RovingFocusGroupImpl = /* @__PURE__ */ React32.forwardRef(/* @__PURE__ */ __
|
|
|
44085
44712
|
);
|
|
44086
44713
|
}, "RovingFocusGroupImpl"));
|
|
44087
44714
|
var ITEM_NAME = "RovingFocusGroupItem";
|
|
44088
|
-
var RovingFocusGroupItem = /* @__PURE__ */
|
|
44715
|
+
var RovingFocusGroupItem = /* @__PURE__ */ React33.forwardRef(
|
|
44089
44716
|
// blank line to reduce diff noise
|
|
44090
44717
|
/* @__PURE__ */ __name20(function RovingFocusGroupItem2(props, forwardedRef) {
|
|
44091
44718
|
const {
|
|
@@ -44110,7 +44737,7 @@ var RovingFocusGroupItem = /* @__PURE__ */ React32.forwardRef(
|
|
|
44110
44737
|
onFocusableItemAdd();
|
|
44111
44738
|
return () => onFocusableItemRemove();
|
|
44112
44739
|
}, [isHydrated, focusable, onFocusableItemAdd, onFocusableItemRemove]);
|
|
44113
|
-
|
|
44740
|
+
React33.useEffect(() => {
|
|
44114
44741
|
if (isHydrated || !focusable) {
|
|
44115
44742
|
return;
|
|
44116
44743
|
}
|
|
@@ -44356,10 +44983,10 @@ function __spreadArray(to, from, pack) {
|
|
|
44356
44983
|
}
|
|
44357
44984
|
|
|
44358
44985
|
// node_modules/react-remove-scroll/dist/es2015/Combination.js
|
|
44359
|
-
import * as
|
|
44986
|
+
import * as React40 from "react";
|
|
44360
44987
|
|
|
44361
44988
|
// node_modules/react-remove-scroll/dist/es2015/UI.js
|
|
44362
|
-
import * as
|
|
44989
|
+
import * as React36 from "react";
|
|
44363
44990
|
|
|
44364
44991
|
// node_modules/react-remove-scroll-bar/dist/es2015/constants.js
|
|
44365
44992
|
var zeroRightClassName = "right-scroll-bar-position";
|
|
@@ -44406,8 +45033,8 @@ function useCallbackRef2(initialValue, callback) {
|
|
|
44406
45033
|
}
|
|
44407
45034
|
|
|
44408
45035
|
// node_modules/use-callback-ref/dist/es2015/useMergeRef.js
|
|
44409
|
-
import * as
|
|
44410
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ?
|
|
45036
|
+
import * as React34 from "react";
|
|
45037
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React34.useLayoutEffect : React34.useEffect;
|
|
44411
45038
|
var currentValues = /* @__PURE__ */ new WeakMap();
|
|
44412
45039
|
function useMergeRefs(refs, defaultValue) {
|
|
44413
45040
|
var callbackRef = useCallbackRef2(defaultValue || null, function(newValue) {
|
|
@@ -44524,7 +45151,7 @@ function createSidecarMedium(options) {
|
|
|
44524
45151
|
}
|
|
44525
45152
|
|
|
44526
45153
|
// node_modules/use-sidecar/dist/es2015/exports.js
|
|
44527
|
-
import * as
|
|
45154
|
+
import * as React35 from "react";
|
|
44528
45155
|
var SideCar = function(_a) {
|
|
44529
45156
|
var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
|
|
44530
45157
|
if (!sideCar) {
|
|
@@ -44534,7 +45161,7 @@ var SideCar = function(_a) {
|
|
|
44534
45161
|
if (!Target) {
|
|
44535
45162
|
throw new Error("Sidecar medium not found");
|
|
44536
45163
|
}
|
|
44537
|
-
return
|
|
45164
|
+
return React35.createElement(Target, __assign({}, rest));
|
|
44538
45165
|
};
|
|
44539
45166
|
SideCar.isSideCarExport = true;
|
|
44540
45167
|
function exportSidecar(medium, exported) {
|
|
@@ -44549,9 +45176,9 @@ var effectCar = createSidecarMedium();
|
|
|
44549
45176
|
var nothing = function() {
|
|
44550
45177
|
return;
|
|
44551
45178
|
};
|
|
44552
|
-
var RemoveScroll =
|
|
44553
|
-
var ref =
|
|
44554
|
-
var _a =
|
|
45179
|
+
var RemoveScroll = React36.forwardRef(function(props, parentRef) {
|
|
45180
|
+
var ref = React36.useRef(null);
|
|
45181
|
+
var _a = React36.useState({
|
|
44555
45182
|
onScrollCapture: nothing,
|
|
44556
45183
|
onWheelCapture: nothing,
|
|
44557
45184
|
onTouchMoveCapture: nothing
|
|
@@ -44560,11 +45187,11 @@ var RemoveScroll = React35.forwardRef(function(props, parentRef) {
|
|
|
44560
45187
|
var SideCar2 = sideCar;
|
|
44561
45188
|
var containerRef = useMergeRefs([ref, parentRef]);
|
|
44562
45189
|
var containerProps = __assign(__assign({}, rest), callbacks);
|
|
44563
|
-
return
|
|
44564
|
-
|
|
45190
|
+
return React36.createElement(
|
|
45191
|
+
React36.Fragment,
|
|
44565
45192
|
null,
|
|
44566
|
-
enabled &&
|
|
44567
|
-
forwardProps ?
|
|
45193
|
+
enabled && React36.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noRelative, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
|
|
45194
|
+
forwardProps ? React36.cloneElement(React36.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React36.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
|
|
44568
45195
|
);
|
|
44569
45196
|
});
|
|
44570
45197
|
RemoveScroll.defaultProps = {
|
|
@@ -44578,13 +45205,13 @@ RemoveScroll.classNames = {
|
|
|
44578
45205
|
};
|
|
44579
45206
|
|
|
44580
45207
|
// node_modules/react-remove-scroll/dist/es2015/SideEffect.js
|
|
44581
|
-
import * as
|
|
45208
|
+
import * as React39 from "react";
|
|
44582
45209
|
|
|
44583
45210
|
// node_modules/react-remove-scroll-bar/dist/es2015/component.js
|
|
44584
|
-
import * as
|
|
45211
|
+
import * as React38 from "react";
|
|
44585
45212
|
|
|
44586
45213
|
// node_modules/react-style-singleton/dist/es2015/hook.js
|
|
44587
|
-
import * as
|
|
45214
|
+
import * as React37 from "react";
|
|
44588
45215
|
|
|
44589
45216
|
// node_modules/get-nonce/dist/es2015/index.js
|
|
44590
45217
|
var currentNonce;
|
|
@@ -44648,7 +45275,7 @@ var stylesheetSingleton = function() {
|
|
|
44648
45275
|
var styleHookSingleton = function() {
|
|
44649
45276
|
var sheet = stylesheetSingleton();
|
|
44650
45277
|
return function(styles, isDynamic) {
|
|
44651
|
-
|
|
45278
|
+
React37.useEffect(function() {
|
|
44652
45279
|
sheet.add(styles);
|
|
44653
45280
|
return function() {
|
|
44654
45281
|
sheet.remove();
|
|
@@ -44722,7 +45349,7 @@ var getCurrentUseCounter = function() {
|
|
|
44722
45349
|
return isFinite(counter) ? counter : 0;
|
|
44723
45350
|
};
|
|
44724
45351
|
var useLockAttribute = function() {
|
|
44725
|
-
|
|
45352
|
+
React38.useEffect(function() {
|
|
44726
45353
|
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
|
|
44727
45354
|
return function() {
|
|
44728
45355
|
var newCounter = getCurrentUseCounter() - 1;
|
|
@@ -44737,10 +45364,10 @@ var useLockAttribute = function() {
|
|
|
44737
45364
|
var RemoveScrollBar = function(_a) {
|
|
44738
45365
|
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
|
|
44739
45366
|
useLockAttribute();
|
|
44740
|
-
var gap =
|
|
45367
|
+
var gap = React38.useMemo(function() {
|
|
44741
45368
|
return getGapWidth(gapMode);
|
|
44742
45369
|
}, [gapMode]);
|
|
44743
|
-
return
|
|
45370
|
+
return React38.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
|
|
44744
45371
|
};
|
|
44745
45372
|
|
|
44746
45373
|
// node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
|
|
@@ -44881,16 +45508,16 @@ var generateStyle = function(id) {
|
|
|
44881
45508
|
var idCounter = 0;
|
|
44882
45509
|
var lockStack = [];
|
|
44883
45510
|
function RemoveScrollSideCar(props) {
|
|
44884
|
-
var shouldPreventQueue =
|
|
44885
|
-
var touchStartRef =
|
|
44886
|
-
var activeAxis =
|
|
44887
|
-
var id =
|
|
44888
|
-
var Style2 =
|
|
44889
|
-
var lastProps =
|
|
44890
|
-
|
|
45511
|
+
var shouldPreventQueue = React39.useRef([]);
|
|
45512
|
+
var touchStartRef = React39.useRef([0, 0]);
|
|
45513
|
+
var activeAxis = React39.useRef();
|
|
45514
|
+
var id = React39.useState(idCounter++)[0];
|
|
45515
|
+
var Style2 = React39.useState(styleSingleton)[0];
|
|
45516
|
+
var lastProps = React39.useRef(props);
|
|
45517
|
+
React39.useEffect(function() {
|
|
44891
45518
|
lastProps.current = props;
|
|
44892
45519
|
}, [props]);
|
|
44893
|
-
|
|
45520
|
+
React39.useEffect(function() {
|
|
44894
45521
|
if (props.inert) {
|
|
44895
45522
|
document.body.classList.add("block-interactivity-".concat(id));
|
|
44896
45523
|
var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
|
@@ -44906,7 +45533,7 @@ function RemoveScrollSideCar(props) {
|
|
|
44906
45533
|
}
|
|
44907
45534
|
return;
|
|
44908
45535
|
}, [props.inert, props.lockRef.current, props.shards]);
|
|
44909
|
-
var shouldCancelEvent =
|
|
45536
|
+
var shouldCancelEvent = React39.useCallback(function(event, parent) {
|
|
44910
45537
|
if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
|
|
44911
45538
|
return !lastProps.current.allowPinchZoom;
|
|
44912
45539
|
}
|
|
@@ -44948,7 +45575,7 @@ function RemoveScrollSideCar(props) {
|
|
|
44948
45575
|
var cancelingAxis = activeAxis.current || currentAxis;
|
|
44949
45576
|
return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
|
|
44950
45577
|
}, []);
|
|
44951
|
-
var shouldPrevent =
|
|
45578
|
+
var shouldPrevent = React39.useCallback(function(_event) {
|
|
44952
45579
|
var event = _event;
|
|
44953
45580
|
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
|
|
44954
45581
|
return;
|
|
@@ -44975,7 +45602,7 @@ function RemoveScrollSideCar(props) {
|
|
|
44975
45602
|
}
|
|
44976
45603
|
}
|
|
44977
45604
|
}, []);
|
|
44978
|
-
var shouldCancel =
|
|
45605
|
+
var shouldCancel = React39.useCallback(function(name, delta, target, should) {
|
|
44979
45606
|
var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
|
|
44980
45607
|
shouldPreventQueue.current.push(event);
|
|
44981
45608
|
setTimeout(function() {
|
|
@@ -44984,17 +45611,17 @@ function RemoveScrollSideCar(props) {
|
|
|
44984
45611
|
});
|
|
44985
45612
|
}, 1);
|
|
44986
45613
|
}, []);
|
|
44987
|
-
var scrollTouchStart =
|
|
45614
|
+
var scrollTouchStart = React39.useCallback(function(event) {
|
|
44988
45615
|
touchStartRef.current = getTouchXY(event);
|
|
44989
45616
|
activeAxis.current = void 0;
|
|
44990
45617
|
}, []);
|
|
44991
|
-
var scrollWheel =
|
|
45618
|
+
var scrollWheel = React39.useCallback(function(event) {
|
|
44992
45619
|
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
44993
45620
|
}, []);
|
|
44994
|
-
var scrollTouchMove =
|
|
45621
|
+
var scrollTouchMove = React39.useCallback(function(event) {
|
|
44995
45622
|
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
44996
45623
|
}, []);
|
|
44997
|
-
|
|
45624
|
+
React39.useEffect(function() {
|
|
44998
45625
|
lockStack.push(Style2);
|
|
44999
45626
|
props.setCallbacks({
|
|
45000
45627
|
onScrollCapture: scrollWheel,
|
|
@@ -45014,11 +45641,11 @@ function RemoveScrollSideCar(props) {
|
|
|
45014
45641
|
};
|
|
45015
45642
|
}, []);
|
|
45016
45643
|
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
|
45017
|
-
return
|
|
45018
|
-
|
|
45644
|
+
return React39.createElement(
|
|
45645
|
+
React39.Fragment,
|
|
45019
45646
|
null,
|
|
45020
|
-
inert ?
|
|
45021
|
-
removeScrollBar ?
|
|
45647
|
+
inert ? React39.createElement(Style2, { styles: generateStyle(id) }) : null,
|
|
45648
|
+
removeScrollBar ? React39.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
|
|
45022
45649
|
);
|
|
45023
45650
|
}
|
|
45024
45651
|
function getOutermostShadowParent(node) {
|
|
@@ -45037,8 +45664,8 @@ function getOutermostShadowParent(node) {
|
|
|
45037
45664
|
var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar);
|
|
45038
45665
|
|
|
45039
45666
|
// node_modules/react-remove-scroll/dist/es2015/Combination.js
|
|
45040
|
-
var ReactRemoveScroll =
|
|
45041
|
-
return
|
|
45667
|
+
var ReactRemoveScroll = React40.forwardRef(function(props, ref) {
|
|
45668
|
+
return React40.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: sidecar_default }));
|
|
45042
45669
|
});
|
|
45043
45670
|
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
|
45044
45671
|
var Combination_default = ReactRemoveScroll;
|
|
@@ -45073,11 +45700,11 @@ var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
|
|
|
45073
45700
|
var Menu = /* @__PURE__ */ __name21((props) => {
|
|
45074
45701
|
const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
|
|
45075
45702
|
const popperScope = usePopperScope(__scopeMenu);
|
|
45076
|
-
const [content, setContent] =
|
|
45077
|
-
const isUsingKeyboardRef =
|
|
45703
|
+
const [content, setContent] = React41.useState(null);
|
|
45704
|
+
const isUsingKeyboardRef = React41.useRef(false);
|
|
45078
45705
|
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
45079
45706
|
const direction = useDirection(dir);
|
|
45080
|
-
|
|
45707
|
+
React41.useEffect(() => {
|
|
45081
45708
|
const handleKeyDown = /* @__PURE__ */ __name21(() => {
|
|
45082
45709
|
isUsingKeyboardRef.current = true;
|
|
45083
45710
|
document.addEventListener("pointerdown", handlePointer, { capture: true, once: true });
|
|
@@ -45091,7 +45718,7 @@ var Menu = /* @__PURE__ */ __name21((props) => {
|
|
|
45091
45718
|
document.removeEventListener("pointermove", handlePointer, { capture: true });
|
|
45092
45719
|
};
|
|
45093
45720
|
}, []);
|
|
45094
|
-
|
|
45721
|
+
React41.useEffect(() => {
|
|
45095
45722
|
if (!open) {
|
|
45096
45723
|
return;
|
|
45097
45724
|
}
|
|
@@ -45111,7 +45738,7 @@ var Menu = /* @__PURE__ */ __name21((props) => {
|
|
|
45111
45738
|
MenuRootProvider,
|
|
45112
45739
|
{
|
|
45113
45740
|
scope: __scopeMenu,
|
|
45114
|
-
onClose:
|
|
45741
|
+
onClose: React41.useCallback(() => handleOpenChange(false), [handleOpenChange]),
|
|
45115
45742
|
isUsingKeyboardRef,
|
|
45116
45743
|
dir: direction,
|
|
45117
45744
|
modal,
|
|
@@ -45121,7 +45748,7 @@ var Menu = /* @__PURE__ */ __name21((props) => {
|
|
|
45121
45748
|
}
|
|
45122
45749
|
) });
|
|
45123
45750
|
}, "Menu");
|
|
45124
|
-
var MenuAnchor = /* @__PURE__ */
|
|
45751
|
+
var MenuAnchor = /* @__PURE__ */ React41.forwardRef(
|
|
45125
45752
|
/* @__PURE__ */ __name21(function MenuAnchor2(props, forwardedRef) {
|
|
45126
45753
|
const { __scopeMenu, ...anchorProps } = props;
|
|
45127
45754
|
const popperScope = usePopperScope(__scopeMenu);
|
|
@@ -45139,7 +45766,7 @@ var MenuPortal = /* @__PURE__ */ __name21((props) => {
|
|
|
45139
45766
|
}, "MenuPortal");
|
|
45140
45767
|
var CONTENT_NAME2 = "MenuContent";
|
|
45141
45768
|
var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME2);
|
|
45142
|
-
var MenuContent = /* @__PURE__ */
|
|
45769
|
+
var MenuContent = /* @__PURE__ */ React41.forwardRef(
|
|
45143
45770
|
/* @__PURE__ */ __name21(function MenuContent2(props, forwardedRef) {
|
|
45144
45771
|
const portalContext = usePortalContext(CONTENT_NAME2, props.__scopeMenu);
|
|
45145
45772
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
@@ -45148,13 +45775,13 @@ var MenuContent = /* @__PURE__ */ React40.forwardRef(
|
|
|
45148
45775
|
return /* @__PURE__ */ jsx30(Collection2.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx30(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx30(Collection2.Slot, { scope: props.__scopeMenu, children: rootContext.modal ? /* @__PURE__ */ jsx30(MenuRootContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx30(MenuRootContentNonModal, { ...contentProps, ref: forwardedRef }) }) }) });
|
|
45149
45776
|
}, "MenuContent")
|
|
45150
45777
|
);
|
|
45151
|
-
var MenuRootContentModal = /* @__PURE__ */
|
|
45778
|
+
var MenuRootContentModal = /* @__PURE__ */ React41.forwardRef(
|
|
45152
45779
|
// blank line to reduce diff noise
|
|
45153
45780
|
/* @__PURE__ */ __name21(function MenuRootContentModal2(props, forwardedRef) {
|
|
45154
45781
|
const context = useMenuContext(CONTENT_NAME2, props.__scopeMenu);
|
|
45155
|
-
const ref =
|
|
45782
|
+
const ref = React41.useRef(null);
|
|
45156
45783
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
45157
|
-
|
|
45784
|
+
React41.useEffect(() => {
|
|
45158
45785
|
const content = ref.current;
|
|
45159
45786
|
if (content) return hideOthers(content);
|
|
45160
45787
|
}, []);
|
|
@@ -45176,7 +45803,7 @@ var MenuRootContentModal = /* @__PURE__ */ React40.forwardRef(
|
|
|
45176
45803
|
);
|
|
45177
45804
|
}, "MenuRootContentModal")
|
|
45178
45805
|
);
|
|
45179
|
-
var MenuRootContentNonModal = /* @__PURE__ */
|
|
45806
|
+
var MenuRootContentNonModal = /* @__PURE__ */ React41.forwardRef(/* @__PURE__ */ __name21(function MenuRootContentNonModal2(props, forwardedRef) {
|
|
45180
45807
|
const context = useMenuContext(CONTENT_NAME2, props.__scopeMenu);
|
|
45181
45808
|
return /* @__PURE__ */ jsx30(
|
|
45182
45809
|
MenuContentImpl,
|
|
@@ -45191,7 +45818,7 @@ var MenuRootContentNonModal = /* @__PURE__ */ React40.forwardRef(/* @__PURE__ */
|
|
|
45191
45818
|
);
|
|
45192
45819
|
}, "MenuRootContentNonModal"));
|
|
45193
45820
|
var Slot = createSlot("MenuContent.ScrollLock");
|
|
45194
|
-
var MenuContentImpl = /* @__PURE__ */
|
|
45821
|
+
var MenuContentImpl = /* @__PURE__ */ React41.forwardRef(
|
|
45195
45822
|
// blank line to reduce diff noise
|
|
45196
45823
|
/* @__PURE__ */ __name21(function MenuContentImpl2(props, forwardedRef) {
|
|
45197
45824
|
const {
|
|
@@ -45215,16 +45842,16 @@ var MenuContentImpl = /* @__PURE__ */ React40.forwardRef(
|
|
|
45215
45842
|
const popperScope = usePopperScope(__scopeMenu);
|
|
45216
45843
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
45217
45844
|
const getItems = useCollection2(__scopeMenu);
|
|
45218
|
-
const [currentItemId, setCurrentItemId] =
|
|
45219
|
-
const contentRef =
|
|
45845
|
+
const [currentItemId, setCurrentItemId] = React41.useState(null);
|
|
45846
|
+
const contentRef = React41.useRef(null);
|
|
45220
45847
|
const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
|
|
45221
|
-
const timerRef =
|
|
45222
|
-
const searchRef =
|
|
45223
|
-
const pointerGraceTimerRef =
|
|
45224
|
-
const pointerGraceIntentRef =
|
|
45225
|
-
const pointerDirRef =
|
|
45226
|
-
const lastPointerXRef =
|
|
45227
|
-
const ScrollLockWrapper = disableOutsideScroll ? Combination_default :
|
|
45848
|
+
const timerRef = React41.useRef(0);
|
|
45849
|
+
const searchRef = React41.useRef("");
|
|
45850
|
+
const pointerGraceTimerRef = React41.useRef(0);
|
|
45851
|
+
const pointerGraceIntentRef = React41.useRef(null);
|
|
45852
|
+
const pointerDirRef = React41.useRef("right");
|
|
45853
|
+
const lastPointerXRef = React41.useRef(0);
|
|
45854
|
+
const ScrollLockWrapper = disableOutsideScroll ? Combination_default : React41.Fragment;
|
|
45228
45855
|
const scrollLockWrapperProps = disableOutsideScroll ? { as: Slot, allowPinchZoom: true } : void 0;
|
|
45229
45856
|
const handleTypeaheadSearch = /* @__PURE__ */ __name21((key) => {
|
|
45230
45857
|
const search = searchRef.current + key;
|
|
@@ -45243,11 +45870,11 @@ var MenuContentImpl = /* @__PURE__ */ React40.forwardRef(
|
|
|
45243
45870
|
setTimeout(() => newItem.focus());
|
|
45244
45871
|
}
|
|
45245
45872
|
}, "handleTypeaheadSearch");
|
|
45246
|
-
|
|
45873
|
+
React41.useEffect(() => {
|
|
45247
45874
|
return () => window.clearTimeout(timerRef.current);
|
|
45248
45875
|
}, []);
|
|
45249
45876
|
useFocusGuards();
|
|
45250
|
-
const isPointerMovingToSubmenu =
|
|
45877
|
+
const isPointerMovingToSubmenu = React41.useCallback((event) => {
|
|
45251
45878
|
const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
|
|
45252
45879
|
return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
|
|
45253
45880
|
}, []);
|
|
@@ -45256,13 +45883,13 @@ var MenuContentImpl = /* @__PURE__ */ React40.forwardRef(
|
|
|
45256
45883
|
{
|
|
45257
45884
|
scope: __scopeMenu,
|
|
45258
45885
|
searchRef,
|
|
45259
|
-
onItemEnter:
|
|
45886
|
+
onItemEnter: React41.useCallback(
|
|
45260
45887
|
(event) => {
|
|
45261
45888
|
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
45262
45889
|
},
|
|
45263
45890
|
[isPointerMovingToSubmenu]
|
|
45264
45891
|
),
|
|
45265
|
-
onItemLeave:
|
|
45892
|
+
onItemLeave: React41.useCallback(
|
|
45266
45893
|
(event) => {
|
|
45267
45894
|
if (isPointerMovingToSubmenu(event)) return;
|
|
45268
45895
|
contentRef.current?.focus();
|
|
@@ -45270,14 +45897,14 @@ var MenuContentImpl = /* @__PURE__ */ React40.forwardRef(
|
|
|
45270
45897
|
},
|
|
45271
45898
|
[isPointerMovingToSubmenu]
|
|
45272
45899
|
),
|
|
45273
|
-
onTriggerLeave:
|
|
45900
|
+
onTriggerLeave: React41.useCallback(
|
|
45274
45901
|
(event) => {
|
|
45275
45902
|
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
45276
45903
|
},
|
|
45277
45904
|
[isPointerMovingToSubmenu]
|
|
45278
45905
|
),
|
|
45279
45906
|
pointerGraceTimerRef,
|
|
45280
|
-
onPointerGraceIntentChange:
|
|
45907
|
+
onPointerGraceIntentChange: React41.useCallback((intent) => {
|
|
45281
45908
|
pointerGraceIntentRef.current = intent;
|
|
45282
45909
|
}, []),
|
|
45283
45910
|
children: /* @__PURE__ */ jsx30(ScrollLockWrapper, { ...scrollLockWrapperProps, children: /* @__PURE__ */ jsx30(
|
|
@@ -45376,15 +46003,15 @@ var MenuContentImpl = /* @__PURE__ */ React40.forwardRef(
|
|
|
45376
46003
|
);
|
|
45377
46004
|
var ITEM_NAME2 = "MenuItem";
|
|
45378
46005
|
var ITEM_SELECT = "menu.itemSelect";
|
|
45379
|
-
var MenuItem = /* @__PURE__ */
|
|
46006
|
+
var MenuItem = /* @__PURE__ */ React41.forwardRef(
|
|
45380
46007
|
// blank line to reduce diff noise
|
|
45381
46008
|
/* @__PURE__ */ __name21(function MenuItem2(props, forwardedRef) {
|
|
45382
46009
|
const { disabled = false, onSelect, ...itemProps } = props;
|
|
45383
|
-
const ref =
|
|
46010
|
+
const ref = React41.useRef(null);
|
|
45384
46011
|
const rootContext = useMenuRootContext(ITEM_NAME2, props.__scopeMenu);
|
|
45385
46012
|
const contentContext = useMenuContentContext(ITEM_NAME2, props.__scopeMenu);
|
|
45386
46013
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
45387
|
-
const isPointerDownRef =
|
|
46014
|
+
const isPointerDownRef = React41.useRef(false);
|
|
45388
46015
|
const handleSelect = /* @__PURE__ */ __name21(() => {
|
|
45389
46016
|
const menuItem = ref.current;
|
|
45390
46017
|
if (!disabled && menuItem) {
|
|
@@ -45429,16 +46056,16 @@ var MenuItem = /* @__PURE__ */ React40.forwardRef(
|
|
|
45429
46056
|
);
|
|
45430
46057
|
}, "MenuItem")
|
|
45431
46058
|
);
|
|
45432
|
-
var MenuItemImpl = /* @__PURE__ */
|
|
46059
|
+
var MenuItemImpl = /* @__PURE__ */ React41.forwardRef(
|
|
45433
46060
|
/* @__PURE__ */ __name21(function MenuItemImpl2(props, forwardedRef) {
|
|
45434
46061
|
const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
|
|
45435
46062
|
const contentContext = useMenuContentContext(ITEM_NAME2, __scopeMenu);
|
|
45436
46063
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
45437
|
-
const ref =
|
|
46064
|
+
const ref = React41.useRef(null);
|
|
45438
46065
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
45439
|
-
const [isFocused, setIsFocused] =
|
|
45440
|
-
const [textContent, setTextContent] =
|
|
45441
|
-
|
|
46066
|
+
const [isFocused, setIsFocused] = React41.useState(false);
|
|
46067
|
+
const [textContent, setTextContent] = React41.useState("");
|
|
46068
|
+
React41.useEffect(() => {
|
|
45442
46069
|
const menuItem = ref.current;
|
|
45443
46070
|
if (menuItem) {
|
|
45444
46071
|
setTextContent((menuItem.textContent ?? "").trim());
|
|
@@ -45496,7 +46123,7 @@ var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(
|
|
|
45496
46123
|
ITEM_INDICATOR_NAME,
|
|
45497
46124
|
{ checked: false }
|
|
45498
46125
|
);
|
|
45499
|
-
var MenuSeparator = /* @__PURE__ */
|
|
46126
|
+
var MenuSeparator = /* @__PURE__ */ React41.forwardRef(
|
|
45500
46127
|
/* @__PURE__ */ __name21(function MenuSeparator2(props, forwardedRef) {
|
|
45501
46128
|
const { __scopeMenu, ...separatorProps } = props;
|
|
45502
46129
|
return /* @__PURE__ */ jsx30(
|
|
@@ -45516,10 +46143,10 @@ var MenuSub = /* @__PURE__ */ __name21((props) => {
|
|
|
45516
46143
|
const { __scopeMenu, children, open = false, onOpenChange } = props;
|
|
45517
46144
|
const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
|
|
45518
46145
|
const popperScope = usePopperScope(__scopeMenu);
|
|
45519
|
-
const [trigger, setTrigger] =
|
|
45520
|
-
const [content, setContent] =
|
|
46146
|
+
const [trigger, setTrigger] = React41.useState(null);
|
|
46147
|
+
const [content, setContent] = React41.useState(null);
|
|
45521
46148
|
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
45522
|
-
|
|
46149
|
+
React41.useEffect(() => {
|
|
45523
46150
|
if (parentMenuContext.open === false) handleOpenChange(false);
|
|
45524
46151
|
return () => handleOpenChange(false);
|
|
45525
46152
|
}, [parentMenuContext.open, handleOpenChange]);
|
|
@@ -45546,21 +46173,21 @@ var MenuSub = /* @__PURE__ */ __name21((props) => {
|
|
|
45546
46173
|
) });
|
|
45547
46174
|
}, "MenuSub");
|
|
45548
46175
|
var SUB_TRIGGER_NAME = "MenuSubTrigger";
|
|
45549
|
-
var MenuSubTrigger = /* @__PURE__ */
|
|
46176
|
+
var MenuSubTrigger = /* @__PURE__ */ React41.forwardRef(
|
|
45550
46177
|
/* @__PURE__ */ __name21(function MenuSubTrigger2(props, forwardedRef) {
|
|
45551
46178
|
const context = useMenuContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
45552
46179
|
const rootContext = useMenuRootContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
45553
46180
|
const subContext = useMenuSubContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
45554
46181
|
const contentContext = useMenuContentContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
45555
|
-
const openTimerRef =
|
|
46182
|
+
const openTimerRef = React41.useRef(null);
|
|
45556
46183
|
const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
|
|
45557
46184
|
const scope = { __scopeMenu: props.__scopeMenu };
|
|
45558
|
-
const clearOpenTimer =
|
|
46185
|
+
const clearOpenTimer = React41.useCallback(() => {
|
|
45559
46186
|
if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
|
|
45560
46187
|
openTimerRef.current = null;
|
|
45561
46188
|
}, []);
|
|
45562
|
-
|
|
45563
|
-
|
|
46189
|
+
React41.useEffect(() => clearOpenTimer, [clearOpenTimer]);
|
|
46190
|
+
React41.useEffect(() => {
|
|
45564
46191
|
const pointerGraceTimer = pointerGraceTimerRef.current;
|
|
45565
46192
|
return () => {
|
|
45566
46193
|
window.clearTimeout(pointerGraceTimer);
|
|
@@ -45652,14 +46279,14 @@ var MenuSubTrigger = /* @__PURE__ */ React40.forwardRef(
|
|
|
45652
46279
|
}, "MenuSubTrigger")
|
|
45653
46280
|
);
|
|
45654
46281
|
var SUB_CONTENT_NAME = "MenuSubContent";
|
|
45655
|
-
var MenuSubContent = /* @__PURE__ */
|
|
46282
|
+
var MenuSubContent = /* @__PURE__ */ React41.forwardRef(
|
|
45656
46283
|
/* @__PURE__ */ __name21(function MenuSubContent2(props, forwardedRef) {
|
|
45657
46284
|
const portalContext = usePortalContext(CONTENT_NAME2, props.__scopeMenu);
|
|
45658
46285
|
const { forceMount = portalContext.forceMount, align = "start", ...subContentProps } = props;
|
|
45659
46286
|
const context = useMenuContext(CONTENT_NAME2, props.__scopeMenu);
|
|
45660
46287
|
const rootContext = useMenuRootContext(CONTENT_NAME2, props.__scopeMenu);
|
|
45661
46288
|
const subContext = useMenuSubContext(SUB_CONTENT_NAME, props.__scopeMenu);
|
|
45662
|
-
const ref =
|
|
46289
|
+
const ref = React41.useRef(null);
|
|
45663
46290
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
45664
46291
|
return /* @__PURE__ */ jsx30(Collection2.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx30(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx30(Collection2.Slot, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx30(
|
|
45665
46292
|
MenuContentImpl,
|
|
@@ -45794,7 +46421,7 @@ var DropdownMenu = /* @__PURE__ */ __name22((props) => {
|
|
|
45794
46421
|
modal = true
|
|
45795
46422
|
} = props;
|
|
45796
46423
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
45797
|
-
const triggerRef =
|
|
46424
|
+
const triggerRef = React42.useRef(null);
|
|
45798
46425
|
const [open, setOpen] = useControllableState({
|
|
45799
46426
|
prop: openProp,
|
|
45800
46427
|
defaultProp: defaultOpen ?? false,
|
|
@@ -45810,14 +46437,14 @@ var DropdownMenu = /* @__PURE__ */ __name22((props) => {
|
|
|
45810
46437
|
contentId: useId(),
|
|
45811
46438
|
open,
|
|
45812
46439
|
onOpenChange: setOpen,
|
|
45813
|
-
onOpenToggle:
|
|
46440
|
+
onOpenToggle: React42.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
45814
46441
|
modal,
|
|
45815
46442
|
children: /* @__PURE__ */ jsx31(Root3, { ...menuScope, open, onOpenChange: setOpen, dir, modal, children })
|
|
45816
46443
|
}
|
|
45817
46444
|
);
|
|
45818
46445
|
}, "DropdownMenu");
|
|
45819
46446
|
var TRIGGER_NAME = "DropdownMenuTrigger";
|
|
45820
|
-
var DropdownMenuTrigger = /* @__PURE__ */
|
|
46447
|
+
var DropdownMenuTrigger = /* @__PURE__ */ React42.forwardRef(
|
|
45821
46448
|
// blank line to reduce diff noise
|
|
45822
46449
|
/* @__PURE__ */ __name22(function DropdownMenuTrigger2(props, forwardedRef) {
|
|
45823
46450
|
const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
|
|
@@ -45859,13 +46486,13 @@ var DropdownMenuPortal = /* @__PURE__ */ __name22((props) => {
|
|
|
45859
46486
|
return /* @__PURE__ */ jsx31(Portal3, { ...menuScope, ...portalProps });
|
|
45860
46487
|
}, "DropdownMenuPortal");
|
|
45861
46488
|
var CONTENT_NAME3 = "DropdownMenuContent";
|
|
45862
|
-
var DropdownMenuContent = /* @__PURE__ */
|
|
46489
|
+
var DropdownMenuContent = /* @__PURE__ */ React42.forwardRef(
|
|
45863
46490
|
// blank line to reduce diff noise
|
|
45864
46491
|
/* @__PURE__ */ __name22(function DropdownMenuContent2(props, forwardedRef) {
|
|
45865
46492
|
const { __scopeDropdownMenu, ...contentProps } = props;
|
|
45866
46493
|
const context = useDropdownMenuContext(CONTENT_NAME3, __scopeDropdownMenu);
|
|
45867
46494
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
45868
|
-
const hasInteractedOutsideRef =
|
|
46495
|
+
const hasInteractedOutsideRef = React42.useRef(false);
|
|
45869
46496
|
return /* @__PURE__ */ jsx31(
|
|
45870
46497
|
Content2,
|
|
45871
46498
|
{
|
|
@@ -45900,7 +46527,7 @@ var DropdownMenuContent = /* @__PURE__ */ React41.forwardRef(
|
|
|
45900
46527
|
);
|
|
45901
46528
|
}, "DropdownMenuContent")
|
|
45902
46529
|
);
|
|
45903
|
-
var DropdownMenuItem = /* @__PURE__ */
|
|
46530
|
+
var DropdownMenuItem = /* @__PURE__ */ React42.forwardRef(
|
|
45904
46531
|
// blank line to reduce diff noise
|
|
45905
46532
|
/* @__PURE__ */ __name22(function DropdownMenuItem2(props, forwardedRef) {
|
|
45906
46533
|
const { __scopeDropdownMenu, ...itemProps } = props;
|
|
@@ -45908,7 +46535,7 @@ var DropdownMenuItem = /* @__PURE__ */ React41.forwardRef(
|
|
|
45908
46535
|
return /* @__PURE__ */ jsx31(Item2, { ...menuScope, ...itemProps, ref: forwardedRef });
|
|
45909
46536
|
}, "DropdownMenuItem")
|
|
45910
46537
|
);
|
|
45911
|
-
var DropdownMenuSeparator = /* @__PURE__ */
|
|
46538
|
+
var DropdownMenuSeparator = /* @__PURE__ */ React42.forwardRef(/* @__PURE__ */ __name22(function DropdownMenuSeparator2(props, forwardedRef) {
|
|
45912
46539
|
const { __scopeDropdownMenu, ...separatorProps } = props;
|
|
45913
46540
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
45914
46541
|
return /* @__PURE__ */ jsx31(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef });
|
|
@@ -45924,12 +46551,12 @@ var DropdownMenuSub = /* @__PURE__ */ __name22((props) => {
|
|
|
45924
46551
|
});
|
|
45925
46552
|
return /* @__PURE__ */ jsx31(Sub, { ...menuScope, open, onOpenChange: setOpen, children });
|
|
45926
46553
|
}, "DropdownMenuSub");
|
|
45927
|
-
var DropdownMenuSubTrigger = /* @__PURE__ */
|
|
46554
|
+
var DropdownMenuSubTrigger = /* @__PURE__ */ React42.forwardRef(/* @__PURE__ */ __name22(function DropdownMenuSubTrigger2(props, forwardedRef) {
|
|
45928
46555
|
const { __scopeDropdownMenu, ...subTriggerProps } = props;
|
|
45929
46556
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
45930
46557
|
return /* @__PURE__ */ jsx31(SubTrigger, { ...menuScope, ...subTriggerProps, ref: forwardedRef });
|
|
45931
46558
|
}, "DropdownMenuSubTrigger"));
|
|
45932
|
-
var DropdownMenuSubContent = /* @__PURE__ */
|
|
46559
|
+
var DropdownMenuSubContent = /* @__PURE__ */ React42.forwardRef(/* @__PURE__ */ __name22(function DropdownMenuSubContent2(props, forwardedRef) {
|
|
45933
46560
|
const { __scopeDropdownMenu, ...subContentProps } = props;
|
|
45934
46561
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
45935
46562
|
return /* @__PURE__ */ jsx31(
|
|
@@ -45962,6 +46589,9 @@ var Sub2 = DropdownMenuSub;
|
|
|
45962
46589
|
var SubTrigger2 = DropdownMenuSubTrigger;
|
|
45963
46590
|
var SubContent2 = DropdownMenuSubContent;
|
|
45964
46591
|
|
|
46592
|
+
// src/components/ContextMenu.tsx
|
|
46593
|
+
import { useState as useState35 } from "react";
|
|
46594
|
+
|
|
45965
46595
|
// src/components/AppearanceMenu.tsx
|
|
45966
46596
|
import { useState as useState34 } from "react";
|
|
45967
46597
|
|
|
@@ -46478,14 +47108,19 @@ var ContextMenu = ({
|
|
|
46478
47108
|
engine,
|
|
46479
47109
|
cameraPreset,
|
|
46480
47110
|
autoRotate,
|
|
47111
|
+
referenceObject = null,
|
|
46481
47112
|
onEngineSwitch,
|
|
46482
47113
|
onCameraPresetSelect,
|
|
46483
47114
|
onAutoRotateToggle,
|
|
47115
|
+
onReferenceObjectSelect = () => {
|
|
47116
|
+
},
|
|
46484
47117
|
onDownloadGltf,
|
|
46485
47118
|
onOpenKeyboardShortcuts
|
|
46486
47119
|
}) => {
|
|
46487
47120
|
const { cameraType, setCameraType } = useCameraController();
|
|
47121
|
+
const { gridEnabled, setGridEnabled } = useAppearance();
|
|
46488
47122
|
const [cameraSubOpen, setCameraSubOpen] = useState35(false);
|
|
47123
|
+
const [referenceObjectSubOpen, setReferenceObjectSubOpen] = useState35(false);
|
|
46489
47124
|
const [hoveredItem, setHoveredItem] = useState35(null);
|
|
46490
47125
|
return /* @__PURE__ */ jsx34(
|
|
46491
47126
|
"div",
|
|
@@ -46622,6 +47257,93 @@ var ContextMenu = ({
|
|
|
46622
47257
|
]
|
|
46623
47258
|
}
|
|
46624
47259
|
),
|
|
47260
|
+
/* @__PURE__ */ jsxs8(Sub2, { onOpenChange: setReferenceObjectSubOpen, children: [
|
|
47261
|
+
/* @__PURE__ */ jsxs8(
|
|
47262
|
+
SubTrigger2,
|
|
47263
|
+
{
|
|
47264
|
+
style: {
|
|
47265
|
+
...itemStyles2,
|
|
47266
|
+
...itemPaddingStyles2,
|
|
47267
|
+
backgroundColor: referenceObjectSubOpen || hoveredItem === "reference-object" ? "#404040" : "transparent"
|
|
47268
|
+
},
|
|
47269
|
+
onMouseEnter: () => setHoveredItem("reference-object"),
|
|
47270
|
+
onMouseLeave: () => setHoveredItem(null),
|
|
47271
|
+
onTouchStart: () => setHoveredItem("reference-object"),
|
|
47272
|
+
children: [
|
|
47273
|
+
/* @__PURE__ */ jsx34(
|
|
47274
|
+
"span",
|
|
47275
|
+
{
|
|
47276
|
+
style: { flex: 1, display: "flex", alignItems: "center" },
|
|
47277
|
+
children: "Show Reference Object"
|
|
47278
|
+
}
|
|
47279
|
+
),
|
|
47280
|
+
/* @__PURE__ */ jsx34(
|
|
47281
|
+
"div",
|
|
47282
|
+
{
|
|
47283
|
+
style: {
|
|
47284
|
+
display: "flex",
|
|
47285
|
+
alignItems: "flex-end",
|
|
47286
|
+
gap: 6,
|
|
47287
|
+
marginLeft: "auto"
|
|
47288
|
+
},
|
|
47289
|
+
children: /* @__PURE__ */ jsx34(ChevronRightIcon, { isOpen: referenceObjectSubOpen })
|
|
47290
|
+
}
|
|
47291
|
+
)
|
|
47292
|
+
]
|
|
47293
|
+
}
|
|
47294
|
+
),
|
|
47295
|
+
/* @__PURE__ */ jsx34(Portal22, { children: /* @__PURE__ */ jsx34(
|
|
47296
|
+
SubContent2,
|
|
47297
|
+
{
|
|
47298
|
+
style: { ...contentStyles2, marginLeft: -2 },
|
|
47299
|
+
collisionPadding: 10,
|
|
47300
|
+
avoidCollisions: true,
|
|
47301
|
+
children: REFERENCE_OBJECT_OPTIONS.map((option) => /* @__PURE__ */ jsxs8(
|
|
47302
|
+
Item22,
|
|
47303
|
+
{
|
|
47304
|
+
style: {
|
|
47305
|
+
...itemStyles2,
|
|
47306
|
+
backgroundColor: hoveredItem === option.type ? "#404040" : "transparent"
|
|
47307
|
+
},
|
|
47308
|
+
onSelect: (event) => event.preventDefault(),
|
|
47309
|
+
onPointerDown: (event) => {
|
|
47310
|
+
event.preventDefault();
|
|
47311
|
+
onReferenceObjectSelect(option.type);
|
|
47312
|
+
},
|
|
47313
|
+
onMouseEnter: () => setHoveredItem(option.type),
|
|
47314
|
+
onMouseLeave: () => setHoveredItem(null),
|
|
47315
|
+
onTouchStart: () => setHoveredItem(option.type),
|
|
47316
|
+
children: [
|
|
47317
|
+
/* @__PURE__ */ jsx34("span", { style: iconContainerStyles2, children: referenceObject === option.type && /* @__PURE__ */ jsx34(DotIcon, {}) }),
|
|
47318
|
+
/* @__PURE__ */ jsx34("span", { style: { display: "flex", alignItems: "center" }, children: option.label })
|
|
47319
|
+
]
|
|
47320
|
+
},
|
|
47321
|
+
option.type
|
|
47322
|
+
))
|
|
47323
|
+
}
|
|
47324
|
+
) })
|
|
47325
|
+
] }),
|
|
47326
|
+
/* @__PURE__ */ jsxs8(
|
|
47327
|
+
Item22,
|
|
47328
|
+
{
|
|
47329
|
+
style: {
|
|
47330
|
+
...itemStyles2,
|
|
47331
|
+
backgroundColor: hoveredItem === "grid" ? "#404040" : "transparent"
|
|
47332
|
+
},
|
|
47333
|
+
onSelect: (e) => e.preventDefault(),
|
|
47334
|
+
onPointerDown: (e) => {
|
|
47335
|
+
e.preventDefault();
|
|
47336
|
+
setGridEnabled(!gridEnabled);
|
|
47337
|
+
},
|
|
47338
|
+
onMouseEnter: () => setHoveredItem("grid"),
|
|
47339
|
+
onMouseLeave: () => setHoveredItem(null),
|
|
47340
|
+
onTouchStart: () => setHoveredItem("grid"),
|
|
47341
|
+
children: [
|
|
47342
|
+
/* @__PURE__ */ jsx34("span", { style: iconContainerStyles2, children: gridEnabled && /* @__PURE__ */ jsx34(CheckIcon, {}) }),
|
|
47343
|
+
/* @__PURE__ */ jsx34("span", { style: { display: "flex", alignItems: "center" }, children: "Show Grid" })
|
|
47344
|
+
]
|
|
47345
|
+
}
|
|
47346
|
+
),
|
|
46625
47347
|
/* @__PURE__ */ jsx34(AppearanceMenu, {}),
|
|
46626
47348
|
/* @__PURE__ */ jsx34(Separator2, { style: separatorStyles2 }),
|
|
46627
47349
|
/* @__PURE__ */ jsx34(
|
|
@@ -46744,10 +47466,10 @@ var ContextMenu = ({
|
|
|
46744
47466
|
};
|
|
46745
47467
|
|
|
46746
47468
|
// src/components/KeyboardShortcutsDialog.tsx
|
|
46747
|
-
import { useEffect as
|
|
47469
|
+
import { useEffect as useEffect47, useMemo as useMemo32, useRef as useRef27, useState as useState37 } from "react";
|
|
46748
47470
|
|
|
46749
47471
|
// src/hooks/useRegisteredHotkey.ts
|
|
46750
|
-
import { useEffect as
|
|
47472
|
+
import { useEffect as useEffect46, useMemo as useMemo31, useRef as useRef26, useState as useState36 } from "react";
|
|
46751
47473
|
var hotkeyRegistry = /* @__PURE__ */ new Map();
|
|
46752
47474
|
var subscribers = /* @__PURE__ */ new Set();
|
|
46753
47475
|
var isListenerAttached = false;
|
|
@@ -46871,14 +47593,14 @@ var subscribeToRegistry = (subscriber) => {
|
|
|
46871
47593
|
var useRegisteredHotkey = (id, handler, metadata) => {
|
|
46872
47594
|
const handlerRef = useRef26(handler);
|
|
46873
47595
|
handlerRef.current = handler;
|
|
46874
|
-
const normalizedMetadata =
|
|
47596
|
+
const normalizedMetadata = useMemo31(
|
|
46875
47597
|
() => ({
|
|
46876
47598
|
shortcut: metadata.shortcut,
|
|
46877
47599
|
description: metadata.description
|
|
46878
47600
|
}),
|
|
46879
47601
|
[metadata.shortcut, metadata.description]
|
|
46880
47602
|
);
|
|
46881
|
-
|
|
47603
|
+
useEffect46(() => {
|
|
46882
47604
|
const registration = {
|
|
46883
47605
|
id,
|
|
46884
47606
|
...normalizedMetadata,
|
|
@@ -46894,7 +47616,7 @@ var useHotkeyRegistry = () => {
|
|
|
46894
47616
|
const [entries, setEntries] = useState36(
|
|
46895
47617
|
() => Array.from(hotkeyRegistry.values())
|
|
46896
47618
|
);
|
|
46897
|
-
|
|
47619
|
+
useEffect46(() => subscribeToRegistry(setEntries), []);
|
|
46898
47620
|
return entries;
|
|
46899
47621
|
};
|
|
46900
47622
|
var registerHotkeyViewer = (element) => {
|
|
@@ -46911,7 +47633,7 @@ var KeyboardShortcutsDialog = ({
|
|
|
46911
47633
|
const [query, setQuery] = useState37("");
|
|
46912
47634
|
const inputRef = useRef27(null);
|
|
46913
47635
|
const hotkeys = useHotkeyRegistry();
|
|
46914
|
-
|
|
47636
|
+
useEffect47(() => {
|
|
46915
47637
|
if (!open) return void 0;
|
|
46916
47638
|
const handleKeyDown = (event) => {
|
|
46917
47639
|
if (event.key === "Escape") {
|
|
@@ -46922,14 +47644,14 @@ var KeyboardShortcutsDialog = ({
|
|
|
46922
47644
|
window.addEventListener("keydown", handleKeyDown);
|
|
46923
47645
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
46924
47646
|
}, [open, onClose]);
|
|
46925
|
-
|
|
47647
|
+
useEffect47(() => {
|
|
46926
47648
|
if (open) {
|
|
46927
47649
|
setTimeout(() => {
|
|
46928
47650
|
inputRef.current?.focus();
|
|
46929
47651
|
}, 0);
|
|
46930
47652
|
}
|
|
46931
47653
|
}, [open]);
|
|
46932
|
-
const filteredHotkeys =
|
|
47654
|
+
const filteredHotkeys = useMemo32(() => {
|
|
46933
47655
|
const normalizedQuery = query.trim().toLowerCase();
|
|
46934
47656
|
if (!normalizedQuery) {
|
|
46935
47657
|
return hotkeys;
|
|
@@ -47151,7 +47873,7 @@ function useCameraPreset({
|
|
|
47151
47873
|
}
|
|
47152
47874
|
|
|
47153
47875
|
// src/hooks/useContextMenu.ts
|
|
47154
|
-
import { useState as useState38, useCallback as useCallback22, useRef as useRef28, useEffect as
|
|
47876
|
+
import { useState as useState38, useCallback as useCallback22, useRef as useRef28, useEffect as useEffect48 } from "react";
|
|
47155
47877
|
var useContextMenu = ({ containerRef }) => {
|
|
47156
47878
|
const [menuVisible, setMenuVisible] = useState38(false);
|
|
47157
47879
|
const [menuPos, setMenuPos] = useState38({
|
|
@@ -47266,7 +47988,7 @@ var useContextMenu = ({ containerRef }) => {
|
|
|
47266
47988
|
}
|
|
47267
47989
|
setMenuVisible(false);
|
|
47268
47990
|
}, []);
|
|
47269
|
-
|
|
47991
|
+
useEffect48(() => {
|
|
47270
47992
|
if (menuVisible) {
|
|
47271
47993
|
document.addEventListener("mousedown", handleClickAway);
|
|
47272
47994
|
document.addEventListener("touchstart", handleClickAway);
|
|
@@ -47330,7 +48052,7 @@ var useGlobalDownloadGltf = () => {
|
|
|
47330
48052
|
|
|
47331
48053
|
// src/CadViewer.tsx
|
|
47332
48054
|
import { jsx as jsx37, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
47333
|
-
var DEFAULT_TARGET = new
|
|
48055
|
+
var DEFAULT_TARGET = new THREE48.Vector3(0, 0, 0);
|
|
47334
48056
|
var INITIAL_CAMERA_POSITION = [5, -5, 5];
|
|
47335
48057
|
var readStoredCameraType = () => {
|
|
47336
48058
|
if (typeof window === "undefined") return void 0;
|
|
@@ -47353,6 +48075,7 @@ var CadViewerInner = (props) => {
|
|
|
47353
48075
|
return stored === "true";
|
|
47354
48076
|
});
|
|
47355
48077
|
const [cameraPreset, setCameraPreset] = useState39("Custom");
|
|
48078
|
+
const [referenceObject, setReferenceObject] = useState39(null);
|
|
47356
48079
|
const { cameraType } = useCameraController();
|
|
47357
48080
|
const { visibility, setLayerVisibility } = useLayerVisibility();
|
|
47358
48081
|
const { showToast } = useToast();
|
|
@@ -47463,24 +48186,24 @@ var CadViewerInner = (props) => {
|
|
|
47463
48186
|
description: "Toggle translucent components"
|
|
47464
48187
|
}
|
|
47465
48188
|
);
|
|
47466
|
-
|
|
48189
|
+
useEffect49(() => {
|
|
47467
48190
|
if (containerRef.current) {
|
|
47468
48191
|
registerHotkeyViewer(containerRef.current);
|
|
47469
48192
|
}
|
|
47470
48193
|
}, []);
|
|
47471
|
-
|
|
48194
|
+
useEffect49(() => {
|
|
47472
48195
|
window.localStorage.setItem("cadViewerEngine", engine);
|
|
47473
48196
|
}, [engine]);
|
|
47474
|
-
|
|
48197
|
+
useEffect49(() => {
|
|
47475
48198
|
window.localStorage.setItem("cadViewerAutoRotate", String(autoRotate));
|
|
47476
48199
|
}, [autoRotate]);
|
|
47477
|
-
|
|
48200
|
+
useEffect49(() => {
|
|
47478
48201
|
window.localStorage.setItem(
|
|
47479
48202
|
"cadViewerAutoRotateUserToggled",
|
|
47480
48203
|
String(autoRotateUserToggled)
|
|
47481
48204
|
);
|
|
47482
48205
|
}, [autoRotateUserToggled]);
|
|
47483
|
-
|
|
48206
|
+
useEffect49(() => {
|
|
47484
48207
|
window.localStorage.setItem("cadViewerCameraType", cameraType);
|
|
47485
48208
|
}, [cameraType]);
|
|
47486
48209
|
const viewerKey = props.circuitJson ? JSON.stringify(props.circuitJson) : void 0;
|
|
@@ -47507,7 +48230,8 @@ var CadViewerInner = (props) => {
|
|
|
47507
48230
|
autoRotateDisabled: props.autoRotateDisabled || !autoRotate,
|
|
47508
48231
|
cameraType,
|
|
47509
48232
|
onUserInteraction: handleUserInteraction,
|
|
47510
|
-
onCameraControllerReady: handleCameraControllerReady
|
|
48233
|
+
onCameraControllerReady: handleCameraControllerReady,
|
|
48234
|
+
referenceObject
|
|
47511
48235
|
}
|
|
47512
48236
|
) : /* @__PURE__ */ jsx37(
|
|
47513
48237
|
CadViewerManifold_default,
|
|
@@ -47516,7 +48240,8 @@ var CadViewerInner = (props) => {
|
|
|
47516
48240
|
autoRotateDisabled: props.autoRotateDisabled || !autoRotate,
|
|
47517
48241
|
cameraType,
|
|
47518
48242
|
onUserInteraction: handleUserInteraction,
|
|
47519
|
-
onCameraControllerReady: handleCameraControllerReady
|
|
48243
|
+
onCameraControllerReady: handleCameraControllerReady,
|
|
48244
|
+
referenceObject
|
|
47520
48245
|
}
|
|
47521
48246
|
),
|
|
47522
48247
|
/* @__PURE__ */ jsxs11(
|
|
@@ -47548,6 +48273,7 @@ var CadViewerInner = (props) => {
|
|
|
47548
48273
|
engine,
|
|
47549
48274
|
cameraPreset,
|
|
47550
48275
|
autoRotate,
|
|
48276
|
+
referenceObject,
|
|
47551
48277
|
onEngineSwitch: (newEngine) => {
|
|
47552
48278
|
setEngine(newEngine);
|
|
47553
48279
|
closeMenu();
|
|
@@ -47557,6 +48283,13 @@ var CadViewerInner = (props) => {
|
|
|
47557
48283
|
toggleAutoRotate();
|
|
47558
48284
|
closeMenu();
|
|
47559
48285
|
},
|
|
48286
|
+
onReferenceObjectSelect: (nextReferenceObject) => {
|
|
48287
|
+
setReferenceObject(nextReferenceObject);
|
|
48288
|
+
setAutoRotate(false);
|
|
48289
|
+
setAutoRotateUserToggled(true);
|
|
48290
|
+
setCameraPreset("Custom");
|
|
48291
|
+
closeMenu();
|
|
48292
|
+
},
|
|
47560
48293
|
onDownloadGltf: () => {
|
|
47561
48294
|
downloadGltf();
|
|
47562
48295
|
closeMenu();
|
|
@@ -47594,14 +48327,14 @@ var CadViewer = (props) => {
|
|
|
47594
48327
|
// src/convert-circuit-json-to-3d-svg.ts
|
|
47595
48328
|
var import_debug = __toESM(require_browser(), 1);
|
|
47596
48329
|
import { su as su18 } from "@tscircuit/circuit-json-util";
|
|
47597
|
-
import * as
|
|
48330
|
+
import * as THREE52 from "three";
|
|
47598
48331
|
import { SVGRenderer } from "three/examples/jsm/renderers/SVGRenderer.js";
|
|
47599
48332
|
|
|
47600
48333
|
// src/utils/create-geometry-from-polygons.ts
|
|
47601
|
-
import * as
|
|
47602
|
-
import { BufferGeometry as
|
|
48334
|
+
import * as THREE49 from "three";
|
|
48335
|
+
import { BufferGeometry as BufferGeometry5, Float32BufferAttribute as Float32BufferAttribute4 } from "three";
|
|
47603
48336
|
function createGeometryFromPolygons(polygons) {
|
|
47604
|
-
const geometry = new
|
|
48337
|
+
const geometry = new BufferGeometry5();
|
|
47605
48338
|
const vertices = [];
|
|
47606
48339
|
const normals = [];
|
|
47607
48340
|
for (const polygon2 of polygons) {
|
|
@@ -47612,12 +48345,12 @@ function createGeometryFromPolygons(polygons) {
|
|
|
47612
48345
|
...polygon2.vertices[i + 1]
|
|
47613
48346
|
// Third vertex
|
|
47614
48347
|
);
|
|
47615
|
-
const v1 = new
|
|
47616
|
-
const v2 = new
|
|
47617
|
-
const v3 = new
|
|
47618
|
-
const normal = new
|
|
47619
|
-
new
|
|
47620
|
-
new
|
|
48348
|
+
const v1 = new THREE49.Vector3(...polygon2.vertices[0]);
|
|
48349
|
+
const v2 = new THREE49.Vector3(...polygon2.vertices[i]);
|
|
48350
|
+
const v3 = new THREE49.Vector3(...polygon2.vertices[i + 1]);
|
|
48351
|
+
const normal = new THREE49.Vector3().crossVectors(
|
|
48352
|
+
new THREE49.Vector3().subVectors(v2, v1),
|
|
48353
|
+
new THREE49.Vector3().subVectors(v3, v1)
|
|
47621
48354
|
).normalize();
|
|
47622
48355
|
normals.push(
|
|
47623
48356
|
normal.x,
|
|
@@ -47632,8 +48365,8 @@ function createGeometryFromPolygons(polygons) {
|
|
|
47632
48365
|
);
|
|
47633
48366
|
}
|
|
47634
48367
|
}
|
|
47635
|
-
geometry.setAttribute("position", new
|
|
47636
|
-
geometry.setAttribute("normal", new
|
|
48368
|
+
geometry.setAttribute("position", new Float32BufferAttribute4(vertices, 3));
|
|
48369
|
+
geometry.setAttribute("normal", new Float32BufferAttribute4(normals, 3));
|
|
47637
48370
|
return geometry;
|
|
47638
48371
|
}
|
|
47639
48372
|
|
|
@@ -47641,10 +48374,10 @@ function createGeometryFromPolygons(polygons) {
|
|
|
47641
48374
|
var import_modeling2 = __toESM(require_src(), 1);
|
|
47642
48375
|
var import_jscad_planner2 = __toESM(require_dist(), 1);
|
|
47643
48376
|
var jscadModeling2 = __toESM(require_src(), 1);
|
|
47644
|
-
import * as
|
|
48377
|
+
import * as THREE51 from "three";
|
|
47645
48378
|
|
|
47646
48379
|
// src/utils/load-model.ts
|
|
47647
|
-
import * as
|
|
48380
|
+
import * as THREE50 from "three";
|
|
47648
48381
|
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
47649
48382
|
import { OBJLoader as OBJLoader2 } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
47650
48383
|
import { STLLoader as STLLoader2 } from "three/examples/jsm/loaders/STLLoader.js";
|
|
@@ -47652,12 +48385,12 @@ async function load3DModel(url) {
|
|
|
47652
48385
|
if (url.endsWith(".stl")) {
|
|
47653
48386
|
const loader = new STLLoader2();
|
|
47654
48387
|
const geometry = await loader.loadAsync(url);
|
|
47655
|
-
const material = new
|
|
48388
|
+
const material = new THREE50.MeshStandardMaterial({
|
|
47656
48389
|
color: 8947848,
|
|
47657
48390
|
metalness: 0.5,
|
|
47658
48391
|
roughness: 0.5
|
|
47659
48392
|
});
|
|
47660
|
-
return new
|
|
48393
|
+
return new THREE50.Mesh(geometry, material);
|
|
47661
48394
|
}
|
|
47662
48395
|
if (url.endsWith(".obj")) {
|
|
47663
48396
|
const loader = new OBJLoader2();
|
|
@@ -47690,9 +48423,9 @@ async function renderComponent(component, scene) {
|
|
|
47690
48423
|
}
|
|
47691
48424
|
if (component.rotation) {
|
|
47692
48425
|
model.rotation.set(
|
|
47693
|
-
|
|
47694
|
-
|
|
47695
|
-
|
|
48426
|
+
THREE51.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
48427
|
+
THREE51.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
48428
|
+
THREE51.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
47696
48429
|
);
|
|
47697
48430
|
}
|
|
47698
48431
|
scene.add(model);
|
|
@@ -47706,13 +48439,13 @@ async function renderComponent(component, scene) {
|
|
|
47706
48439
|
);
|
|
47707
48440
|
if (jscadObject && (jscadObject.polygons || jscadObject.sides)) {
|
|
47708
48441
|
const threeGeom = convertCSGToThreeGeom(jscadObject);
|
|
47709
|
-
const material2 = new
|
|
48442
|
+
const material2 = new THREE51.MeshStandardMaterial({
|
|
47710
48443
|
color: 8947848,
|
|
47711
48444
|
metalness: 0.5,
|
|
47712
48445
|
roughness: 0.5,
|
|
47713
|
-
side:
|
|
48446
|
+
side: THREE51.DoubleSide
|
|
47714
48447
|
});
|
|
47715
|
-
const mesh2 = new
|
|
48448
|
+
const mesh2 = new THREE51.Mesh(threeGeom, material2);
|
|
47716
48449
|
if (component.position) {
|
|
47717
48450
|
mesh2.position.set(
|
|
47718
48451
|
component.position.x ?? 0,
|
|
@@ -47722,9 +48455,9 @@ async function renderComponent(component, scene) {
|
|
|
47722
48455
|
}
|
|
47723
48456
|
if (component.rotation) {
|
|
47724
48457
|
mesh2.rotation.set(
|
|
47725
|
-
|
|
47726
|
-
|
|
47727
|
-
|
|
48458
|
+
THREE51.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
48459
|
+
THREE51.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
48460
|
+
THREE51.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
47728
48461
|
);
|
|
47729
48462
|
}
|
|
47730
48463
|
scene.add(mesh2);
|
|
@@ -47741,17 +48474,17 @@ async function renderComponent(component, scene) {
|
|
|
47741
48474
|
if (!geom || !geom.polygons && !geom.sides) {
|
|
47742
48475
|
continue;
|
|
47743
48476
|
}
|
|
47744
|
-
const color = new
|
|
48477
|
+
const color = new THREE51.Color(geomInfo.color);
|
|
47745
48478
|
color.convertLinearToSRGB();
|
|
47746
48479
|
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
47747
48480
|
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
47748
|
-
const material2 = new
|
|
48481
|
+
const material2 = new THREE51.MeshStandardMaterial({
|
|
47749
48482
|
vertexColors: true,
|
|
47750
48483
|
metalness: 0.2,
|
|
47751
48484
|
roughness: 0.8,
|
|
47752
|
-
side:
|
|
48485
|
+
side: THREE51.DoubleSide
|
|
47753
48486
|
});
|
|
47754
|
-
const mesh2 = new
|
|
48487
|
+
const mesh2 = new THREE51.Mesh(threeGeom, material2);
|
|
47755
48488
|
if (component.position) {
|
|
47756
48489
|
mesh2.position.set(
|
|
47757
48490
|
component.position.x ?? 0,
|
|
@@ -47761,22 +48494,22 @@ async function renderComponent(component, scene) {
|
|
|
47761
48494
|
}
|
|
47762
48495
|
if (component.rotation) {
|
|
47763
48496
|
mesh2.rotation.set(
|
|
47764
|
-
|
|
47765
|
-
|
|
47766
|
-
|
|
48497
|
+
THREE51.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
48498
|
+
THREE51.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
48499
|
+
THREE51.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
47767
48500
|
);
|
|
47768
48501
|
}
|
|
47769
48502
|
scene.add(mesh2);
|
|
47770
48503
|
}
|
|
47771
48504
|
return;
|
|
47772
48505
|
}
|
|
47773
|
-
const geometry = new
|
|
47774
|
-
const material = new
|
|
48506
|
+
const geometry = new THREE51.BoxGeometry(0.5, 0.5, 0.5);
|
|
48507
|
+
const material = new THREE51.MeshStandardMaterial({
|
|
47775
48508
|
color: 16711680,
|
|
47776
48509
|
transparent: true,
|
|
47777
48510
|
opacity: 0.25
|
|
47778
48511
|
});
|
|
47779
|
-
const mesh = new
|
|
48512
|
+
const mesh = new THREE51.Mesh(geometry, material);
|
|
47780
48513
|
if (component.position) {
|
|
47781
48514
|
mesh.position.set(
|
|
47782
48515
|
component.position.x ?? 0,
|
|
@@ -47797,11 +48530,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
47797
48530
|
padding = 20,
|
|
47798
48531
|
zoom = 1.5
|
|
47799
48532
|
} = options;
|
|
47800
|
-
const scene = new
|
|
48533
|
+
const scene = new THREE52.Scene();
|
|
47801
48534
|
const renderer = new SVGRenderer();
|
|
47802
48535
|
renderer.setSize(width10, height10);
|
|
47803
|
-
renderer.setClearColor(new
|
|
47804
|
-
const camera = new
|
|
48536
|
+
renderer.setClearColor(new THREE52.Color(backgroundColor), 1);
|
|
48537
|
+
const camera = new THREE52.OrthographicCamera();
|
|
47805
48538
|
const aspect = width10 / height10;
|
|
47806
48539
|
const frustumSize = 100;
|
|
47807
48540
|
const halfFrustumSize = frustumSize / 2 / zoom;
|
|
@@ -47815,11 +48548,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
47815
48548
|
camera.position.set(position.x, position.y, position.z);
|
|
47816
48549
|
camera.up.set(0, 1, 0);
|
|
47817
48550
|
const lookAt = options.camera?.lookAt ?? { x: 0, y: 0, z: 0 };
|
|
47818
|
-
camera.lookAt(new
|
|
48551
|
+
camera.lookAt(new THREE52.Vector3(lookAt.x, lookAt.y, lookAt.z));
|
|
47819
48552
|
camera.updateProjectionMatrix();
|
|
47820
|
-
const ambientLight = new
|
|
48553
|
+
const ambientLight = new THREE52.AmbientLight(16777215, Math.PI / 2);
|
|
47821
48554
|
scene.add(ambientLight);
|
|
47822
|
-
const pointLight = new
|
|
48555
|
+
const pointLight = new THREE52.PointLight(16777215, Math.PI / 4);
|
|
47823
48556
|
pointLight.position.set(-10, -10, 10);
|
|
47824
48557
|
scene.add(pointLight);
|
|
47825
48558
|
const components = su18(circuitJson).cad_component.list();
|
|
@@ -47830,7 +48563,7 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
47830
48563
|
const boardGeom = createSimplifiedBoardGeom(circuitJson);
|
|
47831
48564
|
if (boardGeom) {
|
|
47832
48565
|
const solderMaskColor = colors.fr4SolderMaskGreen;
|
|
47833
|
-
const baseColor = new
|
|
48566
|
+
const baseColor = new THREE52.Color(
|
|
47834
48567
|
solderMaskColor[0],
|
|
47835
48568
|
solderMaskColor[1],
|
|
47836
48569
|
solderMaskColor[2]
|
|
@@ -47842,28 +48575,28 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
47842
48575
|
const material = createBoardMaterial({
|
|
47843
48576
|
material: boardData?.material,
|
|
47844
48577
|
color: baseColor,
|
|
47845
|
-
side:
|
|
48578
|
+
side: THREE52.DoubleSide
|
|
47846
48579
|
});
|
|
47847
|
-
const mesh = new
|
|
48580
|
+
const mesh = new THREE52.Mesh(geometry, material);
|
|
47848
48581
|
scene.add(mesh);
|
|
47849
48582
|
}
|
|
47850
48583
|
}
|
|
47851
|
-
const gridColor = new
|
|
47852
|
-
const gridHelper = new
|
|
48584
|
+
const gridColor = new THREE52.Color(8947848);
|
|
48585
|
+
const gridHelper = new THREE52.GridHelper(100, 100, gridColor, gridColor);
|
|
47853
48586
|
gridHelper.rotation.x = Math.PI / 2;
|
|
47854
48587
|
const materials = Array.isArray(gridHelper.material) ? gridHelper.material : [gridHelper.material];
|
|
47855
48588
|
for (const mat of materials) {
|
|
47856
48589
|
mat.transparent = true;
|
|
47857
48590
|
mat.opacity = 0.3;
|
|
47858
|
-
if (mat instanceof
|
|
48591
|
+
if (mat instanceof THREE52.LineBasicMaterial) {
|
|
47859
48592
|
mat.color = gridColor;
|
|
47860
48593
|
mat.vertexColors = false;
|
|
47861
48594
|
}
|
|
47862
48595
|
}
|
|
47863
48596
|
scene.add(gridHelper);
|
|
47864
|
-
const box = new
|
|
47865
|
-
const center = box.getCenter(new
|
|
47866
|
-
const size4 = box.getSize(new
|
|
48597
|
+
const box = new THREE52.Box3().setFromObject(scene);
|
|
48598
|
+
const center = box.getCenter(new THREE52.Vector3());
|
|
48599
|
+
const size4 = box.getSize(new THREE52.Vector3());
|
|
47867
48600
|
scene.position.sub(center);
|
|
47868
48601
|
const maxDim = Math.max(size4.x, size4.y, size4.z);
|
|
47869
48602
|
if (maxDim > 0) {
|
|
@@ -47881,10 +48614,10 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
47881
48614
|
|
|
47882
48615
|
// src/hooks/exporter/gltf.ts
|
|
47883
48616
|
import { GLTFExporter as GLTFExporter3 } from "three-stdlib";
|
|
47884
|
-
import { useEffect as
|
|
48617
|
+
import { useEffect as useEffect50, useState as useState40, useMemo as useMemo33, useCallback as useCallback25 } from "react";
|
|
47885
48618
|
function useSaveGltfAs(options = {}) {
|
|
47886
48619
|
const parse2 = useParser(options);
|
|
47887
|
-
const link =
|
|
48620
|
+
const link = useMemo33(() => document.createElement("a"), []);
|
|
47888
48621
|
const saveAs = async (filename) => {
|
|
47889
48622
|
const name = filename ?? options.filename ?? "";
|
|
47890
48623
|
if (options.binary == null) options.binary = name.endsWith(".glb");
|
|
@@ -47894,7 +48627,7 @@ function useSaveGltfAs(options = {}) {
|
|
|
47894
48627
|
link.dispatchEvent(new MouseEvent("click"));
|
|
47895
48628
|
URL.revokeObjectURL(url);
|
|
47896
48629
|
};
|
|
47897
|
-
|
|
48630
|
+
useEffect50(
|
|
47898
48631
|
() => () => {
|
|
47899
48632
|
link.remove();
|
|
47900
48633
|
instance = null;
|
|
@@ -47915,11 +48648,11 @@ function useExportGltfUrl(options = {}) {
|
|
|
47915
48648
|
(instance) => parse2(instance).then(setUrl).catch(setError),
|
|
47916
48649
|
[]
|
|
47917
48650
|
);
|
|
47918
|
-
|
|
48651
|
+
useEffect50(() => () => URL.revokeObjectURL(url), [url]);
|
|
47919
48652
|
return [ref, url, error];
|
|
47920
48653
|
}
|
|
47921
48654
|
function useParser(options = {}) {
|
|
47922
|
-
const exporter =
|
|
48655
|
+
const exporter = useMemo33(() => new GLTFExporter3(), []);
|
|
47923
48656
|
return (instance) => {
|
|
47924
48657
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
47925
48658
|
exporter.parse(
|