@soonspacejs/plugin-soonbuilder-loader 2.15.4 → 2.15.5

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.
Files changed (2) hide show
  1. package/dist/index.esm.js +47 -45
  2. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
- class T {
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, d = e ? `${t}/FileInfo.xml` : t;
11
- this.fileInfo = await i(d);
12
- const x = this._getFileExtensionFc(this.fileInfo), p = d.split("FileInfo.xml")[0], E = this.fileInfo.folder._attributes.name;
13
- this.sceneInfo = await i(`${p}${E}.xml`);
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, y = async (a) => {
19
- const { _attributes: g, FileSource: D } = a, { id: _, name: M } = g, { name: P } = D._attributes, f = {
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: M,
22
- url: this._pathModeChange(p, P),
22
+ name: P,
23
+ url: this._pathModeChange(p, A),
23
24
  children: [],
24
- userData: a
25
+ userData: l
25
26
  };
26
27
  this._pushModelData(f);
27
- const F = await this.ssp.loadModelToGroup(
28
+ const E = await this.ssp.loadModelToGroup(
28
29
  {
29
30
  id: `${f.id}_group`
30
31
  },
31
32
  [f]
32
33
  );
33
- if (!F) return;
34
- let l = null;
34
+ if (!E) return;
35
+ let n = null;
35
36
  if (s(u.Entity))
36
- l = u.Entity.find(
37
- ({ _attributes: { id: o, type: h } }) => h === "Floor" && o === _
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: h } = u.Entity._attributes;
41
- o === _ && h === "Floor" && (l = u.Entity);
41
+ const { id: o, type: d } = u.Entity._attributes;
42
+ o === _ && d === "Floor" && (n = u.Entity);
42
43
  }
43
- if (!l) return;
44
- let n = null;
45
- if (s(l.Entity) ? n = l.Entity.filter(
46
- ({ _attributes: { type: o } }) => o === "FACILITY"
47
- ) : r(l.Entity) && l.Entity._attributes.type === "FACILITY" && (n = l.Entity), !!n) {
48
- for (let o = 0; o < n.length; o++) {
49
- const { id: h, longname: I, visible: $, position: w, eular: A, scale: C } = {
50
- ...n[o]._attributes,
51
- ...n[o].Properties?._attributes ?? {}
52
- }, b = {
53
- id: h,
54
- name: I,
55
- url: this._pathModeChange(p, `/${x(I)}`),
56
- visible: this._text2Bool($),
57
- position: this._text2IVector3(w),
58
- rotation: this._text2IVector3(A),
59
- scale: this._text2IVector3(C),
60
- userData: n[o]
61
- }, m = await this.ssp.loadModel(b);
62
- m && (this.ssp.addObject(m, F), this._pushModelData(b), f.children?.push(b));
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 a = 0; a < c.Floor.length; a++)
69
- await y(c.Floor[a]);
70
- else r(c.Floor) && await y(c.Floor);
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
- return t === "True";
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((d) => d?._attributes?.name.startsWith(s))?._attributes;
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
- T as default
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",
4
+ "version": "2.15.5",
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.4"
18
+ "soonspacejs": "2.15.5"
19
19
  }
20
20
  }