@tscircuit/3d-viewer 0.0.405 → 0.0.406
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 +213 -137
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14598,9 +14598,39 @@ function MixedStlModel({
|
|
|
14598
14598
|
|
|
14599
14599
|
// src/three-components/GltfModel.tsx
|
|
14600
14600
|
import { useState as useState3, useEffect as useEffect5 } from "react";
|
|
14601
|
-
import * as
|
|
14601
|
+
import * as THREE4 from "three";
|
|
14602
14602
|
import { GLTFLoader } from "three-stdlib";
|
|
14603
|
+
|
|
14604
|
+
// src/react-three/getDefaultEnvironmentMap.ts
|
|
14605
|
+
import * as THREE3 from "three";
|
|
14606
|
+
import { RoomEnvironment } from "three-stdlib";
|
|
14607
|
+
var environmentCache = /* @__PURE__ */ new WeakMap();
|
|
14608
|
+
var createFallbackEnvironmentMap = () => {
|
|
14609
|
+
const texture = new THREE3.Texture();
|
|
14610
|
+
texture.name = "fallback-environment-map";
|
|
14611
|
+
texture.mapping = THREE3.EquirectangularReflectionMapping;
|
|
14612
|
+
return texture;
|
|
14613
|
+
};
|
|
14614
|
+
var getDefaultEnvironmentMap = (renderer) => {
|
|
14615
|
+
if (!renderer) return null;
|
|
14616
|
+
const cacheKey = renderer;
|
|
14617
|
+
const cached = environmentCache.get(cacheKey);
|
|
14618
|
+
if (cached) return cached;
|
|
14619
|
+
let texture;
|
|
14620
|
+
if (renderer instanceof THREE3.WebGLRenderer) {
|
|
14621
|
+
const pmremGenerator = new THREE3.PMREMGenerator(renderer);
|
|
14622
|
+
texture = pmremGenerator.fromScene(RoomEnvironment(), 0.04).texture;
|
|
14623
|
+
pmremGenerator.dispose();
|
|
14624
|
+
} else {
|
|
14625
|
+
texture = createFallbackEnvironmentMap();
|
|
14626
|
+
}
|
|
14627
|
+
environmentCache.set(cacheKey, texture);
|
|
14628
|
+
return texture;
|
|
14629
|
+
};
|
|
14630
|
+
|
|
14631
|
+
// src/three-components/GltfModel.tsx
|
|
14603
14632
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
14633
|
+
var DEFAULT_ENV_MAP_INTENSITY = 1.25;
|
|
14604
14634
|
function GltfModel({
|
|
14605
14635
|
gltfUrl,
|
|
14606
14636
|
position,
|
|
@@ -14610,7 +14640,7 @@ function GltfModel({
|
|
|
14610
14640
|
isHovered,
|
|
14611
14641
|
scale: scale2
|
|
14612
14642
|
}) {
|
|
14613
|
-
const { rootObject } = useThree();
|
|
14643
|
+
const { renderer, rootObject } = useThree();
|
|
14614
14644
|
const [model, setModel] = useState3(null);
|
|
14615
14645
|
useEffect5(() => {
|
|
14616
14646
|
if (!gltfUrl) return;
|
|
@@ -14653,10 +14683,47 @@ function GltfModel({
|
|
|
14653
14683
|
rootObject.remove(model);
|
|
14654
14684
|
};
|
|
14655
14685
|
}, [rootObject, model]);
|
|
14686
|
+
useEffect5(() => {
|
|
14687
|
+
if (!model || !renderer) return;
|
|
14688
|
+
const environmentMap = getDefaultEnvironmentMap(renderer);
|
|
14689
|
+
if (!environmentMap) return;
|
|
14690
|
+
const previousMaterialState = [];
|
|
14691
|
+
const applyEnvironmentToMaterial = (material) => {
|
|
14692
|
+
if (!(material instanceof THREE4.MeshStandardMaterial)) return;
|
|
14693
|
+
previousMaterialState.push({
|
|
14694
|
+
material,
|
|
14695
|
+
envMap: material.envMap ?? null,
|
|
14696
|
+
envMapIntensity: material.envMapIntensity ?? 1
|
|
14697
|
+
});
|
|
14698
|
+
if (!material.envMap) {
|
|
14699
|
+
material.envMap = environmentMap;
|
|
14700
|
+
}
|
|
14701
|
+
if (typeof material.envMapIntensity !== "number" || material.envMapIntensity < DEFAULT_ENV_MAP_INTENSITY) {
|
|
14702
|
+
material.envMapIntensity = DEFAULT_ENV_MAP_INTENSITY;
|
|
14703
|
+
}
|
|
14704
|
+
material.needsUpdate = true;
|
|
14705
|
+
};
|
|
14706
|
+
model.traverse((child) => {
|
|
14707
|
+
if (!(child instanceof THREE4.Mesh)) return;
|
|
14708
|
+
const material = child.material;
|
|
14709
|
+
if (Array.isArray(material)) {
|
|
14710
|
+
material.forEach(applyEnvironmentToMaterial);
|
|
14711
|
+
} else if (material) {
|
|
14712
|
+
applyEnvironmentToMaterial(material);
|
|
14713
|
+
}
|
|
14714
|
+
});
|
|
14715
|
+
return () => {
|
|
14716
|
+
previousMaterialState.forEach(({ material, envMap, envMapIntensity }) => {
|
|
14717
|
+
material.envMap = envMap;
|
|
14718
|
+
material.envMapIntensity = envMapIntensity;
|
|
14719
|
+
material.needsUpdate = true;
|
|
14720
|
+
});
|
|
14721
|
+
};
|
|
14722
|
+
}, [model, renderer]);
|
|
14656
14723
|
useEffect5(() => {
|
|
14657
14724
|
if (!model) return;
|
|
14658
14725
|
model.traverse((child) => {
|
|
14659
|
-
if (child instanceof
|
|
14726
|
+
if (child instanceof THREE4.Mesh && child.material instanceof THREE4.MeshStandardMaterial) {
|
|
14660
14727
|
if (isHovered) {
|
|
14661
14728
|
child.material.emissive.setHex(255);
|
|
14662
14729
|
child.material.emissiveIntensity = 0.2;
|
|
@@ -25695,7 +25762,7 @@ function getJscadModelForFootprint(footprint) {
|
|
|
25695
25762
|
}
|
|
25696
25763
|
|
|
25697
25764
|
// src/three-components/JscadModel.tsx
|
|
25698
|
-
import * as
|
|
25765
|
+
import * as THREE5 from "three";
|
|
25699
25766
|
import { useMemo as useMemo4, useEffect as useEffect6 } from "react";
|
|
25700
25767
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
25701
25768
|
var JscadModel = ({
|
|
@@ -25714,16 +25781,16 @@ var JscadModel = ({
|
|
|
25714
25781
|
return { threeGeom: null, material: null };
|
|
25715
25782
|
}
|
|
25716
25783
|
const threeGeom2 = convertCSGToThreeGeom(jscadObject);
|
|
25717
|
-
const material2 = new
|
|
25784
|
+
const material2 = new THREE5.MeshStandardMaterial({
|
|
25718
25785
|
vertexColors: true,
|
|
25719
|
-
side:
|
|
25786
|
+
side: THREE5.DoubleSide
|
|
25720
25787
|
// Ensure both sides are visible
|
|
25721
25788
|
});
|
|
25722
25789
|
return { threeGeom: threeGeom2, material: material2 };
|
|
25723
25790
|
}, [jscadPlan]);
|
|
25724
25791
|
const mesh = useMemo4(() => {
|
|
25725
25792
|
if (!threeGeom) return null;
|
|
25726
|
-
return new
|
|
25793
|
+
return new THREE5.Mesh(threeGeom, material);
|
|
25727
25794
|
}, [threeGeom, material]);
|
|
25728
25795
|
useEffect6(() => {
|
|
25729
25796
|
if (!mesh || !rootObject) return;
|
|
@@ -25750,7 +25817,7 @@ var JscadModel = ({
|
|
|
25750
25817
|
useMemo4(() => {
|
|
25751
25818
|
if (!material) return;
|
|
25752
25819
|
if (isHovered) {
|
|
25753
|
-
const color = new
|
|
25820
|
+
const color = new THREE5.Color(material.color.getHex());
|
|
25754
25821
|
material.emissive.copy(color);
|
|
25755
25822
|
material.emissive.setRGB(0, 0, 1);
|
|
25756
25823
|
material.emissiveIntensity = 0.2;
|
|
@@ -25772,7 +25839,7 @@ var JscadModel = ({
|
|
|
25772
25839
|
|
|
25773
25840
|
// src/three-components/FootprinterModel.tsx
|
|
25774
25841
|
import { useMemo as useMemo5, useEffect as useEffect7 } from "react";
|
|
25775
|
-
import * as
|
|
25842
|
+
import * as THREE6 from "three";
|
|
25776
25843
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
25777
25844
|
var FootprinterModel = ({
|
|
25778
25845
|
positionOffset,
|
|
@@ -25787,21 +25854,21 @@ var FootprinterModel = ({
|
|
|
25787
25854
|
const group = useMemo5(() => {
|
|
25788
25855
|
if (!footprint) return null;
|
|
25789
25856
|
const { geometries: geometries2 } = getJscadModelForFootprint(footprint);
|
|
25790
|
-
const group2 = new
|
|
25857
|
+
const group2 = new THREE6.Group();
|
|
25791
25858
|
for (const geomInfo of geometries2.flat(Infinity)) {
|
|
25792
25859
|
const geom = geomInfo.geom;
|
|
25793
25860
|
if (!geom || !geom.polygons && !geom.sides) {
|
|
25794
25861
|
continue;
|
|
25795
25862
|
}
|
|
25796
|
-
const color = new
|
|
25863
|
+
const color = new THREE6.Color(geomInfo.color);
|
|
25797
25864
|
color.convertLinearToSRGB();
|
|
25798
25865
|
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
25799
25866
|
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
25800
|
-
const material = new
|
|
25867
|
+
const material = new THREE6.MeshStandardMaterial({
|
|
25801
25868
|
vertexColors: true,
|
|
25802
|
-
side:
|
|
25869
|
+
side: THREE6.DoubleSide
|
|
25803
25870
|
});
|
|
25804
|
-
const mesh = new
|
|
25871
|
+
const mesh = new THREE6.Mesh(threeGeom, material);
|
|
25805
25872
|
group2.add(mesh);
|
|
25806
25873
|
}
|
|
25807
25874
|
return group2;
|
|
@@ -25831,7 +25898,7 @@ var FootprinterModel = ({
|
|
|
25831
25898
|
useEffect7(() => {
|
|
25832
25899
|
if (!group) return;
|
|
25833
25900
|
group.traverse((child) => {
|
|
25834
|
-
if (child instanceof
|
|
25901
|
+
if (child instanceof THREE6.Mesh && child.material instanceof THREE6.MeshStandardMaterial) {
|
|
25835
25902
|
if (isHovered) {
|
|
25836
25903
|
child.material.emissive.setHex(255);
|
|
25837
25904
|
child.material.emissiveIntensity = 0.2;
|
|
@@ -25859,7 +25926,7 @@ var tuple = (...args) => args;
|
|
|
25859
25926
|
// src/react-three/Html.tsx
|
|
25860
25927
|
import { useRef as useRef2, useEffect as useEffect8, useState as useState4 } from "react";
|
|
25861
25928
|
import ReactDOM from "react-dom";
|
|
25862
|
-
import * as
|
|
25929
|
+
import * as THREE7 from "three";
|
|
25863
25930
|
var Html = ({ children, position, style }) => {
|
|
25864
25931
|
const { camera, renderer } = useThree();
|
|
25865
25932
|
const el = useRef2(document.createElement("div"));
|
|
@@ -25880,7 +25947,7 @@ var Html = ({ children, position, style }) => {
|
|
|
25880
25947
|
}, [renderer, children]);
|
|
25881
25948
|
useFrame(() => {
|
|
25882
25949
|
if (!camera || !el.current || !renderer) return;
|
|
25883
|
-
const vector = new
|
|
25950
|
+
const vector = new THREE7.Vector3(...position);
|
|
25884
25951
|
vector.project(camera);
|
|
25885
25952
|
const rect = renderer.domElement.getBoundingClientRect();
|
|
25886
25953
|
const x = Math.round((vector.x + 1) / 2 * rect.width);
|
|
@@ -26028,12 +26095,12 @@ import {
|
|
|
26028
26095
|
useMemo as useMemo13,
|
|
26029
26096
|
useState as useState7
|
|
26030
26097
|
} from "react";
|
|
26031
|
-
import * as
|
|
26098
|
+
import * as THREE13 from "three";
|
|
26032
26099
|
|
|
26033
26100
|
// package.json
|
|
26034
26101
|
var package_default = {
|
|
26035
26102
|
name: "@tscircuit/3d-viewer",
|
|
26036
|
-
version: "0.0.
|
|
26103
|
+
version: "0.0.405",
|
|
26037
26104
|
main: "./dist/index.js",
|
|
26038
26105
|
module: "./dist/index.js",
|
|
26039
26106
|
type: "module",
|
|
@@ -26109,7 +26176,7 @@ var package_default = {
|
|
|
26109
26176
|
|
|
26110
26177
|
// src/three-components/cube-with-labeled-sides.tsx
|
|
26111
26178
|
import { useEffect as useEffect10, useMemo as useMemo8 } from "react";
|
|
26112
|
-
import * as
|
|
26179
|
+
import * as THREE8 from "three";
|
|
26113
26180
|
|
|
26114
26181
|
// src/react-three/Text.tsx
|
|
26115
26182
|
import { useEffect as useEffect9, useMemo as useMemo7 } from "react";
|
|
@@ -26167,13 +26234,13 @@ var Text = ({
|
|
|
26167
26234
|
// src/three-components/cube-with-labeled-sides.tsx
|
|
26168
26235
|
import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
26169
26236
|
if (typeof window !== "undefined") {
|
|
26170
|
-
window.TSCI_MAIN_CAMERA_ROTATION = new
|
|
26237
|
+
window.TSCI_MAIN_CAMERA_ROTATION = new THREE8.Euler(0, 0, 0);
|
|
26171
26238
|
}
|
|
26172
26239
|
function computePointInFront(rotationVector, distance2) {
|
|
26173
|
-
const quaternion = new
|
|
26174
|
-
new
|
|
26240
|
+
const quaternion = new THREE8.Quaternion().setFromEuler(
|
|
26241
|
+
new THREE8.Euler(rotationVector.x, rotationVector.y, rotationVector.z)
|
|
26175
26242
|
);
|
|
26176
|
-
const forwardVector = new
|
|
26243
|
+
const forwardVector = new THREE8.Vector3(0, 0, 1);
|
|
26177
26244
|
forwardVector.applyQuaternion(quaternion);
|
|
26178
26245
|
const result = forwardVector.multiplyScalar(distance2);
|
|
26179
26246
|
return result;
|
|
@@ -26182,7 +26249,7 @@ var CubeWithLabeledSides = ({}) => {
|
|
|
26182
26249
|
const { camera, scene } = useThree();
|
|
26183
26250
|
useEffect10(() => {
|
|
26184
26251
|
if (!scene) return;
|
|
26185
|
-
const ambientLight = new
|
|
26252
|
+
const ambientLight = new THREE8.AmbientLight(16777215, Math.PI / 2);
|
|
26186
26253
|
scene.add(ambientLight);
|
|
26187
26254
|
return () => {
|
|
26188
26255
|
scene.remove(ambientLight);
|
|
@@ -26196,16 +26263,16 @@ var CubeWithLabeledSides = ({}) => {
|
|
|
26196
26263
|
camera.lookAt(0, 0, 0);
|
|
26197
26264
|
});
|
|
26198
26265
|
const group = useMemo8(() => {
|
|
26199
|
-
const g = new
|
|
26266
|
+
const g = new THREE8.Group();
|
|
26200
26267
|
g.rotation.fromArray([Math.PI / 2, 0, 0]);
|
|
26201
|
-
const box = new
|
|
26202
|
-
new
|
|
26203
|
-
new
|
|
26268
|
+
const box = new THREE8.Mesh(
|
|
26269
|
+
new THREE8.BoxGeometry(1, 1, 1),
|
|
26270
|
+
new THREE8.MeshStandardMaterial({ color: "white" })
|
|
26204
26271
|
);
|
|
26205
26272
|
g.add(box);
|
|
26206
|
-
const edges = new
|
|
26207
|
-
new
|
|
26208
|
-
new
|
|
26273
|
+
const edges = new THREE8.LineSegments(
|
|
26274
|
+
new THREE8.EdgesGeometry(new THREE8.BoxGeometry(1, 1, 1)),
|
|
26275
|
+
new THREE8.LineBasicMaterial({ color: 0, linewidth: 2 })
|
|
26209
26276
|
);
|
|
26210
26277
|
g.add(edges);
|
|
26211
26278
|
return g;
|
|
@@ -26296,13 +26363,21 @@ import {
|
|
|
26296
26363
|
useImperativeHandle,
|
|
26297
26364
|
useMemo as useMemo9
|
|
26298
26365
|
} from "react";
|
|
26299
|
-
import * as
|
|
26366
|
+
import * as THREE10 from "three";
|
|
26300
26367
|
|
|
26301
26368
|
// src/react-three/remove-existing-canvases.ts
|
|
26302
26369
|
function removeExistingCanvases(container) {
|
|
26303
26370
|
container.querySelectorAll("canvas").forEach((existingCanvas) => existingCanvas.remove());
|
|
26304
26371
|
}
|
|
26305
26372
|
|
|
26373
|
+
// src/react-three/configure-renderer.ts
|
|
26374
|
+
import * as THREE9 from "three";
|
|
26375
|
+
var configureRenderer = (renderer) => {
|
|
26376
|
+
renderer.outputColorSpace = THREE9.SRGBColorSpace;
|
|
26377
|
+
renderer.toneMapping = THREE9.ACESFilmicToneMapping;
|
|
26378
|
+
renderer.toneMappingExposure = 1;
|
|
26379
|
+
};
|
|
26380
|
+
|
|
26306
26381
|
// src/react-three/Canvas.tsx
|
|
26307
26382
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
26308
26383
|
var Canvas = forwardRef(
|
|
@@ -26328,23 +26403,24 @@ var Canvas = forwardRef(
|
|
|
26328
26403
|
},
|
|
26329
26404
|
[]
|
|
26330
26405
|
);
|
|
26331
|
-
const scene = useMemo9(() => new
|
|
26406
|
+
const scene = useMemo9(() => new THREE10.Scene(), []);
|
|
26332
26407
|
if (sceneProps?.up) {
|
|
26333
26408
|
scene.up.set(sceneProps.up.x, sceneProps.up.y, sceneProps.up.z);
|
|
26334
26409
|
}
|
|
26335
|
-
const rootObject = useRef4(new
|
|
26410
|
+
const rootObject = useRef4(new THREE10.Object3D());
|
|
26336
26411
|
useImperativeHandle(ref, () => rootObject.current);
|
|
26337
26412
|
useEffect11(() => {
|
|
26338
26413
|
if (!mountRef.current) return;
|
|
26339
26414
|
removeExistingCanvases(mountRef.current);
|
|
26340
|
-
const renderer = new
|
|
26415
|
+
const renderer = new THREE10.WebGLRenderer({ antialias: true, alpha: true });
|
|
26416
|
+
configureRenderer(renderer);
|
|
26341
26417
|
renderer.setSize(
|
|
26342
26418
|
mountRef.current.clientWidth,
|
|
26343
26419
|
mountRef.current.clientHeight
|
|
26344
26420
|
);
|
|
26345
26421
|
renderer.setPixelRatio(window.devicePixelRatio);
|
|
26346
26422
|
mountRef.current.appendChild(renderer.domElement);
|
|
26347
|
-
const camera = new
|
|
26423
|
+
const camera = new THREE10.PerspectiveCamera(
|
|
26348
26424
|
75,
|
|
26349
26425
|
mountRef.current.clientWidth / mountRef.current.clientHeight,
|
|
26350
26426
|
0.1,
|
|
@@ -26372,7 +26448,7 @@ var Canvas = forwardRef(
|
|
|
26372
26448
|
removeFrameListener
|
|
26373
26449
|
});
|
|
26374
26450
|
let animationFrameId;
|
|
26375
|
-
const clock = new
|
|
26451
|
+
const clock = new THREE10.Clock();
|
|
26376
26452
|
const animate = () => {
|
|
26377
26453
|
const time2 = clock.getElapsedTime();
|
|
26378
26454
|
const delta = clock.getDelta();
|
|
@@ -26474,7 +26550,7 @@ var OrbitControls = ({
|
|
|
26474
26550
|
|
|
26475
26551
|
// src/react-three/Grid.tsx
|
|
26476
26552
|
import { useEffect as useEffect13, useMemo as useMemo11 } from "react";
|
|
26477
|
-
import * as
|
|
26553
|
+
import * as THREE11 from "three";
|
|
26478
26554
|
var vertexShader = `
|
|
26479
26555
|
varying vec3 worldPosition;
|
|
26480
26556
|
void main() {
|
|
@@ -26520,24 +26596,24 @@ var Grid = ({
|
|
|
26520
26596
|
const { scene, camera } = useThree();
|
|
26521
26597
|
const size2 = 1e3;
|
|
26522
26598
|
const gridMesh = useMemo11(() => {
|
|
26523
|
-
const geometry = new
|
|
26599
|
+
const geometry = new THREE11.PlaneGeometry(size2, size2);
|
|
26524
26600
|
geometry.rotateX(-Math.PI / 2);
|
|
26525
|
-
const material = new
|
|
26601
|
+
const material = new THREE11.ShaderMaterial({
|
|
26526
26602
|
vertexShader,
|
|
26527
26603
|
fragmentShader,
|
|
26528
26604
|
uniforms: {
|
|
26529
26605
|
cellSize: { value: cellSize },
|
|
26530
26606
|
sectionSize: { value: sectionSize },
|
|
26531
|
-
gridColor: { value: new
|
|
26532
|
-
sectionColor: { value: new
|
|
26607
|
+
gridColor: { value: new THREE11.Color(15658734) },
|
|
26608
|
+
sectionColor: { value: new THREE11.Color(13421823) },
|
|
26533
26609
|
fadeDistance: { value: 100 },
|
|
26534
26610
|
// Fade out based on sectionSize
|
|
26535
26611
|
fadeStrength: { value: 1.5 }
|
|
26536
26612
|
},
|
|
26537
26613
|
transparent: true,
|
|
26538
|
-
side:
|
|
26614
|
+
side: THREE11.DoubleSide
|
|
26539
26615
|
});
|
|
26540
|
-
const mesh = new
|
|
26616
|
+
const mesh = new THREE11.Mesh(geometry, material);
|
|
26541
26617
|
if (rotation2) {
|
|
26542
26618
|
mesh.rotation.fromArray(rotation2);
|
|
26543
26619
|
}
|
|
@@ -26566,15 +26642,15 @@ var Grid = ({
|
|
|
26566
26642
|
|
|
26567
26643
|
// src/react-three/Lights.tsx
|
|
26568
26644
|
import { useEffect as useEffect14, useMemo as useMemo12 } from "react";
|
|
26569
|
-
import * as
|
|
26645
|
+
import * as THREE12 from "three";
|
|
26570
26646
|
var Lights = () => {
|
|
26571
26647
|
const { scene } = useThree();
|
|
26572
26648
|
const ambientLight = useMemo12(
|
|
26573
|
-
() => new
|
|
26649
|
+
() => new THREE12.AmbientLight(16777215, Math.PI / 2),
|
|
26574
26650
|
[]
|
|
26575
26651
|
);
|
|
26576
26652
|
const pointLight = useMemo12(() => {
|
|
26577
|
-
const light = new
|
|
26653
|
+
const light = new THREE12.PointLight(16777215, Math.PI / 4);
|
|
26578
26654
|
light.position.set(-10, -10, 10);
|
|
26579
26655
|
light.decay = 0;
|
|
26580
26656
|
return light;
|
|
@@ -26655,7 +26731,7 @@ var CadViewerContainer = forwardRef2(
|
|
|
26655
26731
|
Canvas,
|
|
26656
26732
|
{
|
|
26657
26733
|
ref,
|
|
26658
|
-
scene: { up: new
|
|
26734
|
+
scene: { up: new THREE13.Vector3(0, 0, 1) },
|
|
26659
26735
|
camera: { up: [0, 0, 1], position: initialCameraPosition },
|
|
26660
26736
|
children: [
|
|
26661
26737
|
/* @__PURE__ */ jsx11(RotationTracker, {}),
|
|
@@ -28176,7 +28252,7 @@ var useBoardGeomBuilder = (circuitJson) => {
|
|
|
28176
28252
|
|
|
28177
28253
|
// src/three-components/Error3d.tsx
|
|
28178
28254
|
import { useState as useState10, useCallback as useCallback4, useEffect as useEffect18, useMemo as useMemo15 } from "react";
|
|
28179
|
-
import * as
|
|
28255
|
+
import * as THREE14 from "three";
|
|
28180
28256
|
import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
28181
28257
|
var Error3d = ({
|
|
28182
28258
|
error,
|
|
@@ -28210,7 +28286,7 @@ var Error3d = ({
|
|
|
28210
28286
|
return [0, 0, 0];
|
|
28211
28287
|
}, [cad_component2]);
|
|
28212
28288
|
const group = useMemo15(() => {
|
|
28213
|
-
const g = new
|
|
28289
|
+
const g = new THREE14.Group();
|
|
28214
28290
|
g.position.fromArray(position);
|
|
28215
28291
|
return g;
|
|
28216
28292
|
}, [position]);
|
|
@@ -28270,9 +28346,9 @@ var Error3d = ({
|
|
|
28270
28346
|
};
|
|
28271
28347
|
var ErrorBox = ({ parent }) => {
|
|
28272
28348
|
const mesh = useMemo15(() => {
|
|
28273
|
-
const m = new
|
|
28274
|
-
new
|
|
28275
|
-
new
|
|
28349
|
+
const m = new THREE14.Mesh(
|
|
28350
|
+
new THREE14.BoxGeometry(0.5, 0.5, 0.5),
|
|
28351
|
+
new THREE14.MeshStandardMaterial({
|
|
28276
28352
|
depthTest: false,
|
|
28277
28353
|
transparent: true,
|
|
28278
28354
|
color: "red",
|
|
@@ -28294,7 +28370,7 @@ var ErrorBox = ({ parent }) => {
|
|
|
28294
28370
|
|
|
28295
28371
|
// src/three-components/STLModel.tsx
|
|
28296
28372
|
import { useState as useState11, useEffect as useEffect19, useMemo as useMemo16 } from "react";
|
|
28297
|
-
import * as
|
|
28373
|
+
import * as THREE15 from "three";
|
|
28298
28374
|
import { STLLoader } from "three-stdlib";
|
|
28299
28375
|
function STLModel({
|
|
28300
28376
|
stlUrl,
|
|
@@ -28325,12 +28401,12 @@ function STLModel({
|
|
|
28325
28401
|
}, [stlUrl, stlData]);
|
|
28326
28402
|
const mesh = useMemo16(() => {
|
|
28327
28403
|
if (!geom) return null;
|
|
28328
|
-
const material = new
|
|
28329
|
-
color: Array.isArray(color) ? new
|
|
28404
|
+
const material = new THREE15.MeshStandardMaterial({
|
|
28405
|
+
color: Array.isArray(color) ? new THREE15.Color(color[0], color[1], color[2]) : color,
|
|
28330
28406
|
transparent: opacity !== 1,
|
|
28331
28407
|
opacity
|
|
28332
28408
|
});
|
|
28333
|
-
return new
|
|
28409
|
+
return new THREE15.Mesh(geom, material);
|
|
28334
28410
|
}, [geom, color, opacity]);
|
|
28335
28411
|
useEffect19(() => {
|
|
28336
28412
|
if (!rootObject || !mesh) return;
|
|
@@ -28474,17 +28550,17 @@ import { useEffect as useEffect21, useMemo as useMemo19, useState as useState14
|
|
|
28474
28550
|
// src/hooks/useManifoldBoardBuilder.ts
|
|
28475
28551
|
import { useState as useState13, useEffect as useEffect20, useMemo as useMemo18, useRef as useRef7 } from "react";
|
|
28476
28552
|
import { su as su12 } from "@tscircuit/circuit-json-util";
|
|
28477
|
-
import * as
|
|
28553
|
+
import * as THREE23 from "three";
|
|
28478
28554
|
|
|
28479
28555
|
// src/utils/manifold-mesh-to-three-geometry.ts
|
|
28480
|
-
import * as
|
|
28556
|
+
import * as THREE16 from "three";
|
|
28481
28557
|
function manifoldMeshToThreeGeometry(manifoldMesh) {
|
|
28482
|
-
const geometry = new
|
|
28558
|
+
const geometry = new THREE16.BufferGeometry();
|
|
28483
28559
|
geometry.setAttribute(
|
|
28484
28560
|
"position",
|
|
28485
|
-
new
|
|
28561
|
+
new THREE16.Float32BufferAttribute(manifoldMesh.vertProperties, 3)
|
|
28486
28562
|
);
|
|
28487
|
-
geometry.setIndex(new
|
|
28563
|
+
geometry.setIndex(new THREE16.Uint32BufferAttribute(manifoldMesh.triVerts, 1));
|
|
28488
28564
|
if (manifoldMesh.runIndex && manifoldMesh.runIndex.length > 1 && manifoldMesh.runOriginalID) {
|
|
28489
28565
|
for (let i = 0; i < manifoldMesh.runIndex.length - 1; i++) {
|
|
28490
28566
|
const start = manifoldMesh.runIndex[i];
|
|
@@ -28498,7 +28574,7 @@ function manifoldMeshToThreeGeometry(manifoldMesh) {
|
|
|
28498
28574
|
}
|
|
28499
28575
|
|
|
28500
28576
|
// src/utils/trace-texture.ts
|
|
28501
|
-
import * as
|
|
28577
|
+
import * as THREE17 from "three";
|
|
28502
28578
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
28503
28579
|
function isWireRoutePoint(point2) {
|
|
28504
28580
|
return point2 && point2.route_type === "wire" && typeof point2.layer === "string" && typeof point2.width === "number";
|
|
@@ -28581,10 +28657,10 @@ function createTraceTextureForLayer({
|
|
|
28581
28657
|
}
|
|
28582
28658
|
});
|
|
28583
28659
|
ctx.globalCompositeOperation = "source-over";
|
|
28584
|
-
const texture = new
|
|
28660
|
+
const texture = new THREE17.CanvasTexture(canvas);
|
|
28585
28661
|
texture.generateMipmaps = true;
|
|
28586
|
-
texture.minFilter =
|
|
28587
|
-
texture.magFilter =
|
|
28662
|
+
texture.minFilter = THREE17.LinearMipmapLinearFilter;
|
|
28663
|
+
texture.magFilter = THREE17.LinearFilter;
|
|
28588
28664
|
texture.anisotropy = 16;
|
|
28589
28665
|
texture.needsUpdate = true;
|
|
28590
28666
|
return texture;
|
|
@@ -28592,7 +28668,7 @@ function createTraceTextureForLayer({
|
|
|
28592
28668
|
|
|
28593
28669
|
// src/utils/silkscreen-texture.ts
|
|
28594
28670
|
var import_text2 = __toESM(require_text(), 1);
|
|
28595
|
-
import * as
|
|
28671
|
+
import * as THREE18 from "three";
|
|
28596
28672
|
import { su as su6 } from "@tscircuit/circuit-json-util";
|
|
28597
28673
|
function createSilkscreenTextureForLayer({
|
|
28598
28674
|
layer,
|
|
@@ -28721,10 +28797,10 @@ function createSilkscreenTextureForLayer({
|
|
|
28721
28797
|
ctx.stroke();
|
|
28722
28798
|
});
|
|
28723
28799
|
});
|
|
28724
|
-
const texture = new
|
|
28800
|
+
const texture = new THREE18.CanvasTexture(canvas);
|
|
28725
28801
|
texture.generateMipmaps = true;
|
|
28726
|
-
texture.minFilter =
|
|
28727
|
-
texture.magFilter =
|
|
28802
|
+
texture.minFilter = THREE18.LinearMipmapLinearFilter;
|
|
28803
|
+
texture.magFilter = THREE18.LinearFilter;
|
|
28728
28804
|
texture.anisotropy = 16;
|
|
28729
28805
|
texture.needsUpdate = true;
|
|
28730
28806
|
return texture;
|
|
@@ -28797,7 +28873,7 @@ function processNonPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, m
|
|
|
28797
28873
|
|
|
28798
28874
|
// src/utils/manifold/process-plated-holes.ts
|
|
28799
28875
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
28800
|
-
import * as
|
|
28876
|
+
import * as THREE19 from "three";
|
|
28801
28877
|
|
|
28802
28878
|
// src/utils/pad-geoms.ts
|
|
28803
28879
|
var RECT_PAD_SEGMENTS2 = 64;
|
|
@@ -28861,7 +28937,7 @@ function createPadManifoldOp({
|
|
|
28861
28937
|
}
|
|
28862
28938
|
|
|
28863
28939
|
// src/utils/manifold/process-plated-holes.ts
|
|
28864
|
-
var COPPER_COLOR = new
|
|
28940
|
+
var COPPER_COLOR = new THREE19.Color(...colors.copper);
|
|
28865
28941
|
function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
|
|
28866
28942
|
const platedHoleBoardDrills = [];
|
|
28867
28943
|
const pcbPlatedHoles = su8(circuitJson).pcb_plated_hole.list();
|
|
@@ -29093,7 +29169,7 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
|
|
|
29093
29169
|
|
|
29094
29170
|
// src/utils/manifold/process-vias.ts
|
|
29095
29171
|
import { su as su9 } from "@tscircuit/circuit-json-util";
|
|
29096
|
-
import * as
|
|
29172
|
+
import * as THREE20 from "three";
|
|
29097
29173
|
|
|
29098
29174
|
// src/utils/via-geoms.ts
|
|
29099
29175
|
function createViaCopper({
|
|
@@ -29126,7 +29202,7 @@ function createViaCopper({
|
|
|
29126
29202
|
}
|
|
29127
29203
|
|
|
29128
29204
|
// src/utils/manifold/process-vias.ts
|
|
29129
|
-
var COPPER_COLOR2 = new
|
|
29205
|
+
var COPPER_COLOR2 = new THREE20.Color(...colors.copper);
|
|
29130
29206
|
function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
|
|
29131
29207
|
const viaBoardDrills = [];
|
|
29132
29208
|
const pcbVias = su9(circuitJson).pcb_via.list();
|
|
@@ -29172,8 +29248,8 @@ function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldIns
|
|
|
29172
29248
|
|
|
29173
29249
|
// src/utils/manifold/process-smt-pads.ts
|
|
29174
29250
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
29175
|
-
import * as
|
|
29176
|
-
var COPPER_COLOR3 = new
|
|
29251
|
+
import * as THREE21 from "three";
|
|
29252
|
+
var COPPER_COLOR3 = new THREE21.Color(...colors.copper);
|
|
29177
29253
|
function processSmtPadsForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, holeUnion) {
|
|
29178
29254
|
const smtPadGeoms = [];
|
|
29179
29255
|
const smtPads = su10(circuitJson).pcb_smtpad.list();
|
|
@@ -29262,8 +29338,8 @@ function createManifoldBoard(Manifold, CrossSection, boardData, pcbThickness, ma
|
|
|
29262
29338
|
}
|
|
29263
29339
|
|
|
29264
29340
|
// src/utils/manifold/process-copper-pours.ts
|
|
29265
|
-
import * as
|
|
29266
|
-
var COPPER_COLOR4 = new
|
|
29341
|
+
import * as THREE22 from "three";
|
|
29342
|
+
var COPPER_COLOR4 = new THREE22.Color(...colors.copper);
|
|
29267
29343
|
var arePointsClockwise4 = (points) => {
|
|
29268
29344
|
let area = 0;
|
|
29269
29345
|
for (let i = 0; i < points.length; i++) {
|
|
@@ -29628,7 +29704,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
29628
29704
|
const matColorArray = boardMaterialColors[boardData.material] ?? colors.fr4Green;
|
|
29629
29705
|
currentGeoms.board = {
|
|
29630
29706
|
geometry: finalBoardGeom,
|
|
29631
|
-
color: new
|
|
29707
|
+
color: new THREE23.Color(
|
|
29632
29708
|
matColorArray[0],
|
|
29633
29709
|
matColorArray[1],
|
|
29634
29710
|
matColorArray[2]
|
|
@@ -29711,16 +29787,16 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
29711
29787
|
};
|
|
29712
29788
|
|
|
29713
29789
|
// src/utils/manifold/create-three-geometry-meshes.ts
|
|
29714
|
-
import * as
|
|
29790
|
+
import * as THREE24 from "three";
|
|
29715
29791
|
function createGeometryMeshes(geoms) {
|
|
29716
29792
|
const meshes = [];
|
|
29717
29793
|
if (!geoms) return meshes;
|
|
29718
29794
|
if (geoms.board && geoms.board.geometry) {
|
|
29719
|
-
const mesh = new
|
|
29795
|
+
const mesh = new THREE24.Mesh(
|
|
29720
29796
|
geoms.board.geometry,
|
|
29721
|
-
new
|
|
29797
|
+
new THREE24.MeshStandardMaterial({
|
|
29722
29798
|
color: geoms.board.color,
|
|
29723
|
-
side:
|
|
29799
|
+
side: THREE24.DoubleSide,
|
|
29724
29800
|
flatShading: true
|
|
29725
29801
|
})
|
|
29726
29802
|
);
|
|
@@ -29730,11 +29806,11 @@ function createGeometryMeshes(geoms) {
|
|
|
29730
29806
|
const createMeshesFromArray = (geomArray) => {
|
|
29731
29807
|
if (geomArray) {
|
|
29732
29808
|
geomArray.forEach((comp) => {
|
|
29733
|
-
const mesh = new
|
|
29809
|
+
const mesh = new THREE24.Mesh(
|
|
29734
29810
|
comp.geometry,
|
|
29735
|
-
new
|
|
29811
|
+
new THREE24.MeshStandardMaterial({
|
|
29736
29812
|
color: comp.color,
|
|
29737
|
-
side:
|
|
29813
|
+
side: THREE24.DoubleSide,
|
|
29738
29814
|
flatShading: true
|
|
29739
29815
|
// Consistent with board
|
|
29740
29816
|
})
|
|
@@ -29752,21 +29828,21 @@ function createGeometryMeshes(geoms) {
|
|
|
29752
29828
|
}
|
|
29753
29829
|
|
|
29754
29830
|
// src/utils/manifold/create-three-texture-meshes.ts
|
|
29755
|
-
import * as
|
|
29831
|
+
import * as THREE25 from "three";
|
|
29756
29832
|
function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
29757
29833
|
const meshes = [];
|
|
29758
29834
|
if (!textures || !boardData || pcbThickness === null) return meshes;
|
|
29759
29835
|
const createTexturePlane = (texture, yOffset, isBottomLayer, keySuffix) => {
|
|
29760
29836
|
if (!texture) return null;
|
|
29761
|
-
const planeGeom = new
|
|
29762
|
-
const material = new
|
|
29837
|
+
const planeGeom = new THREE25.PlaneGeometry(boardData.width, boardData.height);
|
|
29838
|
+
const material = new THREE25.MeshBasicMaterial({
|
|
29763
29839
|
map: texture,
|
|
29764
29840
|
transparent: true,
|
|
29765
|
-
side:
|
|
29841
|
+
side: THREE25.DoubleSide,
|
|
29766
29842
|
depthWrite: false
|
|
29767
29843
|
// Important for layers to avoid z-fighting issues with board itself
|
|
29768
29844
|
});
|
|
29769
|
-
const mesh = new
|
|
29845
|
+
const mesh = new THREE25.Mesh(planeGeom, material);
|
|
29770
29846
|
mesh.position.set(boardData.center.x, boardData.center.y, yOffset);
|
|
29771
29847
|
if (isBottomLayer) {
|
|
29772
29848
|
mesh.rotation.set(Math.PI, 0, 0);
|
|
@@ -30422,11 +30498,11 @@ var CadViewer = (props) => {
|
|
|
30422
30498
|
// src/convert-circuit-json-to-3d-svg.ts
|
|
30423
30499
|
var import_debug = __toESM(require_browser(), 1);
|
|
30424
30500
|
import { su as su14 } from "@tscircuit/circuit-json-util";
|
|
30425
|
-
import * as
|
|
30501
|
+
import * as THREE29 from "three";
|
|
30426
30502
|
import { SVGRenderer } from "three/examples/jsm/renderers/SVGRenderer.js";
|
|
30427
30503
|
|
|
30428
30504
|
// src/utils/create-geometry-from-polygons.ts
|
|
30429
|
-
import * as
|
|
30505
|
+
import * as THREE26 from "three";
|
|
30430
30506
|
import { BufferGeometry as BufferGeometry3, Float32BufferAttribute as Float32BufferAttribute2 } from "three";
|
|
30431
30507
|
function createGeometryFromPolygons(polygons) {
|
|
30432
30508
|
const geometry = new BufferGeometry3();
|
|
@@ -30440,12 +30516,12 @@ function createGeometryFromPolygons(polygons) {
|
|
|
30440
30516
|
...polygon3.vertices[i + 1]
|
|
30441
30517
|
// Third vertex
|
|
30442
30518
|
);
|
|
30443
|
-
const v1 = new
|
|
30444
|
-
const v2 = new
|
|
30445
|
-
const v3 = new
|
|
30446
|
-
const normal = new
|
|
30447
|
-
new
|
|
30448
|
-
new
|
|
30519
|
+
const v1 = new THREE26.Vector3(...polygon3.vertices[0]);
|
|
30520
|
+
const v2 = new THREE26.Vector3(...polygon3.vertices[i]);
|
|
30521
|
+
const v3 = new THREE26.Vector3(...polygon3.vertices[i + 1]);
|
|
30522
|
+
const normal = new THREE26.Vector3().crossVectors(
|
|
30523
|
+
new THREE26.Vector3().subVectors(v2, v1),
|
|
30524
|
+
new THREE26.Vector3().subVectors(v3, v1)
|
|
30449
30525
|
).normalize();
|
|
30450
30526
|
normals.push(
|
|
30451
30527
|
normal.x,
|
|
@@ -30468,10 +30544,10 @@ function createGeometryFromPolygons(polygons) {
|
|
|
30468
30544
|
// src/utils/render-component.tsx
|
|
30469
30545
|
var import_modeling3 = __toESM(require_src(), 1);
|
|
30470
30546
|
var import_jscad_planner2 = __toESM(require_dist(), 1);
|
|
30471
|
-
import * as
|
|
30547
|
+
import * as THREE28 from "three";
|
|
30472
30548
|
|
|
30473
30549
|
// src/utils/load-model.ts
|
|
30474
|
-
import * as
|
|
30550
|
+
import * as THREE27 from "three";
|
|
30475
30551
|
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
30476
30552
|
import { OBJLoader as OBJLoader2 } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
30477
30553
|
import { STLLoader as STLLoader2 } from "three/examples/jsm/loaders/STLLoader.js";
|
|
@@ -30479,12 +30555,12 @@ async function load3DModel(url) {
|
|
|
30479
30555
|
if (url.endsWith(".stl")) {
|
|
30480
30556
|
const loader = new STLLoader2();
|
|
30481
30557
|
const geometry = await loader.loadAsync(url);
|
|
30482
|
-
const material = new
|
|
30558
|
+
const material = new THREE27.MeshStandardMaterial({
|
|
30483
30559
|
color: 8947848,
|
|
30484
30560
|
metalness: 0.5,
|
|
30485
30561
|
roughness: 0.5
|
|
30486
30562
|
});
|
|
30487
|
-
return new
|
|
30563
|
+
return new THREE27.Mesh(geometry, material);
|
|
30488
30564
|
}
|
|
30489
30565
|
if (url.endsWith(".obj")) {
|
|
30490
30566
|
const loader = new OBJLoader2();
|
|
@@ -30517,9 +30593,9 @@ async function renderComponent(component, scene) {
|
|
|
30517
30593
|
}
|
|
30518
30594
|
if (component.rotation) {
|
|
30519
30595
|
model.rotation.set(
|
|
30520
|
-
|
|
30521
|
-
|
|
30522
|
-
|
|
30596
|
+
THREE28.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
30597
|
+
THREE28.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
30598
|
+
THREE28.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
30523
30599
|
);
|
|
30524
30600
|
}
|
|
30525
30601
|
scene.add(model);
|
|
@@ -30533,13 +30609,13 @@ async function renderComponent(component, scene) {
|
|
|
30533
30609
|
);
|
|
30534
30610
|
if (jscadObject && (jscadObject.polygons || jscadObject.sides)) {
|
|
30535
30611
|
const threeGeom = convertCSGToThreeGeom(jscadObject);
|
|
30536
|
-
const material2 = new
|
|
30612
|
+
const material2 = new THREE28.MeshStandardMaterial({
|
|
30537
30613
|
color: 8947848,
|
|
30538
30614
|
metalness: 0.5,
|
|
30539
30615
|
roughness: 0.5,
|
|
30540
|
-
side:
|
|
30616
|
+
side: THREE28.DoubleSide
|
|
30541
30617
|
});
|
|
30542
|
-
const mesh2 = new
|
|
30618
|
+
const mesh2 = new THREE28.Mesh(threeGeom, material2);
|
|
30543
30619
|
if (component.position) {
|
|
30544
30620
|
mesh2.position.set(
|
|
30545
30621
|
component.position.x ?? 0,
|
|
@@ -30549,9 +30625,9 @@ async function renderComponent(component, scene) {
|
|
|
30549
30625
|
}
|
|
30550
30626
|
if (component.rotation) {
|
|
30551
30627
|
mesh2.rotation.set(
|
|
30552
|
-
|
|
30553
|
-
|
|
30554
|
-
|
|
30628
|
+
THREE28.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
30629
|
+
THREE28.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
30630
|
+
THREE28.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
30555
30631
|
);
|
|
30556
30632
|
}
|
|
30557
30633
|
scene.add(mesh2);
|
|
@@ -30567,17 +30643,17 @@ async function renderComponent(component, scene) {
|
|
|
30567
30643
|
if (!geom || !geom.polygons && !geom.sides) {
|
|
30568
30644
|
continue;
|
|
30569
30645
|
}
|
|
30570
|
-
const color = new
|
|
30646
|
+
const color = new THREE28.Color(geomInfo.color);
|
|
30571
30647
|
color.convertLinearToSRGB();
|
|
30572
30648
|
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
30573
30649
|
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
30574
|
-
const material2 = new
|
|
30650
|
+
const material2 = new THREE28.MeshStandardMaterial({
|
|
30575
30651
|
vertexColors: true,
|
|
30576
30652
|
metalness: 0.2,
|
|
30577
30653
|
roughness: 0.8,
|
|
30578
|
-
side:
|
|
30654
|
+
side: THREE28.DoubleSide
|
|
30579
30655
|
});
|
|
30580
|
-
const mesh2 = new
|
|
30656
|
+
const mesh2 = new THREE28.Mesh(threeGeom, material2);
|
|
30581
30657
|
if (component.position) {
|
|
30582
30658
|
mesh2.position.set(
|
|
30583
30659
|
component.position.x ?? 0,
|
|
@@ -30587,22 +30663,22 @@ async function renderComponent(component, scene) {
|
|
|
30587
30663
|
}
|
|
30588
30664
|
if (component.rotation) {
|
|
30589
30665
|
mesh2.rotation.set(
|
|
30590
|
-
|
|
30591
|
-
|
|
30592
|
-
|
|
30666
|
+
THREE28.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
30667
|
+
THREE28.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
30668
|
+
THREE28.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
30593
30669
|
);
|
|
30594
30670
|
}
|
|
30595
30671
|
scene.add(mesh2);
|
|
30596
30672
|
}
|
|
30597
30673
|
return;
|
|
30598
30674
|
}
|
|
30599
|
-
const geometry = new
|
|
30600
|
-
const material = new
|
|
30675
|
+
const geometry = new THREE28.BoxGeometry(0.5, 0.5, 0.5);
|
|
30676
|
+
const material = new THREE28.MeshStandardMaterial({
|
|
30601
30677
|
color: 16711680,
|
|
30602
30678
|
transparent: true,
|
|
30603
30679
|
opacity: 0.25
|
|
30604
30680
|
});
|
|
30605
|
-
const mesh = new
|
|
30681
|
+
const mesh = new THREE28.Mesh(geometry, material);
|
|
30606
30682
|
if (component.position) {
|
|
30607
30683
|
mesh.position.set(
|
|
30608
30684
|
component.position.x ?? 0,
|
|
@@ -30623,11 +30699,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
30623
30699
|
padding = 20,
|
|
30624
30700
|
zoom = 1.5
|
|
30625
30701
|
} = options;
|
|
30626
|
-
const scene = new
|
|
30702
|
+
const scene = new THREE29.Scene();
|
|
30627
30703
|
const renderer = new SVGRenderer();
|
|
30628
30704
|
renderer.setSize(width10, height10);
|
|
30629
|
-
renderer.setClearColor(new
|
|
30630
|
-
const camera = new
|
|
30705
|
+
renderer.setClearColor(new THREE29.Color(backgroundColor), 1);
|
|
30706
|
+
const camera = new THREE29.OrthographicCamera();
|
|
30631
30707
|
const aspect = width10 / height10;
|
|
30632
30708
|
const frustumSize = 100;
|
|
30633
30709
|
const halfFrustumSize = frustumSize / 2 / zoom;
|
|
@@ -30641,11 +30717,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
30641
30717
|
camera.position.set(position.x, position.y, position.z);
|
|
30642
30718
|
camera.up.set(0, 1, 0);
|
|
30643
30719
|
const lookAt = options.camera?.lookAt ?? { x: 0, y: 0, z: 0 };
|
|
30644
|
-
camera.lookAt(new
|
|
30720
|
+
camera.lookAt(new THREE29.Vector3(lookAt.x, lookAt.y, lookAt.z));
|
|
30645
30721
|
camera.updateProjectionMatrix();
|
|
30646
|
-
const ambientLight = new
|
|
30722
|
+
const ambientLight = new THREE29.AmbientLight(16777215, Math.PI / 2);
|
|
30647
30723
|
scene.add(ambientLight);
|
|
30648
|
-
const pointLight = new
|
|
30724
|
+
const pointLight = new THREE29.PointLight(16777215, Math.PI / 4);
|
|
30649
30725
|
pointLight.position.set(-10, -10, 10);
|
|
30650
30726
|
scene.add(pointLight);
|
|
30651
30727
|
const components = su14(circuitJson).cad_component.list();
|
|
@@ -30658,8 +30734,8 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
30658
30734
|
const g = geom;
|
|
30659
30735
|
if (!g.polygons || g.polygons.length === 0) continue;
|
|
30660
30736
|
const geometry = createGeometryFromPolygons(g.polygons);
|
|
30661
|
-
const material = new
|
|
30662
|
-
color: new
|
|
30737
|
+
const material = new THREE29.MeshStandardMaterial({
|
|
30738
|
+
color: new THREE29.Color(
|
|
30663
30739
|
g.color?.[0] ?? 0,
|
|
30664
30740
|
g.color?.[1] ?? 0,
|
|
30665
30741
|
g.color?.[2] ?? 0
|
|
@@ -30668,18 +30744,18 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
30668
30744
|
roughness: 0.8,
|
|
30669
30745
|
opacity: 0.9,
|
|
30670
30746
|
transparent: true,
|
|
30671
|
-
side:
|
|
30747
|
+
side: THREE29.DoubleSide
|
|
30672
30748
|
});
|
|
30673
|
-
const mesh = new
|
|
30749
|
+
const mesh = new THREE29.Mesh(geometry, material);
|
|
30674
30750
|
scene.add(mesh);
|
|
30675
30751
|
}
|
|
30676
30752
|
}
|
|
30677
|
-
const gridHelper = new
|
|
30753
|
+
const gridHelper = new THREE29.GridHelper(100, 100);
|
|
30678
30754
|
gridHelper.rotation.x = Math.PI / 2;
|
|
30679
30755
|
scene.add(gridHelper);
|
|
30680
|
-
const box = new
|
|
30681
|
-
const center = box.getCenter(new
|
|
30682
|
-
const size2 = box.getSize(new
|
|
30756
|
+
const box = new THREE29.Box3().setFromObject(scene);
|
|
30757
|
+
const center = box.getCenter(new THREE29.Vector3());
|
|
30758
|
+
const size2 = box.getSize(new THREE29.Vector3());
|
|
30683
30759
|
scene.position.sub(center);
|
|
30684
30760
|
const maxDim = Math.max(size2.x, size2.y, size2.z);
|
|
30685
30761
|
if (maxDim > 0) {
|