@soonspacejs/plugin-soonbuilder-loader 2.15.4 → 2.15.6
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/index.esm.js +47 -45
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
const y = ["FACILITY", "DOOR", "WINDOW"];
|
|
2
|
+
class v {
|
|
2
3
|
constructor(t) {
|
|
3
4
|
this.ssp = t, this.treeData = [], this.modelData = [];
|
|
4
5
|
}
|
|
@@ -7,72 +8,72 @@ class T {
|
|
|
7
8
|
treeData;
|
|
8
9
|
modelData;
|
|
9
10
|
async load(t, e = !1) {
|
|
10
|
-
const { xmlToJson: i, isArray: s, isObject: r } = this.ssp.utils,
|
|
11
|
-
this.fileInfo = await i(
|
|
12
|
-
const x = this._getFileExtensionFc(this.fileInfo), p =
|
|
13
|
-
this.sceneInfo = await i(`${p}${
|
|
11
|
+
const { xmlToJson: i, isArray: s, isObject: r } = this.ssp.utils, h = e ? `${t}/FileInfo.xml` : t;
|
|
12
|
+
this.fileInfo = await i(h);
|
|
13
|
+
const x = this._getFileExtensionFc(this.fileInfo), p = h.split("FileInfo.xml")[0], D = this.fileInfo.folder._attributes.name;
|
|
14
|
+
this.sceneInfo = await i(`${p}${D}.xml`);
|
|
14
15
|
const {
|
|
15
16
|
Project: {
|
|
16
17
|
Building: { Floors: c, ObjectHierarchy: u }
|
|
17
18
|
}
|
|
18
|
-
} = this.sceneInfo,
|
|
19
|
-
const { _attributes: g, FileSource:
|
|
19
|
+
} = this.sceneInfo, m = async (l) => {
|
|
20
|
+
const { _attributes: g, FileSource: M } = l, { id: _, name: P } = g, { name: A } = M._attributes, f = {
|
|
20
21
|
id: _,
|
|
21
|
-
name:
|
|
22
|
-
url: this._pathModeChange(p,
|
|
22
|
+
name: P,
|
|
23
|
+
url: this._pathModeChange(p, A),
|
|
23
24
|
children: [],
|
|
24
|
-
userData:
|
|
25
|
+
userData: l
|
|
25
26
|
};
|
|
26
27
|
this._pushModelData(f);
|
|
27
|
-
const
|
|
28
|
+
const E = await this.ssp.loadModelToGroup(
|
|
28
29
|
{
|
|
29
30
|
id: `${f.id}_group`
|
|
30
31
|
},
|
|
31
32
|
[f]
|
|
32
33
|
);
|
|
33
|
-
if (!
|
|
34
|
-
let
|
|
34
|
+
if (!E) return;
|
|
35
|
+
let n = null;
|
|
35
36
|
if (s(u.Entity))
|
|
36
|
-
|
|
37
|
-
({ _attributes: { id: o, type:
|
|
37
|
+
n = u.Entity.find(
|
|
38
|
+
({ _attributes: { id: o, type: d } }) => d === "Floor" && o === _
|
|
38
39
|
);
|
|
39
40
|
else if (r(u.Entity)) {
|
|
40
|
-
const { id: o, type:
|
|
41
|
-
o === _ &&
|
|
41
|
+
const { id: o, type: d } = u.Entity._attributes;
|
|
42
|
+
o === _ && d === "Floor" && (n = u.Entity);
|
|
42
43
|
}
|
|
43
|
-
if (!
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
({ _attributes: { type: o } }) => o
|
|
47
|
-
) : r(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
this.treeData.push(f);
|
|
44
|
+
if (!n) return;
|
|
45
|
+
let a = [];
|
|
46
|
+
s(n.Entity) ? a = n.Entity.filter(
|
|
47
|
+
({ _attributes: { type: o } }) => y.includes(o)
|
|
48
|
+
) : r(n.Entity) && y.includes(n.Entity._attributes.type) && (a = [n.Entity]);
|
|
49
|
+
for (let o = 0; o < a.length; o++) {
|
|
50
|
+
const { id: d, longname: F, visible: O, position: T, eular: $, scale: w } = {
|
|
51
|
+
...a[o]._attributes,
|
|
52
|
+
...a[o].Properties?._attributes ?? {}
|
|
53
|
+
}, b = {
|
|
54
|
+
id: d,
|
|
55
|
+
name: F,
|
|
56
|
+
url: this._pathModeChange(p, `/${x(F)}`),
|
|
57
|
+
visible: this._text2Bool(O),
|
|
58
|
+
position: this._text2IVector3(T),
|
|
59
|
+
rotation: this._text2IVector3($),
|
|
60
|
+
scale: this._text2IVector3(w),
|
|
61
|
+
userData: a[o]
|
|
62
|
+
}, I = await this.ssp.loadModel(b);
|
|
63
|
+
I && (this.ssp.addObject(I, E), this._pushModelData(b), f.children?.push(b));
|
|
65
64
|
}
|
|
65
|
+
this.treeData.push(f);
|
|
66
66
|
};
|
|
67
67
|
if (s(c.Floor))
|
|
68
|
-
for (let
|
|
69
|
-
await
|
|
70
|
-
else r(c.Floor) && await
|
|
68
|
+
for (let l = 0; l < c.Floor.length; l++)
|
|
69
|
+
await m(c.Floor[l]);
|
|
70
|
+
else r(c.Floor) && await m(c.Floor);
|
|
71
71
|
}
|
|
72
72
|
_pushModelData(t) {
|
|
73
73
|
this.modelData.find(({ url: i }) => i === t.url) || this.modelData.push(t);
|
|
74
74
|
}
|
|
75
75
|
_text2IVector3(t) {
|
|
76
|
+
if (!t) return;
|
|
76
77
|
const e = t.split(", ");
|
|
77
78
|
return {
|
|
78
79
|
x: Number(e[0]),
|
|
@@ -81,7 +82,8 @@ class T {
|
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
_text2Bool(t) {
|
|
84
|
-
|
|
85
|
+
if (t !== void 0)
|
|
86
|
+
return t === "True";
|
|
85
87
|
}
|
|
86
88
|
_pathModeChange(t, e) {
|
|
87
89
|
const i = t + e;
|
|
@@ -98,11 +100,11 @@ class T {
|
|
|
98
100
|
const { Extension: r } = s._attributes;
|
|
99
101
|
return r === ".sbm" || r === ".sbmx";
|
|
100
102
|
}))), (s) => {
|
|
101
|
-
const r = i.find((
|
|
103
|
+
const r = i.find((h) => h?._attributes?.name.startsWith(s))?._attributes;
|
|
102
104
|
return `${s}${r?.Extension || ".sbm"}`;
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
export {
|
|
107
|
-
|
|
109
|
+
v as default
|
|
108
110
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-soonbuilder-loader",
|
|
3
3
|
"pluginName": "SoonbuilderLoaderPlugin",
|
|
4
|
-
"version": "2.15.
|
|
4
|
+
"version": "2.15.6",
|
|
5
5
|
"description": "soonbuilder-loader plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
16
|
"gitHead": "4a87dd85050651088e11c3da777c49fab3db7e5d",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.15.
|
|
18
|
+
"soonspacejs": "2.15.5"
|
|
19
19
|
}
|
|
20
20
|
}
|