@tscircuit/3d-viewer 0.0.478 → 0.0.480
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 +211 -181
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14226,7 +14226,7 @@ var require_browser = __commonJS({
|
|
|
14226
14226
|
|
|
14227
14227
|
// src/CadViewer.tsx
|
|
14228
14228
|
import { useState as useState35, useCallback as useCallback21, useRef as useRef26, useEffect as useEffect43 } from "react";
|
|
14229
|
-
import * as
|
|
14229
|
+
import * as THREE34 from "three";
|
|
14230
14230
|
|
|
14231
14231
|
// src/CadViewerJscad.tsx
|
|
14232
14232
|
import { su as su12 } from "@tscircuit/circuit-json-util";
|
|
@@ -29487,12 +29487,12 @@ var AnyCadComponent = ({
|
|
|
29487
29487
|
|
|
29488
29488
|
// src/CadViewerContainer.tsx
|
|
29489
29489
|
import { forwardRef as forwardRef2, useEffect as useEffect16, useMemo as useMemo13, useState as useState9 } from "react";
|
|
29490
|
-
import * as
|
|
29490
|
+
import * as THREE16 from "three";
|
|
29491
29491
|
|
|
29492
29492
|
// package.json
|
|
29493
29493
|
var package_default = {
|
|
29494
29494
|
name: "@tscircuit/3d-viewer",
|
|
29495
|
-
version: "0.0.
|
|
29495
|
+
version: "0.0.479",
|
|
29496
29496
|
main: "./dist/index.js",
|
|
29497
29497
|
module: "./dist/index.js",
|
|
29498
29498
|
type: "module",
|
|
@@ -29937,6 +29937,7 @@ var Canvas = forwardRef(
|
|
|
29937
29937
|
|
|
29938
29938
|
// src/react-three/OrbitControls.tsx
|
|
29939
29939
|
import { useEffect as useEffect11, useMemo as useMemo10 } from "react";
|
|
29940
|
+
import * as THREE11 from "three";
|
|
29940
29941
|
import { OrbitControls as ThreeOrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
29941
29942
|
var OrbitControls = ({
|
|
29942
29943
|
autoRotate,
|
|
@@ -29979,6 +29980,14 @@ var OrbitControls = ({
|
|
|
29979
29980
|
if (enableDamping !== void 0) controls.enableDamping = enableDamping;
|
|
29980
29981
|
if (dampingFactor !== void 0) controls.dampingFactor = dampingFactor;
|
|
29981
29982
|
controls.zoomToCursor = true;
|
|
29983
|
+
controls.mouseButtons = {
|
|
29984
|
+
LEFT: THREE11.MOUSE.ROTATE,
|
|
29985
|
+
// Left click to rotate
|
|
29986
|
+
MIDDLE: THREE11.MOUSE.PAN,
|
|
29987
|
+
// Middle click to pan
|
|
29988
|
+
RIGHT: null
|
|
29989
|
+
// Right-click always disabled - only context menu
|
|
29990
|
+
};
|
|
29982
29991
|
if (target) {
|
|
29983
29992
|
controls.target.set(target[0], target[1], target[2]);
|
|
29984
29993
|
controls.update();
|
|
@@ -30015,7 +30024,7 @@ var OrbitControls = ({
|
|
|
30015
30024
|
|
|
30016
30025
|
// src/react-three/Grid.tsx
|
|
30017
30026
|
import { useEffect as useEffect12, useMemo as useMemo11 } from "react";
|
|
30018
|
-
import * as
|
|
30027
|
+
import * as THREE12 from "three";
|
|
30019
30028
|
var vertexShader = `
|
|
30020
30029
|
varying vec3 worldPosition;
|
|
30021
30030
|
void main() {
|
|
@@ -30061,24 +30070,24 @@ var Grid = ({
|
|
|
30061
30070
|
const { scene, camera } = useThree();
|
|
30062
30071
|
const size5 = 1e3;
|
|
30063
30072
|
const gridMesh = useMemo11(() => {
|
|
30064
|
-
const geometry = new
|
|
30073
|
+
const geometry = new THREE12.PlaneGeometry(size5, size5);
|
|
30065
30074
|
geometry.rotateX(-Math.PI / 2);
|
|
30066
|
-
const material = new
|
|
30075
|
+
const material = new THREE12.ShaderMaterial({
|
|
30067
30076
|
vertexShader,
|
|
30068
30077
|
fragmentShader,
|
|
30069
30078
|
uniforms: {
|
|
30070
30079
|
cellSize: { value: cellSize },
|
|
30071
30080
|
sectionSize: { value: sectionSize },
|
|
30072
|
-
gridColor: { value: new
|
|
30073
|
-
sectionColor: { value: new
|
|
30081
|
+
gridColor: { value: new THREE12.Color(15658734) },
|
|
30082
|
+
sectionColor: { value: new THREE12.Color(13421823) },
|
|
30074
30083
|
fadeDistance: { value: 100 },
|
|
30075
30084
|
// Fade out based on sectionSize
|
|
30076
30085
|
fadeStrength: { value: 1.5 }
|
|
30077
30086
|
},
|
|
30078
30087
|
transparent: true,
|
|
30079
|
-
side:
|
|
30088
|
+
side: THREE12.DoubleSide
|
|
30080
30089
|
});
|
|
30081
|
-
const mesh = new
|
|
30090
|
+
const mesh = new THREE12.Mesh(geometry, material);
|
|
30082
30091
|
if (rotation2) {
|
|
30083
30092
|
mesh.rotation.fromArray(rotation2);
|
|
30084
30093
|
}
|
|
@@ -30107,15 +30116,15 @@ var Grid = ({
|
|
|
30107
30116
|
|
|
30108
30117
|
// src/react-three/Lights.tsx
|
|
30109
30118
|
import { useEffect as useEffect13, useMemo as useMemo12 } from "react";
|
|
30110
|
-
import * as
|
|
30119
|
+
import * as THREE13 from "three";
|
|
30111
30120
|
var Lights = () => {
|
|
30112
30121
|
const { scene } = useThree();
|
|
30113
30122
|
const ambientLight = useMemo12(
|
|
30114
|
-
() => new
|
|
30123
|
+
() => new THREE13.AmbientLight(16777215, Math.PI / 2),
|
|
30115
30124
|
[]
|
|
30116
30125
|
);
|
|
30117
30126
|
const pointLight = useMemo12(() => {
|
|
30118
|
-
const light = new
|
|
30127
|
+
const light = new THREE13.PointLight(16777215, Math.PI / 4);
|
|
30119
30128
|
light.position.set(-10, -10, 10);
|
|
30120
30129
|
light.decay = 0;
|
|
30121
30130
|
return light;
|
|
@@ -30134,7 +30143,7 @@ var Lights = () => {
|
|
|
30134
30143
|
|
|
30135
30144
|
// src/hooks/cameraAnimation.ts
|
|
30136
30145
|
import { useCallback as useCallback6, useEffect as useEffect14, useRef as useRef5 } from "react";
|
|
30137
|
-
import * as
|
|
30146
|
+
import * as THREE14 from "three";
|
|
30138
30147
|
var easeInOutCubic = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
30139
30148
|
var CameraAnimatorWithContext = () => {
|
|
30140
30149
|
const {
|
|
@@ -30145,24 +30154,24 @@ var CameraAnimatorWithContext = () => {
|
|
|
30145
30154
|
getPresetConfig
|
|
30146
30155
|
} = useCameraController();
|
|
30147
30156
|
const animationRef = useRef5(null);
|
|
30148
|
-
const tempQuaternion = useRef5(new
|
|
30149
|
-
const tempTarget = useRef5(new
|
|
30150
|
-
const tempUp = useRef5(new
|
|
30151
|
-
const tempRoll = useRef5(new
|
|
30152
|
-
const tempRollTarget = useRef5(new
|
|
30153
|
-
const baseOrientationHelper = useRef5(new
|
|
30154
|
-
const orientationHelper = useRef5(new
|
|
30157
|
+
const tempQuaternion = useRef5(new THREE14.Quaternion());
|
|
30158
|
+
const tempTarget = useRef5(new THREE14.Vector3());
|
|
30159
|
+
const tempUp = useRef5(new THREE14.Vector3());
|
|
30160
|
+
const tempRoll = useRef5(new THREE14.Quaternion());
|
|
30161
|
+
const tempRollTarget = useRef5(new THREE14.Quaternion());
|
|
30162
|
+
const baseOrientationHelper = useRef5(new THREE14.Object3D());
|
|
30163
|
+
const orientationHelper = useRef5(new THREE14.Object3D());
|
|
30155
30164
|
const animateTo = useCallback6(
|
|
30156
30165
|
({ position, target, up, durationMs = 600 }) => {
|
|
30157
30166
|
if (!mainCameraRef.current) return;
|
|
30158
30167
|
const currentTarget = controlsRef.current?.target ?? defaultTarget;
|
|
30159
|
-
const toPosition = new
|
|
30168
|
+
const toPosition = new THREE14.Vector3(
|
|
30160
30169
|
position[0],
|
|
30161
30170
|
position[1],
|
|
30162
30171
|
position[2]
|
|
30163
30172
|
);
|
|
30164
|
-
const resolvedTarget = target ? new
|
|
30165
|
-
const resolvedUp = new
|
|
30173
|
+
const resolvedTarget = target ? new THREE14.Vector3(target[0], target[1], target[2]) : defaultTarget.clone();
|
|
30174
|
+
const resolvedUp = new THREE14.Vector3(...up ?? [0, 0, 1]).normalize();
|
|
30166
30175
|
const toOrientationHelper = orientationHelper.current;
|
|
30167
30176
|
toOrientationHelper.position.copy(toPosition);
|
|
30168
30177
|
toOrientationHelper.up.copy(resolvedUp);
|
|
@@ -30319,14 +30328,14 @@ var useCameraSession = () => {
|
|
|
30319
30328
|
|
|
30320
30329
|
// src/three-components/OrientationCubeCanvas.tsx
|
|
30321
30330
|
import { useEffect as useEffect15, useRef as useRef7 } from "react";
|
|
30322
|
-
import * as
|
|
30331
|
+
import * as THREE15 from "three";
|
|
30323
30332
|
import { Text as TroikaText } from "troika-three-text";
|
|
30324
30333
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
30325
30334
|
function computePointInFront(rotationVector, distance3) {
|
|
30326
|
-
const quaternion = new
|
|
30327
|
-
new
|
|
30335
|
+
const quaternion = new THREE15.Quaternion().setFromEuler(
|
|
30336
|
+
new THREE15.Euler(rotationVector.x, rotationVector.y, rotationVector.z)
|
|
30328
30337
|
);
|
|
30329
|
-
const forwardVector = new
|
|
30338
|
+
const forwardVector = new THREE15.Vector3(0, 0, 1);
|
|
30330
30339
|
forwardVector.applyQuaternion(quaternion);
|
|
30331
30340
|
const result = forwardVector.multiplyScalar(distance3);
|
|
30332
30341
|
return result;
|
|
@@ -30344,7 +30353,7 @@ var OrientationCubeCanvas = () => {
|
|
|
30344
30353
|
const canvas = document.createElement("canvas");
|
|
30345
30354
|
canvasRef.current = canvas;
|
|
30346
30355
|
containerRef.current.appendChild(canvas);
|
|
30347
|
-
const renderer = new
|
|
30356
|
+
const renderer = new THREE15.WebGLRenderer({
|
|
30348
30357
|
canvas,
|
|
30349
30358
|
antialias: true,
|
|
30350
30359
|
alpha: true
|
|
@@ -30352,26 +30361,26 @@ var OrientationCubeCanvas = () => {
|
|
|
30352
30361
|
renderer.setSize(120, 120);
|
|
30353
30362
|
renderer.setPixelRatio(window.devicePixelRatio);
|
|
30354
30363
|
rendererRef.current = renderer;
|
|
30355
|
-
const scene = new
|
|
30364
|
+
const scene = new THREE15.Scene();
|
|
30356
30365
|
sceneRef.current = scene;
|
|
30357
|
-
const camera = new
|
|
30366
|
+
const camera = new THREE15.PerspectiveCamera(75, 1, 0.1, 1e3);
|
|
30358
30367
|
camera.up.set(0, 0, 1);
|
|
30359
30368
|
cameraRef.current = camera;
|
|
30360
|
-
const ambientLight = new
|
|
30369
|
+
const ambientLight = new THREE15.AmbientLight(16777215, Math.PI / 2);
|
|
30361
30370
|
scene.add(ambientLight);
|
|
30362
|
-
const group = new
|
|
30371
|
+
const group = new THREE15.Group();
|
|
30363
30372
|
group.rotation.fromArray([Math.PI / 2, 0, 0]);
|
|
30364
30373
|
const cubeSize = 1;
|
|
30365
|
-
const box = new
|
|
30366
|
-
new
|
|
30367
|
-
new
|
|
30374
|
+
const box = new THREE15.Mesh(
|
|
30375
|
+
new THREE15.BoxGeometry(cubeSize, cubeSize, cubeSize),
|
|
30376
|
+
new THREE15.MeshStandardMaterial({ color: "white" })
|
|
30368
30377
|
);
|
|
30369
30378
|
group.add(box);
|
|
30370
|
-
const edges = new
|
|
30371
|
-
new
|
|
30372
|
-
new
|
|
30379
|
+
const edges = new THREE15.LineSegments(
|
|
30380
|
+
new THREE15.EdgesGeometry(
|
|
30381
|
+
new THREE15.BoxGeometry(cubeSize, cubeSize, cubeSize)
|
|
30373
30382
|
),
|
|
30374
|
-
new
|
|
30383
|
+
new THREE15.LineBasicMaterial({ color: 0, linewidth: 2 })
|
|
30375
30384
|
);
|
|
30376
30385
|
group.add(edges);
|
|
30377
30386
|
scene.add(group);
|
|
@@ -30425,7 +30434,7 @@ var OrientationCubeCanvas = () => {
|
|
|
30425
30434
|
const animate = () => {
|
|
30426
30435
|
if (mainCameraRef.current) {
|
|
30427
30436
|
const cameraPosition = computePointInFront(
|
|
30428
|
-
mainCameraRef.current.rotation ?? new
|
|
30437
|
+
mainCameraRef.current.rotation ?? new THREE15.Euler(0, 0, 0),
|
|
30429
30438
|
2
|
|
30430
30439
|
);
|
|
30431
30440
|
if (!cameraPosition.equals(camera.position)) {
|
|
@@ -30528,7 +30537,7 @@ var CadViewerContainer = forwardRef2(
|
|
|
30528
30537
|
Canvas,
|
|
30529
30538
|
{
|
|
30530
30539
|
ref,
|
|
30531
|
-
scene: { up: new
|
|
30540
|
+
scene: { up: new THREE16.Vector3(0, 0, 1) },
|
|
30532
30541
|
camera: { up: [0, 0, 1], position: initialCameraPosition },
|
|
30533
30542
|
onCreated: ({ camera }) => {
|
|
30534
30543
|
mainCameraRef.current = camera;
|
|
@@ -30703,6 +30712,7 @@ var MANIFOLD_Z_OFFSET = 1e-3;
|
|
|
30703
30712
|
var SMOOTH_CIRCLE_SEGMENTS = 32;
|
|
30704
30713
|
var DEFAULT_SMT_PAD_THICKNESS = 0.035;
|
|
30705
30714
|
var TRACE_TEXTURE_RESOLUTION = 150;
|
|
30715
|
+
var FAUX_BOARD_OPACITY = 0.6;
|
|
30706
30716
|
var boardMaterialColors = {
|
|
30707
30717
|
fr1: colors.fr1Tan,
|
|
30708
30718
|
fr4: colors.fr4Tan
|
|
@@ -32383,7 +32393,7 @@ var Text = ({
|
|
|
32383
32393
|
};
|
|
32384
32394
|
|
|
32385
32395
|
// src/three-components/Error3d.tsx
|
|
32386
|
-
import * as
|
|
32396
|
+
import * as THREE17 from "three";
|
|
32387
32397
|
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
32388
32398
|
var Error3d = ({
|
|
32389
32399
|
error,
|
|
@@ -32417,7 +32427,7 @@ var Error3d = ({
|
|
|
32417
32427
|
return [0, 0, 0];
|
|
32418
32428
|
}, [cad_component2]);
|
|
32419
32429
|
const group = useMemo17(() => {
|
|
32420
|
-
const g = new
|
|
32430
|
+
const g = new THREE17.Group();
|
|
32421
32431
|
g.position.fromArray(position);
|
|
32422
32432
|
return g;
|
|
32423
32433
|
}, [position]);
|
|
@@ -32477,9 +32487,9 @@ var Error3d = ({
|
|
|
32477
32487
|
};
|
|
32478
32488
|
var ErrorBox = ({ parent }) => {
|
|
32479
32489
|
const mesh = useMemo17(() => {
|
|
32480
|
-
const m = new
|
|
32481
|
-
new
|
|
32482
|
-
new
|
|
32490
|
+
const m = new THREE17.Mesh(
|
|
32491
|
+
new THREE17.BoxGeometry(0.5, 0.5, 0.5),
|
|
32492
|
+
new THREE17.MeshStandardMaterial({
|
|
32483
32493
|
depthTest: false,
|
|
32484
32494
|
transparent: true,
|
|
32485
32495
|
color: "red",
|
|
@@ -32501,7 +32511,7 @@ var ErrorBox = ({ parent }) => {
|
|
|
32501
32511
|
|
|
32502
32512
|
// src/three-components/STLModel.tsx
|
|
32503
32513
|
import { useState as useState13, useEffect as useEffect21, useMemo as useMemo18 } from "react";
|
|
32504
|
-
import * as
|
|
32514
|
+
import * as THREE18 from "three";
|
|
32505
32515
|
import { STLLoader } from "three-stdlib";
|
|
32506
32516
|
function STLModel({
|
|
32507
32517
|
stlUrl,
|
|
@@ -32532,12 +32542,12 @@ function STLModel({
|
|
|
32532
32542
|
}, [stlUrl, stlData]);
|
|
32533
32543
|
const mesh = useMemo18(() => {
|
|
32534
32544
|
if (!geom) return null;
|
|
32535
|
-
const material = new
|
|
32536
|
-
color: Array.isArray(color) ? new
|
|
32545
|
+
const material = new THREE18.MeshStandardMaterial({
|
|
32546
|
+
color: Array.isArray(color) ? new THREE18.Color(color[0], color[1], color[2]) : color,
|
|
32537
32547
|
transparent: opacity !== 1,
|
|
32538
32548
|
opacity
|
|
32539
32549
|
});
|
|
32540
|
-
return new
|
|
32550
|
+
return new THREE18.Mesh(geom, material);
|
|
32541
32551
|
}, [geom, color, opacity]);
|
|
32542
32552
|
useEffect21(() => {
|
|
32543
32553
|
if (!rootObject || !mesh) return;
|
|
@@ -32602,11 +32612,11 @@ var ThreeErrorBoundary = class extends React11.Component {
|
|
|
32602
32612
|
|
|
32603
32613
|
// src/three-components/JscadBoardTextures.tsx
|
|
32604
32614
|
import { useEffect as useEffect22, useMemo as useMemo19 } from "react";
|
|
32605
|
-
import * as
|
|
32615
|
+
import * as THREE24 from "three";
|
|
32606
32616
|
import { su as su9 } from "@tscircuit/circuit-json-util";
|
|
32607
32617
|
|
|
32608
32618
|
// src/utils/soldermask-texture.ts
|
|
32609
|
-
import * as
|
|
32619
|
+
import * as THREE19 from "three";
|
|
32610
32620
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
32611
32621
|
|
|
32612
32622
|
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
@@ -33151,10 +33161,10 @@ function createSoldermaskTextureForLayer({
|
|
|
33151
33161
|
}
|
|
33152
33162
|
});
|
|
33153
33163
|
ctx.globalCompositeOperation = "source-over";
|
|
33154
|
-
const texture = new
|
|
33164
|
+
const texture = new THREE19.CanvasTexture(canvas);
|
|
33155
33165
|
texture.generateMipmaps = true;
|
|
33156
|
-
texture.minFilter =
|
|
33157
|
-
texture.magFilter =
|
|
33166
|
+
texture.minFilter = THREE19.LinearMipmapLinearFilter;
|
|
33167
|
+
texture.magFilter = THREE19.LinearFilter;
|
|
33158
33168
|
texture.anisotropy = 16;
|
|
33159
33169
|
texture.needsUpdate = true;
|
|
33160
33170
|
return texture;
|
|
@@ -33162,7 +33172,7 @@ function createSoldermaskTextureForLayer({
|
|
|
33162
33172
|
|
|
33163
33173
|
// src/utils/silkscreen-texture.ts
|
|
33164
33174
|
var import_text = __toESM(require_text(), 1);
|
|
33165
|
-
import * as
|
|
33175
|
+
import * as THREE20 from "three";
|
|
33166
33176
|
|
|
33167
33177
|
// node_modules/transformation-matrix/src/applyToPoint.js
|
|
33168
33178
|
function applyToPoint(matrix, point2) {
|
|
@@ -33821,17 +33831,17 @@ function createSilkscreenTextureForLayer({
|
|
|
33821
33831
|
ctx.stroke();
|
|
33822
33832
|
});
|
|
33823
33833
|
});
|
|
33824
|
-
const texture = new
|
|
33834
|
+
const texture = new THREE20.CanvasTexture(canvas);
|
|
33825
33835
|
texture.generateMipmaps = true;
|
|
33826
|
-
texture.minFilter =
|
|
33827
|
-
texture.magFilter =
|
|
33836
|
+
texture.minFilter = THREE20.LinearMipmapLinearFilter;
|
|
33837
|
+
texture.magFilter = THREE20.LinearFilter;
|
|
33828
33838
|
texture.anisotropy = 16;
|
|
33829
33839
|
texture.needsUpdate = true;
|
|
33830
33840
|
return texture;
|
|
33831
33841
|
}
|
|
33832
33842
|
|
|
33833
33843
|
// src/utils/trace-texture.ts
|
|
33834
|
-
import * as
|
|
33844
|
+
import * as THREE21 from "three";
|
|
33835
33845
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
33836
33846
|
function isWireRoutePoint(point2) {
|
|
33837
33847
|
return point2 && point2.route_type === "wire" && typeof point2.layer === "string" && typeof point2.width === "number";
|
|
@@ -33919,10 +33929,10 @@ function createTraceTextureForLayer({
|
|
|
33919
33929
|
}
|
|
33920
33930
|
});
|
|
33921
33931
|
ctx.globalCompositeOperation = "source-over";
|
|
33922
|
-
const texture = new
|
|
33932
|
+
const texture = new THREE21.CanvasTexture(canvas);
|
|
33923
33933
|
texture.generateMipmaps = true;
|
|
33924
|
-
texture.minFilter =
|
|
33925
|
-
texture.magFilter =
|
|
33934
|
+
texture.minFilter = THREE21.LinearMipmapLinearFilter;
|
|
33935
|
+
texture.magFilter = THREE21.LinearFilter;
|
|
33926
33936
|
texture.anisotropy = 16;
|
|
33927
33937
|
texture.needsUpdate = true;
|
|
33928
33938
|
return texture;
|
|
@@ -33930,7 +33940,7 @@ function createTraceTextureForLayer({
|
|
|
33930
33940
|
|
|
33931
33941
|
// src/utils/copper-text-texture.ts
|
|
33932
33942
|
var import_text2 = __toESM(require_text(), 1);
|
|
33933
|
-
import * as
|
|
33943
|
+
import * as THREE22 from "three";
|
|
33934
33944
|
function parseDimension2(value, defaultValue) {
|
|
33935
33945
|
if (value === void 0) return defaultValue;
|
|
33936
33946
|
if (typeof value === "number") return value;
|
|
@@ -34169,17 +34179,17 @@ function createCopperTextTextureForLayer({
|
|
|
34169
34179
|
);
|
|
34170
34180
|
}
|
|
34171
34181
|
});
|
|
34172
|
-
const texture = new
|
|
34182
|
+
const texture = new THREE22.CanvasTexture(canvas);
|
|
34173
34183
|
texture.generateMipmaps = true;
|
|
34174
|
-
texture.minFilter =
|
|
34175
|
-
texture.magFilter =
|
|
34184
|
+
texture.minFilter = THREE22.LinearMipmapLinearFilter;
|
|
34185
|
+
texture.magFilter = THREE22.LinearFilter;
|
|
34176
34186
|
texture.anisotropy = 16;
|
|
34177
34187
|
texture.needsUpdate = true;
|
|
34178
34188
|
return texture;
|
|
34179
34189
|
}
|
|
34180
34190
|
|
|
34181
34191
|
// src/utils/panel-outline-texture.ts
|
|
34182
|
-
import * as
|
|
34192
|
+
import * as THREE23 from "three";
|
|
34183
34193
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
34184
34194
|
function createPanelOutlineTextureForLayer({
|
|
34185
34195
|
layer,
|
|
@@ -34235,10 +34245,10 @@ function createPanelOutlineTextureForLayer({
|
|
|
34235
34245
|
);
|
|
34236
34246
|
}
|
|
34237
34247
|
});
|
|
34238
|
-
const texture = new
|
|
34248
|
+
const texture = new THREE23.CanvasTexture(canvas);
|
|
34239
34249
|
texture.generateMipmaps = true;
|
|
34240
|
-
texture.minFilter =
|
|
34241
|
-
texture.magFilter =
|
|
34250
|
+
texture.minFilter = THREE23.LinearMipmapLinearFilter;
|
|
34251
|
+
texture.magFilter = THREE23.LinearFilter;
|
|
34242
34252
|
texture.anisotropy = 16;
|
|
34243
34253
|
texture.needsUpdate = true;
|
|
34244
34254
|
return texture;
|
|
@@ -34247,7 +34257,8 @@ function createPanelOutlineTextureForLayer({
|
|
|
34247
34257
|
// src/three-components/JscadBoardTextures.tsx
|
|
34248
34258
|
function JscadBoardTextures({
|
|
34249
34259
|
circuitJson,
|
|
34250
|
-
pcbThickness
|
|
34260
|
+
pcbThickness,
|
|
34261
|
+
isFaux = false
|
|
34251
34262
|
}) {
|
|
34252
34263
|
const { rootObject } = useThree();
|
|
34253
34264
|
const { visibility } = useLayerVisibility();
|
|
@@ -34361,20 +34372,21 @@ function JscadBoardTextures({
|
|
|
34361
34372
|
const createTexturePlane2 = (texture, zOffset, isBottomLayer, name, usePolygonOffset = false, depthWrite = false) => {
|
|
34362
34373
|
if (!texture) return null;
|
|
34363
34374
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
34364
|
-
const planeGeom = new
|
|
34375
|
+
const planeGeom = new THREE24.PlaneGeometry(
|
|
34365
34376
|
boardOutlineBounds.width,
|
|
34366
34377
|
boardOutlineBounds.height
|
|
34367
34378
|
);
|
|
34368
|
-
const material = new
|
|
34379
|
+
const material = new THREE24.MeshBasicMaterial({
|
|
34369
34380
|
map: texture,
|
|
34370
34381
|
transparent: true,
|
|
34371
|
-
side:
|
|
34382
|
+
side: THREE24.DoubleSide,
|
|
34372
34383
|
depthWrite,
|
|
34373
34384
|
polygonOffset: usePolygonOffset,
|
|
34374
34385
|
polygonOffsetFactor: usePolygonOffset ? -1 : 0,
|
|
34375
|
-
polygonOffsetUnits: usePolygonOffset ? -1 : 0
|
|
34386
|
+
polygonOffsetUnits: usePolygonOffset ? -1 : 0,
|
|
34387
|
+
opacity: isFaux ? FAUX_BOARD_OPACITY : 1
|
|
34376
34388
|
});
|
|
34377
|
-
const mesh = new
|
|
34389
|
+
const mesh = new THREE24.Mesh(planeGeom, material);
|
|
34378
34390
|
mesh.position.set(
|
|
34379
34391
|
boardOutlineBounds.centerX,
|
|
34380
34392
|
boardOutlineBounds.centerY,
|
|
@@ -34519,7 +34531,7 @@ function JscadBoardTextures({
|
|
|
34519
34531
|
rootObject.remove(mesh);
|
|
34520
34532
|
}
|
|
34521
34533
|
mesh.geometry.dispose();
|
|
34522
|
-
if (mesh.material instanceof
|
|
34534
|
+
if (mesh.material instanceof THREE24.Material) {
|
|
34523
34535
|
mesh.material.dispose();
|
|
34524
34536
|
}
|
|
34525
34537
|
});
|
|
@@ -34720,7 +34732,8 @@ var CadViewerJscad = forwardRef3(
|
|
|
34720
34732
|
JscadBoardTextures,
|
|
34721
34733
|
{
|
|
34722
34734
|
circuitJson: internalCircuitJson,
|
|
34723
|
-
pcbThickness
|
|
34735
|
+
pcbThickness,
|
|
34736
|
+
isFaux: isFauxBoard
|
|
34724
34737
|
}
|
|
34725
34738
|
),
|
|
34726
34739
|
cad_components.map((cad_component2) => /* @__PURE__ */ jsx16(
|
|
@@ -34751,7 +34764,7 @@ import { useEffect as useEffect24, useMemo as useMemo22, useState as useState15
|
|
|
34751
34764
|
// src/hooks/useManifoldBoardBuilder.ts
|
|
34752
34765
|
import { useState as useState14, useEffect as useEffect23, useMemo as useMemo21, useRef as useRef9 } from "react";
|
|
34753
34766
|
import { su as su18 } from "@tscircuit/circuit-json-util";
|
|
34754
|
-
import * as
|
|
34767
|
+
import * as THREE31 from "three";
|
|
34755
34768
|
|
|
34756
34769
|
// src/utils/manifold/create-manifold-board.ts
|
|
34757
34770
|
var arePointsClockwise3 = (points) => {
|
|
@@ -35101,17 +35114,17 @@ function processNonPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, m
|
|
|
35101
35114
|
|
|
35102
35115
|
// src/utils/manifold/process-plated-holes.ts
|
|
35103
35116
|
import { su as su15 } from "@tscircuit/circuit-json-util";
|
|
35104
|
-
import * as
|
|
35117
|
+
import * as THREE26 from "three";
|
|
35105
35118
|
|
|
35106
35119
|
// src/utils/manifold-mesh-to-three-geometry.ts
|
|
35107
|
-
import * as
|
|
35120
|
+
import * as THREE25 from "three";
|
|
35108
35121
|
function manifoldMeshToThreeGeometry(manifoldMesh) {
|
|
35109
|
-
const geometry = new
|
|
35122
|
+
const geometry = new THREE25.BufferGeometry();
|
|
35110
35123
|
geometry.setAttribute(
|
|
35111
35124
|
"position",
|
|
35112
|
-
new
|
|
35125
|
+
new THREE25.Float32BufferAttribute(manifoldMesh.vertProperties, 3)
|
|
35113
35126
|
);
|
|
35114
|
-
geometry.setIndex(new
|
|
35127
|
+
geometry.setIndex(new THREE25.Uint32BufferAttribute(manifoldMesh.triVerts, 1));
|
|
35115
35128
|
if (manifoldMesh.runIndex && manifoldMesh.runIndex.length > 1 && manifoldMesh.runOriginalID) {
|
|
35116
35129
|
for (let i = 0; i < manifoldMesh.runIndex.length - 1; i++) {
|
|
35117
35130
|
const start = manifoldMesh.runIndex[i];
|
|
@@ -35145,7 +35158,7 @@ var createEllipsePoints = (width10, height10, segments) => {
|
|
|
35145
35158
|
}
|
|
35146
35159
|
return points;
|
|
35147
35160
|
};
|
|
35148
|
-
var COPPER_COLOR = new
|
|
35161
|
+
var COPPER_COLOR = new THREE26.Color(...colors.copper);
|
|
35149
35162
|
var PLATED_HOLE_LIP_HEIGHT = 0.05;
|
|
35150
35163
|
function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
35151
35164
|
const platedHoleBoardDrills = [];
|
|
@@ -35719,8 +35732,8 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
35719
35732
|
|
|
35720
35733
|
// src/utils/manifold/process-smt-pads.ts
|
|
35721
35734
|
import { su as su16 } from "@tscircuit/circuit-json-util";
|
|
35722
|
-
import * as
|
|
35723
|
-
var COPPER_COLOR2 = new
|
|
35735
|
+
import * as THREE27 from "three";
|
|
35736
|
+
var COPPER_COLOR2 = new THREE27.Color(...colors.copper);
|
|
35724
35737
|
function processSmtPadsForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, holeUnion, boardClipVolume) {
|
|
35725
35738
|
const smtPadGeoms = [];
|
|
35726
35739
|
const smtPads = su16(circuitJson).pcb_smtpad.list();
|
|
@@ -35759,7 +35772,7 @@ function processSmtPadsForManifold(Manifold, circuitJson, pcbThickness, manifold
|
|
|
35759
35772
|
|
|
35760
35773
|
// src/utils/manifold/process-vias.ts
|
|
35761
35774
|
import { su as su17 } from "@tscircuit/circuit-json-util";
|
|
35762
|
-
import * as
|
|
35775
|
+
import * as THREE28 from "three";
|
|
35763
35776
|
|
|
35764
35777
|
// src/utils/via-geoms.ts
|
|
35765
35778
|
function createViaCopper2({
|
|
@@ -35812,7 +35825,7 @@ function createViaCopper2({
|
|
|
35812
35825
|
}
|
|
35813
35826
|
|
|
35814
35827
|
// src/utils/manifold/process-vias.ts
|
|
35815
|
-
var COPPER_COLOR3 = new
|
|
35828
|
+
var COPPER_COLOR3 = new THREE28.Color(...colors.copper);
|
|
35816
35829
|
function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
35817
35830
|
const viaBoardDrills = [];
|
|
35818
35831
|
const pcbVias = su17(circuitJson).pcb_via.list();
|
|
@@ -35864,7 +35877,7 @@ function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldIns
|
|
|
35864
35877
|
}
|
|
35865
35878
|
|
|
35866
35879
|
// src/textures/create-copper-pour-texture-for-layer.ts
|
|
35867
|
-
import * as
|
|
35880
|
+
import * as THREE29 from "three";
|
|
35868
35881
|
import { CircuitToCanvasDrawer } from "circuit-to-canvas";
|
|
35869
35882
|
function drawPolygon({
|
|
35870
35883
|
ctx,
|
|
@@ -36010,17 +36023,17 @@ function createCopperPourTextureForLayer({
|
|
|
36010
36023
|
ctx.fillStyle = copperColor;
|
|
36011
36024
|
drawBrepShape({ ctx, pour, canvasXFromPcb, canvasYFromPcb });
|
|
36012
36025
|
}
|
|
36013
|
-
const texture = new
|
|
36026
|
+
const texture = new THREE29.CanvasTexture(canvas);
|
|
36014
36027
|
texture.generateMipmaps = true;
|
|
36015
|
-
texture.minFilter =
|
|
36016
|
-
texture.magFilter =
|
|
36028
|
+
texture.minFilter = THREE29.LinearMipmapLinearFilter;
|
|
36029
|
+
texture.magFilter = THREE29.LinearFilter;
|
|
36017
36030
|
texture.anisotropy = 16;
|
|
36018
36031
|
texture.needsUpdate = true;
|
|
36019
36032
|
return texture;
|
|
36020
36033
|
}
|
|
36021
36034
|
|
|
36022
36035
|
// src/textures/create-three-texture-meshes.ts
|
|
36023
|
-
import * as
|
|
36036
|
+
import * as THREE30 from "three";
|
|
36024
36037
|
function createTexturePlane(config, boardData) {
|
|
36025
36038
|
const {
|
|
36026
36039
|
texture,
|
|
@@ -36028,25 +36041,27 @@ function createTexturePlane(config, boardData) {
|
|
|
36028
36041
|
isBottomLayer,
|
|
36029
36042
|
textureType,
|
|
36030
36043
|
usePolygonOffset = false,
|
|
36031
|
-
renderOrder = 0
|
|
36044
|
+
renderOrder = 0,
|
|
36045
|
+
isFaux = false
|
|
36032
36046
|
} = config;
|
|
36033
36047
|
if (!texture) return null;
|
|
36034
36048
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
36035
|
-
const planeGeom = new
|
|
36049
|
+
const planeGeom = new THREE30.PlaneGeometry(
|
|
36036
36050
|
boardOutlineBounds.width,
|
|
36037
36051
|
boardOutlineBounds.height
|
|
36038
36052
|
);
|
|
36039
|
-
const material = new
|
|
36053
|
+
const material = new THREE30.MeshBasicMaterial({
|
|
36040
36054
|
map: texture,
|
|
36041
36055
|
transparent: true,
|
|
36042
|
-
side:
|
|
36056
|
+
side: THREE30.DoubleSide,
|
|
36043
36057
|
depthWrite: textureType === "panel-outlines",
|
|
36044
36058
|
polygonOffset: usePolygonOffset,
|
|
36045
36059
|
polygonOffsetFactor: usePolygonOffset ? -4 : 0,
|
|
36046
36060
|
// Increased for better z-fighting prevention
|
|
36047
|
-
polygonOffsetUnits: usePolygonOffset ? -4 : 0
|
|
36061
|
+
polygonOffsetUnits: usePolygonOffset ? -4 : 0,
|
|
36062
|
+
opacity: isFaux ? FAUX_BOARD_OPACITY : 1
|
|
36048
36063
|
});
|
|
36049
|
-
const mesh = new
|
|
36064
|
+
const mesh = new THREE30.Mesh(planeGeom, material);
|
|
36050
36065
|
mesh.position.set(
|
|
36051
36066
|
boardOutlineBounds.centerX,
|
|
36052
36067
|
boardOutlineBounds.centerY,
|
|
@@ -36059,7 +36074,7 @@ function createTexturePlane(config, boardData) {
|
|
|
36059
36074
|
mesh.renderOrder = renderOrder;
|
|
36060
36075
|
return mesh;
|
|
36061
36076
|
}
|
|
36062
|
-
function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
36077
|
+
function createTextureMeshes(textures, boardData, pcbThickness, isFaux = false) {
|
|
36063
36078
|
const meshes = [];
|
|
36064
36079
|
if (!textures || !boardData || pcbThickness === null) return meshes;
|
|
36065
36080
|
const topTraceMesh = createTexturePlane(
|
|
@@ -36070,8 +36085,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36070
36085
|
isBottomLayer: false,
|
|
36071
36086
|
textureType: "trace",
|
|
36072
36087
|
usePolygonOffset: false,
|
|
36073
|
-
renderOrder: 2
|
|
36088
|
+
renderOrder: 2,
|
|
36074
36089
|
// Render after soldermask
|
|
36090
|
+
isFaux
|
|
36075
36091
|
},
|
|
36076
36092
|
boardData
|
|
36077
36093
|
);
|
|
@@ -36083,8 +36099,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36083
36099
|
isBottomLayer: false,
|
|
36084
36100
|
textureType: "trace-with-mask",
|
|
36085
36101
|
usePolygonOffset: false,
|
|
36086
|
-
renderOrder: 2
|
|
36102
|
+
renderOrder: 2,
|
|
36087
36103
|
// Render after soldermask
|
|
36104
|
+
isFaux
|
|
36088
36105
|
},
|
|
36089
36106
|
boardData
|
|
36090
36107
|
);
|
|
@@ -36097,8 +36114,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36097
36114
|
isBottomLayer: false,
|
|
36098
36115
|
textureType: "silkscreen",
|
|
36099
36116
|
usePolygonOffset: false,
|
|
36100
|
-
renderOrder: 3
|
|
36117
|
+
renderOrder: 3,
|
|
36101
36118
|
// Render after traces
|
|
36119
|
+
isFaux
|
|
36102
36120
|
},
|
|
36103
36121
|
boardData
|
|
36104
36122
|
);
|
|
@@ -36111,8 +36129,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36111
36129
|
isBottomLayer: true,
|
|
36112
36130
|
textureType: "trace",
|
|
36113
36131
|
usePolygonOffset: false,
|
|
36114
|
-
renderOrder: 2
|
|
36132
|
+
renderOrder: 2,
|
|
36115
36133
|
// Render after soldermask
|
|
36134
|
+
isFaux
|
|
36116
36135
|
},
|
|
36117
36136
|
boardData
|
|
36118
36137
|
);
|
|
@@ -36124,8 +36143,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36124
36143
|
isBottomLayer: true,
|
|
36125
36144
|
textureType: "trace-with-mask",
|
|
36126
36145
|
usePolygonOffset: false,
|
|
36127
|
-
renderOrder: 2
|
|
36146
|
+
renderOrder: 2,
|
|
36128
36147
|
// Render after soldermask
|
|
36148
|
+
isFaux
|
|
36129
36149
|
},
|
|
36130
36150
|
boardData
|
|
36131
36151
|
);
|
|
@@ -36137,8 +36157,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36137
36157
|
isBottomLayer: true,
|
|
36138
36158
|
textureType: "silkscreen",
|
|
36139
36159
|
usePolygonOffset: false,
|
|
36140
|
-
renderOrder: 3
|
|
36160
|
+
renderOrder: 3,
|
|
36141
36161
|
// Render after traces
|
|
36162
|
+
isFaux
|
|
36142
36163
|
},
|
|
36143
36164
|
boardData
|
|
36144
36165
|
);
|
|
@@ -36152,8 +36173,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36152
36173
|
textureType: "soldermask",
|
|
36153
36174
|
usePolygonOffset: true,
|
|
36154
36175
|
// Enable polygon offset
|
|
36155
|
-
renderOrder: 1
|
|
36176
|
+
renderOrder: 1,
|
|
36156
36177
|
// Render after board (renderOrder)
|
|
36178
|
+
isFaux
|
|
36157
36179
|
},
|
|
36158
36180
|
boardData
|
|
36159
36181
|
);
|
|
@@ -36167,8 +36189,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36167
36189
|
textureType: "soldermask",
|
|
36168
36190
|
usePolygonOffset: true,
|
|
36169
36191
|
// Enable polygon offset
|
|
36170
|
-
renderOrder: 1
|
|
36192
|
+
renderOrder: 1,
|
|
36171
36193
|
// Render after board (renderOrder)
|
|
36194
|
+
isFaux
|
|
36172
36195
|
},
|
|
36173
36196
|
boardData
|
|
36174
36197
|
);
|
|
@@ -36180,8 +36203,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36180
36203
|
isBottomLayer: false,
|
|
36181
36204
|
textureType: "copper-text",
|
|
36182
36205
|
usePolygonOffset: false,
|
|
36183
|
-
renderOrder: 2
|
|
36206
|
+
renderOrder: 2,
|
|
36184
36207
|
// Render after soldermask
|
|
36208
|
+
isFaux
|
|
36185
36209
|
},
|
|
36186
36210
|
boardData
|
|
36187
36211
|
);
|
|
@@ -36193,8 +36217,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36193
36217
|
isBottomLayer: true,
|
|
36194
36218
|
textureType: "copper-text",
|
|
36195
36219
|
usePolygonOffset: false,
|
|
36196
|
-
renderOrder: 2
|
|
36220
|
+
renderOrder: 2,
|
|
36197
36221
|
// Render after soldermask
|
|
36222
|
+
isFaux
|
|
36198
36223
|
},
|
|
36199
36224
|
boardData
|
|
36200
36225
|
);
|
|
@@ -36206,8 +36231,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36206
36231
|
isBottomLayer: false,
|
|
36207
36232
|
textureType: "copper",
|
|
36208
36233
|
usePolygonOffset: false,
|
|
36209
|
-
renderOrder: 2
|
|
36234
|
+
renderOrder: 2,
|
|
36210
36235
|
// Render after soldermask
|
|
36236
|
+
isFaux
|
|
36211
36237
|
},
|
|
36212
36238
|
boardData
|
|
36213
36239
|
);
|
|
@@ -36219,8 +36245,9 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36219
36245
|
isBottomLayer: true,
|
|
36220
36246
|
textureType: "copper",
|
|
36221
36247
|
usePolygonOffset: false,
|
|
36222
|
-
renderOrder: 2
|
|
36248
|
+
renderOrder: 2,
|
|
36223
36249
|
// Render after soldermask
|
|
36250
|
+
isFaux
|
|
36224
36251
|
},
|
|
36225
36252
|
boardData
|
|
36226
36253
|
);
|
|
@@ -36233,7 +36260,8 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36233
36260
|
isBottomLayer: false,
|
|
36234
36261
|
textureType: "panel-outlines",
|
|
36235
36262
|
usePolygonOffset: false,
|
|
36236
|
-
renderOrder: 4
|
|
36263
|
+
renderOrder: 4,
|
|
36264
|
+
isFaux
|
|
36237
36265
|
},
|
|
36238
36266
|
boardData
|
|
36239
36267
|
);
|
|
@@ -36246,7 +36274,8 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
36246
36274
|
isBottomLayer: true,
|
|
36247
36275
|
textureType: "panel-outlines",
|
|
36248
36276
|
usePolygonOffset: false,
|
|
36249
|
-
renderOrder: 4
|
|
36277
|
+
renderOrder: 4,
|
|
36278
|
+
isFaux
|
|
36250
36279
|
},
|
|
36251
36280
|
boardData
|
|
36252
36281
|
);
|
|
@@ -36422,7 +36451,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
36422
36451
|
{
|
|
36423
36452
|
key: "plated-holes-union",
|
|
36424
36453
|
geometry: cutPlatedGeom,
|
|
36425
|
-
color: new
|
|
36454
|
+
color: new THREE31.Color(
|
|
36426
36455
|
colors.copper[0],
|
|
36427
36456
|
colors.copper[1],
|
|
36428
36457
|
colors.copper[2]
|
|
@@ -36452,7 +36481,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
36452
36481
|
const matColorArray = boardMaterialColors[boardData.material] ?? colors.fr4Tan;
|
|
36453
36482
|
currentGeoms.board = {
|
|
36454
36483
|
geometry: finalBoardGeom,
|
|
36455
|
-
color: new
|
|
36484
|
+
color: new THREE31.Color(
|
|
36456
36485
|
matColorArray[0],
|
|
36457
36486
|
matColorArray[1],
|
|
36458
36487
|
matColorArray[2]
|
|
@@ -36602,11 +36631,11 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
36602
36631
|
};
|
|
36603
36632
|
|
|
36604
36633
|
// src/utils/manifold/create-three-geometry-meshes.ts
|
|
36605
|
-
import * as
|
|
36634
|
+
import * as THREE33 from "three";
|
|
36606
36635
|
|
|
36607
36636
|
// src/utils/create-board-material.ts
|
|
36608
|
-
import * as
|
|
36609
|
-
var DEFAULT_SIDE =
|
|
36637
|
+
import * as THREE32 from "three";
|
|
36638
|
+
var DEFAULT_SIDE = THREE32.DoubleSide;
|
|
36610
36639
|
var createBoardMaterial = ({
|
|
36611
36640
|
material,
|
|
36612
36641
|
color,
|
|
@@ -36614,7 +36643,7 @@ var createBoardMaterial = ({
|
|
|
36614
36643
|
isFaux = false
|
|
36615
36644
|
}) => {
|
|
36616
36645
|
if (material === "fr4") {
|
|
36617
|
-
return new
|
|
36646
|
+
return new THREE32.MeshPhysicalMaterial({
|
|
36618
36647
|
color,
|
|
36619
36648
|
side,
|
|
36620
36649
|
metalness: 0,
|
|
@@ -36624,18 +36653,18 @@ var createBoardMaterial = ({
|
|
|
36624
36653
|
sheen: 0,
|
|
36625
36654
|
clearcoat: 0,
|
|
36626
36655
|
transparent: isFaux,
|
|
36627
|
-
opacity: isFaux ?
|
|
36656
|
+
opacity: isFaux ? FAUX_BOARD_OPACITY : 1,
|
|
36628
36657
|
flatShading: true
|
|
36629
36658
|
});
|
|
36630
36659
|
}
|
|
36631
|
-
return new
|
|
36660
|
+
return new THREE32.MeshStandardMaterial({
|
|
36632
36661
|
color,
|
|
36633
36662
|
side,
|
|
36634
36663
|
flatShading: true,
|
|
36635
36664
|
metalness: 0.1,
|
|
36636
36665
|
roughness: 0.8,
|
|
36637
36666
|
transparent: true,
|
|
36638
|
-
opacity: isFaux ?
|
|
36667
|
+
opacity: isFaux ? FAUX_BOARD_OPACITY : 0.9
|
|
36639
36668
|
});
|
|
36640
36669
|
};
|
|
36641
36670
|
|
|
@@ -36644,12 +36673,12 @@ function createGeometryMeshes(geoms) {
|
|
|
36644
36673
|
const meshes = [];
|
|
36645
36674
|
if (!geoms) return meshes;
|
|
36646
36675
|
if (geoms.board && geoms.board.geometry) {
|
|
36647
|
-
const mesh = new
|
|
36676
|
+
const mesh = new THREE33.Mesh(
|
|
36648
36677
|
geoms.board.geometry,
|
|
36649
36678
|
createBoardMaterial({
|
|
36650
36679
|
material: geoms.board.material,
|
|
36651
36680
|
color: geoms.board.color,
|
|
36652
|
-
side:
|
|
36681
|
+
side: THREE33.DoubleSide,
|
|
36653
36682
|
isFaux: geoms.board.isFaux
|
|
36654
36683
|
})
|
|
36655
36684
|
);
|
|
@@ -36659,11 +36688,11 @@ function createGeometryMeshes(geoms) {
|
|
|
36659
36688
|
const createMeshesFromArray = (geomArray) => {
|
|
36660
36689
|
if (geomArray) {
|
|
36661
36690
|
geomArray.forEach((comp) => {
|
|
36662
|
-
const mesh = new
|
|
36691
|
+
const mesh = new THREE33.Mesh(
|
|
36663
36692
|
comp.geometry,
|
|
36664
|
-
new
|
|
36693
|
+
new THREE33.MeshStandardMaterial({
|
|
36665
36694
|
color: comp.color,
|
|
36666
|
-
side:
|
|
36695
|
+
side: THREE33.DoubleSide,
|
|
36667
36696
|
flatShading: true,
|
|
36668
36697
|
// Consistent with board
|
|
36669
36698
|
polygonOffset: true,
|
|
@@ -36843,12 +36872,13 @@ try {
|
|
|
36843
36872
|
pcbThickness,
|
|
36844
36873
|
error: builderError,
|
|
36845
36874
|
isLoading: builderIsLoading,
|
|
36846
|
-
boardData
|
|
36875
|
+
boardData,
|
|
36876
|
+
isFauxBoard
|
|
36847
36877
|
} = useManifoldBoardBuilder(manifoldJSModule, circuitJson);
|
|
36848
36878
|
const geometryMeshes = useMemo22(() => createGeometryMeshes(geoms), [geoms]);
|
|
36849
36879
|
const textureMeshes = useMemo22(
|
|
36850
|
-
() => createTextureMeshes(textures, boardData, pcbThickness),
|
|
36851
|
-
[textures, boardData, pcbThickness]
|
|
36880
|
+
() => createTextureMeshes(textures, boardData, pcbThickness, isFauxBoard),
|
|
36881
|
+
[textures, boardData, pcbThickness, isFauxBoard]
|
|
36852
36882
|
);
|
|
36853
36883
|
const cadComponents = useMemo22(
|
|
36854
36884
|
() => su19(circuitJson).cad_component.list(),
|
|
@@ -43592,7 +43622,7 @@ var KeyboardShortcutsDialog = ({
|
|
|
43592
43622
|
|
|
43593
43623
|
// src/CadViewer.tsx
|
|
43594
43624
|
import { jsx as jsx37, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
43595
|
-
var DEFAULT_TARGET = new
|
|
43625
|
+
var DEFAULT_TARGET = new THREE34.Vector3(0, 0, 0);
|
|
43596
43626
|
var INITIAL_CAMERA_POSITION = [5, -5, 5];
|
|
43597
43627
|
var CadViewerInner = (props) => {
|
|
43598
43628
|
const [engine, setEngine] = useState35("manifold");
|
|
@@ -43859,11 +43889,11 @@ var CadViewer = (props) => {
|
|
|
43859
43889
|
// src/convert-circuit-json-to-3d-svg.ts
|
|
43860
43890
|
var import_debug = __toESM(require_browser(), 1);
|
|
43861
43891
|
import { su as su20 } from "@tscircuit/circuit-json-util";
|
|
43862
|
-
import * as
|
|
43892
|
+
import * as THREE38 from "three";
|
|
43863
43893
|
import { SVGRenderer } from "three/examples/jsm/renderers/SVGRenderer.js";
|
|
43864
43894
|
|
|
43865
43895
|
// src/utils/create-geometry-from-polygons.ts
|
|
43866
|
-
import * as
|
|
43896
|
+
import * as THREE35 from "three";
|
|
43867
43897
|
import { BufferGeometry as BufferGeometry3, Float32BufferAttribute as Float32BufferAttribute2 } from "three";
|
|
43868
43898
|
function createGeometryFromPolygons(polygons) {
|
|
43869
43899
|
const geometry = new BufferGeometry3();
|
|
@@ -43877,12 +43907,12 @@ function createGeometryFromPolygons(polygons) {
|
|
|
43877
43907
|
...polygon3.vertices[i + 1]
|
|
43878
43908
|
// Third vertex
|
|
43879
43909
|
);
|
|
43880
|
-
const v1 = new
|
|
43881
|
-
const v2 = new
|
|
43882
|
-
const v3 = new
|
|
43883
|
-
const normal = new
|
|
43884
|
-
new
|
|
43885
|
-
new
|
|
43910
|
+
const v1 = new THREE35.Vector3(...polygon3.vertices[0]);
|
|
43911
|
+
const v2 = new THREE35.Vector3(...polygon3.vertices[i]);
|
|
43912
|
+
const v3 = new THREE35.Vector3(...polygon3.vertices[i + 1]);
|
|
43913
|
+
const normal = new THREE35.Vector3().crossVectors(
|
|
43914
|
+
new THREE35.Vector3().subVectors(v2, v1),
|
|
43915
|
+
new THREE35.Vector3().subVectors(v3, v1)
|
|
43886
43916
|
).normalize();
|
|
43887
43917
|
normals.push(
|
|
43888
43918
|
normal.x,
|
|
@@ -43906,10 +43936,10 @@ function createGeometryFromPolygons(polygons) {
|
|
|
43906
43936
|
var import_modeling2 = __toESM(require_src(), 1);
|
|
43907
43937
|
var import_jscad_planner2 = __toESM(require_dist(), 1);
|
|
43908
43938
|
var jscadModeling2 = __toESM(require_src(), 1);
|
|
43909
|
-
import * as
|
|
43939
|
+
import * as THREE37 from "three";
|
|
43910
43940
|
|
|
43911
43941
|
// src/utils/load-model.ts
|
|
43912
|
-
import * as
|
|
43942
|
+
import * as THREE36 from "three";
|
|
43913
43943
|
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
43914
43944
|
import { OBJLoader as OBJLoader2 } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
43915
43945
|
import { STLLoader as STLLoader2 } from "three/examples/jsm/loaders/STLLoader.js";
|
|
@@ -43917,12 +43947,12 @@ async function load3DModel(url) {
|
|
|
43917
43947
|
if (url.endsWith(".stl")) {
|
|
43918
43948
|
const loader = new STLLoader2();
|
|
43919
43949
|
const geometry = await loader.loadAsync(url);
|
|
43920
|
-
const material = new
|
|
43950
|
+
const material = new THREE36.MeshStandardMaterial({
|
|
43921
43951
|
color: 8947848,
|
|
43922
43952
|
metalness: 0.5,
|
|
43923
43953
|
roughness: 0.5
|
|
43924
43954
|
});
|
|
43925
|
-
return new
|
|
43955
|
+
return new THREE36.Mesh(geometry, material);
|
|
43926
43956
|
}
|
|
43927
43957
|
if (url.endsWith(".obj")) {
|
|
43928
43958
|
const loader = new OBJLoader2();
|
|
@@ -43955,9 +43985,9 @@ async function renderComponent(component, scene) {
|
|
|
43955
43985
|
}
|
|
43956
43986
|
if (component.rotation) {
|
|
43957
43987
|
model.rotation.set(
|
|
43958
|
-
|
|
43959
|
-
|
|
43960
|
-
|
|
43988
|
+
THREE37.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
43989
|
+
THREE37.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
43990
|
+
THREE37.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
43961
43991
|
);
|
|
43962
43992
|
}
|
|
43963
43993
|
scene.add(model);
|
|
@@ -43971,13 +44001,13 @@ async function renderComponent(component, scene) {
|
|
|
43971
44001
|
);
|
|
43972
44002
|
if (jscadObject && (jscadObject.polygons || jscadObject.sides)) {
|
|
43973
44003
|
const threeGeom = convertCSGToThreeGeom(jscadObject);
|
|
43974
|
-
const material2 = new
|
|
44004
|
+
const material2 = new THREE37.MeshStandardMaterial({
|
|
43975
44005
|
color: 8947848,
|
|
43976
44006
|
metalness: 0.5,
|
|
43977
44007
|
roughness: 0.5,
|
|
43978
|
-
side:
|
|
44008
|
+
side: THREE37.DoubleSide
|
|
43979
44009
|
});
|
|
43980
|
-
const mesh2 = new
|
|
44010
|
+
const mesh2 = new THREE37.Mesh(threeGeom, material2);
|
|
43981
44011
|
if (component.position) {
|
|
43982
44012
|
mesh2.position.set(
|
|
43983
44013
|
component.position.x ?? 0,
|
|
@@ -43987,9 +44017,9 @@ async function renderComponent(component, scene) {
|
|
|
43987
44017
|
}
|
|
43988
44018
|
if (component.rotation) {
|
|
43989
44019
|
mesh2.rotation.set(
|
|
43990
|
-
|
|
43991
|
-
|
|
43992
|
-
|
|
44020
|
+
THREE37.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
44021
|
+
THREE37.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
44022
|
+
THREE37.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
43993
44023
|
);
|
|
43994
44024
|
}
|
|
43995
44025
|
scene.add(mesh2);
|
|
@@ -44006,17 +44036,17 @@ async function renderComponent(component, scene) {
|
|
|
44006
44036
|
if (!geom || !geom.polygons && !geom.sides) {
|
|
44007
44037
|
continue;
|
|
44008
44038
|
}
|
|
44009
|
-
const color = new
|
|
44039
|
+
const color = new THREE37.Color(geomInfo.color);
|
|
44010
44040
|
color.convertLinearToSRGB();
|
|
44011
44041
|
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
44012
44042
|
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
44013
|
-
const material2 = new
|
|
44043
|
+
const material2 = new THREE37.MeshStandardMaterial({
|
|
44014
44044
|
vertexColors: true,
|
|
44015
44045
|
metalness: 0.2,
|
|
44016
44046
|
roughness: 0.8,
|
|
44017
|
-
side:
|
|
44047
|
+
side: THREE37.DoubleSide
|
|
44018
44048
|
});
|
|
44019
|
-
const mesh2 = new
|
|
44049
|
+
const mesh2 = new THREE37.Mesh(threeGeom, material2);
|
|
44020
44050
|
if (component.position) {
|
|
44021
44051
|
mesh2.position.set(
|
|
44022
44052
|
component.position.x ?? 0,
|
|
@@ -44026,22 +44056,22 @@ async function renderComponent(component, scene) {
|
|
|
44026
44056
|
}
|
|
44027
44057
|
if (component.rotation) {
|
|
44028
44058
|
mesh2.rotation.set(
|
|
44029
|
-
|
|
44030
|
-
|
|
44031
|
-
|
|
44059
|
+
THREE37.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
44060
|
+
THREE37.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
44061
|
+
THREE37.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
44032
44062
|
);
|
|
44033
44063
|
}
|
|
44034
44064
|
scene.add(mesh2);
|
|
44035
44065
|
}
|
|
44036
44066
|
return;
|
|
44037
44067
|
}
|
|
44038
|
-
const geometry = new
|
|
44039
|
-
const material = new
|
|
44068
|
+
const geometry = new THREE37.BoxGeometry(0.5, 0.5, 0.5);
|
|
44069
|
+
const material = new THREE37.MeshStandardMaterial({
|
|
44040
44070
|
color: 16711680,
|
|
44041
44071
|
transparent: true,
|
|
44042
44072
|
opacity: 0.25
|
|
44043
44073
|
});
|
|
44044
|
-
const mesh = new
|
|
44074
|
+
const mesh = new THREE37.Mesh(geometry, material);
|
|
44045
44075
|
if (component.position) {
|
|
44046
44076
|
mesh.position.set(
|
|
44047
44077
|
component.position.x ?? 0,
|
|
@@ -44062,11 +44092,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44062
44092
|
padding = 20,
|
|
44063
44093
|
zoom = 1.5
|
|
44064
44094
|
} = options;
|
|
44065
|
-
const scene = new
|
|
44095
|
+
const scene = new THREE38.Scene();
|
|
44066
44096
|
const renderer = new SVGRenderer();
|
|
44067
44097
|
renderer.setSize(width10, height10);
|
|
44068
|
-
renderer.setClearColor(new
|
|
44069
|
-
const camera = new
|
|
44098
|
+
renderer.setClearColor(new THREE38.Color(backgroundColor), 1);
|
|
44099
|
+
const camera = new THREE38.OrthographicCamera();
|
|
44070
44100
|
const aspect = width10 / height10;
|
|
44071
44101
|
const frustumSize = 100;
|
|
44072
44102
|
const halfFrustumSize = frustumSize / 2 / zoom;
|
|
@@ -44080,11 +44110,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44080
44110
|
camera.position.set(position.x, position.y, position.z);
|
|
44081
44111
|
camera.up.set(0, 1, 0);
|
|
44082
44112
|
const lookAt = options.camera?.lookAt ?? { x: 0, y: 0, z: 0 };
|
|
44083
|
-
camera.lookAt(new
|
|
44113
|
+
camera.lookAt(new THREE38.Vector3(lookAt.x, lookAt.y, lookAt.z));
|
|
44084
44114
|
camera.updateProjectionMatrix();
|
|
44085
|
-
const ambientLight = new
|
|
44115
|
+
const ambientLight = new THREE38.AmbientLight(16777215, Math.PI / 2);
|
|
44086
44116
|
scene.add(ambientLight);
|
|
44087
|
-
const pointLight = new
|
|
44117
|
+
const pointLight = new THREE38.PointLight(16777215, Math.PI / 4);
|
|
44088
44118
|
pointLight.position.set(-10, -10, 10);
|
|
44089
44119
|
scene.add(pointLight);
|
|
44090
44120
|
const components = su20(circuitJson).cad_component.list();
|
|
@@ -44095,7 +44125,7 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44095
44125
|
const boardGeom = createBoardGeomFromCircuitJson(circuitJson);
|
|
44096
44126
|
if (boardGeom) {
|
|
44097
44127
|
const solderMaskColor = colors.fr4SolderMaskGreen;
|
|
44098
|
-
const baseColor = new
|
|
44128
|
+
const baseColor = new THREE38.Color(
|
|
44099
44129
|
solderMaskColor[0],
|
|
44100
44130
|
solderMaskColor[1],
|
|
44101
44131
|
solderMaskColor[2]
|
|
@@ -44107,28 +44137,28 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44107
44137
|
const material = createBoardMaterial({
|
|
44108
44138
|
material: boardData?.material,
|
|
44109
44139
|
color: baseColor,
|
|
44110
|
-
side:
|
|
44140
|
+
side: THREE38.DoubleSide
|
|
44111
44141
|
});
|
|
44112
|
-
const mesh = new
|
|
44142
|
+
const mesh = new THREE38.Mesh(geometry, material);
|
|
44113
44143
|
scene.add(mesh);
|
|
44114
44144
|
}
|
|
44115
44145
|
}
|
|
44116
|
-
const gridColor = new
|
|
44117
|
-
const gridHelper = new
|
|
44146
|
+
const gridColor = new THREE38.Color(8947848);
|
|
44147
|
+
const gridHelper = new THREE38.GridHelper(100, 100, gridColor, gridColor);
|
|
44118
44148
|
gridHelper.rotation.x = Math.PI / 2;
|
|
44119
44149
|
const materials = Array.isArray(gridHelper.material) ? gridHelper.material : [gridHelper.material];
|
|
44120
44150
|
for (const mat of materials) {
|
|
44121
44151
|
mat.transparent = true;
|
|
44122
44152
|
mat.opacity = 0.3;
|
|
44123
|
-
if (mat instanceof
|
|
44153
|
+
if (mat instanceof THREE38.LineBasicMaterial) {
|
|
44124
44154
|
mat.color = gridColor;
|
|
44125
44155
|
mat.vertexColors = false;
|
|
44126
44156
|
}
|
|
44127
44157
|
}
|
|
44128
44158
|
scene.add(gridHelper);
|
|
44129
|
-
const box = new
|
|
44130
|
-
const center = box.getCenter(new
|
|
44131
|
-
const size5 = box.getSize(new
|
|
44159
|
+
const box = new THREE38.Box3().setFromObject(scene);
|
|
44160
|
+
const center = box.getCenter(new THREE38.Vector3());
|
|
44161
|
+
const size5 = box.getSize(new THREE38.Vector3());
|
|
44132
44162
|
scene.position.sub(center);
|
|
44133
44163
|
const maxDim = Math.max(size5.x, size5.y, size5.z);
|
|
44134
44164
|
if (maxDim > 0) {
|