@base2datadesign/viewer-kit 0.2.21 → 0.2.23
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.
|
@@ -172,11 +172,11 @@ export class DebugSystem {
|
|
|
172
172
|
: (extras.gridAutoScale ?? extras.groundAutoScale ?? 2.5);
|
|
173
173
|
const groundSizeDefault = isHdr ? HDR_GROUND_SIZE : DEFAULT_GRID_SIZE;
|
|
174
174
|
const gridSizeDefault = isHdr ? HDR_GRID_SIZE : DEFAULT_GRID_SIZE;
|
|
175
|
-
const derivedGroundSize = modelSpan ?
|
|
175
|
+
const derivedGroundSize = modelSpan ? modelSpan * groundScale : groundSizeDefault;
|
|
176
176
|
const derivedGridSize = groundEnabled
|
|
177
177
|
? (extras.groundSize ?? derivedGroundSize)
|
|
178
178
|
: modelSpan
|
|
179
|
-
?
|
|
179
|
+
? modelSpan * gridScale
|
|
180
180
|
: gridSizeDefault;
|
|
181
181
|
const groundOffset = extras.groundOffset ?? DEFAULT_GROUND_OFFSET;
|
|
182
182
|
const gridHeightOffset = extras.gridHeightOffset ?? DEFAULT_GRID_HEIGHT_OFFSET;
|
|
@@ -196,10 +196,10 @@ export class DebugSystem {
|
|
|
196
196
|
this.add(ground);
|
|
197
197
|
}
|
|
198
198
|
let lastGridPositionY = 0;
|
|
199
|
+
const gridSize = extras.gridSize ?? derivedGridSize;
|
|
199
200
|
if (gridEnabled) {
|
|
200
201
|
const gridPrimary = new THREE.Color(extras.gridColor ?? adjustGridColor(groundColor));
|
|
201
202
|
const gridSecondary = new THREE.Color(extras.gridColorSecondary ?? gridPrimary.getHex());
|
|
202
|
-
const gridSize = extras.gridSize ?? derivedGridSize;
|
|
203
203
|
const gridDivisions = extras.gridDivisions ?? Math.max(1, gridSize);
|
|
204
204
|
const grid = new THREE.GridHelper(gridSize, gridDivisions, gridPrimary, gridSecondary);
|
|
205
205
|
const gridY = groundEnabled ? groundOffset + gridHeightOffset : -gridHeightOffset;
|
|
@@ -220,7 +220,7 @@ export class DebugSystem {
|
|
|
220
220
|
}
|
|
221
221
|
const originPlaneY = groundEnabled ? groundOffset : lastGridPositionY || -gridHeightOffset;
|
|
222
222
|
if (extras.originHighlight !== false) {
|
|
223
|
-
const originCross = buildOriginCross(extras,
|
|
223
|
+
const originCross = buildOriginCross(extras, gridSize, originPlaneY);
|
|
224
224
|
this.add(originCross);
|
|
225
225
|
}
|
|
226
226
|
if (originEnabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grasshopper.d.ts","sourceRoot":"","sources":["../../src/uploads/grasshopper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"grasshopper.d.ts","sourceRoot":"","sources":["../../src/uploads/grasshopper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA0D1F,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAAC;AAuBF,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,EAAE,QAA0B,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAE,uBAA4B,GACtF,OAAO,CAAC,sBAAsB,CAAC,CAgCjC;AAED,eAAO,MAAM,uBAAuB,GAAI,YAAY,MAAM,KAAG,MAM5D,CAAC;AAsBF,eAAO,MAAM,sBAAsB,GACjC,QAAQ,gBAAgB,EAAE,EAC1B,aAAa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,cAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,KAC/D,gBAAgB,EAWlB,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,QAAQ,gBAAgB,EAAE,EAC1B,cAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,KAC/D,MAAM,CAAC,MAAM,EAAE,OAAO,CAexB,CAAC"}
|
|
@@ -1,3 +1,56 @@
|
|
|
1
|
+
const isGhxFile = (file) => /\.ghx$/i.test(file.name);
|
|
2
|
+
const normalizeGhxInputs = async (file, onStatus) => {
|
|
3
|
+
if (typeof DOMParser === "undefined" || typeof XMLSerializer === "undefined")
|
|
4
|
+
return file;
|
|
5
|
+
if (!isGhxFile(file))
|
|
6
|
+
return file;
|
|
7
|
+
try {
|
|
8
|
+
onStatus?.("normalizing ghx inputs");
|
|
9
|
+
const text = await file.text();
|
|
10
|
+
const parser = new DOMParser();
|
|
11
|
+
const doc = parser.parseFromString(text, "text/xml");
|
|
12
|
+
if (doc.getElementsByTagName("parsererror").length > 0)
|
|
13
|
+
return file;
|
|
14
|
+
const chunks = Array.from(doc.getElementsByTagName("chunk")).filter((chunk) => chunk.getAttribute("name") === "param_input");
|
|
15
|
+
const entries = [];
|
|
16
|
+
for (const chunk of chunks) {
|
|
17
|
+
let nameItem = null;
|
|
18
|
+
let guidItem = null;
|
|
19
|
+
const items = Array.from(chunk.getElementsByTagName("item"));
|
|
20
|
+
for (const item of items) {
|
|
21
|
+
const key = item.getAttribute("name");
|
|
22
|
+
if (key === "Name")
|
|
23
|
+
nameItem = item;
|
|
24
|
+
if (key === "InstanceGuid")
|
|
25
|
+
guidItem = item;
|
|
26
|
+
}
|
|
27
|
+
const name = nameItem?.textContent?.trim();
|
|
28
|
+
const guid = guidItem?.textContent?.trim();
|
|
29
|
+
if (name && guid && nameItem) {
|
|
30
|
+
entries.push({ name, guid, item: nameItem });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const seen = new Map();
|
|
34
|
+
let mutated = false;
|
|
35
|
+
entries.forEach((entry) => {
|
|
36
|
+
const count = (seen.get(entry.name) ?? 0) + 1;
|
|
37
|
+
seen.set(entry.name, count);
|
|
38
|
+
if (count > 1) {
|
|
39
|
+
const suffix = entry.guid.slice(-6);
|
|
40
|
+
entry.item.textContent = `${entry.name}__${suffix}`;
|
|
41
|
+
mutated = true;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (!mutated)
|
|
45
|
+
return file;
|
|
46
|
+
const serializer = new XMLSerializer();
|
|
47
|
+
const normalized = serializer.serializeToString(doc);
|
|
48
|
+
return new File([normalized], file.name, { type: file.type || "application/xml" });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return file;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
1
54
|
const normalizeInputs = (inputs) => {
|
|
2
55
|
if (!Array.isArray(inputs))
|
|
3
56
|
return [];
|
|
@@ -22,8 +75,9 @@ const extractSolvePayload = (payload) => {
|
|
|
22
75
|
};
|
|
23
76
|
export async function solveGrasshopperFile(file, { apiRoute = "/api/gh-solve", values, preview, onStatus } = {}) {
|
|
24
77
|
onStatus?.("preparing payload");
|
|
78
|
+
const uploadFile = await normalizeGhxInputs(file, onStatus);
|
|
25
79
|
const formData = new FormData();
|
|
26
|
-
formData.append("algo",
|
|
80
|
+
formData.append("algo", uploadFile);
|
|
27
81
|
formData.append("values", JSON.stringify(values ?? []));
|
|
28
82
|
if (preview) {
|
|
29
83
|
formData.append("preview", JSON.stringify(preview));
|