circuit-json-to-gltf 0.0.165 → 0.0.166
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.d.ts +4 -1
- package/dist/index.js +9 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ interface ConversionOptions {
|
|
|
78
78
|
showBoundingBoxes?: boolean;
|
|
79
79
|
coordinateTransform?: CoordinateTransformConfig;
|
|
80
80
|
projectBaseUrl?: string;
|
|
81
|
+
resolveStaticAsset?: CircuitTo3DOptions["resolveStaticAsset"];
|
|
81
82
|
authHeaders?: AuthHeaders;
|
|
82
83
|
}
|
|
83
84
|
interface CoordinateTransformConfig {
|
|
@@ -253,6 +254,8 @@ interface CircuitTo3DOptions {
|
|
|
253
254
|
showReferenceSurfaces?: boolean;
|
|
254
255
|
showBoundingBoxes?: boolean;
|
|
255
256
|
projectBaseUrl?: string;
|
|
257
|
+
/** Resolve the selected CAD model URL before loading it. */
|
|
258
|
+
resolveStaticAsset?: (modelUrl: string) => string;
|
|
256
259
|
authHeaders?: AuthHeaders;
|
|
257
260
|
}
|
|
258
261
|
interface BoardRenderOptions {
|
|
@@ -342,7 +345,7 @@ interface CadComponentMesh {
|
|
|
342
345
|
positions: number[];
|
|
343
346
|
indices: number[];
|
|
344
347
|
}
|
|
345
|
-
type CadComponentMeshOptions = Pick<CircuitTo3DOptions, "coordinateTransform" | "projectBaseUrl" | "authHeaders"> & {
|
|
348
|
+
type CadComponentMeshOptions = Pick<CircuitTo3DOptions, "coordinateTransform" | "projectBaseUrl" | "resolveStaticAsset" | "authHeaders"> & {
|
|
346
349
|
pcbComponent?: PcbComponent;
|
|
347
350
|
};
|
|
348
351
|
/** Load the actual CAD model at its supplied position and rotation, using the
|
package/dist/index.js
CHANGED
|
@@ -17331,6 +17331,7 @@ async function loadCadComponentBox(cad, options = {}) {
|
|
|
17331
17331
|
showBoundingBoxes = false,
|
|
17332
17332
|
coordinateTransform,
|
|
17333
17333
|
projectBaseUrl,
|
|
17334
|
+
resolveStaticAsset = (url) => url,
|
|
17334
17335
|
authHeaders
|
|
17335
17336
|
} = options;
|
|
17336
17337
|
const {
|
|
@@ -17423,14 +17424,14 @@ async function loadCadComponentBox(cad, options = {}) {
|
|
|
17423
17424
|
});
|
|
17424
17425
|
if (model_stl_url) {
|
|
17425
17426
|
box.mesh = await loadSTL({
|
|
17426
|
-
url: model_stl_url,
|
|
17427
|
+
url: resolveStaticAsset(model_stl_url),
|
|
17427
17428
|
transform: defaultTransform,
|
|
17428
17429
|
projectBaseUrl,
|
|
17429
17430
|
authHeaders
|
|
17430
17431
|
});
|
|
17431
17432
|
} else if (model_obj_url) {
|
|
17432
17433
|
box.mesh = await loadOBJ({
|
|
17433
|
-
url: model_obj_url,
|
|
17434
|
+
url: resolveStaticAsset(model_obj_url),
|
|
17434
17435
|
transform: defaultTransform,
|
|
17435
17436
|
projectBaseUrl,
|
|
17436
17437
|
authHeaders
|
|
@@ -17438,7 +17439,7 @@ async function loadCadComponentBox(cad, options = {}) {
|
|
|
17438
17439
|
} else if (model_glb_url) {
|
|
17439
17440
|
try {
|
|
17440
17441
|
box.mesh = await loadGLB({
|
|
17441
|
-
url: model_glb_url,
|
|
17442
|
+
url: resolveStaticAsset(model_glb_url),
|
|
17442
17443
|
transform: defaultTransform,
|
|
17443
17444
|
projectBaseUrl,
|
|
17444
17445
|
authHeaders
|
|
@@ -17448,7 +17449,7 @@ async function loadCadComponentBox(cad, options = {}) {
|
|
|
17448
17449
|
}
|
|
17449
17450
|
} else if (model_gltf_url) {
|
|
17450
17451
|
box.mesh = await loadGLTF({
|
|
17451
|
-
url: model_gltf_url,
|
|
17452
|
+
url: resolveStaticAsset(model_gltf_url),
|
|
17452
17453
|
transform: defaultTransform,
|
|
17453
17454
|
projectBaseUrl,
|
|
17454
17455
|
authHeaders
|
|
@@ -17456,7 +17457,7 @@ async function loadCadComponentBox(cad, options = {}) {
|
|
|
17456
17457
|
} else if (model_step_url) {
|
|
17457
17458
|
try {
|
|
17458
17459
|
box.mesh = await loadSTEP({
|
|
17459
|
-
url: model_step_url,
|
|
17460
|
+
url: resolveStaticAsset(model_step_url),
|
|
17460
17461
|
transform: defaultTransform,
|
|
17461
17462
|
projectBaseUrl,
|
|
17462
17463
|
authHeaders
|
|
@@ -19047,6 +19048,7 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
|
|
|
19047
19048
|
coordinateTransform,
|
|
19048
19049
|
showBoundingBoxes = false,
|
|
19049
19050
|
projectBaseUrl,
|
|
19051
|
+
resolveStaticAsset,
|
|
19050
19052
|
authHeaders
|
|
19051
19053
|
} = options;
|
|
19052
19054
|
const foldPcbs = options.foldPcbs ?? inputCircuitJson.some(
|
|
@@ -19342,6 +19344,7 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
|
|
|
19342
19344
|
showBoundingBoxes,
|
|
19343
19345
|
coordinateTransform,
|
|
19344
19346
|
projectBaseUrl,
|
|
19347
|
+
resolveStaticAsset,
|
|
19345
19348
|
authHeaders,
|
|
19346
19349
|
// Preserve the fold renderer's existing flat bottom-layer convention.
|
|
19347
19350
|
defaultCadRotation: bends.length && pcbComponent ? {
|
|
@@ -20967,6 +20970,7 @@ async function convertCircuitJsonToGltf(circuitJson, options = {}) {
|
|
|
20967
20970
|
showBoundingBoxes,
|
|
20968
20971
|
showReferenceSurfaces: options.showReferenceSurfaces,
|
|
20969
20972
|
projectBaseUrl: options.projectBaseUrl,
|
|
20973
|
+
resolveStaticAsset: options.resolveStaticAsset,
|
|
20970
20974
|
authHeaders: options.authHeaders
|
|
20971
20975
|
});
|
|
20972
20976
|
const gltfOptions = {
|