@soonspacejs/plugin-soonbuilder-loader 2.6.7 → 2.6.10

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:o}=this.ssp.utils,r=e?`${t}/FileInfo.xml`:t;this.fileInfo=await i(r);const a=r.split("FileInfo.xml")[0],l=this.fileInfo.folder._attributes.name;this.sceneInfo=await i(`${a}${l}.xml`);const{Project:{Building:{Floors:n,SpaceInfo:u,ObjectHierarchy:c}}}=this.sceneInfo,h=async t=>{var e;const{_attributes:i,FileSource:r}=t,{id:l,name:n}=i,{name:u}=r._attributes,h={id:l,name:n,url:this._pathModeChange(a,u),children:[],userData:t};this._pushModelData(h);const d=await this.ssp.loadModelToGroup({id:`${h.id}_group`},[h]);if(!d)return;let p=null;if(s(c.Entity))p=c.Entity.find((t=>{let{_attributes:{id:e,type:i}}=t;return"Floor"===i&&e===l}));else if(o(c.Entity)){const{id:t,type:e}=c.Entity._attributes;t===l&&"Floor"===e&&(p=c.Entity)}if(!p)return;const f=p.Entity.filter((t=>{let{_attributes:{type:e}}=t;return"FACILITY"===e}));for(let t=0;t<f.length;t++){const{id:i,longname:s,visible:o,position:r,eular:l,scale:n}=f[t]._attributes,u={id:i,name:s,url:this._pathModeChange(a,`/${s}.sbm`),visible:this._text2Bool(o),position:this._text2IVector3(r),rotation:this._text2IVector3(l),scale:this._text2IVector3(n),userData:f[t]},c=await this.ssp.loadModel(u);c&&(this.ssp.addObject(c,d),this._pushModelData(u),null===(e=h.children)||void 0===e||e.push(u))}this.treeData.push(h)};if(s(n.Floor))for(let t=0;t<n.Floor.length;t++)await h(n.Floor[t]);else o(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};
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};
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.7",
4
+ "version": "2.6.10",
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": "1367858f0722a9695212d5f4da58df5e6d0714bb",
16
+ "gitHead": "7ea34202f269224509f8da784a857c8b91011e6a",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.6.7"
18
+ "soonspacejs": "2.6.10"
19
19
  }
20
20
  }