@sequent-org/ifc-viewer 1.0.6-ci.11.0 → 1.0.10-ci.12.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/README.md CHANGED
@@ -149,6 +149,7 @@ const viewer = new IfcViewer({
149
149
  - **Fallback защита** - автоматическое переключение на резервные пути при ошибках WASM
150
150
  - **Обработка ошибок** - graceful degradation при критических ошибках
151
151
  - **Поддержка wasmUrl** - гибкая настройка пути к WASM файлу
152
+ - **Патч совместимости Three.js** - автоматическое исправление проблем с mergeGeometries
152
153
 
153
154
  ### 🚫 Что НЕ включено
154
155
 
@@ -416,6 +417,25 @@ Failed to load IFCWorker.js
416
417
  npm list @sequent-org/ifc-viewer
417
418
  ```
418
419
 
420
+ ### Проблемы совместимости с Three.js
421
+
422
+ **Ошибка mergeGeometries:**
423
+ ```
424
+ mergeGeometries is not a function
425
+ ```
426
+
427
+ **Решение:** Пакет автоматически применяет патч совместимости для Three.js 0.149+. Если проблемы продолжаются:
428
+
429
+ 1. **Проверьте версию Three.js:**
430
+ ```bash
431
+ npm list three
432
+ ```
433
+
434
+ 2. **Убедитесь, что используется Three.js 0.149+:**
435
+ ```bash
436
+ npm install three@^0.149.0
437
+ ```
438
+
419
439
  2. **Очистите кэш:**
420
440
  ```bash
421
441
  npm cache clean --force
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sequent-org/ifc-viewer",
3
3
  "private": false,
4
- "version": "1.0.6-ci.11.0",
4
+ "version": "1.0.10-ci.12.0",
5
5
  "type": "module",
6
6
  "description": "IFC 3D model viewer component for web applications",
7
7
  "main": "src/index.js",
@@ -5,6 +5,59 @@ import { IFCLoader } from "web-ifc-three/IFCLoader";
5
5
  // Примечание: IFCWorker не используется, так как мы отключаем Web Workers
6
6
  // для стабильности работы в различных окружениях
7
7
 
8
+ // Патч совместимости для Three.js 0.149+
9
+ // web-ifc-three ожидает mergeGeometries, но в новой версии Three.js его нет
10
+ import * as THREE from 'three';
11
+ import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
12
+
13
+ // Создаем совместимую функцию mergeGeometries
14
+ function createMergeGeometries() {
15
+ return function mergeGeometries(geometries, useGroups = false) {
16
+ if (!Array.isArray(geometries) || geometries.length === 0) return null;
17
+ const prepared = [];
18
+ for (const g of geometries) {
19
+ if (!g) continue;
20
+ const geom = g.isBufferGeometry ? g : new THREE.BufferGeometry().copy(g);
21
+ // Гарантируем наличие индекса, иначе mergeBufferGeometries может падать
22
+ if (!geom.index) {
23
+ const position = geom.getAttribute('position');
24
+ if (!position) continue;
25
+ const count = position.count;
26
+ const IndexArray = count > 65535 ? Uint32Array : Uint16Array;
27
+ const indices = new IndexArray(count);
28
+ for (let i = 0; i < count; i++) indices[i] = i;
29
+ geom.setIndex(new THREE.BufferAttribute(indices, 1));
30
+ }
31
+ prepared.push(geom);
32
+ }
33
+ if (prepared.length === 0) {
34
+ const empty = new THREE.BufferGeometry();
35
+ empty.setAttribute('position', new THREE.Float32BufferAttribute([], 3));
36
+ empty.setIndex(new THREE.BufferAttribute(new Uint16Array(0), 1));
37
+ return empty;
38
+ }
39
+ const merged = mergeBufferGeometries(prepared, useGroups);
40
+ if (merged) return merged;
41
+ const fallback = new THREE.BufferGeometry();
42
+ fallback.setAttribute('position', new THREE.Float32BufferAttribute([], 3));
43
+ fallback.setIndex(new THREE.BufferAttribute(new Uint16Array(0), 1));
44
+ return fallback;
45
+ };
46
+ }
47
+
48
+ // Патчим BufferGeometryUtils если нужно
49
+ if (typeof window !== 'undefined' && window.THREE) {
50
+ try {
51
+ const BufferGeometryUtils = window.THREE.BufferGeometryUtils || {};
52
+ if (!BufferGeometryUtils.mergeGeometries) {
53
+ BufferGeometryUtils.mergeGeometries = createMergeGeometries();
54
+ window.THREE.BufferGeometryUtils = BufferGeometryUtils;
55
+ }
56
+ } catch (error) {
57
+ console.warn('IfcService: не удалось применить патч совместимости:', error.message);
58
+ }
59
+ }
60
+
8
61
  export class IfcService {
9
62
  /**
10
63
  * @param {import('../viewer/Viewer').Viewer} viewer