easyeda 0.0.257 → 0.0.258
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/browser/index.js +12 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +15 -6
- package/dist/main.cjs.map +1 -1
- package/package.json +3 -3
package/dist/browser/index.js
CHANGED
|
@@ -10385,7 +10385,13 @@ var getRotatedOffsetMm = ({
|
|
|
10385
10385
|
};
|
|
10386
10386
|
var getCadModelOffsetMm = (easyEdaJson) => {
|
|
10387
10387
|
const svgNode = getCadSvgNode(easyEdaJson);
|
|
10388
|
-
|
|
10388
|
+
return getCadModelOffsetMmFromBounds(
|
|
10389
|
+
easyEdaJson,
|
|
10390
|
+
easyEdaJson._objMetadata?.bounds
|
|
10391
|
+
);
|
|
10392
|
+
};
|
|
10393
|
+
var getCadModelOffsetMmFromBounds = (easyEdaJson, bounds) => {
|
|
10394
|
+
const svgNode = getCadSvgNode(easyEdaJson);
|
|
10389
10395
|
if (!svgNode || !bounds) return null;
|
|
10390
10396
|
const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
|
|
10391
10397
|
if (!Number.isFinite(originX) || !Number.isFinite(originY)) return null;
|
|
@@ -10479,9 +10485,8 @@ var getPositionZMmFromBounds = (bounds, svgNodeZOffsetMm) => {
|
|
|
10479
10485
|
var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalThis.fetch } = {}) => {
|
|
10480
10486
|
const modelUuid = getCadSvgNodeModelUuid(easyEdaJson);
|
|
10481
10487
|
const partNumber = easyEdaJson.lcsc.number;
|
|
10482
|
-
const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
|
|
10483
10488
|
const svgNodeZOffsetMm = getCadSvgNodeZOffsetMm(easyEdaJson);
|
|
10484
|
-
if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !
|
|
10489
|
+
if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !fetch2) {
|
|
10485
10490
|
return null;
|
|
10486
10491
|
}
|
|
10487
10492
|
const modelObjUrl = getModelObjCdnUrl({
|
|
@@ -10494,6 +10499,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
|
|
|
10494
10499
|
});
|
|
10495
10500
|
const metadataBounds = easyEdaJson._objMetadata?.bounds;
|
|
10496
10501
|
if (metadataBounds) {
|
|
10502
|
+
const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
|
|
10503
|
+
if (!derivedOffsetMm) return null;
|
|
10497
10504
|
return {
|
|
10498
10505
|
modelObjUrl,
|
|
10499
10506
|
positionXMm: derivedOffsetMm.x,
|
|
@@ -10513,6 +10520,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
|
|
|
10513
10520
|
const objText = await response.text();
|
|
10514
10521
|
const bounds = parseObjBounds(objText);
|
|
10515
10522
|
if (!bounds) return null;
|
|
10523
|
+
const derivedOffsetMm = getCadModelOffsetMmFromBounds(easyEdaJson, bounds);
|
|
10524
|
+
if (!derivedOffsetMm) return null;
|
|
10516
10525
|
return {
|
|
10517
10526
|
modelObjUrl,
|
|
10518
10527
|
positionXMm: derivedOffsetMm.x,
|