@sequent-org/ifc-viewer 1.0.10-ci.12.0 → 1.0.14-ci.13.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 +21 -36
- package/package.json +1 -1
- package/src/compat/three-compat-patch.js +58 -0
- package/src/ifc/IfcService.js +23 -55
package/README.md
CHANGED
|
@@ -13,12 +13,7 @@ IFC 3D model viewer component for web applications. Основан на Three.js
|
|
|
13
13
|
npm install @sequent-org/ifc-viewer
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
2.
|
|
17
|
-
```bash
|
|
18
|
-
cp node_modules/web-ifc/web-ifc.wasm public/wasm/
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
3. **Используйте в коде:**
|
|
16
|
+
2. **Используйте в коде:**
|
|
22
17
|
```javascript
|
|
23
18
|
import { IfcViewer } from '@sequent-org/ifc-viewer'
|
|
24
19
|
|
|
@@ -30,7 +25,7 @@ IFC 3D model viewer component for web applications. Основан на Three.js
|
|
|
30
25
|
await viewer.init()
|
|
31
26
|
```
|
|
32
27
|
|
|
33
|
-
**Готово!** Пакет
|
|
28
|
+
**Готово!** Пакет полностью автоматический - никаких дополнительных настроек не требуется.
|
|
34
29
|
|
|
35
30
|
## 🚀 Установка
|
|
36
31
|
|
|
@@ -38,20 +33,19 @@ IFC 3D model viewer component for web applications. Основан на Three.js
|
|
|
38
33
|
npm install @sequent-org/ifc-viewer
|
|
39
34
|
```
|
|
40
35
|
|
|
41
|
-
###
|
|
36
|
+
### ✨ Полная автоматизация
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
**Никаких дополнительных настроек не требуется!** Пакет автоматически:
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
- ✅ Находит WASM файл из node_modules
|
|
41
|
+
- ✅ Применяет патч совместимости Three.js
|
|
42
|
+
- ✅ Отключает Web Workers для стабильности
|
|
43
|
+
- ✅ Работает в любом проекте "из коробки"
|
|
49
44
|
|
|
50
|
-
**Умный
|
|
51
|
-
- `/
|
|
52
|
-
- `/web-ifc.wasm`
|
|
53
|
-
- `/wasm
|
|
54
|
-
- `/node_modules/web-ifc/web-ifc.wasm`
|
|
45
|
+
**Умный поиск WASM:** Пакет автоматически ищет файл по путям:
|
|
46
|
+
- `/node_modules/web-ifc/web-ifc.wasm` (основной путь)
|
|
47
|
+
- `/wasm/web-ifc.wasm` (если скопировали в public/wasm/)
|
|
48
|
+
- `/web-ifc.wasm` (если скопировали в корень public/)
|
|
55
49
|
- И другие стандартные пути
|
|
56
50
|
|
|
57
51
|
**Важно:** Пакет использует парсинг в главном потоке (Web Workers отключены) для максимальной совместимости с различными окружениями.
|
|
@@ -115,29 +109,20 @@ function showIfcModal(ifcUrl) {
|
|
|
115
109
|
}
|
|
116
110
|
```
|
|
117
111
|
|
|
118
|
-
**Настройка
|
|
112
|
+
**Настройка в Laravel:**
|
|
119
113
|
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
cp node_modules/web-ifc/web-ifc.wasm public/wasm/
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
2. **Или используйте Laravel Storage:**
|
|
126
|
-
```bash
|
|
127
|
-
cp node_modules/web-ifc/web-ifc.wasm storage/app/public/
|
|
128
|
-
php artisan storage:link
|
|
129
|
-
```
|
|
114
|
+
WASM файл автоматически загружается из node_modules. Дополнительная настройка не требуется!
|
|
130
115
|
|
|
131
|
-
|
|
116
|
+
**Для кастомных путей (опционально):**
|
|
132
117
|
```javascript
|
|
133
118
|
const viewer = new IfcViewer({
|
|
134
119
|
container: container,
|
|
135
120
|
ifcUrl: ifcUrl,
|
|
136
|
-
wasmUrl: '/storage/web-ifc.wasm' //
|
|
121
|
+
wasmUrl: '/storage/web-ifc.wasm' // Только если нужен кастомный путь
|
|
137
122
|
})
|
|
138
123
|
```
|
|
139
124
|
|
|
140
|
-
**Важно для Laravel:**
|
|
125
|
+
**Важно для Laravel:** Пакет работает "из коробки" без дополнительных настроек Vite.
|
|
141
126
|
|
|
142
127
|
## 🔧 Особенности и совместимость
|
|
143
128
|
|
|
@@ -499,17 +484,17 @@ Cannot resolve module '@sequent-org/ifc-viewer'
|
|
|
499
484
|
|
|
500
485
|
При помощи с интеграцией пакета учитывайте:
|
|
501
486
|
|
|
502
|
-
1.
|
|
487
|
+
1. **WASM файл автоматически найден** - никаких дополнительных настроек не требуется
|
|
503
488
|
2. **Web Workers отключены** - не пытайтесь их включить
|
|
504
|
-
3. **Используйте параметр wasmUrl** для кастомных путей к WASM файлу
|
|
489
|
+
3. **Используйте параметр wasmUrl** только для кастомных путей к WASM файлу
|
|
505
490
|
4. **Пакет полностью автономен** - не требует внешних CSS фреймворков
|
|
506
491
|
5. **Поддерживает все современные фреймворки** - React, Vue, Angular, Laravel
|
|
507
|
-
6.
|
|
492
|
+
6. **Работает "из коробки"** - просто установите и используйте
|
|
508
493
|
|
|
509
494
|
### Отладка
|
|
510
495
|
|
|
511
496
|
- Проверьте консоль на сообщение "Web Workers отключены"
|
|
512
|
-
-
|
|
497
|
+
- WASM файл автоматически загружается из node_modules
|
|
513
498
|
- Используйте DevTools → Network для проверки загрузки ресурсов
|
|
514
499
|
- При проблемах используйте параметр `wasmUrl` для кастомного пути
|
|
515
500
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Патч совместимости для Three.js 0.149+ и web-ifc-three
|
|
2
|
+
// web-ifc-three ожидает mergeGeometries, но в новой версии Three.js его нет
|
|
3
|
+
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
6
|
+
|
|
7
|
+
// Создаем совместимую функцию mergeGeometries
|
|
8
|
+
function createMergeGeometries() {
|
|
9
|
+
return function mergeGeometries(geometries, useGroups = false) {
|
|
10
|
+
if (!Array.isArray(geometries) || geometries.length === 0) return null;
|
|
11
|
+
const prepared = [];
|
|
12
|
+
for (const g of geometries) {
|
|
13
|
+
if (!g) continue;
|
|
14
|
+
const geom = g.isBufferGeometry ? g : new THREE.BufferGeometry().copy(g);
|
|
15
|
+
// Гарантируем наличие индекса, иначе mergeBufferGeometries может падать
|
|
16
|
+
if (!geom.index) {
|
|
17
|
+
const position = geom.getAttribute('position');
|
|
18
|
+
if (!position) continue;
|
|
19
|
+
const count = position.count;
|
|
20
|
+
const IndexArray = count > 65535 ? Uint32Array : Uint16Array;
|
|
21
|
+
const indices = new IndexArray(count);
|
|
22
|
+
for (let i = 0; i < count; i++) indices[i] = i;
|
|
23
|
+
geom.setIndex(new THREE.BufferAttribute(indices, 1));
|
|
24
|
+
}
|
|
25
|
+
prepared.push(geom);
|
|
26
|
+
}
|
|
27
|
+
if (prepared.length === 0) {
|
|
28
|
+
const empty = new THREE.BufferGeometry();
|
|
29
|
+
empty.setAttribute('position', new THREE.Float32BufferAttribute([], 3));
|
|
30
|
+
empty.setIndex(new THREE.BufferAttribute(new Uint16Array(0), 1));
|
|
31
|
+
return empty;
|
|
32
|
+
}
|
|
33
|
+
const merged = mergeBufferGeometries(prepared, useGroups);
|
|
34
|
+
if (merged) return merged;
|
|
35
|
+
const fallback = new THREE.BufferGeometry();
|
|
36
|
+
fallback.setAttribute('position', new THREE.Float32BufferAttribute([], 3));
|
|
37
|
+
fallback.setIndex(new THREE.BufferAttribute(new Uint16Array(0), 1));
|
|
38
|
+
return fallback;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Экспортируем совместимую функцию
|
|
43
|
+
export const mergeGeometries = createMergeGeometries();
|
|
44
|
+
export { mergeBufferGeometries };
|
|
45
|
+
|
|
46
|
+
// Патчим глобальный THREE если доступен
|
|
47
|
+
if (typeof window !== 'undefined' && window.THREE) {
|
|
48
|
+
try {
|
|
49
|
+
const BufferGeometryUtils = window.THREE.BufferGeometryUtils || {};
|
|
50
|
+
if (!BufferGeometryUtils.mergeGeometries) {
|
|
51
|
+
BufferGeometryUtils.mergeGeometries = mergeGeometries;
|
|
52
|
+
window.THREE.BufferGeometryUtils = BufferGeometryUtils;
|
|
53
|
+
console.log('✅ Three.js патч: mergeGeometries добавлен в глобальный THREE');
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.warn('Three.js патч: не удалось применить к глобальному THREE:', error.message);
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/ifc/IfcService.js
CHANGED
|
@@ -5,58 +5,7 @@ import { IFCLoader } from "web-ifc-three/IFCLoader";
|
|
|
5
5
|
// Примечание: IFCWorker не используется, так как мы отключаем Web Workers
|
|
6
6
|
// для стабильности работы в различных окружениях
|
|
7
7
|
|
|
8
|
-
// Патч совместимости
|
|
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
|
-
}
|
|
8
|
+
// Патч совместимости будет применен после инициализации WASM
|
|
60
9
|
|
|
61
10
|
export class IfcService {
|
|
62
11
|
/**
|
|
@@ -92,6 +41,9 @@ export class IfcService {
|
|
|
92
41
|
// Настройка конфигурации web-ifc
|
|
93
42
|
this._setupWebIfcConfig();
|
|
94
43
|
|
|
44
|
+
// Применяем патч совместимости Three.js после успешной инициализации
|
|
45
|
+
this._applyThreeJsPatch();
|
|
46
|
+
|
|
95
47
|
} catch (error) {
|
|
96
48
|
console.error('IfcService: критическая ошибка инициализации:', error);
|
|
97
49
|
this._handleCriticalError(error);
|
|
@@ -132,12 +84,11 @@ export class IfcService {
|
|
|
132
84
|
paths.push(this.wasmUrl);
|
|
133
85
|
}
|
|
134
86
|
|
|
135
|
-
// 2. Популярные пути по умолчанию
|
|
87
|
+
// 2. Популярные пути по умолчанию (в порядке приоритета)
|
|
136
88
|
paths.push(
|
|
89
|
+
'/node_modules/web-ifc/web-ifc.wasm', // Прямо из node_modules (самый надежный)
|
|
137
90
|
'/wasm/web-ifc.wasm', // Стандартный путь в public/wasm/
|
|
138
91
|
'/web-ifc.wasm', // Корневой путь
|
|
139
|
-
'/wasm/', // Директория wasm
|
|
140
|
-
'/node_modules/web-ifc/web-ifc.wasm', // Прямо из node_modules
|
|
141
92
|
'./web-ifc.wasm', // Относительный путь
|
|
142
93
|
'web-ifc.wasm' // Просто имя файла
|
|
143
94
|
);
|
|
@@ -162,6 +113,23 @@ export class IfcService {
|
|
|
162
113
|
}
|
|
163
114
|
}
|
|
164
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Применяет патч совместимости для Three.js 0.149+
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
_applyThreeJsPatch() {
|
|
121
|
+
try {
|
|
122
|
+
// Динамически импортируем патч совместимости
|
|
123
|
+
import('../compat/three-compat-patch.js').then(() => {
|
|
124
|
+
console.log('✅ IfcService: Патч совместимости Three.js применен');
|
|
125
|
+
}).catch(error => {
|
|
126
|
+
console.warn('IfcService: не удалось применить патч совместимости:', error.message);
|
|
127
|
+
});
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.warn('IfcService: ошибка при применении патча совместимости:', error.message);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
165
133
|
/**
|
|
166
134
|
* Обработка критических ошибок инициализации
|
|
167
135
|
* @private
|