@tscircuit/3d-viewer 0.0.478 → 0.0.479
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 +165 -156
- 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.478",
|
|
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;
|
|
@@ -32383,7 +32392,7 @@ var Text = ({
|
|
|
32383
32392
|
};
|
|
32384
32393
|
|
|
32385
32394
|
// src/three-components/Error3d.tsx
|
|
32386
|
-
import * as
|
|
32395
|
+
import * as THREE17 from "three";
|
|
32387
32396
|
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
32388
32397
|
var Error3d = ({
|
|
32389
32398
|
error,
|
|
@@ -32417,7 +32426,7 @@ var Error3d = ({
|
|
|
32417
32426
|
return [0, 0, 0];
|
|
32418
32427
|
}, [cad_component2]);
|
|
32419
32428
|
const group = useMemo17(() => {
|
|
32420
|
-
const g = new
|
|
32429
|
+
const g = new THREE17.Group();
|
|
32421
32430
|
g.position.fromArray(position);
|
|
32422
32431
|
return g;
|
|
32423
32432
|
}, [position]);
|
|
@@ -32477,9 +32486,9 @@ var Error3d = ({
|
|
|
32477
32486
|
};
|
|
32478
32487
|
var ErrorBox = ({ parent }) => {
|
|
32479
32488
|
const mesh = useMemo17(() => {
|
|
32480
|
-
const m = new
|
|
32481
|
-
new
|
|
32482
|
-
new
|
|
32489
|
+
const m = new THREE17.Mesh(
|
|
32490
|
+
new THREE17.BoxGeometry(0.5, 0.5, 0.5),
|
|
32491
|
+
new THREE17.MeshStandardMaterial({
|
|
32483
32492
|
depthTest: false,
|
|
32484
32493
|
transparent: true,
|
|
32485
32494
|
color: "red",
|
|
@@ -32501,7 +32510,7 @@ var ErrorBox = ({ parent }) => {
|
|
|
32501
32510
|
|
|
32502
32511
|
// src/three-components/STLModel.tsx
|
|
32503
32512
|
import { useState as useState13, useEffect as useEffect21, useMemo as useMemo18 } from "react";
|
|
32504
|
-
import * as
|
|
32513
|
+
import * as THREE18 from "three";
|
|
32505
32514
|
import { STLLoader } from "three-stdlib";
|
|
32506
32515
|
function STLModel({
|
|
32507
32516
|
stlUrl,
|
|
@@ -32532,12 +32541,12 @@ function STLModel({
|
|
|
32532
32541
|
}, [stlUrl, stlData]);
|
|
32533
32542
|
const mesh = useMemo18(() => {
|
|
32534
32543
|
if (!geom) return null;
|
|
32535
|
-
const material = new
|
|
32536
|
-
color: Array.isArray(color) ? new
|
|
32544
|
+
const material = new THREE18.MeshStandardMaterial({
|
|
32545
|
+
color: Array.isArray(color) ? new THREE18.Color(color[0], color[1], color[2]) : color,
|
|
32537
32546
|
transparent: opacity !== 1,
|
|
32538
32547
|
opacity
|
|
32539
32548
|
});
|
|
32540
|
-
return new
|
|
32549
|
+
return new THREE18.Mesh(geom, material);
|
|
32541
32550
|
}, [geom, color, opacity]);
|
|
32542
32551
|
useEffect21(() => {
|
|
32543
32552
|
if (!rootObject || !mesh) return;
|
|
@@ -32602,11 +32611,11 @@ var ThreeErrorBoundary = class extends React11.Component {
|
|
|
32602
32611
|
|
|
32603
32612
|
// src/three-components/JscadBoardTextures.tsx
|
|
32604
32613
|
import { useEffect as useEffect22, useMemo as useMemo19 } from "react";
|
|
32605
|
-
import * as
|
|
32614
|
+
import * as THREE24 from "three";
|
|
32606
32615
|
import { su as su9 } from "@tscircuit/circuit-json-util";
|
|
32607
32616
|
|
|
32608
32617
|
// src/utils/soldermask-texture.ts
|
|
32609
|
-
import * as
|
|
32618
|
+
import * as THREE19 from "three";
|
|
32610
32619
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
32611
32620
|
|
|
32612
32621
|
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
@@ -33151,10 +33160,10 @@ function createSoldermaskTextureForLayer({
|
|
|
33151
33160
|
}
|
|
33152
33161
|
});
|
|
33153
33162
|
ctx.globalCompositeOperation = "source-over";
|
|
33154
|
-
const texture = new
|
|
33163
|
+
const texture = new THREE19.CanvasTexture(canvas);
|
|
33155
33164
|
texture.generateMipmaps = true;
|
|
33156
|
-
texture.minFilter =
|
|
33157
|
-
texture.magFilter =
|
|
33165
|
+
texture.minFilter = THREE19.LinearMipmapLinearFilter;
|
|
33166
|
+
texture.magFilter = THREE19.LinearFilter;
|
|
33158
33167
|
texture.anisotropy = 16;
|
|
33159
33168
|
texture.needsUpdate = true;
|
|
33160
33169
|
return texture;
|
|
@@ -33162,7 +33171,7 @@ function createSoldermaskTextureForLayer({
|
|
|
33162
33171
|
|
|
33163
33172
|
// src/utils/silkscreen-texture.ts
|
|
33164
33173
|
var import_text = __toESM(require_text(), 1);
|
|
33165
|
-
import * as
|
|
33174
|
+
import * as THREE20 from "three";
|
|
33166
33175
|
|
|
33167
33176
|
// node_modules/transformation-matrix/src/applyToPoint.js
|
|
33168
33177
|
function applyToPoint(matrix, point2) {
|
|
@@ -33821,17 +33830,17 @@ function createSilkscreenTextureForLayer({
|
|
|
33821
33830
|
ctx.stroke();
|
|
33822
33831
|
});
|
|
33823
33832
|
});
|
|
33824
|
-
const texture = new
|
|
33833
|
+
const texture = new THREE20.CanvasTexture(canvas);
|
|
33825
33834
|
texture.generateMipmaps = true;
|
|
33826
|
-
texture.minFilter =
|
|
33827
|
-
texture.magFilter =
|
|
33835
|
+
texture.minFilter = THREE20.LinearMipmapLinearFilter;
|
|
33836
|
+
texture.magFilter = THREE20.LinearFilter;
|
|
33828
33837
|
texture.anisotropy = 16;
|
|
33829
33838
|
texture.needsUpdate = true;
|
|
33830
33839
|
return texture;
|
|
33831
33840
|
}
|
|
33832
33841
|
|
|
33833
33842
|
// src/utils/trace-texture.ts
|
|
33834
|
-
import * as
|
|
33843
|
+
import * as THREE21 from "three";
|
|
33835
33844
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
33836
33845
|
function isWireRoutePoint(point2) {
|
|
33837
33846
|
return point2 && point2.route_type === "wire" && typeof point2.layer === "string" && typeof point2.width === "number";
|
|
@@ -33919,10 +33928,10 @@ function createTraceTextureForLayer({
|
|
|
33919
33928
|
}
|
|
33920
33929
|
});
|
|
33921
33930
|
ctx.globalCompositeOperation = "source-over";
|
|
33922
|
-
const texture = new
|
|
33931
|
+
const texture = new THREE21.CanvasTexture(canvas);
|
|
33923
33932
|
texture.generateMipmaps = true;
|
|
33924
|
-
texture.minFilter =
|
|
33925
|
-
texture.magFilter =
|
|
33933
|
+
texture.minFilter = THREE21.LinearMipmapLinearFilter;
|
|
33934
|
+
texture.magFilter = THREE21.LinearFilter;
|
|
33926
33935
|
texture.anisotropy = 16;
|
|
33927
33936
|
texture.needsUpdate = true;
|
|
33928
33937
|
return texture;
|
|
@@ -33930,7 +33939,7 @@ function createTraceTextureForLayer({
|
|
|
33930
33939
|
|
|
33931
33940
|
// src/utils/copper-text-texture.ts
|
|
33932
33941
|
var import_text2 = __toESM(require_text(), 1);
|
|
33933
|
-
import * as
|
|
33942
|
+
import * as THREE22 from "three";
|
|
33934
33943
|
function parseDimension2(value, defaultValue) {
|
|
33935
33944
|
if (value === void 0) return defaultValue;
|
|
33936
33945
|
if (typeof value === "number") return value;
|
|
@@ -34169,17 +34178,17 @@ function createCopperTextTextureForLayer({
|
|
|
34169
34178
|
);
|
|
34170
34179
|
}
|
|
34171
34180
|
});
|
|
34172
|
-
const texture = new
|
|
34181
|
+
const texture = new THREE22.CanvasTexture(canvas);
|
|
34173
34182
|
texture.generateMipmaps = true;
|
|
34174
|
-
texture.minFilter =
|
|
34175
|
-
texture.magFilter =
|
|
34183
|
+
texture.minFilter = THREE22.LinearMipmapLinearFilter;
|
|
34184
|
+
texture.magFilter = THREE22.LinearFilter;
|
|
34176
34185
|
texture.anisotropy = 16;
|
|
34177
34186
|
texture.needsUpdate = true;
|
|
34178
34187
|
return texture;
|
|
34179
34188
|
}
|
|
34180
34189
|
|
|
34181
34190
|
// src/utils/panel-outline-texture.ts
|
|
34182
|
-
import * as
|
|
34191
|
+
import * as THREE23 from "three";
|
|
34183
34192
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
34184
34193
|
function createPanelOutlineTextureForLayer({
|
|
34185
34194
|
layer,
|
|
@@ -34235,10 +34244,10 @@ function createPanelOutlineTextureForLayer({
|
|
|
34235
34244
|
);
|
|
34236
34245
|
}
|
|
34237
34246
|
});
|
|
34238
|
-
const texture = new
|
|
34247
|
+
const texture = new THREE23.CanvasTexture(canvas);
|
|
34239
34248
|
texture.generateMipmaps = true;
|
|
34240
|
-
texture.minFilter =
|
|
34241
|
-
texture.magFilter =
|
|
34249
|
+
texture.minFilter = THREE23.LinearMipmapLinearFilter;
|
|
34250
|
+
texture.magFilter = THREE23.LinearFilter;
|
|
34242
34251
|
texture.anisotropy = 16;
|
|
34243
34252
|
texture.needsUpdate = true;
|
|
34244
34253
|
return texture;
|
|
@@ -34361,20 +34370,20 @@ function JscadBoardTextures({
|
|
|
34361
34370
|
const createTexturePlane2 = (texture, zOffset, isBottomLayer, name, usePolygonOffset = false, depthWrite = false) => {
|
|
34362
34371
|
if (!texture) return null;
|
|
34363
34372
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
34364
|
-
const planeGeom = new
|
|
34373
|
+
const planeGeom = new THREE24.PlaneGeometry(
|
|
34365
34374
|
boardOutlineBounds.width,
|
|
34366
34375
|
boardOutlineBounds.height
|
|
34367
34376
|
);
|
|
34368
|
-
const material = new
|
|
34377
|
+
const material = new THREE24.MeshBasicMaterial({
|
|
34369
34378
|
map: texture,
|
|
34370
34379
|
transparent: true,
|
|
34371
|
-
side:
|
|
34380
|
+
side: THREE24.DoubleSide,
|
|
34372
34381
|
depthWrite,
|
|
34373
34382
|
polygonOffset: usePolygonOffset,
|
|
34374
34383
|
polygonOffsetFactor: usePolygonOffset ? -1 : 0,
|
|
34375
34384
|
polygonOffsetUnits: usePolygonOffset ? -1 : 0
|
|
34376
34385
|
});
|
|
34377
|
-
const mesh = new
|
|
34386
|
+
const mesh = new THREE24.Mesh(planeGeom, material);
|
|
34378
34387
|
mesh.position.set(
|
|
34379
34388
|
boardOutlineBounds.centerX,
|
|
34380
34389
|
boardOutlineBounds.centerY,
|
|
@@ -34519,7 +34528,7 @@ function JscadBoardTextures({
|
|
|
34519
34528
|
rootObject.remove(mesh);
|
|
34520
34529
|
}
|
|
34521
34530
|
mesh.geometry.dispose();
|
|
34522
|
-
if (mesh.material instanceof
|
|
34531
|
+
if (mesh.material instanceof THREE24.Material) {
|
|
34523
34532
|
mesh.material.dispose();
|
|
34524
34533
|
}
|
|
34525
34534
|
});
|
|
@@ -34751,7 +34760,7 @@ import { useEffect as useEffect24, useMemo as useMemo22, useState as useState15
|
|
|
34751
34760
|
// src/hooks/useManifoldBoardBuilder.ts
|
|
34752
34761
|
import { useState as useState14, useEffect as useEffect23, useMemo as useMemo21, useRef as useRef9 } from "react";
|
|
34753
34762
|
import { su as su18 } from "@tscircuit/circuit-json-util";
|
|
34754
|
-
import * as
|
|
34763
|
+
import * as THREE31 from "three";
|
|
34755
34764
|
|
|
34756
34765
|
// src/utils/manifold/create-manifold-board.ts
|
|
34757
34766
|
var arePointsClockwise3 = (points) => {
|
|
@@ -35101,17 +35110,17 @@ function processNonPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, m
|
|
|
35101
35110
|
|
|
35102
35111
|
// src/utils/manifold/process-plated-holes.ts
|
|
35103
35112
|
import { su as su15 } from "@tscircuit/circuit-json-util";
|
|
35104
|
-
import * as
|
|
35113
|
+
import * as THREE26 from "three";
|
|
35105
35114
|
|
|
35106
35115
|
// src/utils/manifold-mesh-to-three-geometry.ts
|
|
35107
|
-
import * as
|
|
35116
|
+
import * as THREE25 from "three";
|
|
35108
35117
|
function manifoldMeshToThreeGeometry(manifoldMesh) {
|
|
35109
|
-
const geometry = new
|
|
35118
|
+
const geometry = new THREE25.BufferGeometry();
|
|
35110
35119
|
geometry.setAttribute(
|
|
35111
35120
|
"position",
|
|
35112
|
-
new
|
|
35121
|
+
new THREE25.Float32BufferAttribute(manifoldMesh.vertProperties, 3)
|
|
35113
35122
|
);
|
|
35114
|
-
geometry.setIndex(new
|
|
35123
|
+
geometry.setIndex(new THREE25.Uint32BufferAttribute(manifoldMesh.triVerts, 1));
|
|
35115
35124
|
if (manifoldMesh.runIndex && manifoldMesh.runIndex.length > 1 && manifoldMesh.runOriginalID) {
|
|
35116
35125
|
for (let i = 0; i < manifoldMesh.runIndex.length - 1; i++) {
|
|
35117
35126
|
const start = manifoldMesh.runIndex[i];
|
|
@@ -35145,7 +35154,7 @@ var createEllipsePoints = (width10, height10, segments) => {
|
|
|
35145
35154
|
}
|
|
35146
35155
|
return points;
|
|
35147
35156
|
};
|
|
35148
|
-
var COPPER_COLOR = new
|
|
35157
|
+
var COPPER_COLOR = new THREE26.Color(...colors.copper);
|
|
35149
35158
|
var PLATED_HOLE_LIP_HEIGHT = 0.05;
|
|
35150
35159
|
function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
35151
35160
|
const platedHoleBoardDrills = [];
|
|
@@ -35719,8 +35728,8 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
35719
35728
|
|
|
35720
35729
|
// src/utils/manifold/process-smt-pads.ts
|
|
35721
35730
|
import { su as su16 } from "@tscircuit/circuit-json-util";
|
|
35722
|
-
import * as
|
|
35723
|
-
var COPPER_COLOR2 = new
|
|
35731
|
+
import * as THREE27 from "three";
|
|
35732
|
+
var COPPER_COLOR2 = new THREE27.Color(...colors.copper);
|
|
35724
35733
|
function processSmtPadsForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, holeUnion, boardClipVolume) {
|
|
35725
35734
|
const smtPadGeoms = [];
|
|
35726
35735
|
const smtPads = su16(circuitJson).pcb_smtpad.list();
|
|
@@ -35759,7 +35768,7 @@ function processSmtPadsForManifold(Manifold, circuitJson, pcbThickness, manifold
|
|
|
35759
35768
|
|
|
35760
35769
|
// src/utils/manifold/process-vias.ts
|
|
35761
35770
|
import { su as su17 } from "@tscircuit/circuit-json-util";
|
|
35762
|
-
import * as
|
|
35771
|
+
import * as THREE28 from "three";
|
|
35763
35772
|
|
|
35764
35773
|
// src/utils/via-geoms.ts
|
|
35765
35774
|
function createViaCopper2({
|
|
@@ -35812,7 +35821,7 @@ function createViaCopper2({
|
|
|
35812
35821
|
}
|
|
35813
35822
|
|
|
35814
35823
|
// src/utils/manifold/process-vias.ts
|
|
35815
|
-
var COPPER_COLOR3 = new
|
|
35824
|
+
var COPPER_COLOR3 = new THREE28.Color(...colors.copper);
|
|
35816
35825
|
function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
35817
35826
|
const viaBoardDrills = [];
|
|
35818
35827
|
const pcbVias = su17(circuitJson).pcb_via.list();
|
|
@@ -35864,7 +35873,7 @@ function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldIns
|
|
|
35864
35873
|
}
|
|
35865
35874
|
|
|
35866
35875
|
// src/textures/create-copper-pour-texture-for-layer.ts
|
|
35867
|
-
import * as
|
|
35876
|
+
import * as THREE29 from "three";
|
|
35868
35877
|
import { CircuitToCanvasDrawer } from "circuit-to-canvas";
|
|
35869
35878
|
function drawPolygon({
|
|
35870
35879
|
ctx,
|
|
@@ -36010,17 +36019,17 @@ function createCopperPourTextureForLayer({
|
|
|
36010
36019
|
ctx.fillStyle = copperColor;
|
|
36011
36020
|
drawBrepShape({ ctx, pour, canvasXFromPcb, canvasYFromPcb });
|
|
36012
36021
|
}
|
|
36013
|
-
const texture = new
|
|
36022
|
+
const texture = new THREE29.CanvasTexture(canvas);
|
|
36014
36023
|
texture.generateMipmaps = true;
|
|
36015
|
-
texture.minFilter =
|
|
36016
|
-
texture.magFilter =
|
|
36024
|
+
texture.minFilter = THREE29.LinearMipmapLinearFilter;
|
|
36025
|
+
texture.magFilter = THREE29.LinearFilter;
|
|
36017
36026
|
texture.anisotropy = 16;
|
|
36018
36027
|
texture.needsUpdate = true;
|
|
36019
36028
|
return texture;
|
|
36020
36029
|
}
|
|
36021
36030
|
|
|
36022
36031
|
// src/textures/create-three-texture-meshes.ts
|
|
36023
|
-
import * as
|
|
36032
|
+
import * as THREE30 from "three";
|
|
36024
36033
|
function createTexturePlane(config, boardData) {
|
|
36025
36034
|
const {
|
|
36026
36035
|
texture,
|
|
@@ -36032,21 +36041,21 @@ function createTexturePlane(config, boardData) {
|
|
|
36032
36041
|
} = config;
|
|
36033
36042
|
if (!texture) return null;
|
|
36034
36043
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
36035
|
-
const planeGeom = new
|
|
36044
|
+
const planeGeom = new THREE30.PlaneGeometry(
|
|
36036
36045
|
boardOutlineBounds.width,
|
|
36037
36046
|
boardOutlineBounds.height
|
|
36038
36047
|
);
|
|
36039
|
-
const material = new
|
|
36048
|
+
const material = new THREE30.MeshBasicMaterial({
|
|
36040
36049
|
map: texture,
|
|
36041
36050
|
transparent: true,
|
|
36042
|
-
side:
|
|
36051
|
+
side: THREE30.DoubleSide,
|
|
36043
36052
|
depthWrite: textureType === "panel-outlines",
|
|
36044
36053
|
polygonOffset: usePolygonOffset,
|
|
36045
36054
|
polygonOffsetFactor: usePolygonOffset ? -4 : 0,
|
|
36046
36055
|
// Increased for better z-fighting prevention
|
|
36047
36056
|
polygonOffsetUnits: usePolygonOffset ? -4 : 0
|
|
36048
36057
|
});
|
|
36049
|
-
const mesh = new
|
|
36058
|
+
const mesh = new THREE30.Mesh(planeGeom, material);
|
|
36050
36059
|
mesh.position.set(
|
|
36051
36060
|
boardOutlineBounds.centerX,
|
|
36052
36061
|
boardOutlineBounds.centerY,
|
|
@@ -36422,7 +36431,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
36422
36431
|
{
|
|
36423
36432
|
key: "plated-holes-union",
|
|
36424
36433
|
geometry: cutPlatedGeom,
|
|
36425
|
-
color: new
|
|
36434
|
+
color: new THREE31.Color(
|
|
36426
36435
|
colors.copper[0],
|
|
36427
36436
|
colors.copper[1],
|
|
36428
36437
|
colors.copper[2]
|
|
@@ -36452,7 +36461,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
36452
36461
|
const matColorArray = boardMaterialColors[boardData.material] ?? colors.fr4Tan;
|
|
36453
36462
|
currentGeoms.board = {
|
|
36454
36463
|
geometry: finalBoardGeom,
|
|
36455
|
-
color: new
|
|
36464
|
+
color: new THREE31.Color(
|
|
36456
36465
|
matColorArray[0],
|
|
36457
36466
|
matColorArray[1],
|
|
36458
36467
|
matColorArray[2]
|
|
@@ -36602,11 +36611,11 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
36602
36611
|
};
|
|
36603
36612
|
|
|
36604
36613
|
// src/utils/manifold/create-three-geometry-meshes.ts
|
|
36605
|
-
import * as
|
|
36614
|
+
import * as THREE33 from "three";
|
|
36606
36615
|
|
|
36607
36616
|
// src/utils/create-board-material.ts
|
|
36608
|
-
import * as
|
|
36609
|
-
var DEFAULT_SIDE =
|
|
36617
|
+
import * as THREE32 from "three";
|
|
36618
|
+
var DEFAULT_SIDE = THREE32.DoubleSide;
|
|
36610
36619
|
var createBoardMaterial = ({
|
|
36611
36620
|
material,
|
|
36612
36621
|
color,
|
|
@@ -36614,7 +36623,7 @@ var createBoardMaterial = ({
|
|
|
36614
36623
|
isFaux = false
|
|
36615
36624
|
}) => {
|
|
36616
36625
|
if (material === "fr4") {
|
|
36617
|
-
return new
|
|
36626
|
+
return new THREE32.MeshPhysicalMaterial({
|
|
36618
36627
|
color,
|
|
36619
36628
|
side,
|
|
36620
36629
|
metalness: 0,
|
|
@@ -36628,7 +36637,7 @@ var createBoardMaterial = ({
|
|
|
36628
36637
|
flatShading: true
|
|
36629
36638
|
});
|
|
36630
36639
|
}
|
|
36631
|
-
return new
|
|
36640
|
+
return new THREE32.MeshStandardMaterial({
|
|
36632
36641
|
color,
|
|
36633
36642
|
side,
|
|
36634
36643
|
flatShading: true,
|
|
@@ -36644,12 +36653,12 @@ function createGeometryMeshes(geoms) {
|
|
|
36644
36653
|
const meshes = [];
|
|
36645
36654
|
if (!geoms) return meshes;
|
|
36646
36655
|
if (geoms.board && geoms.board.geometry) {
|
|
36647
|
-
const mesh = new
|
|
36656
|
+
const mesh = new THREE33.Mesh(
|
|
36648
36657
|
geoms.board.geometry,
|
|
36649
36658
|
createBoardMaterial({
|
|
36650
36659
|
material: geoms.board.material,
|
|
36651
36660
|
color: geoms.board.color,
|
|
36652
|
-
side:
|
|
36661
|
+
side: THREE33.DoubleSide,
|
|
36653
36662
|
isFaux: geoms.board.isFaux
|
|
36654
36663
|
})
|
|
36655
36664
|
);
|
|
@@ -36659,11 +36668,11 @@ function createGeometryMeshes(geoms) {
|
|
|
36659
36668
|
const createMeshesFromArray = (geomArray) => {
|
|
36660
36669
|
if (geomArray) {
|
|
36661
36670
|
geomArray.forEach((comp) => {
|
|
36662
|
-
const mesh = new
|
|
36671
|
+
const mesh = new THREE33.Mesh(
|
|
36663
36672
|
comp.geometry,
|
|
36664
|
-
new
|
|
36673
|
+
new THREE33.MeshStandardMaterial({
|
|
36665
36674
|
color: comp.color,
|
|
36666
|
-
side:
|
|
36675
|
+
side: THREE33.DoubleSide,
|
|
36667
36676
|
flatShading: true,
|
|
36668
36677
|
// Consistent with board
|
|
36669
36678
|
polygonOffset: true,
|
|
@@ -43592,7 +43601,7 @@ var KeyboardShortcutsDialog = ({
|
|
|
43592
43601
|
|
|
43593
43602
|
// src/CadViewer.tsx
|
|
43594
43603
|
import { jsx as jsx37, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
43595
|
-
var DEFAULT_TARGET = new
|
|
43604
|
+
var DEFAULT_TARGET = new THREE34.Vector3(0, 0, 0);
|
|
43596
43605
|
var INITIAL_CAMERA_POSITION = [5, -5, 5];
|
|
43597
43606
|
var CadViewerInner = (props) => {
|
|
43598
43607
|
const [engine, setEngine] = useState35("manifold");
|
|
@@ -43859,11 +43868,11 @@ var CadViewer = (props) => {
|
|
|
43859
43868
|
// src/convert-circuit-json-to-3d-svg.ts
|
|
43860
43869
|
var import_debug = __toESM(require_browser(), 1);
|
|
43861
43870
|
import { su as su20 } from "@tscircuit/circuit-json-util";
|
|
43862
|
-
import * as
|
|
43871
|
+
import * as THREE38 from "three";
|
|
43863
43872
|
import { SVGRenderer } from "three/examples/jsm/renderers/SVGRenderer.js";
|
|
43864
43873
|
|
|
43865
43874
|
// src/utils/create-geometry-from-polygons.ts
|
|
43866
|
-
import * as
|
|
43875
|
+
import * as THREE35 from "three";
|
|
43867
43876
|
import { BufferGeometry as BufferGeometry3, Float32BufferAttribute as Float32BufferAttribute2 } from "three";
|
|
43868
43877
|
function createGeometryFromPolygons(polygons) {
|
|
43869
43878
|
const geometry = new BufferGeometry3();
|
|
@@ -43877,12 +43886,12 @@ function createGeometryFromPolygons(polygons) {
|
|
|
43877
43886
|
...polygon3.vertices[i + 1]
|
|
43878
43887
|
// Third vertex
|
|
43879
43888
|
);
|
|
43880
|
-
const v1 = new
|
|
43881
|
-
const v2 = new
|
|
43882
|
-
const v3 = new
|
|
43883
|
-
const normal = new
|
|
43884
|
-
new
|
|
43885
|
-
new
|
|
43889
|
+
const v1 = new THREE35.Vector3(...polygon3.vertices[0]);
|
|
43890
|
+
const v2 = new THREE35.Vector3(...polygon3.vertices[i]);
|
|
43891
|
+
const v3 = new THREE35.Vector3(...polygon3.vertices[i + 1]);
|
|
43892
|
+
const normal = new THREE35.Vector3().crossVectors(
|
|
43893
|
+
new THREE35.Vector3().subVectors(v2, v1),
|
|
43894
|
+
new THREE35.Vector3().subVectors(v3, v1)
|
|
43886
43895
|
).normalize();
|
|
43887
43896
|
normals.push(
|
|
43888
43897
|
normal.x,
|
|
@@ -43906,10 +43915,10 @@ function createGeometryFromPolygons(polygons) {
|
|
|
43906
43915
|
var import_modeling2 = __toESM(require_src(), 1);
|
|
43907
43916
|
var import_jscad_planner2 = __toESM(require_dist(), 1);
|
|
43908
43917
|
var jscadModeling2 = __toESM(require_src(), 1);
|
|
43909
|
-
import * as
|
|
43918
|
+
import * as THREE37 from "three";
|
|
43910
43919
|
|
|
43911
43920
|
// src/utils/load-model.ts
|
|
43912
|
-
import * as
|
|
43921
|
+
import * as THREE36 from "three";
|
|
43913
43922
|
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
43914
43923
|
import { OBJLoader as OBJLoader2 } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
43915
43924
|
import { STLLoader as STLLoader2 } from "three/examples/jsm/loaders/STLLoader.js";
|
|
@@ -43917,12 +43926,12 @@ async function load3DModel(url) {
|
|
|
43917
43926
|
if (url.endsWith(".stl")) {
|
|
43918
43927
|
const loader = new STLLoader2();
|
|
43919
43928
|
const geometry = await loader.loadAsync(url);
|
|
43920
|
-
const material = new
|
|
43929
|
+
const material = new THREE36.MeshStandardMaterial({
|
|
43921
43930
|
color: 8947848,
|
|
43922
43931
|
metalness: 0.5,
|
|
43923
43932
|
roughness: 0.5
|
|
43924
43933
|
});
|
|
43925
|
-
return new
|
|
43934
|
+
return new THREE36.Mesh(geometry, material);
|
|
43926
43935
|
}
|
|
43927
43936
|
if (url.endsWith(".obj")) {
|
|
43928
43937
|
const loader = new OBJLoader2();
|
|
@@ -43955,9 +43964,9 @@ async function renderComponent(component, scene) {
|
|
|
43955
43964
|
}
|
|
43956
43965
|
if (component.rotation) {
|
|
43957
43966
|
model.rotation.set(
|
|
43958
|
-
|
|
43959
|
-
|
|
43960
|
-
|
|
43967
|
+
THREE37.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
43968
|
+
THREE37.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
43969
|
+
THREE37.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
43961
43970
|
);
|
|
43962
43971
|
}
|
|
43963
43972
|
scene.add(model);
|
|
@@ -43971,13 +43980,13 @@ async function renderComponent(component, scene) {
|
|
|
43971
43980
|
);
|
|
43972
43981
|
if (jscadObject && (jscadObject.polygons || jscadObject.sides)) {
|
|
43973
43982
|
const threeGeom = convertCSGToThreeGeom(jscadObject);
|
|
43974
|
-
const material2 = new
|
|
43983
|
+
const material2 = new THREE37.MeshStandardMaterial({
|
|
43975
43984
|
color: 8947848,
|
|
43976
43985
|
metalness: 0.5,
|
|
43977
43986
|
roughness: 0.5,
|
|
43978
|
-
side:
|
|
43987
|
+
side: THREE37.DoubleSide
|
|
43979
43988
|
});
|
|
43980
|
-
const mesh2 = new
|
|
43989
|
+
const mesh2 = new THREE37.Mesh(threeGeom, material2);
|
|
43981
43990
|
if (component.position) {
|
|
43982
43991
|
mesh2.position.set(
|
|
43983
43992
|
component.position.x ?? 0,
|
|
@@ -43987,9 +43996,9 @@ async function renderComponent(component, scene) {
|
|
|
43987
43996
|
}
|
|
43988
43997
|
if (component.rotation) {
|
|
43989
43998
|
mesh2.rotation.set(
|
|
43990
|
-
|
|
43991
|
-
|
|
43992
|
-
|
|
43999
|
+
THREE37.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
44000
|
+
THREE37.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
44001
|
+
THREE37.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
43993
44002
|
);
|
|
43994
44003
|
}
|
|
43995
44004
|
scene.add(mesh2);
|
|
@@ -44006,17 +44015,17 @@ async function renderComponent(component, scene) {
|
|
|
44006
44015
|
if (!geom || !geom.polygons && !geom.sides) {
|
|
44007
44016
|
continue;
|
|
44008
44017
|
}
|
|
44009
|
-
const color = new
|
|
44018
|
+
const color = new THREE37.Color(geomInfo.color);
|
|
44010
44019
|
color.convertLinearToSRGB();
|
|
44011
44020
|
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
44012
44021
|
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
44013
|
-
const material2 = new
|
|
44022
|
+
const material2 = new THREE37.MeshStandardMaterial({
|
|
44014
44023
|
vertexColors: true,
|
|
44015
44024
|
metalness: 0.2,
|
|
44016
44025
|
roughness: 0.8,
|
|
44017
|
-
side:
|
|
44026
|
+
side: THREE37.DoubleSide
|
|
44018
44027
|
});
|
|
44019
|
-
const mesh2 = new
|
|
44028
|
+
const mesh2 = new THREE37.Mesh(threeGeom, material2);
|
|
44020
44029
|
if (component.position) {
|
|
44021
44030
|
mesh2.position.set(
|
|
44022
44031
|
component.position.x ?? 0,
|
|
@@ -44026,22 +44035,22 @@ async function renderComponent(component, scene) {
|
|
|
44026
44035
|
}
|
|
44027
44036
|
if (component.rotation) {
|
|
44028
44037
|
mesh2.rotation.set(
|
|
44029
|
-
|
|
44030
|
-
|
|
44031
|
-
|
|
44038
|
+
THREE37.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
44039
|
+
THREE37.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
44040
|
+
THREE37.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
44032
44041
|
);
|
|
44033
44042
|
}
|
|
44034
44043
|
scene.add(mesh2);
|
|
44035
44044
|
}
|
|
44036
44045
|
return;
|
|
44037
44046
|
}
|
|
44038
|
-
const geometry = new
|
|
44039
|
-
const material = new
|
|
44047
|
+
const geometry = new THREE37.BoxGeometry(0.5, 0.5, 0.5);
|
|
44048
|
+
const material = new THREE37.MeshStandardMaterial({
|
|
44040
44049
|
color: 16711680,
|
|
44041
44050
|
transparent: true,
|
|
44042
44051
|
opacity: 0.25
|
|
44043
44052
|
});
|
|
44044
|
-
const mesh = new
|
|
44053
|
+
const mesh = new THREE37.Mesh(geometry, material);
|
|
44045
44054
|
if (component.position) {
|
|
44046
44055
|
mesh.position.set(
|
|
44047
44056
|
component.position.x ?? 0,
|
|
@@ -44062,11 +44071,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44062
44071
|
padding = 20,
|
|
44063
44072
|
zoom = 1.5
|
|
44064
44073
|
} = options;
|
|
44065
|
-
const scene = new
|
|
44074
|
+
const scene = new THREE38.Scene();
|
|
44066
44075
|
const renderer = new SVGRenderer();
|
|
44067
44076
|
renderer.setSize(width10, height10);
|
|
44068
|
-
renderer.setClearColor(new
|
|
44069
|
-
const camera = new
|
|
44077
|
+
renderer.setClearColor(new THREE38.Color(backgroundColor), 1);
|
|
44078
|
+
const camera = new THREE38.OrthographicCamera();
|
|
44070
44079
|
const aspect = width10 / height10;
|
|
44071
44080
|
const frustumSize = 100;
|
|
44072
44081
|
const halfFrustumSize = frustumSize / 2 / zoom;
|
|
@@ -44080,11 +44089,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44080
44089
|
camera.position.set(position.x, position.y, position.z);
|
|
44081
44090
|
camera.up.set(0, 1, 0);
|
|
44082
44091
|
const lookAt = options.camera?.lookAt ?? { x: 0, y: 0, z: 0 };
|
|
44083
|
-
camera.lookAt(new
|
|
44092
|
+
camera.lookAt(new THREE38.Vector3(lookAt.x, lookAt.y, lookAt.z));
|
|
44084
44093
|
camera.updateProjectionMatrix();
|
|
44085
|
-
const ambientLight = new
|
|
44094
|
+
const ambientLight = new THREE38.AmbientLight(16777215, Math.PI / 2);
|
|
44086
44095
|
scene.add(ambientLight);
|
|
44087
|
-
const pointLight = new
|
|
44096
|
+
const pointLight = new THREE38.PointLight(16777215, Math.PI / 4);
|
|
44088
44097
|
pointLight.position.set(-10, -10, 10);
|
|
44089
44098
|
scene.add(pointLight);
|
|
44090
44099
|
const components = su20(circuitJson).cad_component.list();
|
|
@@ -44095,7 +44104,7 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44095
44104
|
const boardGeom = createBoardGeomFromCircuitJson(circuitJson);
|
|
44096
44105
|
if (boardGeom) {
|
|
44097
44106
|
const solderMaskColor = colors.fr4SolderMaskGreen;
|
|
44098
|
-
const baseColor = new
|
|
44107
|
+
const baseColor = new THREE38.Color(
|
|
44099
44108
|
solderMaskColor[0],
|
|
44100
44109
|
solderMaskColor[1],
|
|
44101
44110
|
solderMaskColor[2]
|
|
@@ -44107,28 +44116,28 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
44107
44116
|
const material = createBoardMaterial({
|
|
44108
44117
|
material: boardData?.material,
|
|
44109
44118
|
color: baseColor,
|
|
44110
|
-
side:
|
|
44119
|
+
side: THREE38.DoubleSide
|
|
44111
44120
|
});
|
|
44112
|
-
const mesh = new
|
|
44121
|
+
const mesh = new THREE38.Mesh(geometry, material);
|
|
44113
44122
|
scene.add(mesh);
|
|
44114
44123
|
}
|
|
44115
44124
|
}
|
|
44116
|
-
const gridColor = new
|
|
44117
|
-
const gridHelper = new
|
|
44125
|
+
const gridColor = new THREE38.Color(8947848);
|
|
44126
|
+
const gridHelper = new THREE38.GridHelper(100, 100, gridColor, gridColor);
|
|
44118
44127
|
gridHelper.rotation.x = Math.PI / 2;
|
|
44119
44128
|
const materials = Array.isArray(gridHelper.material) ? gridHelper.material : [gridHelper.material];
|
|
44120
44129
|
for (const mat of materials) {
|
|
44121
44130
|
mat.transparent = true;
|
|
44122
44131
|
mat.opacity = 0.3;
|
|
44123
|
-
if (mat instanceof
|
|
44132
|
+
if (mat instanceof THREE38.LineBasicMaterial) {
|
|
44124
44133
|
mat.color = gridColor;
|
|
44125
44134
|
mat.vertexColors = false;
|
|
44126
44135
|
}
|
|
44127
44136
|
}
|
|
44128
44137
|
scene.add(gridHelper);
|
|
44129
|
-
const box = new
|
|
44130
|
-
const center = box.getCenter(new
|
|
44131
|
-
const size5 = box.getSize(new
|
|
44138
|
+
const box = new THREE38.Box3().setFromObject(scene);
|
|
44139
|
+
const center = box.getCenter(new THREE38.Vector3());
|
|
44140
|
+
const size5 = box.getSize(new THREE38.Vector3());
|
|
44132
44141
|
scene.position.sub(center);
|
|
44133
44142
|
const maxDim = Math.max(size5.x, size5.y, size5.z);
|
|
44134
44143
|
if (maxDim > 0) {
|