@soonspacejs/plugin-soonbuilder-loader 2.11.28 → 2.11.30

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
- import{ModelFormat as t}from"soonspacejs";class e{constructor(t){this.ssp=t,this.treeData=[],this.modelData=[]}async load(e,i=!1){const{xmlToJson:s,isArray:o,isObject:a}=this.ssp.utils,r=i?`${e}/FileInfo.xml`:e;this.fileInfo=await s(r);const l=r.split("FileInfo.xml")[0],n=this.fileInfo.folder._attributes.name;this.sceneInfo=await s(`${l}${n}.xml`);const{Project:{Building:{Floors:u,SpaceInfo:c,ObjectHierarchy:h}}}=this.sceneInfo,d=async e=>{var i,s,r;const{_attributes:n,FileSource:u}=e,{id:c,name:d}=n,{name:p}=u._attributes,f={id:c,name:d,format:t.sbm,url:this._pathModeChange(l,p),children:[],userData:e};this._pushModelData(f);const m=await this.ssp.loadModelToGroup({id:`${f.id}_group`},[f]);if(!m)return;let b=null;if(o(h.Entity))b=h.Entity.find((({_attributes:{id:t,type:e}})=>"Floor"===e&&t===c));else if(a(h.Entity)){const{id:t,type:e}=h.Entity._attributes;t===c&&"Floor"===e&&(b=h.Entity)}if(!b)return;let _=null;if(o(b.Entity)?_=b.Entity.filter((({_attributes:{type:t}})=>"FACILITY"===t)):a(h.Entity)&&"FACILITY"===b.Entity._attributes.type&&(_=b.Entity),_){for(let e=0;e<_.length;e++){const{id:o,longname:a,visible:n,position:u,eular:c,scale:h}=Object.assign(Object.assign({},_[e]._attributes),null!==(s=null===(i=_[e].Properties)||void 0===i?void 0:i._attributes)&&void 0!==s?s:{}),d={id:o,name:a,format:t.sbm,url:this._pathModeChange(l,`/${a}.sbm`),visible:this._text2Bool(n),position:this._text2IVector3(u),rotation:this._text2IVector3(c),scale:this._text2IVector3(h),userData:_[e]},p=await this.ssp.loadModel(d);p&&(this.ssp.addObject(p,m),this._pushModelData(d),null===(r=f.children)||void 0===r||r.push(d))}this.treeData.push(f)}};if(o(u.Floor))for(let t=0;t<u.Floor.length;t++)await d(u.Floor[t]);else a(u.Floor)&&await d(u.Floor)}_pushModelData(t){this.modelData.find((({url:e})=>e===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{e as default};
1
+ class t{constructor(t){this.ssp=t,this.treeData=[],this.modelData=[]}async load(t,e=!1){const{xmlToJson:i,isArray:s,isObject:o}=this.ssp.utils,a=e?`${t}/FileInfo.xml`:t;this.fileInfo=await i(a);const l=a.split("FileInfo.xml")[0],r=this.fileInfo.folder._attributes.name;this.sceneInfo=await i(`${l}${r}.xml`);const{Project:{Building:{Floors:n,ObjectHierarchy:u}}}=this.sceneInfo,c=async t=>{var e,i,a;const{_attributes:r,FileSource:n}=t,{id:c,name:h}=r,{name:d}=n._attributes,p={id:c,name:h,url:this._pathModeChange(l,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(u.Entity))_=u.Entity.find((({_attributes:{id:t,type:e}})=>"Floor"===e&&t===c));else if(o(u.Entity)){const{id:t,type:e}=u.Entity._attributes;t===c&&"Floor"===e&&(_=u.Entity)}if(!_)return;let b=null;if(s(_.Entity)?b=_.Entity.filter((({_attributes:{type:t}})=>"FACILITY"===t)):o(u.Entity)&&"FACILITY"===_.Entity._attributes.type&&(b=_.Entity),b){for(let t=0;t<b.length;t++){const{id:s,longname:o,visible:r,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:o,url:this._pathModeChange(l,`/${o}.sbm`),visible:this._text2Bool(r),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===(a=p.children)||void 0===a||a.push(h))}this.treeData.push(p)}};if(s(n.Floor))for(let t=0;t<n.Floor.length;t++)await c(n.Floor[t]);else o(n.Floor)&&await c(n.Floor)}_pushModelData(t){this.modelData.find((({url:e})=>e===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.11.28",
4
+ "version": "2.11.30",
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": "xunwei",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "0f600384831eda612ffcad94a6bbe5b289988c87",
16
+ "gitHead": "c334435282652b1a591caf8fd6feed5334ddafff",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.11.28"
18
+ "soonspacejs": "2.11.30"
19
19
  }
20
20
  }