@tscircuit/3d-viewer 0.0.522 → 0.0.524
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 +502 -132
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14245,7 +14245,7 @@ var require_browser = __commonJS({
|
|
|
14245
14245
|
|
|
14246
14246
|
// src/CadViewer.tsx
|
|
14247
14247
|
import { useState as useState36, useCallback as useCallback21, useRef as useRef26, useEffect as useEffect44 } from "react";
|
|
14248
|
-
import * as
|
|
14248
|
+
import * as THREE38 from "three";
|
|
14249
14249
|
|
|
14250
14250
|
// src/CadViewerJscad.tsx
|
|
14251
14251
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
@@ -28483,7 +28483,7 @@ import * as THREE16 from "three";
|
|
|
28483
28483
|
// package.json
|
|
28484
28484
|
var package_default = {
|
|
28485
28485
|
name: "@tscircuit/3d-viewer",
|
|
28486
|
-
version: "0.0.
|
|
28486
|
+
version: "0.0.523",
|
|
28487
28487
|
main: "./dist/index.js",
|
|
28488
28488
|
module: "./dist/index.js",
|
|
28489
28489
|
type: "module",
|
|
@@ -31452,7 +31452,7 @@ import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
|
31452
31452
|
import { useEffect as useEffect23, useMemo as useMemo19 } from "react";
|
|
31453
31453
|
|
|
31454
31454
|
// src/textures/create-combined-board-textures.ts
|
|
31455
|
-
import * as
|
|
31455
|
+
import * as THREE28 from "three";
|
|
31456
31456
|
|
|
31457
31457
|
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
31458
31458
|
var getBoundsFromPoints = (points) => {
|
|
@@ -32164,9 +32164,158 @@ function createCopperPourTextureForLayer({
|
|
|
32164
32164
|
return texture;
|
|
32165
32165
|
}
|
|
32166
32166
|
|
|
32167
|
-
// src/textures/create-
|
|
32167
|
+
// src/textures/create-fabrication-note-texture-for-layer.ts
|
|
32168
32168
|
import * as THREE24 from "three";
|
|
32169
32169
|
|
|
32170
|
+
// src/textures/fabrication-note/fabrication-note-drawing.ts
|
|
32171
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
|
|
32172
|
+
|
|
32173
|
+
// src/utils/units.ts
|
|
32174
|
+
var MM_PER_INCH = 25.4;
|
|
32175
|
+
var MM_PER_MIL = MM_PER_INCH / 1e3;
|
|
32176
|
+
var dimensionRegex = /^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;
|
|
32177
|
+
function normalizeUnit(unit) {
|
|
32178
|
+
if (!unit) return void 0;
|
|
32179
|
+
const normalized = unit.trim().toLowerCase();
|
|
32180
|
+
if (normalized === '"') return "in";
|
|
32181
|
+
if (normalized === "inch") return "in";
|
|
32182
|
+
return normalized;
|
|
32183
|
+
}
|
|
32184
|
+
function parseDimensionToMm(value) {
|
|
32185
|
+
if (value === null || value === void 0) return void 0;
|
|
32186
|
+
if (typeof value === "number") {
|
|
32187
|
+
return Number.isFinite(value) ? value : void 0;
|
|
32188
|
+
}
|
|
32189
|
+
if (typeof value !== "string") return void 0;
|
|
32190
|
+
const trimmed = value.trim();
|
|
32191
|
+
if (trimmed.length === 0) return void 0;
|
|
32192
|
+
const match = trimmed.match(dimensionRegex);
|
|
32193
|
+
if (!match) {
|
|
32194
|
+
const numeric = Number.parseFloat(trimmed);
|
|
32195
|
+
return Number.isFinite(numeric) ? numeric : void 0;
|
|
32196
|
+
}
|
|
32197
|
+
const [, magnitudeRaw, unitRaw] = match;
|
|
32198
|
+
const magnitude = Number.parseFloat(magnitudeRaw || "0");
|
|
32199
|
+
if (!Number.isFinite(magnitude)) return void 0;
|
|
32200
|
+
const unit = normalizeUnit(unitRaw);
|
|
32201
|
+
switch (unit) {
|
|
32202
|
+
case "mil":
|
|
32203
|
+
return magnitude * MM_PER_MIL;
|
|
32204
|
+
case "in":
|
|
32205
|
+
return magnitude * MM_PER_INCH;
|
|
32206
|
+
case "mm":
|
|
32207
|
+
case void 0:
|
|
32208
|
+
return magnitude;
|
|
32209
|
+
default:
|
|
32210
|
+
return magnitude;
|
|
32211
|
+
}
|
|
32212
|
+
}
|
|
32213
|
+
function coerceDimensionToMm(value, fallback) {
|
|
32214
|
+
const parsed = parseDimensionToMm(value);
|
|
32215
|
+
return parsed === void 0 ? fallback : parsed;
|
|
32216
|
+
}
|
|
32217
|
+
|
|
32218
|
+
// src/textures/fabrication-note/fabrication-note-drawing.ts
|
|
32219
|
+
var FABRICATION_NOTE_COLOR = "rgb(255,243,204)";
|
|
32220
|
+
var TRANSPARENT = "rgba(0,0,0,0)";
|
|
32221
|
+
var setDrawerBounds2 = (drawer, bounds) => {
|
|
32222
|
+
drawer.setCameraBounds({
|
|
32223
|
+
minX: bounds.minX,
|
|
32224
|
+
maxX: bounds.maxX,
|
|
32225
|
+
minY: bounds.minY,
|
|
32226
|
+
maxY: bounds.maxY
|
|
32227
|
+
});
|
|
32228
|
+
};
|
|
32229
|
+
var normalizeFabricationElement = (element) => {
|
|
32230
|
+
if (element.type === "pcb_fabrication_note_rect") {
|
|
32231
|
+
return {
|
|
32232
|
+
...element,
|
|
32233
|
+
width: parseDimensionToMm(element.width) ?? 0,
|
|
32234
|
+
height: parseDimensionToMm(element.height) ?? 0,
|
|
32235
|
+
stroke_width: coerceDimensionToMm(element.stroke_width, 0.1),
|
|
32236
|
+
corner_radius: parseDimensionToMm(element.corner_radius)
|
|
32237
|
+
};
|
|
32238
|
+
}
|
|
32239
|
+
if (element.type === "pcb_fabrication_note_path") {
|
|
32240
|
+
return {
|
|
32241
|
+
...element,
|
|
32242
|
+
stroke_width: coerceDimensionToMm(element.stroke_width, 0.1)
|
|
32243
|
+
};
|
|
32244
|
+
}
|
|
32245
|
+
if (element.type === "pcb_fabrication_note_text") {
|
|
32246
|
+
return {
|
|
32247
|
+
...element,
|
|
32248
|
+
font_size: coerceDimensionToMm(element.font_size, 1)
|
|
32249
|
+
};
|
|
32250
|
+
}
|
|
32251
|
+
if (element.type === "pcb_fabrication_note_dimension") {
|
|
32252
|
+
return {
|
|
32253
|
+
...element,
|
|
32254
|
+
font_size: coerceDimensionToMm(element.font_size, 1),
|
|
32255
|
+
arrow_size: coerceDimensionToMm(element.arrow_size, 1),
|
|
32256
|
+
offset_distance: coerceDimensionToMm(element.offset_distance, 0)
|
|
32257
|
+
};
|
|
32258
|
+
}
|
|
32259
|
+
return element;
|
|
32260
|
+
};
|
|
32261
|
+
var drawFabricationNoteLayer = ({
|
|
32262
|
+
ctx,
|
|
32263
|
+
layer,
|
|
32264
|
+
bounds,
|
|
32265
|
+
elements
|
|
32266
|
+
}) => {
|
|
32267
|
+
const renderLayer = `${layer}_fabrication_note`;
|
|
32268
|
+
const normalizedElements = elements.map(normalizeFabricationElement);
|
|
32269
|
+
const drawer = new CircuitToCanvasDrawer3(ctx);
|
|
32270
|
+
drawer.configure({
|
|
32271
|
+
colorOverrides: {
|
|
32272
|
+
copper: {
|
|
32273
|
+
top: TRANSPARENT,
|
|
32274
|
+
bottom: TRANSPARENT,
|
|
32275
|
+
inner1: TRANSPARENT,
|
|
32276
|
+
inner2: TRANSPARENT,
|
|
32277
|
+
inner3: TRANSPARENT,
|
|
32278
|
+
inner4: TRANSPARENT,
|
|
32279
|
+
inner5: TRANSPARENT,
|
|
32280
|
+
inner6: TRANSPARENT
|
|
32281
|
+
},
|
|
32282
|
+
copperPour: {
|
|
32283
|
+
top: TRANSPARENT,
|
|
32284
|
+
bottom: TRANSPARENT
|
|
32285
|
+
},
|
|
32286
|
+
drill: TRANSPARENT,
|
|
32287
|
+
boardOutline: TRANSPARENT,
|
|
32288
|
+
substrate: TRANSPARENT,
|
|
32289
|
+
keepout: TRANSPARENT,
|
|
32290
|
+
courtyard: {
|
|
32291
|
+
top: TRANSPARENT,
|
|
32292
|
+
bottom: TRANSPARENT
|
|
32293
|
+
},
|
|
32294
|
+
soldermask: {
|
|
32295
|
+
top: TRANSPARENT,
|
|
32296
|
+
bottom: TRANSPARENT
|
|
32297
|
+
},
|
|
32298
|
+
soldermaskWithCopperUnderneath: {
|
|
32299
|
+
top: TRANSPARENT,
|
|
32300
|
+
bottom: TRANSPARENT
|
|
32301
|
+
},
|
|
32302
|
+
soldermaskOverCopper: {
|
|
32303
|
+
top: TRANSPARENT,
|
|
32304
|
+
bottom: TRANSPARENT
|
|
32305
|
+
},
|
|
32306
|
+
silkscreen: {
|
|
32307
|
+
top: TRANSPARENT,
|
|
32308
|
+
bottom: TRANSPARENT
|
|
32309
|
+
},
|
|
32310
|
+
fabricationNote: FABRICATION_NOTE_COLOR
|
|
32311
|
+
}
|
|
32312
|
+
});
|
|
32313
|
+
setDrawerBounds2(drawer, bounds);
|
|
32314
|
+
drawer.drawElements(normalizedElements, {
|
|
32315
|
+
layers: [renderLayer]
|
|
32316
|
+
});
|
|
32317
|
+
};
|
|
32318
|
+
|
|
32170
32319
|
// src/textures/soldermask/soldermask-bounds.ts
|
|
32171
32320
|
var boundsFromPanel = (panel) => ({
|
|
32172
32321
|
minX: panel.center.x - panel.width / 2,
|
|
@@ -32209,11 +32358,218 @@ var getSoldermaskRenderBounds = (circuitJson, boardData) => {
|
|
|
32209
32358
|
return boardsForBounds.map((board) => calculateOutlineBounds(board)).reduce((acc, bounds) => mergeBounds(acc, bounds));
|
|
32210
32359
|
};
|
|
32211
32360
|
|
|
32361
|
+
// src/textures/create-fabrication-note-texture-for-layer.ts
|
|
32362
|
+
var isFabricationNoteElement = (element, layer) => {
|
|
32363
|
+
if (!("layer" in element) || element.layer !== layer) return false;
|
|
32364
|
+
return element.type.startsWith("pcb_fabrication_note_");
|
|
32365
|
+
};
|
|
32366
|
+
function createFabricationNoteTextureForLayer({
|
|
32367
|
+
layer,
|
|
32368
|
+
circuitJson,
|
|
32369
|
+
boardData,
|
|
32370
|
+
traceTextureResolution = TRACE_TEXTURE_RESOLUTION
|
|
32371
|
+
}) {
|
|
32372
|
+
const elements = circuitJson.filter(
|
|
32373
|
+
(element) => isFabricationNoteElement(element, layer)
|
|
32374
|
+
);
|
|
32375
|
+
if (elements.length === 0) return null;
|
|
32376
|
+
const bounds = getSoldermaskRenderBounds(circuitJson, boardData);
|
|
32377
|
+
const canvasWidth = Math.floor(bounds.width * traceTextureResolution);
|
|
32378
|
+
const canvasHeight = Math.floor(bounds.height * traceTextureResolution);
|
|
32379
|
+
if (canvasWidth <= 0 || canvasHeight <= 0) return null;
|
|
32380
|
+
const canvas = document.createElement("canvas");
|
|
32381
|
+
canvas.width = canvasWidth;
|
|
32382
|
+
canvas.height = canvasHeight;
|
|
32383
|
+
const ctx = canvas.getContext("2d");
|
|
32384
|
+
if (!ctx) return null;
|
|
32385
|
+
if (layer === "bottom") {
|
|
32386
|
+
ctx.translate(0, canvasHeight);
|
|
32387
|
+
ctx.scale(1, -1);
|
|
32388
|
+
}
|
|
32389
|
+
drawFabricationNoteLayer({
|
|
32390
|
+
ctx,
|
|
32391
|
+
layer,
|
|
32392
|
+
bounds,
|
|
32393
|
+
elements
|
|
32394
|
+
});
|
|
32395
|
+
const texture = new THREE24.CanvasTexture(canvas);
|
|
32396
|
+
texture.generateMipmaps = true;
|
|
32397
|
+
texture.minFilter = THREE24.LinearMipmapLinearFilter;
|
|
32398
|
+
texture.magFilter = THREE24.LinearFilter;
|
|
32399
|
+
texture.anisotropy = 16;
|
|
32400
|
+
texture.needsUpdate = true;
|
|
32401
|
+
return texture;
|
|
32402
|
+
}
|
|
32403
|
+
|
|
32404
|
+
// src/textures/create-pcb-note-texture-for-layer.ts
|
|
32405
|
+
import * as THREE25 from "three";
|
|
32406
|
+
|
|
32407
|
+
// src/textures/pcb-note/pcb-note-drawing.ts
|
|
32408
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
|
|
32409
|
+
var TRANSPARENT2 = "rgba(0,0,0,0)";
|
|
32410
|
+
var setDrawerBounds3 = (drawer, bounds) => {
|
|
32411
|
+
drawer.setCameraBounds({
|
|
32412
|
+
minX: bounds.minX,
|
|
32413
|
+
maxX: bounds.maxX,
|
|
32414
|
+
minY: bounds.minY,
|
|
32415
|
+
maxY: bounds.maxY
|
|
32416
|
+
});
|
|
32417
|
+
};
|
|
32418
|
+
var normalizePcbNoteElement = (element) => {
|
|
32419
|
+
if (element.type === "pcb_note_line") {
|
|
32420
|
+
return {
|
|
32421
|
+
...element,
|
|
32422
|
+
x1: coerceDimensionToMm(element.x1, 0),
|
|
32423
|
+
y1: coerceDimensionToMm(element.y1, 0),
|
|
32424
|
+
x2: coerceDimensionToMm(element.x2, 0),
|
|
32425
|
+
y2: coerceDimensionToMm(element.y2, 0),
|
|
32426
|
+
stroke_width: coerceDimensionToMm(element.stroke_width, 0.1)
|
|
32427
|
+
};
|
|
32428
|
+
}
|
|
32429
|
+
if (element.type === "pcb_note_rect") {
|
|
32430
|
+
return {
|
|
32431
|
+
...element,
|
|
32432
|
+
center: {
|
|
32433
|
+
x: coerceDimensionToMm(element.center.x, 0),
|
|
32434
|
+
y: coerceDimensionToMm(element.center.y, 0)
|
|
32435
|
+
},
|
|
32436
|
+
width: coerceDimensionToMm(element.width, 0),
|
|
32437
|
+
height: coerceDimensionToMm(element.height, 0),
|
|
32438
|
+
stroke_width: coerceDimensionToMm(element.stroke_width, 0.1),
|
|
32439
|
+
corner_radius: coerceDimensionToMm(element.corner_radius, 0)
|
|
32440
|
+
};
|
|
32441
|
+
}
|
|
32442
|
+
if (element.type === "pcb_note_text") {
|
|
32443
|
+
return {
|
|
32444
|
+
...element,
|
|
32445
|
+
anchor_position: {
|
|
32446
|
+
x: coerceDimensionToMm(element.anchor_position.x, 0),
|
|
32447
|
+
y: coerceDimensionToMm(element.anchor_position.y, 0)
|
|
32448
|
+
},
|
|
32449
|
+
font_size: coerceDimensionToMm(element.font_size, 1)
|
|
32450
|
+
};
|
|
32451
|
+
}
|
|
32452
|
+
if (element.type === "pcb_note_path") {
|
|
32453
|
+
return {
|
|
32454
|
+
...element,
|
|
32455
|
+
route: element.route.map((point) => ({
|
|
32456
|
+
...point,
|
|
32457
|
+
x: coerceDimensionToMm(point.x, 0),
|
|
32458
|
+
y: coerceDimensionToMm(point.y, 0)
|
|
32459
|
+
})),
|
|
32460
|
+
stroke_width: coerceDimensionToMm(element.stroke_width, 0.1)
|
|
32461
|
+
};
|
|
32462
|
+
}
|
|
32463
|
+
if (element.type === "pcb_note_dimension") {
|
|
32464
|
+
return {
|
|
32465
|
+
...element,
|
|
32466
|
+
from: {
|
|
32467
|
+
x: coerceDimensionToMm(element.from.x, 0),
|
|
32468
|
+
y: coerceDimensionToMm(element.from.y, 0)
|
|
32469
|
+
},
|
|
32470
|
+
to: {
|
|
32471
|
+
x: coerceDimensionToMm(element.to.x, 0),
|
|
32472
|
+
y: coerceDimensionToMm(element.to.y, 0)
|
|
32473
|
+
},
|
|
32474
|
+
font_size: coerceDimensionToMm(element.font_size, 1),
|
|
32475
|
+
arrow_size: coerceDimensionToMm(element.arrow_size, 1),
|
|
32476
|
+
offset_distance: coerceDimensionToMm(element.offset_distance, 0)
|
|
32477
|
+
};
|
|
32478
|
+
}
|
|
32479
|
+
return element;
|
|
32480
|
+
};
|
|
32481
|
+
var drawPcbNoteLayer = ({
|
|
32482
|
+
ctx,
|
|
32483
|
+
bounds,
|
|
32484
|
+
elements
|
|
32485
|
+
}) => {
|
|
32486
|
+
const normalizedElements = elements.map(normalizePcbNoteElement);
|
|
32487
|
+
const drawer = new CircuitToCanvasDrawer4(ctx);
|
|
32488
|
+
drawer.configure({
|
|
32489
|
+
colorOverrides: {
|
|
32490
|
+
copper: {
|
|
32491
|
+
top: TRANSPARENT2,
|
|
32492
|
+
bottom: TRANSPARENT2,
|
|
32493
|
+
inner1: TRANSPARENT2,
|
|
32494
|
+
inner2: TRANSPARENT2,
|
|
32495
|
+
inner3: TRANSPARENT2,
|
|
32496
|
+
inner4: TRANSPARENT2,
|
|
32497
|
+
inner5: TRANSPARENT2,
|
|
32498
|
+
inner6: TRANSPARENT2
|
|
32499
|
+
},
|
|
32500
|
+
copperPour: { top: TRANSPARENT2, bottom: TRANSPARENT2 },
|
|
32501
|
+
drill: TRANSPARENT2,
|
|
32502
|
+
boardOutline: TRANSPARENT2,
|
|
32503
|
+
substrate: TRANSPARENT2,
|
|
32504
|
+
keepout: TRANSPARENT2,
|
|
32505
|
+
courtyard: { top: TRANSPARENT2, bottom: TRANSPARENT2 },
|
|
32506
|
+
soldermask: { top: TRANSPARENT2, bottom: TRANSPARENT2 },
|
|
32507
|
+
soldermaskWithCopperUnderneath: {
|
|
32508
|
+
top: TRANSPARENT2,
|
|
32509
|
+
bottom: TRANSPARENT2
|
|
32510
|
+
},
|
|
32511
|
+
soldermaskOverCopper: {
|
|
32512
|
+
top: TRANSPARENT2,
|
|
32513
|
+
bottom: TRANSPARENT2
|
|
32514
|
+
},
|
|
32515
|
+
silkscreen: { top: TRANSPARENT2, bottom: TRANSPARENT2 },
|
|
32516
|
+
fabricationNote: TRANSPARENT2
|
|
32517
|
+
}
|
|
32518
|
+
});
|
|
32519
|
+
setDrawerBounds3(drawer, bounds);
|
|
32520
|
+
drawer.drawElements(normalizedElements);
|
|
32521
|
+
};
|
|
32522
|
+
|
|
32523
|
+
// src/textures/create-pcb-note-texture-for-layer.ts
|
|
32524
|
+
var isPcbNoteElement = (element, layer) => {
|
|
32525
|
+
if (!("layer" in element) || element.layer !== layer) return false;
|
|
32526
|
+
return element.type.startsWith("pcb_note_");
|
|
32527
|
+
};
|
|
32528
|
+
function createPcbNoteTextureForLayer({
|
|
32529
|
+
layer,
|
|
32530
|
+
circuitJson,
|
|
32531
|
+
boardData,
|
|
32532
|
+
traceTextureResolution = TRACE_TEXTURE_RESOLUTION
|
|
32533
|
+
}) {
|
|
32534
|
+
const elements = circuitJson.filter(
|
|
32535
|
+
(element) => isPcbNoteElement(element, layer)
|
|
32536
|
+
);
|
|
32537
|
+
if (elements.length === 0) return null;
|
|
32538
|
+
const bounds = getSoldermaskRenderBounds(circuitJson, boardData);
|
|
32539
|
+
const canvasWidth = Math.floor(bounds.width * traceTextureResolution);
|
|
32540
|
+
const canvasHeight = Math.floor(bounds.height * traceTextureResolution);
|
|
32541
|
+
if (canvasWidth <= 0 || canvasHeight <= 0) return null;
|
|
32542
|
+
const canvas = document.createElement("canvas");
|
|
32543
|
+
canvas.width = canvasWidth;
|
|
32544
|
+
canvas.height = canvasHeight;
|
|
32545
|
+
const ctx = canvas.getContext("2d");
|
|
32546
|
+
if (!ctx) return null;
|
|
32547
|
+
if (layer === "bottom") {
|
|
32548
|
+
ctx.translate(0, canvasHeight);
|
|
32549
|
+
ctx.scale(1, -1);
|
|
32550
|
+
}
|
|
32551
|
+
drawPcbNoteLayer({
|
|
32552
|
+
ctx,
|
|
32553
|
+
bounds,
|
|
32554
|
+
elements
|
|
32555
|
+
});
|
|
32556
|
+
const texture = new THREE25.CanvasTexture(canvas);
|
|
32557
|
+
texture.generateMipmaps = true;
|
|
32558
|
+
texture.minFilter = THREE25.LinearMipmapLinearFilter;
|
|
32559
|
+
texture.magFilter = THREE25.LinearFilter;
|
|
32560
|
+
texture.anisotropy = 16;
|
|
32561
|
+
texture.needsUpdate = true;
|
|
32562
|
+
return texture;
|
|
32563
|
+
}
|
|
32564
|
+
|
|
32565
|
+
// src/textures/create-silkscreen-texture-for-layer.ts
|
|
32566
|
+
import * as THREE26 from "three";
|
|
32567
|
+
|
|
32212
32568
|
// src/textures/silkscreen/silkscreen-drawing.ts
|
|
32213
|
-
import { CircuitToCanvasDrawer as
|
|
32214
|
-
var
|
|
32215
|
-
var
|
|
32216
|
-
var
|
|
32569
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
|
|
32570
|
+
var FABRICATION_NOTE_COLOR2 = "rgb(255,243,204)";
|
|
32571
|
+
var TRANSPARENT3 = "rgba(0,0,0,0)";
|
|
32572
|
+
var setDrawerBounds4 = (drawer, bounds) => {
|
|
32217
32573
|
drawer.setCameraBounds({
|
|
32218
32574
|
minX: bounds.minX,
|
|
32219
32575
|
maxX: bounds.maxX,
|
|
@@ -32229,51 +32585,51 @@ var drawSilkscreenLayer = ({
|
|
|
32229
32585
|
silkscreenColor
|
|
32230
32586
|
}) => {
|
|
32231
32587
|
const renderLayer = layer === "top" ? "top_silkscreen" : "bottom_silkscreen";
|
|
32232
|
-
const drawer = new
|
|
32588
|
+
const drawer = new CircuitToCanvasDrawer5(ctx);
|
|
32233
32589
|
drawer.configure({
|
|
32234
32590
|
colorOverrides: {
|
|
32235
32591
|
copper: {
|
|
32236
|
-
top:
|
|
32237
|
-
bottom:
|
|
32238
|
-
inner1:
|
|
32239
|
-
inner2:
|
|
32240
|
-
inner3:
|
|
32241
|
-
inner4:
|
|
32242
|
-
inner5:
|
|
32243
|
-
inner6:
|
|
32592
|
+
top: TRANSPARENT3,
|
|
32593
|
+
bottom: TRANSPARENT3,
|
|
32594
|
+
inner1: TRANSPARENT3,
|
|
32595
|
+
inner2: TRANSPARENT3,
|
|
32596
|
+
inner3: TRANSPARENT3,
|
|
32597
|
+
inner4: TRANSPARENT3,
|
|
32598
|
+
inner5: TRANSPARENT3,
|
|
32599
|
+
inner6: TRANSPARENT3
|
|
32244
32600
|
},
|
|
32245
32601
|
copperPour: {
|
|
32246
|
-
top:
|
|
32247
|
-
bottom:
|
|
32602
|
+
top: TRANSPARENT3,
|
|
32603
|
+
bottom: TRANSPARENT3
|
|
32248
32604
|
},
|
|
32249
|
-
drill:
|
|
32250
|
-
boardOutline:
|
|
32251
|
-
substrate:
|
|
32252
|
-
keepout:
|
|
32605
|
+
drill: TRANSPARENT3,
|
|
32606
|
+
boardOutline: TRANSPARENT3,
|
|
32607
|
+
substrate: TRANSPARENT3,
|
|
32608
|
+
keepout: TRANSPARENT3,
|
|
32253
32609
|
courtyard: {
|
|
32254
|
-
top:
|
|
32255
|
-
bottom:
|
|
32610
|
+
top: TRANSPARENT3,
|
|
32611
|
+
bottom: TRANSPARENT3
|
|
32256
32612
|
},
|
|
32257
32613
|
soldermask: {
|
|
32258
|
-
top:
|
|
32259
|
-
bottom:
|
|
32614
|
+
top: TRANSPARENT3,
|
|
32615
|
+
bottom: TRANSPARENT3
|
|
32260
32616
|
},
|
|
32261
32617
|
soldermaskWithCopperUnderneath: {
|
|
32262
|
-
top:
|
|
32263
|
-
bottom:
|
|
32618
|
+
top: TRANSPARENT3,
|
|
32619
|
+
bottom: TRANSPARENT3
|
|
32264
32620
|
},
|
|
32265
32621
|
soldermaskOverCopper: {
|
|
32266
|
-
top:
|
|
32267
|
-
bottom:
|
|
32622
|
+
top: TRANSPARENT3,
|
|
32623
|
+
bottom: TRANSPARENT3
|
|
32268
32624
|
},
|
|
32269
32625
|
silkscreen: {
|
|
32270
32626
|
top: silkscreenColor,
|
|
32271
32627
|
bottom: silkscreenColor
|
|
32272
32628
|
},
|
|
32273
|
-
fabricationNote:
|
|
32629
|
+
fabricationNote: FABRICATION_NOTE_COLOR2
|
|
32274
32630
|
}
|
|
32275
32631
|
});
|
|
32276
|
-
|
|
32632
|
+
setDrawerBounds4(drawer, bounds);
|
|
32277
32633
|
drawer.drawElements(elements, {
|
|
32278
32634
|
layers: [renderLayer]
|
|
32279
32635
|
});
|
|
@@ -32283,7 +32639,7 @@ var drawSilkscreenLayer = ({
|
|
|
32283
32639
|
var isSilkscreenElement = (element, layer) => {
|
|
32284
32640
|
if (!("layer" in element) || element.layer !== layer) return false;
|
|
32285
32641
|
const elementType = element.type;
|
|
32286
|
-
return elementType.startsWith("pcb_silkscreen_")
|
|
32642
|
+
return elementType.startsWith("pcb_silkscreen_");
|
|
32287
32643
|
};
|
|
32288
32644
|
function createSilkscreenTextureForLayer({
|
|
32289
32645
|
layer,
|
|
@@ -32316,20 +32672,20 @@ function createSilkscreenTextureForLayer({
|
|
|
32316
32672
|
elements,
|
|
32317
32673
|
silkscreenColor
|
|
32318
32674
|
});
|
|
32319
|
-
const texture = new
|
|
32675
|
+
const texture = new THREE26.CanvasTexture(canvas);
|
|
32320
32676
|
texture.generateMipmaps = true;
|
|
32321
|
-
texture.minFilter =
|
|
32322
|
-
texture.magFilter =
|
|
32677
|
+
texture.minFilter = THREE26.LinearMipmapLinearFilter;
|
|
32678
|
+
texture.magFilter = THREE26.LinearFilter;
|
|
32323
32679
|
texture.anisotropy = 16;
|
|
32324
32680
|
texture.needsUpdate = true;
|
|
32325
32681
|
return texture;
|
|
32326
32682
|
}
|
|
32327
32683
|
|
|
32328
32684
|
// src/textures/create-soldermask-texture-for-layer.ts
|
|
32329
|
-
import * as
|
|
32685
|
+
import * as THREE27 from "three";
|
|
32330
32686
|
|
|
32331
32687
|
// src/textures/soldermask/soldermask-drawing.ts
|
|
32332
|
-
import { CircuitToCanvasDrawer as
|
|
32688
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
|
|
32333
32689
|
var toRgb = (colorArr) => {
|
|
32334
32690
|
const [r = 0, g = 0, b = 0] = colorArr;
|
|
32335
32691
|
return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
|
|
@@ -32348,7 +32704,7 @@ var getSoldermaskPalette = (material) => {
|
|
|
32348
32704
|
transparent: "rgba(0,0,0,0)"
|
|
32349
32705
|
};
|
|
32350
32706
|
};
|
|
32351
|
-
var
|
|
32707
|
+
var setDrawerBounds5 = (drawer, bounds) => {
|
|
32352
32708
|
drawer.setCameraBounds({
|
|
32353
32709
|
minX: bounds.minX,
|
|
32354
32710
|
maxX: bounds.maxX,
|
|
@@ -32365,7 +32721,7 @@ var drawSoldermaskLayer = ({
|
|
|
32365
32721
|
}) => {
|
|
32366
32722
|
const palette = getSoldermaskPalette(boardMaterial);
|
|
32367
32723
|
const copperRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
32368
|
-
const drawer = new
|
|
32724
|
+
const drawer = new CircuitToCanvasDrawer6(ctx);
|
|
32369
32725
|
drawer.configure({
|
|
32370
32726
|
colorOverrides: {
|
|
32371
32727
|
copper: {
|
|
@@ -32396,7 +32752,7 @@ var drawSoldermaskLayer = ({
|
|
|
32396
32752
|
}
|
|
32397
32753
|
}
|
|
32398
32754
|
});
|
|
32399
|
-
|
|
32755
|
+
setDrawerBounds5(drawer, bounds);
|
|
32400
32756
|
drawer.drawElements(elements, {
|
|
32401
32757
|
layers: [copperRenderLayer],
|
|
32402
32758
|
drawSoldermask: true,
|
|
@@ -32409,7 +32765,7 @@ var drawSoldermaskLayer = ({
|
|
|
32409
32765
|
if (uncoveredPours.length > 0) {
|
|
32410
32766
|
ctx.save();
|
|
32411
32767
|
ctx.globalCompositeOperation = "destination-out";
|
|
32412
|
-
const cutoutDrawer = new
|
|
32768
|
+
const cutoutDrawer = new CircuitToCanvasDrawer6(ctx);
|
|
32413
32769
|
cutoutDrawer.configure({
|
|
32414
32770
|
colorOverrides: {
|
|
32415
32771
|
copper: {
|
|
@@ -32424,7 +32780,7 @@ var drawSoldermaskLayer = ({
|
|
|
32424
32780
|
}
|
|
32425
32781
|
}
|
|
32426
32782
|
});
|
|
32427
|
-
|
|
32783
|
+
setDrawerBounds5(cutoutDrawer, bounds);
|
|
32428
32784
|
cutoutDrawer.drawElements(uncoveredPours, { layers: [copperRenderLayer] });
|
|
32429
32785
|
ctx.restore();
|
|
32430
32786
|
}
|
|
@@ -32458,10 +32814,10 @@ function createSoldermaskTextureForLayer({
|
|
|
32458
32814
|
elements,
|
|
32459
32815
|
boardMaterial: boardData.material
|
|
32460
32816
|
});
|
|
32461
|
-
const texture = new
|
|
32817
|
+
const texture = new THREE27.CanvasTexture(canvas);
|
|
32462
32818
|
texture.generateMipmaps = true;
|
|
32463
|
-
texture.minFilter =
|
|
32464
|
-
texture.magFilter =
|
|
32819
|
+
texture.minFilter = THREE27.LinearMipmapLinearFilter;
|
|
32820
|
+
texture.magFilter = THREE27.LinearFilter;
|
|
32465
32821
|
texture.anisotropy = 16;
|
|
32466
32822
|
texture.needsUpdate = true;
|
|
32467
32823
|
return texture;
|
|
@@ -32499,10 +32855,10 @@ var createCombinedTexture = ({
|
|
|
32499
32855
|
const image = texture.image;
|
|
32500
32856
|
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
|
|
32501
32857
|
});
|
|
32502
|
-
const combinedTexture = new
|
|
32858
|
+
const combinedTexture = new THREE28.CanvasTexture(canvas);
|
|
32503
32859
|
combinedTexture.generateMipmaps = false;
|
|
32504
|
-
combinedTexture.minFilter =
|
|
32505
|
-
combinedTexture.magFilter =
|
|
32860
|
+
combinedTexture.minFilter = THREE28.LinearFilter;
|
|
32861
|
+
combinedTexture.magFilter = THREE28.LinearFilter;
|
|
32506
32862
|
combinedTexture.premultiplyAlpha = true;
|
|
32507
32863
|
combinedTexture.anisotropy = 16;
|
|
32508
32864
|
combinedTexture.needsUpdate = true;
|
|
@@ -32563,6 +32919,18 @@ function createCombinedBoardTextures({
|
|
|
32563
32919
|
silkscreenColor,
|
|
32564
32920
|
traceTextureResolution
|
|
32565
32921
|
}) : null;
|
|
32922
|
+
const fabricationNoteTexture = showSilkscreen ? createFabricationNoteTextureForLayer({
|
|
32923
|
+
layer,
|
|
32924
|
+
circuitJson,
|
|
32925
|
+
boardData,
|
|
32926
|
+
traceTextureResolution
|
|
32927
|
+
}) : null;
|
|
32928
|
+
const pcbNoteTexture = showSilkscreen ? createPcbNoteTextureForLayer({
|
|
32929
|
+
layer,
|
|
32930
|
+
circuitJson,
|
|
32931
|
+
boardData,
|
|
32932
|
+
traceTextureResolution
|
|
32933
|
+
}) : null;
|
|
32566
32934
|
const panelOutlineTexture = showBoardBody ? createPanelOutlineTextureForLayer({
|
|
32567
32935
|
layer,
|
|
32568
32936
|
circuitJson,
|
|
@@ -32577,6 +32945,8 @@ function createCombinedBoardTextures({
|
|
|
32577
32945
|
soldermaskTexture,
|
|
32578
32946
|
copperTextTexture,
|
|
32579
32947
|
silkscreenTexture,
|
|
32948
|
+
fabricationNoteTexture,
|
|
32949
|
+
pcbNoteTexture,
|
|
32580
32950
|
panelOutlineTexture
|
|
32581
32951
|
],
|
|
32582
32952
|
boardData,
|
|
@@ -32591,7 +32961,7 @@ function createCombinedBoardTextures({
|
|
|
32591
32961
|
}
|
|
32592
32962
|
|
|
32593
32963
|
// src/textures/create-three-texture-meshes.ts
|
|
32594
|
-
import * as
|
|
32964
|
+
import * as THREE29 from "three";
|
|
32595
32965
|
function createTexturePlane(config, boardData) {
|
|
32596
32966
|
const {
|
|
32597
32967
|
texture,
|
|
@@ -32603,15 +32973,15 @@ function createTexturePlane(config, boardData) {
|
|
|
32603
32973
|
} = config;
|
|
32604
32974
|
if (!texture) return null;
|
|
32605
32975
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
32606
|
-
const planeGeom = new
|
|
32976
|
+
const planeGeom = new THREE29.PlaneGeometry(
|
|
32607
32977
|
boardOutlineBounds.width,
|
|
32608
32978
|
boardOutlineBounds.height
|
|
32609
32979
|
);
|
|
32610
|
-
const material = new
|
|
32980
|
+
const material = new THREE29.MeshBasicMaterial({
|
|
32611
32981
|
map: texture,
|
|
32612
32982
|
transparent: true,
|
|
32613
32983
|
alphaTest: 0.08,
|
|
32614
|
-
side:
|
|
32984
|
+
side: THREE29.DoubleSide,
|
|
32615
32985
|
depthWrite: true,
|
|
32616
32986
|
polygonOffset: usePolygonOffset,
|
|
32617
32987
|
polygonOffsetFactor: usePolygonOffset ? -4 : 0,
|
|
@@ -32619,7 +32989,7 @@ function createTexturePlane(config, boardData) {
|
|
|
32619
32989
|
polygonOffsetUnits: usePolygonOffset ? -4 : 0,
|
|
32620
32990
|
opacity: isFaux ? FAUX_BOARD_OPACITY : 1
|
|
32621
32991
|
});
|
|
32622
|
-
const mesh = new
|
|
32992
|
+
const mesh = new THREE29.Mesh(planeGeom, material);
|
|
32623
32993
|
mesh.position.set(
|
|
32624
32994
|
boardOutlineBounds.centerX,
|
|
32625
32995
|
boardOutlineBounds.centerY,
|
|
@@ -32664,7 +33034,7 @@ function createTextureMeshes(textures, boardData, pcbThickness, isFaux = false)
|
|
|
32664
33034
|
}
|
|
32665
33035
|
|
|
32666
33036
|
// src/three-components/JscadBoardTextures.tsx
|
|
32667
|
-
import * as
|
|
33037
|
+
import * as THREE30 from "three";
|
|
32668
33038
|
|
|
32669
33039
|
// src/utils/layer-texture-resolution.ts
|
|
32670
33040
|
var DEFAULT_MAX_TEXTURE_PIXELS = 4e6;
|
|
@@ -32760,7 +33130,7 @@ function JscadBoardTextures({
|
|
|
32760
33130
|
const typedMaterial = material;
|
|
32761
33131
|
for (const prop of textureProps) {
|
|
32762
33132
|
const texture = typedMaterial[prop];
|
|
32763
|
-
if (texture && texture instanceof
|
|
33133
|
+
if (texture && texture instanceof THREE30.Texture) {
|
|
32764
33134
|
texture.dispose();
|
|
32765
33135
|
typedMaterial[prop] = null;
|
|
32766
33136
|
}
|
|
@@ -32770,22 +33140,22 @@ function JscadBoardTextures({
|
|
|
32770
33140
|
const createTexturePlane2 = (texture, zOffset, isBottomLayer, name, usePolygonOffset = false, depthWrite = true, renderOrder = 1) => {
|
|
32771
33141
|
if (!texture) return null;
|
|
32772
33142
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
32773
|
-
const planeGeom = new
|
|
33143
|
+
const planeGeom = new THREE30.PlaneGeometry(
|
|
32774
33144
|
boardOutlineBounds.width,
|
|
32775
33145
|
boardOutlineBounds.height
|
|
32776
33146
|
);
|
|
32777
|
-
const material = new
|
|
33147
|
+
const material = new THREE30.MeshBasicMaterial({
|
|
32778
33148
|
map: texture,
|
|
32779
33149
|
transparent: true,
|
|
32780
33150
|
alphaTest: 0.08,
|
|
32781
|
-
side:
|
|
33151
|
+
side: THREE30.DoubleSide,
|
|
32782
33152
|
depthWrite,
|
|
32783
33153
|
polygonOffset: usePolygonOffset,
|
|
32784
33154
|
polygonOffsetFactor: usePolygonOffset ? -4 : 0,
|
|
32785
33155
|
polygonOffsetUnits: usePolygonOffset ? -4 : 0,
|
|
32786
33156
|
opacity: isFaux ? FAUX_BOARD_OPACITY : 1
|
|
32787
33157
|
});
|
|
32788
|
-
const mesh = new
|
|
33158
|
+
const mesh = new THREE30.Mesh(planeGeom, material);
|
|
32789
33159
|
mesh.position.set(
|
|
32790
33160
|
boardOutlineBounds.centerX,
|
|
32791
33161
|
boardOutlineBounds.centerY,
|
|
@@ -32830,7 +33200,7 @@ function JscadBoardTextures({
|
|
|
32830
33200
|
mesh.geometry.dispose();
|
|
32831
33201
|
if (Array.isArray(mesh.material)) {
|
|
32832
33202
|
mesh.material.forEach((material) => disposeTextureMaterial(material));
|
|
32833
|
-
} else if (mesh.material instanceof
|
|
33203
|
+
} else if (mesh.material instanceof THREE30.Material) {
|
|
32834
33204
|
disposeTextureMaterial(mesh.material);
|
|
32835
33205
|
}
|
|
32836
33206
|
});
|
|
@@ -33063,12 +33433,12 @@ var CadViewerJscad = forwardRef3(
|
|
|
33063
33433
|
// src/CadViewerManifold.tsx
|
|
33064
33434
|
import { su as su17 } from "@tscircuit/circuit-json-util";
|
|
33065
33435
|
import { useEffect as useEffect25, useMemo as useMemo22, useState as useState16 } from "react";
|
|
33066
|
-
import * as
|
|
33436
|
+
import * as THREE37 from "three";
|
|
33067
33437
|
|
|
33068
33438
|
// src/hooks/useManifoldBoardBuilder.ts
|
|
33069
33439
|
import { su as su16 } from "@tscircuit/circuit-json-util";
|
|
33070
33440
|
import { useEffect as useEffect24, useMemo as useMemo21, useRef as useRef9, useState as useState15 } from "react";
|
|
33071
|
-
import * as
|
|
33441
|
+
import * as THREE34 from "three";
|
|
33072
33442
|
|
|
33073
33443
|
// src/utils/manifold/create-manifold-board.ts
|
|
33074
33444
|
var arePointsClockwise2 = (points) => {
|
|
@@ -33410,17 +33780,17 @@ function processNonPlatedHolesForManifold(Manifold, CrossSection, circuitJson, p
|
|
|
33410
33780
|
|
|
33411
33781
|
// src/utils/manifold/process-plated-holes.ts
|
|
33412
33782
|
import { su as su14 } from "@tscircuit/circuit-json-util";
|
|
33413
|
-
import * as
|
|
33783
|
+
import * as THREE32 from "three";
|
|
33414
33784
|
|
|
33415
33785
|
// src/utils/manifold-mesh-to-three-geometry.ts
|
|
33416
|
-
import * as
|
|
33786
|
+
import * as THREE31 from "three";
|
|
33417
33787
|
function manifoldMeshToThreeGeometry(manifoldMesh) {
|
|
33418
|
-
const geometry = new
|
|
33788
|
+
const geometry = new THREE31.BufferGeometry();
|
|
33419
33789
|
geometry.setAttribute(
|
|
33420
33790
|
"position",
|
|
33421
|
-
new
|
|
33791
|
+
new THREE31.Float32BufferAttribute(manifoldMesh.vertProperties, 3)
|
|
33422
33792
|
);
|
|
33423
|
-
geometry.setIndex(new
|
|
33793
|
+
geometry.setIndex(new THREE31.Uint32BufferAttribute(manifoldMesh.triVerts, 1));
|
|
33424
33794
|
if (manifoldMesh.runIndex && manifoldMesh.runIndex.length > 1 && manifoldMesh.runOriginalID) {
|
|
33425
33795
|
for (let i = 0; i < manifoldMesh.runIndex.length - 1; i++) {
|
|
33426
33796
|
const start = manifoldMesh.runIndex[i];
|
|
@@ -33454,7 +33824,7 @@ var createEllipsePoints = (width10, height10, segments) => {
|
|
|
33454
33824
|
}
|
|
33455
33825
|
return points;
|
|
33456
33826
|
};
|
|
33457
|
-
var COPPER_COLOR = new
|
|
33827
|
+
var COPPER_COLOR = new THREE32.Color(...colors.copper);
|
|
33458
33828
|
var PLATED_HOLE_LIP_HEIGHT = 0.05;
|
|
33459
33829
|
var PLATED_HOLE_PAD_THICKNESS = 3e-3;
|
|
33460
33830
|
var PLATED_HOLE_SURFACE_CLEARANCE = 5e-4;
|
|
@@ -34196,7 +34566,7 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
34196
34566
|
|
|
34197
34567
|
// src/utils/manifold/process-vias.ts
|
|
34198
34568
|
import { su as su15 } from "@tscircuit/circuit-json-util";
|
|
34199
|
-
import * as
|
|
34569
|
+
import * as THREE33 from "three";
|
|
34200
34570
|
|
|
34201
34571
|
// src/utils/via-geoms.ts
|
|
34202
34572
|
function createViaCopper2({
|
|
@@ -34249,7 +34619,7 @@ function createViaCopper2({
|
|
|
34249
34619
|
}
|
|
34250
34620
|
|
|
34251
34621
|
// src/utils/manifold/process-vias.ts
|
|
34252
|
-
var COPPER_COLOR2 = new
|
|
34622
|
+
var COPPER_COLOR2 = new THREE33.Color(...colors.copper);
|
|
34253
34623
|
function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
34254
34624
|
const viaBoardDrills = [];
|
|
34255
34625
|
const pcbVias = su15(circuitJson).pcb_via.list();
|
|
@@ -34469,7 +34839,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
34469
34839
|
{
|
|
34470
34840
|
key: "plated-holes-union",
|
|
34471
34841
|
geometry: cutPlatedGeom,
|
|
34472
|
-
color: new
|
|
34842
|
+
color: new THREE34.Color(
|
|
34473
34843
|
colors.copper[0],
|
|
34474
34844
|
colors.copper[1],
|
|
34475
34845
|
colors.copper[2]
|
|
@@ -34499,7 +34869,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
34499
34869
|
const matColorArray = boardMaterialColors[boardData.material] ?? colors.fr4Tan;
|
|
34500
34870
|
currentGeoms.board = {
|
|
34501
34871
|
geometry: finalBoardGeom,
|
|
34502
|
-
color: new
|
|
34872
|
+
color: new THREE34.Color(
|
|
34503
34873
|
matColorArray[0],
|
|
34504
34874
|
matColorArray[1],
|
|
34505
34875
|
matColorArray[2]
|
|
@@ -34544,11 +34914,11 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
34544
34914
|
};
|
|
34545
34915
|
|
|
34546
34916
|
// src/utils/manifold/create-three-geometry-meshes.ts
|
|
34547
|
-
import * as
|
|
34917
|
+
import * as THREE36 from "three";
|
|
34548
34918
|
|
|
34549
34919
|
// src/utils/create-board-material.ts
|
|
34550
|
-
import * as
|
|
34551
|
-
var DEFAULT_SIDE =
|
|
34920
|
+
import * as THREE35 from "three";
|
|
34921
|
+
var DEFAULT_SIDE = THREE35.DoubleSide;
|
|
34552
34922
|
var createBoardMaterial = ({
|
|
34553
34923
|
material,
|
|
34554
34924
|
color,
|
|
@@ -34556,7 +34926,7 @@ var createBoardMaterial = ({
|
|
|
34556
34926
|
isFaux = false
|
|
34557
34927
|
}) => {
|
|
34558
34928
|
if (material === "fr4") {
|
|
34559
|
-
return new
|
|
34929
|
+
return new THREE35.MeshPhysicalMaterial({
|
|
34560
34930
|
color,
|
|
34561
34931
|
side,
|
|
34562
34932
|
metalness: 0,
|
|
@@ -34573,7 +34943,7 @@ var createBoardMaterial = ({
|
|
|
34573
34943
|
polygonOffsetUnits: 1
|
|
34574
34944
|
});
|
|
34575
34945
|
}
|
|
34576
|
-
return new
|
|
34946
|
+
return new THREE35.MeshStandardMaterial({
|
|
34577
34947
|
color,
|
|
34578
34948
|
side,
|
|
34579
34949
|
flatShading: true,
|
|
@@ -34592,12 +34962,12 @@ function createGeometryMeshes(geoms) {
|
|
|
34592
34962
|
const meshes = [];
|
|
34593
34963
|
if (!geoms) return meshes;
|
|
34594
34964
|
if (geoms.board && geoms.board.geometry) {
|
|
34595
|
-
const mesh = new
|
|
34965
|
+
const mesh = new THREE36.Mesh(
|
|
34596
34966
|
geoms.board.geometry,
|
|
34597
34967
|
createBoardMaterial({
|
|
34598
34968
|
material: geoms.board.material,
|
|
34599
34969
|
color: geoms.board.color,
|
|
34600
|
-
side:
|
|
34970
|
+
side: THREE36.DoubleSide,
|
|
34601
34971
|
isFaux: geoms.board.isFaux
|
|
34602
34972
|
})
|
|
34603
34973
|
);
|
|
@@ -34607,11 +34977,11 @@ function createGeometryMeshes(geoms) {
|
|
|
34607
34977
|
const createMeshesFromArray = (geomArray) => {
|
|
34608
34978
|
if (geomArray) {
|
|
34609
34979
|
geomArray.forEach((comp) => {
|
|
34610
|
-
const mesh = new
|
|
34980
|
+
const mesh = new THREE36.Mesh(
|
|
34611
34981
|
comp.geometry,
|
|
34612
|
-
new
|
|
34982
|
+
new THREE36.MeshStandardMaterial({
|
|
34613
34983
|
color: comp.color,
|
|
34614
|
-
side:
|
|
34984
|
+
side: THREE36.DoubleSide,
|
|
34615
34985
|
flatShading: true
|
|
34616
34986
|
// Consistent with board
|
|
34617
34987
|
})
|
|
@@ -34655,7 +35025,7 @@ var BoardMeshes = ({
|
|
|
34655
35025
|
const typedMaterial = material;
|
|
34656
35026
|
for (const prop of textureProps) {
|
|
34657
35027
|
const texture = typedMaterial[prop];
|
|
34658
|
-
if (texture && texture instanceof
|
|
35028
|
+
if (texture && texture instanceof THREE37.Texture) {
|
|
34659
35029
|
texture.dispose();
|
|
34660
35030
|
typedMaterial[prop] = null;
|
|
34661
35031
|
}
|
|
@@ -41544,7 +41914,7 @@ var KeyboardShortcutsDialog = ({
|
|
|
41544
41914
|
|
|
41545
41915
|
// src/CadViewer.tsx
|
|
41546
41916
|
import { jsx as jsx38, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
41547
|
-
var DEFAULT_TARGET = new
|
|
41917
|
+
var DEFAULT_TARGET = new THREE38.Vector3(0, 0, 0);
|
|
41548
41918
|
var INITIAL_CAMERA_POSITION = [5, -5, 5];
|
|
41549
41919
|
var CadViewerInner = (props) => {
|
|
41550
41920
|
const [engine, setEngine] = useState36("manifold");
|
|
@@ -41811,11 +42181,11 @@ var CadViewer = (props) => {
|
|
|
41811
42181
|
// src/convert-circuit-json-to-3d-svg.ts
|
|
41812
42182
|
var import_debug = __toESM(require_browser(), 1);
|
|
41813
42183
|
import { su as su18 } from "@tscircuit/circuit-json-util";
|
|
41814
|
-
import * as
|
|
42184
|
+
import * as THREE42 from "three";
|
|
41815
42185
|
import { SVGRenderer } from "three/examples/jsm/renderers/SVGRenderer.js";
|
|
41816
42186
|
|
|
41817
42187
|
// src/utils/create-geometry-from-polygons.ts
|
|
41818
|
-
import * as
|
|
42188
|
+
import * as THREE39 from "three";
|
|
41819
42189
|
import { BufferGeometry as BufferGeometry4, Float32BufferAttribute as Float32BufferAttribute3 } from "three";
|
|
41820
42190
|
function createGeometryFromPolygons(polygons) {
|
|
41821
42191
|
const geometry = new BufferGeometry4();
|
|
@@ -41829,12 +42199,12 @@ function createGeometryFromPolygons(polygons) {
|
|
|
41829
42199
|
...polygon3.vertices[i + 1]
|
|
41830
42200
|
// Third vertex
|
|
41831
42201
|
);
|
|
41832
|
-
const v1 = new
|
|
41833
|
-
const v2 = new
|
|
41834
|
-
const v3 = new
|
|
41835
|
-
const normal = new
|
|
41836
|
-
new
|
|
41837
|
-
new
|
|
42202
|
+
const v1 = new THREE39.Vector3(...polygon3.vertices[0]);
|
|
42203
|
+
const v2 = new THREE39.Vector3(...polygon3.vertices[i]);
|
|
42204
|
+
const v3 = new THREE39.Vector3(...polygon3.vertices[i + 1]);
|
|
42205
|
+
const normal = new THREE39.Vector3().crossVectors(
|
|
42206
|
+
new THREE39.Vector3().subVectors(v2, v1),
|
|
42207
|
+
new THREE39.Vector3().subVectors(v3, v1)
|
|
41838
42208
|
).normalize();
|
|
41839
42209
|
normals.push(
|
|
41840
42210
|
normal.x,
|
|
@@ -41858,10 +42228,10 @@ function createGeometryFromPolygons(polygons) {
|
|
|
41858
42228
|
var import_modeling2 = __toESM(require_src(), 1);
|
|
41859
42229
|
var import_jscad_planner2 = __toESM(require_dist(), 1);
|
|
41860
42230
|
var jscadModeling2 = __toESM(require_src(), 1);
|
|
41861
|
-
import * as
|
|
42231
|
+
import * as THREE41 from "three";
|
|
41862
42232
|
|
|
41863
42233
|
// src/utils/load-model.ts
|
|
41864
|
-
import * as
|
|
42234
|
+
import * as THREE40 from "three";
|
|
41865
42235
|
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
41866
42236
|
import { OBJLoader as OBJLoader2 } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
41867
42237
|
import { STLLoader as STLLoader2 } from "three/examples/jsm/loaders/STLLoader.js";
|
|
@@ -41869,12 +42239,12 @@ async function load3DModel(url) {
|
|
|
41869
42239
|
if (url.endsWith(".stl")) {
|
|
41870
42240
|
const loader = new STLLoader2();
|
|
41871
42241
|
const geometry = await loader.loadAsync(url);
|
|
41872
|
-
const material = new
|
|
42242
|
+
const material = new THREE40.MeshStandardMaterial({
|
|
41873
42243
|
color: 8947848,
|
|
41874
42244
|
metalness: 0.5,
|
|
41875
42245
|
roughness: 0.5
|
|
41876
42246
|
});
|
|
41877
|
-
return new
|
|
42247
|
+
return new THREE40.Mesh(geometry, material);
|
|
41878
42248
|
}
|
|
41879
42249
|
if (url.endsWith(".obj")) {
|
|
41880
42250
|
const loader = new OBJLoader2();
|
|
@@ -41907,9 +42277,9 @@ async function renderComponent(component, scene) {
|
|
|
41907
42277
|
}
|
|
41908
42278
|
if (component.rotation) {
|
|
41909
42279
|
model.rotation.set(
|
|
41910
|
-
|
|
41911
|
-
|
|
41912
|
-
|
|
42280
|
+
THREE41.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
42281
|
+
THREE41.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
42282
|
+
THREE41.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
41913
42283
|
);
|
|
41914
42284
|
}
|
|
41915
42285
|
scene.add(model);
|
|
@@ -41923,13 +42293,13 @@ async function renderComponent(component, scene) {
|
|
|
41923
42293
|
);
|
|
41924
42294
|
if (jscadObject && (jscadObject.polygons || jscadObject.sides)) {
|
|
41925
42295
|
const threeGeom = convertCSGToThreeGeom(jscadObject);
|
|
41926
|
-
const material2 = new
|
|
42296
|
+
const material2 = new THREE41.MeshStandardMaterial({
|
|
41927
42297
|
color: 8947848,
|
|
41928
42298
|
metalness: 0.5,
|
|
41929
42299
|
roughness: 0.5,
|
|
41930
|
-
side:
|
|
42300
|
+
side: THREE41.DoubleSide
|
|
41931
42301
|
});
|
|
41932
|
-
const mesh2 = new
|
|
42302
|
+
const mesh2 = new THREE41.Mesh(threeGeom, material2);
|
|
41933
42303
|
if (component.position) {
|
|
41934
42304
|
mesh2.position.set(
|
|
41935
42305
|
component.position.x ?? 0,
|
|
@@ -41939,9 +42309,9 @@ async function renderComponent(component, scene) {
|
|
|
41939
42309
|
}
|
|
41940
42310
|
if (component.rotation) {
|
|
41941
42311
|
mesh2.rotation.set(
|
|
41942
|
-
|
|
41943
|
-
|
|
41944
|
-
|
|
42312
|
+
THREE41.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
42313
|
+
THREE41.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
42314
|
+
THREE41.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
41945
42315
|
);
|
|
41946
42316
|
}
|
|
41947
42317
|
scene.add(mesh2);
|
|
@@ -41958,17 +42328,17 @@ async function renderComponent(component, scene) {
|
|
|
41958
42328
|
if (!geom || !geom.polygons && !geom.sides) {
|
|
41959
42329
|
continue;
|
|
41960
42330
|
}
|
|
41961
|
-
const color = new
|
|
42331
|
+
const color = new THREE41.Color(geomInfo.color);
|
|
41962
42332
|
color.convertLinearToSRGB();
|
|
41963
42333
|
const geomWithColor = { ...geom, color: [color.r, color.g, color.b] };
|
|
41964
42334
|
const threeGeom = convertCSGToThreeGeom(geomWithColor);
|
|
41965
|
-
const material2 = new
|
|
42335
|
+
const material2 = new THREE41.MeshStandardMaterial({
|
|
41966
42336
|
vertexColors: true,
|
|
41967
42337
|
metalness: 0.2,
|
|
41968
42338
|
roughness: 0.8,
|
|
41969
|
-
side:
|
|
42339
|
+
side: THREE41.DoubleSide
|
|
41970
42340
|
});
|
|
41971
|
-
const mesh2 = new
|
|
42341
|
+
const mesh2 = new THREE41.Mesh(threeGeom, material2);
|
|
41972
42342
|
if (component.position) {
|
|
41973
42343
|
mesh2.position.set(
|
|
41974
42344
|
component.position.x ?? 0,
|
|
@@ -41978,22 +42348,22 @@ async function renderComponent(component, scene) {
|
|
|
41978
42348
|
}
|
|
41979
42349
|
if (component.rotation) {
|
|
41980
42350
|
mesh2.rotation.set(
|
|
41981
|
-
|
|
41982
|
-
|
|
41983
|
-
|
|
42351
|
+
THREE41.MathUtils.degToRad(component.rotation.x ?? 0),
|
|
42352
|
+
THREE41.MathUtils.degToRad(component.rotation.y ?? 0),
|
|
42353
|
+
THREE41.MathUtils.degToRad(component.rotation.z ?? 0)
|
|
41984
42354
|
);
|
|
41985
42355
|
}
|
|
41986
42356
|
scene.add(mesh2);
|
|
41987
42357
|
}
|
|
41988
42358
|
return;
|
|
41989
42359
|
}
|
|
41990
|
-
const geometry = new
|
|
41991
|
-
const material = new
|
|
42360
|
+
const geometry = new THREE41.BoxGeometry(0.5, 0.5, 0.5);
|
|
42361
|
+
const material = new THREE41.MeshStandardMaterial({
|
|
41992
42362
|
color: 16711680,
|
|
41993
42363
|
transparent: true,
|
|
41994
42364
|
opacity: 0.25
|
|
41995
42365
|
});
|
|
41996
|
-
const mesh = new
|
|
42366
|
+
const mesh = new THREE41.Mesh(geometry, material);
|
|
41997
42367
|
if (component.position) {
|
|
41998
42368
|
mesh.position.set(
|
|
41999
42369
|
component.position.x ?? 0,
|
|
@@ -42014,11 +42384,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
42014
42384
|
padding = 20,
|
|
42015
42385
|
zoom = 1.5
|
|
42016
42386
|
} = options;
|
|
42017
|
-
const scene = new
|
|
42387
|
+
const scene = new THREE42.Scene();
|
|
42018
42388
|
const renderer = new SVGRenderer();
|
|
42019
42389
|
renderer.setSize(width10, height10);
|
|
42020
|
-
renderer.setClearColor(new
|
|
42021
|
-
const camera = new
|
|
42390
|
+
renderer.setClearColor(new THREE42.Color(backgroundColor), 1);
|
|
42391
|
+
const camera = new THREE42.OrthographicCamera();
|
|
42022
42392
|
const aspect = width10 / height10;
|
|
42023
42393
|
const frustumSize = 100;
|
|
42024
42394
|
const halfFrustumSize = frustumSize / 2 / zoom;
|
|
@@ -42032,11 +42402,11 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
42032
42402
|
camera.position.set(position.x, position.y, position.z);
|
|
42033
42403
|
camera.up.set(0, 1, 0);
|
|
42034
42404
|
const lookAt = options.camera?.lookAt ?? { x: 0, y: 0, z: 0 };
|
|
42035
|
-
camera.lookAt(new
|
|
42405
|
+
camera.lookAt(new THREE42.Vector3(lookAt.x, lookAt.y, lookAt.z));
|
|
42036
42406
|
camera.updateProjectionMatrix();
|
|
42037
|
-
const ambientLight = new
|
|
42407
|
+
const ambientLight = new THREE42.AmbientLight(16777215, Math.PI / 2);
|
|
42038
42408
|
scene.add(ambientLight);
|
|
42039
|
-
const pointLight = new
|
|
42409
|
+
const pointLight = new THREE42.PointLight(16777215, Math.PI / 4);
|
|
42040
42410
|
pointLight.position.set(-10, -10, 10);
|
|
42041
42411
|
scene.add(pointLight);
|
|
42042
42412
|
const components = su18(circuitJson).cad_component.list();
|
|
@@ -42047,7 +42417,7 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
42047
42417
|
const boardGeom = createBoardGeomFromCircuitJson(circuitJson);
|
|
42048
42418
|
if (boardGeom) {
|
|
42049
42419
|
const solderMaskColor = colors.fr4SolderMaskGreen;
|
|
42050
|
-
const baseColor = new
|
|
42420
|
+
const baseColor = new THREE42.Color(
|
|
42051
42421
|
solderMaskColor[0],
|
|
42052
42422
|
solderMaskColor[1],
|
|
42053
42423
|
solderMaskColor[2]
|
|
@@ -42059,28 +42429,28 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
42059
42429
|
const material = createBoardMaterial({
|
|
42060
42430
|
material: boardData?.material,
|
|
42061
42431
|
color: baseColor,
|
|
42062
|
-
side:
|
|
42432
|
+
side: THREE42.DoubleSide
|
|
42063
42433
|
});
|
|
42064
|
-
const mesh = new
|
|
42434
|
+
const mesh = new THREE42.Mesh(geometry, material);
|
|
42065
42435
|
scene.add(mesh);
|
|
42066
42436
|
}
|
|
42067
42437
|
}
|
|
42068
|
-
const gridColor = new
|
|
42069
|
-
const gridHelper = new
|
|
42438
|
+
const gridColor = new THREE42.Color(8947848);
|
|
42439
|
+
const gridHelper = new THREE42.GridHelper(100, 100, gridColor, gridColor);
|
|
42070
42440
|
gridHelper.rotation.x = Math.PI / 2;
|
|
42071
42441
|
const materials = Array.isArray(gridHelper.material) ? gridHelper.material : [gridHelper.material];
|
|
42072
42442
|
for (const mat of materials) {
|
|
42073
42443
|
mat.transparent = true;
|
|
42074
42444
|
mat.opacity = 0.3;
|
|
42075
|
-
if (mat instanceof
|
|
42445
|
+
if (mat instanceof THREE42.LineBasicMaterial) {
|
|
42076
42446
|
mat.color = gridColor;
|
|
42077
42447
|
mat.vertexColors = false;
|
|
42078
42448
|
}
|
|
42079
42449
|
}
|
|
42080
42450
|
scene.add(gridHelper);
|
|
42081
|
-
const box = new
|
|
42082
|
-
const center = box.getCenter(new
|
|
42083
|
-
const size4 = box.getSize(new
|
|
42451
|
+
const box = new THREE42.Box3().setFromObject(scene);
|
|
42452
|
+
const center = box.getCenter(new THREE42.Vector3());
|
|
42453
|
+
const size4 = box.getSize(new THREE42.Vector3());
|
|
42084
42454
|
scene.position.sub(center);
|
|
42085
42455
|
const maxDim = Math.max(size4.x, size4.y, size4.z);
|
|
42086
42456
|
if (maxDim > 0) {
|