@tscircuit/3d-viewer 0.0.344 → 0.0.345
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 +53 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25291,6 +25291,9 @@ var JscadModel = ({
|
|
|
25291
25291
|
const { rootObject } = useThree();
|
|
25292
25292
|
const { threeGeom, material } = useMemo3(() => {
|
|
25293
25293
|
const jscadObject = (0, import_jscad_planner.executeJscadOperations)(import_modeling2.default, jscadPlan);
|
|
25294
|
+
if (!jscadObject || !jscadObject.polygons && !jscadObject.sides) {
|
|
25295
|
+
return { threeGeom: null, material: null };
|
|
25296
|
+
}
|
|
25294
25297
|
const threeGeom2 = convertCSGToThreeGeom(jscadObject);
|
|
25295
25298
|
const material2 = new THREE3.MeshStandardMaterial({
|
|
25296
25299
|
vertexColors: true,
|
|
@@ -25363,8 +25366,15 @@ var FootprinterModel = ({
|
|
|
25363
25366
|
if (!footprint) return null;
|
|
25364
25367
|
const { geometries: geometries2 } = getJscadModelForFootprint(footprint);
|
|
25365
25368
|
const group2 = new THREE4.Group();
|
|
25366
|
-
for (const
|
|
25367
|
-
const
|
|
25369
|
+
for (const geomInfo of geometries2.flat(Infinity)) {
|
|
25370
|
+
const geom = geomInfo.geom;
|
|
25371
|
+
if (!geom || !geom.polygons && !geom.sides) {
|
|
25372
|
+
continue;
|
|
25373
|
+
}
|
|
25374
|
+
const color = new THREE4.Color(geomInfo.color);
|
|
25375
|
+
color.convertLinearToSRGB();
|
|
25376
|
+
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
25377
|
+
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
25368
25378
|
const material = new THREE4.MeshStandardMaterial({
|
|
25369
25379
|
vertexColors: true,
|
|
25370
25380
|
side: THREE4.DoubleSide
|
|
@@ -25572,7 +25582,7 @@ import * as THREE10 from "three";
|
|
|
25572
25582
|
// package.json
|
|
25573
25583
|
var package_default = {
|
|
25574
25584
|
name: "@tscircuit/3d-viewer",
|
|
25575
|
-
version: "0.0.
|
|
25585
|
+
version: "0.0.344",
|
|
25576
25586
|
main: "./dist/index.js",
|
|
25577
25587
|
module: "./dist/index.js",
|
|
25578
25588
|
type: "module",
|
|
@@ -29407,39 +29417,48 @@ async function renderComponent(component, scene) {
|
|
|
29407
29417
|
import_modeling3.default,
|
|
29408
29418
|
component.model_jscad
|
|
29409
29419
|
);
|
|
29410
|
-
|
|
29411
|
-
|
|
29412
|
-
|
|
29413
|
-
|
|
29414
|
-
|
|
29415
|
-
|
|
29416
|
-
|
|
29417
|
-
|
|
29418
|
-
|
|
29419
|
-
|
|
29420
|
-
|
|
29421
|
-
|
|
29422
|
-
|
|
29423
|
-
|
|
29424
|
-
|
|
29425
|
-
|
|
29426
|
-
|
|
29427
|
-
|
|
29428
|
-
|
|
29429
|
-
|
|
29430
|
-
|
|
29420
|
+
if (jscadObject && (jscadObject.polygons || jscadObject.sides)) {
|
|
29421
|
+
const threeGeom = convertCSGToThreeGeom(jscadObject);
|
|
29422
|
+
const material2 = new THREE24.MeshStandardMaterial({
|
|
29423
|
+
color: 8947848,
|
|
29424
|
+
metalness: 0.5,
|
|
29425
|
+
roughness: 0.5,
|
|
29426
|
+
side: THREE24.DoubleSide
|
|
29427
|
+
});
|
|
29428
|
+
const mesh2 = new THREE24.Mesh(threeGeom, material2);
|
|
29429
|
+
if (component.position) {
|
|
29430
|
+
mesh2.position.set(
|
|
29431
|
+
component.position.x ?? 0,
|
|
29432
|
+
component.position.y ?? 0,
|
|
29433
|
+
(component.position.z ?? 0) + 0.5
|
|
29434
|
+
);
|
|
29435
|
+
}
|
|
29436
|
+
if (component.rotation) {
|
|
29437
|
+
mesh2.rotation.set(
|
|
29438
|
+
THREE24.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
29439
|
+
THREE24.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
29440
|
+
THREE24.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
29441
|
+
);
|
|
29442
|
+
}
|
|
29443
|
+
scene.add(mesh2);
|
|
29431
29444
|
}
|
|
29432
|
-
scene.add(mesh2);
|
|
29433
29445
|
return;
|
|
29434
29446
|
}
|
|
29435
29447
|
if (component.footprinter_string) {
|
|
29436
29448
|
const { geometries: geometries2 } = getJscadModelForFootprint(
|
|
29437
29449
|
component.footprinter_string
|
|
29438
29450
|
);
|
|
29439
|
-
for (const
|
|
29440
|
-
const
|
|
29451
|
+
for (const geomInfo of geometries2.flat(Infinity)) {
|
|
29452
|
+
const geom = geomInfo.geom;
|
|
29453
|
+
if (!geom || !geom.polygons && !geom.sides) {
|
|
29454
|
+
continue;
|
|
29455
|
+
}
|
|
29456
|
+
const color = new THREE24.Color(geomInfo.color);
|
|
29457
|
+
color.convertLinearToSRGB();
|
|
29458
|
+
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
29459
|
+
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
29441
29460
|
const material2 = new THREE24.MeshStandardMaterial({
|
|
29442
|
-
|
|
29461
|
+
vertexColors: true,
|
|
29443
29462
|
metalness: 0.2,
|
|
29444
29463
|
roughness: 0.8,
|
|
29445
29464
|
side: THREE24.DoubleSide
|
|
@@ -29522,12 +29541,14 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
29522
29541
|
const boardGeom = createBoardGeomFromCircuitJson(circuitJson);
|
|
29523
29542
|
if (boardGeom) {
|
|
29524
29543
|
for (const geom of boardGeom) {
|
|
29525
|
-
const
|
|
29544
|
+
const g = geom;
|
|
29545
|
+
if (!g.polygons || g.polygons.length === 0) continue;
|
|
29546
|
+
const geometry = createGeometryFromPolygons(g.polygons);
|
|
29526
29547
|
const material = new THREE25.MeshStandardMaterial({
|
|
29527
29548
|
color: new THREE25.Color(
|
|
29528
|
-
|
|
29529
|
-
|
|
29530
|
-
|
|
29549
|
+
g.color?.[0] ?? 0,
|
|
29550
|
+
g.color?.[1] ?? 0,
|
|
29551
|
+
g.color?.[2] ?? 0
|
|
29531
29552
|
),
|
|
29532
29553
|
metalness: 0.1,
|
|
29533
29554
|
roughness: 0.8,
|