@soonspacejs/plugin-soonbuilder-loader 2.8.16 → 2.9.2

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){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{xmlToJson:s,isArray:o,isObject:r}=this.ssp.utils,a=i?`${e}/FileInfo.xml`:e;this.fileInfo=await s(a);const l=a.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,a;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((t=>{let{_attributes:{id:e,type:i}}=t;return"Floor"===i&&e===c}));else if(r(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((t=>{let{_attributes:{type:e}}=t;return"FACILITY"===e})):r(h.Entity)&&"FACILITY"===b.Entity._attributes.type&&(_=b.Entity),_){for(let e=0;e<_.length;e++){const{id:o,longname:r,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:r,format:t.sbm,url:this._pathModeChange(l,`/${r}.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===(a=f.children)||void 0===a||a.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 r(u.Floor)&&await d(u.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{e as default};
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};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-soonbuilder-loader",
3
3
  "pluginName": "SoonbuilderLoaderPlugin",
4
- "version": "2.8.16",
4
+ "version": "2.9.2",
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": "9ab2d57059c8e476c755f6830e133725250d78fe",
16
+ "gitHead": "d50554119e48f8560f4e894e54eba35e54b78962",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.8.16"
18
+ "soonspacejs": "2.9.2"
19
19
  }
20
20
  }