@sequent-org/ifc-viewer 1.2.4-ci.56.0 → 1.2.4-ci.57.0
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequent-org/ifc-viewer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.2.4-ci.
|
|
4
|
+
"version": "1.2.4-ci.57.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "IFC 3D model viewer component for web applications - fully self-contained with local IFCLoader",
|
|
7
7
|
"main": "src/index.js",
|
|
@@ -282,11 +282,16 @@ export class LabelPlacementController {
|
|
|
282
282
|
planes?.[1]?.constant,
|
|
283
283
|
planes?.[2]?.constant,
|
|
284
284
|
];
|
|
285
|
+
const clipPlanes = {
|
|
286
|
+
x: this.#getAxisPlaneState('x', planes?.[0]),
|
|
287
|
+
y: this.#getAxisPlaneState('y', planes?.[1]),
|
|
288
|
+
z: this.#getAxisPlaneState('z', planes?.[2]),
|
|
289
|
+
};
|
|
285
290
|
|
|
286
291
|
return {
|
|
287
292
|
camera: cam,
|
|
288
293
|
modelTransform,
|
|
289
|
-
clipping: { constants: clipConstants },
|
|
294
|
+
clipping: { constants: clipConstants, planes: clipPlanes },
|
|
290
295
|
};
|
|
291
296
|
}
|
|
292
297
|
|
|
@@ -361,17 +366,7 @@ export class LabelPlacementController {
|
|
|
361
366
|
} catch (_) {}
|
|
362
367
|
|
|
363
368
|
// 5) Клиппинг (как Home: сначала восстановили камеру+модель, затем planes)
|
|
364
|
-
|
|
365
|
-
const constants = sceneState?.clipping?.constants || [];
|
|
366
|
-
if (typeof viewer.setSection === "function") {
|
|
367
|
-
["x", "y", "z"].forEach((axis, i) => {
|
|
368
|
-
const c = constants[i];
|
|
369
|
-
const enabled = Number.isFinite(c);
|
|
370
|
-
const dist = -Number(c);
|
|
371
|
-
viewer.setSection(axis, enabled, enabled ? dist : 0);
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
} catch (_) {}
|
|
369
|
+
this.#applyClippingFromState(sceneState);
|
|
375
370
|
|
|
376
371
|
try { camera?.updateProjectionMatrix?.(); } catch (_) {}
|
|
377
372
|
try { controls?.update?.(); } catch (_) {}
|
|
@@ -401,18 +396,65 @@ export class LabelPlacementController {
|
|
|
401
396
|
const viewer = this.viewer;
|
|
402
397
|
if (!viewer || !sceneState) return;
|
|
403
398
|
try {
|
|
399
|
+
const byAxis = sceneState?.clipping?.planes || null;
|
|
400
|
+
if (byAxis && typeof viewer.setSection === "function") {
|
|
401
|
+
["x", "y", "z"].forEach((axis) => {
|
|
402
|
+
const s = byAxis?.[axis] || null;
|
|
403
|
+
const enabled = !!s?.enabled;
|
|
404
|
+
const dist = Number(s?.distance);
|
|
405
|
+
viewer.setSection(axis, enabled, (enabled && Number.isFinite(dist)) ? dist : 0);
|
|
406
|
+
});
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
404
409
|
const constants = sceneState?.clipping?.constants || [];
|
|
405
410
|
if (typeof viewer.setSection === "function") {
|
|
406
411
|
["x", "y", "z"].forEach((axis, i) => {
|
|
407
412
|
const c = constants[i];
|
|
408
413
|
const enabled = Number.isFinite(c);
|
|
409
|
-
const dist =
|
|
410
|
-
viewer.setSection(axis, enabled, enabled ? dist : 0);
|
|
414
|
+
const dist = this.#getAxisDistanceFromConstant(axis, c);
|
|
415
|
+
viewer.setSection(axis, enabled, (enabled && Number.isFinite(dist)) ? dist : 0);
|
|
411
416
|
});
|
|
412
417
|
}
|
|
413
418
|
} catch (_) {}
|
|
414
419
|
}
|
|
415
420
|
|
|
421
|
+
#getAxisPlaneState(axis, plane) {
|
|
422
|
+
if (!plane) return { enabled: false, distance: null };
|
|
423
|
+
const constant = plane.constant;
|
|
424
|
+
const enabled = Number.isFinite(constant);
|
|
425
|
+
if (!enabled) return { enabled: false, distance: null };
|
|
426
|
+
const distance = this.#getAxisDistanceFromPlane(axis, plane);
|
|
427
|
+
return { enabled: true, distance };
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
#getAxisDistanceFromPlane(axis, plane) {
|
|
431
|
+
if (!plane || !Number.isFinite(plane.constant)) return null;
|
|
432
|
+
const n = plane.normal || null;
|
|
433
|
+
const nx = Number(n?.x ?? 1);
|
|
434
|
+
const ny = Number(n?.y ?? 1);
|
|
435
|
+
const nz = Number(n?.z ?? 1);
|
|
436
|
+
const sign = (axis === 'x') ? (nx >= 0 ? 1 : -1)
|
|
437
|
+
: (axis === 'y') ? (ny >= 0 ? 1 : -1)
|
|
438
|
+
: (nz >= 0 ? 1 : -1);
|
|
439
|
+
return (sign > 0) ? -Number(plane.constant) : Number(plane.constant);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
#getAxisDistanceFromConstant(axis, constant) {
|
|
443
|
+
if (!Number.isFinite(constant)) return null;
|
|
444
|
+
const viewer = this.viewer;
|
|
445
|
+
const planes = viewer?.clipping?.planes || [];
|
|
446
|
+
const idx = axis === 'x' ? 0 : axis === 'y' ? 1 : 2;
|
|
447
|
+
const plane = planes[idx] || null;
|
|
448
|
+
const n = plane?.normal || null;
|
|
449
|
+
const nx = Number(n?.x ?? 1);
|
|
450
|
+
const ny = Number(n?.y ?? 1);
|
|
451
|
+
const nz = Number(n?.z ?? 1);
|
|
452
|
+
const sign = (axis === 'x') ? (nx >= 0 ? 1 : -1)
|
|
453
|
+
: (axis === 'y') ? (ny >= 0 ? 1 : -1)
|
|
454
|
+
: (nz >= 0 ? 1 : -1);
|
|
455
|
+
return (sign > 0) ? -Number(constant) : Number(constant);
|
|
456
|
+
}
|
|
457
|
+
|
|
416
458
|
#applyViewOffset(camera, viewOffset) {
|
|
417
459
|
if (!camera || !viewOffset) return;
|
|
418
460
|
try {
|
package/src/viewer/Viewer.js
CHANGED
|
@@ -3464,7 +3464,7 @@ export class Viewer {
|
|
|
3464
3464
|
const s = plane.normal.dot(c) + plane.constant;
|
|
3465
3465
|
if (s < minSigned) minSigned = s;
|
|
3466
3466
|
}
|
|
3467
|
-
if (minSigned < 0) {
|
|
3467
|
+
if (minSigned < 0 && minSigned >= -1e-3) {
|
|
3468
3468
|
plane.constant -= (minSigned - (-1e-4)); // сдвинем чуть так, чтобы все вершины имели s >= -1e-4
|
|
3469
3469
|
}
|
|
3470
3470
|
}
|