@soonspacejs/plugin-soonbuilder-loader 2.6.20 → 2.6.22

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 CHANGED
@@ -1 +1 @@
1
- class t{constructor(t){this.ssp=t,this.treeData=[],this.modelData=[]}async load(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{xmlToJson:i,isArray:s,isObject:l}=this.ssp.utils,o=e?`${t}/FileInfo.xml`:t;this.fileInfo=await i(o);const r=o.split("FileInfo.xml")[0],a=this.fileInfo.folder._attributes.name;this.sceneInfo=await i(`${r}${a}.xml`);const{Project:{Building:{Floors:n,SpaceInfo:u,ObjectHierarchy:h}}}=this.sceneInfo,c=async t=>{var e;const{_attributes:i,FileSource:o}=t,{id:a,name:n}=i,{name:u}=o._attributes,c={id:a,name:n,url:this._pathModeChange(r,u),children:[],userData:t};this._pushModelData(c);const d=await this.ssp.loadModelToGroup({id:`${c.id}_group`},[c]);if(!d)return;let p=null;if(s(h.Entity))p=h.Entity.find((t=>{let{_attributes:{id:e,type:i}}=t;return"Floor"===i&&e===a}));else if(l(h.Entity)){const{id:t,type:e}=h.Entity._attributes;t===a&&"Floor"===e&&(p=h.Entity)}if(!p)return;let f=null;if(s(p.Entity)?f=p.Entity.filter((t=>{let{_attributes:{type:e}}=t;return"FACILITY"===e})):l(h.Entity)&&"FACILITY"===p.Entity._attributes.type&&(f=p.Entity),f){for(let t=0;t<f.length;t++){const{id:i,longname:s,visible:l,position:o,eular:a,scale:n}=f[t]._attributes,u={id:i,name:s,url:this._pathModeChange(r,`/${s}.sbm`),visible:this._text2Bool(l),position:this._text2IVector3(o),rotation:this._text2IVector3(a),scale:this._text2IVector3(n),userData:f[t]},h=await this.ssp.loadModel(u);h&&(this.ssp.addObject(h,d),this._pushModelData(u),null===(e=c.children)||void 0===e||e.push(u))}this.treeData.push(c)}};if(s(n.Floor))for(let t=0;t<n.Floor.length;t++)await c(n.Floor[t]);else l(n.Floor)&&await c(n.Floor)}_pushModelData(t){this.modelData.find((e=>{let{url:i}=e;return i===t.url}))||this.modelData.push(t)}_text2IVector3(t){const e=t.split(", ");return{x:Number(e[0]),y:Number(e[1]),z:Number(e[2])}}_text2Bool(t){return"True"===t}_pathModeChange(t,e){const i=t+e;if(i.includes("://")){const t=i.split("://");return t[0]+"://"+t[1].replace("\\","/").replace("./","/").replace("//","/")}return i.replace("\\","/").replace("./","/").replace("//","/")}}export{t as default};
1
+ class t{constructor(t){this.ssp=t,this.treeData=[],this.modelData=[]}async load(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{xmlToJson:i,isArray:s,isObject:l}=this.ssp.utils,o=e?`${t}/FileInfo.xml`:t;this.fileInfo=await i(o);const r=o.split("FileInfo.xml")[0],a=this.fileInfo.folder._attributes.name;this.sceneInfo=await i(`${r}${a}.xml`);const{Project:{Building:{Floors:n,SpaceInfo:u,ObjectHierarchy:c}}}=this.sceneInfo,h=async t=>{var e,i,o;const{_attributes:a,FileSource:n}=t,{id:u,name:h}=a,{name:d}=n._attributes,p={id:u,name:h,url:this._pathModeChange(r,d),children:[],userData:t};this._pushModelData(p);const f=await this.ssp.loadModelToGroup({id:`${p.id}_group`},[p]);if(!f)return;let _=null;if(s(c.Entity))_=c.Entity.find((t=>{let{_attributes:{id:e,type:i}}=t;return"Floor"===i&&e===u}));else if(l(c.Entity)){const{id:t,type:e}=c.Entity._attributes;t===u&&"Floor"===e&&(_=c.Entity)}if(!_)return;let b=null;if(s(_.Entity)?b=_.Entity.filter((t=>{let{_attributes:{type:e}}=t;return"FACILITY"===e})):l(c.Entity)&&"FACILITY"===_.Entity._attributes.type&&(b=_.Entity),b){for(let t=0;t<b.length;t++){const{id:s,longname:l,visible:a,position:n,eular:u,scale:c}=Object.assign(Object.assign({},b[t]._attributes),null!==(i=null===(e=b[t].Properties)||void 0===e?void 0:e._attributes)&&void 0!==i?i:{}),h={id:s,name:l,url:this._pathModeChange(r,`/${l}.sbm`),visible:this._text2Bool(a),position:this._text2IVector3(n),rotation:this._text2IVector3(u),scale:this._text2IVector3(c),userData:b[t]},d=await this.ssp.loadModel(h);d&&(this.ssp.addObject(d,f),this._pushModelData(h),null===(o=p.children)||void 0===o||o.push(h))}this.treeData.push(p)}};if(s(n.Floor))for(let t=0;t<n.Floor.length;t++)await h(n.Floor[t]);else l(n.Floor)&&await h(n.Floor)}_pushModelData(t){this.modelData.find((e=>{let{url:i}=e;return i===t.url}))||this.modelData.push(t)}_text2IVector3(t){const e=t.split(", ");return{x:Number(e[0]),y:Number(e[1]),z:Number(e[2])}}_text2Bool(t){return"True"===t}_pathModeChange(t,e){const i=t+e;if(i.includes("://")){const t=i.split("://");return t[0]+"://"+t[1].replace("\\","/").replace("./","/").replace("//","/")}return i.replace("\\","/").replace("./","/").replace("//","/")}}export{t as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-soonbuilder-loader",
3
3
  "pluginName": "SoonbuilderLoaderPlugin",
4
- "version": "2.6.20",
4
+ "version": "2.6.22",
5
5
  "description": "soonbuilder-loader plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -13,8 +13,8 @@
13
13
  ],
14
14
  "author": "xuek",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "a11b43e7b50334fd298b1d24e658f5ea97d9d72a",
16
+ "gitHead": "e716bff27e8da3f62a5f620c325551a97c27752d",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.6.20"
18
+ "soonspacejs": "2.6.22"
19
19
  }
20
20
  }