@xeokit/xeokit-sdk 2.6.86-beta.0 → 2.6.86
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/xeokit-sdk.cjs.js +4115 -32
- package/dist/xeokit-sdk.es.js +4115 -33
- package/dist/xeokit-sdk.es5.js +201 -163
- package/dist/xeokit-sdk.min.cjs.js +8 -8
- package/dist/xeokit-sdk.min.es.js +7 -7
- package/dist/xeokit-sdk.min.es5.js +7 -7
- package/package.json +2 -1
- package/src/plugins/CxConverterIFCLoaderPlugin/CxConverterIFCLoaderPlugin.js +86 -0
- package/src/plugins/CxConverterIFCLoaderPlugin/index.js +1 -0
- package/src/plugins/index.js +1 -0
- package/src/plugins/lib/html/MenuEvent.js +2 -2
- package/src/viewer/utils/os.js +9 -0
- package/dist/xeokit-sdk.es5.js.map +0 -1
- package/dist/xeokit-sdk.min.es5.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeokit/xeokit-sdk",
|
|
3
|
-
"version": "2.6.86
|
|
3
|
+
"version": "2.6.86",
|
|
4
4
|
"description": "3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision",
|
|
5
5
|
"module": "./dist/xeokit-sdk.es.js",
|
|
6
6
|
"main": "./dist/xeokit-sdk.cjs.js",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://xeokit.io",
|
|
54
54
|
"dependencies": {
|
|
55
|
+
"@creooxag/cxconverter": "^0.0.3-alpha",
|
|
55
56
|
"@loaders.gl/core": "^4.3.3",
|
|
56
57
|
"@loaders.gl/gltf": "^4.3.3",
|
|
57
58
|
"@loaders.gl/las": "^4.3.3",
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Plugin } from "../../viewer/Plugin.js";
|
|
2
|
+
import { GLTFLoaderPlugin } from "../GLTFLoaderPlugin/GLTFLoaderPlugin.js";
|
|
3
|
+
import { ifc2gltf } from "@creooxag/cxconverter";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Fetches a file from the given URL and returns its contents as text.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} url - The URL to fetch the file from.
|
|
9
|
+
* @returns {Promise<string>} A promise that resolves to the file contents.
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
async function fetchFile(url) {
|
|
13
|
+
try {
|
|
14
|
+
const response = await fetch(url);
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
17
|
+
}
|
|
18
|
+
return response.text();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error fetching file:', error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* {@link Viewer} plugin that uses [CxConverter](https://github.com/Creoox/cxconverter) to load BIM models directly from IFC files, using its WebAssembly buid from [npm package](https://www.npmjs.com/package/@creooxag/cxconverter).
|
|
26
|
+
*
|
|
27
|
+
* ## Overview
|
|
28
|
+
* The WebAssembly build of CxConverter is still in alfa stage, so it may not work as expected. This documentation will be updated as the library and the plugin evolve. The example below shows how to use the plugin:
|
|
29
|
+
* ````javascript
|
|
30
|
+
* import { CxConverterIFCLoaderPlugin, Viewer } from "../../dist/xeokit-sdk.es.js";
|
|
31
|
+
* const cxConverterIFCLoaderPlugin = new CxConverterIFCLoaderPlugin(viewer);
|
|
32
|
+
*
|
|
33
|
+
* const sceneModel = await cxConverterIFCLoaderPlugin.load({
|
|
34
|
+
* src: "../../assets/models/ifc/Duplex.ifc"
|
|
35
|
+
* });
|
|
36
|
+
* ````
|
|
37
|
+
See the code in action [here](https://xeokit.github.io/xeokit-sdk/examples/buildings/#cxConverterIFC_vbo_Duplex).
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
class CxConverterIFCLoaderPlugin extends Plugin {
|
|
41
|
+
/**
|
|
42
|
+
* @constructor
|
|
43
|
+
* @param {Viewer} viewer The Viewer.
|
|
44
|
+
* @param {Object} [cfg={}] Plugin configuration.
|
|
45
|
+
*/
|
|
46
|
+
constructor(viewer, cfg = {}) {
|
|
47
|
+
super("ifcLoader", viewer, cfg);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The GLTFLoaderPlugin used internally to load the converted GLTF.
|
|
51
|
+
* @type {GLTFLoaderPlugin}
|
|
52
|
+
*/
|
|
53
|
+
this.gltfLoader = new GLTFLoaderPlugin(this.viewer);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Loads an IFC model from the given source.
|
|
58
|
+
*
|
|
59
|
+
* @param {Object} [params={}] Loading parameters.
|
|
60
|
+
* @param {string} params.src Path to an IFC file.
|
|
61
|
+
* @param {Function} [params.progressCallback] Callback to track loading progress.
|
|
62
|
+
* @param {Function} [params.progressTextCallback] Callback to track loading progress with text updates.
|
|
63
|
+
* @returns {Promise<SceneModel>} A promise that resolves to the loaded SceneModel.
|
|
64
|
+
*/
|
|
65
|
+
async load(params = {}) {
|
|
66
|
+
if (!params.src) {
|
|
67
|
+
this.error("load() param expected: src");
|
|
68
|
+
}
|
|
69
|
+
const data = await fetchFile(params.src);
|
|
70
|
+
const { gltf, metaData } = await ifc2gltf(
|
|
71
|
+
data,
|
|
72
|
+
{
|
|
73
|
+
remote: true,
|
|
74
|
+
progressCallback: params.progressCallback,
|
|
75
|
+
progressTextCallback: params.progressTextCallback
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
const sceneModel = this.gltfLoader.load({
|
|
79
|
+
id: "myModel",
|
|
80
|
+
gltf: gltf,
|
|
81
|
+
metaModelJSON: metaData
|
|
82
|
+
});
|
|
83
|
+
return sceneModel;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export { CxConverterIFCLoaderPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CxConverterIFCLoaderPlugin.js";
|
package/src/plugins/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./ViewCullPlugin/index.js";
|
|
|
17
17
|
export * from "./XKTLoaderPlugin/index.js";
|
|
18
18
|
export * from "./XML3DLoaderPlugin/index.js";
|
|
19
19
|
export * from "./WebIFCLoaderPlugin/index.js";
|
|
20
|
+
export * from "./CxConverterIFCLoaderPlugin/index.js";
|
|
20
21
|
export * from "./LASLoaderPlugin/index.js";
|
|
21
22
|
export * from "./CityJSONLoaderPlugin/index.js";
|
|
22
23
|
export * from "./DotBIMLoaderPlugin/index.js";
|
|
@@ -67,7 +67,7 @@ export function addContextMenuListener(elem, callback, failCallback = () => {})
|
|
|
67
67
|
event.stopPropagation();
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
if (os.
|
|
70
|
+
if (os.isIphoneOrIpadSafari()) {
|
|
71
71
|
elem.addEventListener('touchstart', touchStartHandler);
|
|
72
72
|
elem.addEventListener('touchmove', touchMoveHandler);
|
|
73
73
|
elem.addEventListener('touchend', touchEndHandler);
|
|
@@ -77,7 +77,7 @@ export function addContextMenuListener(elem, callback, failCallback = () => {})
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
return function removeContextMenuListener() {
|
|
80
|
-
if (os.
|
|
80
|
+
if (os.isIphoneOrIpadSafari()) {
|
|
81
81
|
elem.removeEventListener('touchstart', touchStartHandler);
|
|
82
82
|
elem.removeEventListener('touchmove', touchMoveHandler);
|
|
83
83
|
elem.removeEventListener('touchend', touchEndHandler);
|
package/src/viewer/utils/os.js
CHANGED
|
@@ -6,6 +6,15 @@ const os = {
|
|
|
6
6
|
|
|
7
7
|
return isIphone && isSafari;
|
|
8
8
|
},
|
|
9
|
+
isIphoneOrIpadSafari() {
|
|
10
|
+
const userAgent = window.navigator.userAgent;
|
|
11
|
+
const isIphoneOrIpad = /iPhone|iPad/i.test(userAgent) || (
|
|
12
|
+
// iPad detection: Check for touch support and macOS-like user agent
|
|
13
|
+
/Macintosh/i.test(userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 2
|
|
14
|
+
);
|
|
15
|
+
const isSafari = /Safari/i.test(userAgent) && !/Chrome/i.test(userAgent);
|
|
16
|
+
return isIphoneOrIpad && isSafari;
|
|
17
|
+
},
|
|
9
18
|
isTouchDevice() {
|
|
10
19
|
return (
|
|
11
20
|
'ontouchstart' in window || //works for most devices
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xeokit-sdk.es5.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xeokit-sdk.min.es5.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|