@soonspacejs/plugin-soonmanager2-sync 2.4.3 → 2.4.4
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 +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e,i;!function(t){t.Sbm="Sbm",t.Model="Model",t.Poi="Poi",t.Point="Point",t.Line="Line",t.Polygon="Polygon",t.Circle="Circle",t.Grid="Grid",t.Ground="Ground",t.Light="Light"}(t||(t={})),function(t){t.Model="model",t.MarkPoint="markPoint",t.BaseObject="baseObject",t.Topology="topology",t.Light="light",t.Effect="effect"}(e||(e={})),function(t){t.SimpleModel="simpleModel",t.GroupModel="groupModel",t.Point="point",t.Line="line",t.Polygon="polygon",t.AmbientLight="ambientLight",t.DirectionalLight="directionalLight",t.HemisphereLight="hemisphereLight"}(i||(i={}));const a=t=>{var e;if(!t)return{};try{return null!==(e=JSON.parse(t))&&void 0!==e?e:{}}catch(t){return{}}};
|
|
1
|
+
var t,e,i;!function(t){t.Sbm="Sbm",t.Model="Model",t.Poi="Poi",t.Point="Point",t.Line="Line",t.Polygon="Polygon",t.Circle="Circle",t.Grid="Grid",t.Ground="Ground",t.Light="Light"}(t||(t={})),function(t){t.Model="model",t.MarkPoint="markPoint",t.BaseObject="baseObject",t.Topology="topology",t.Light="light",t.Effect="effect"}(e||(e={})),function(t){t.SimpleModel="simpleModel",t.GroupModel="groupModel",t.Point="point",t.Line="line",t.Polygon="polygon",t.AmbientLight="ambientLight",t.DirectionalLight="directionalLight",t.HemisphereLight="hemisphereLight"}(i||(i={}));const a=t=>{var e;if(!t)return{};try{return null!==(e=JSON.parse(t))&&void 0!==e?e:{}}catch(t){return{}}};class s{constructor(t){this.ssp=t,this.baseUrl="",this.spaceData=null,this.lightData=null,this.spaceTreeData=null}setBaseUrl(t){this.baseUrl=t}async syncLight(){if(this.lightData=await this.getData("/data/light.json"),!this.lightData||!this.lightData.length)return;const t=this.ssp;t.removeLightById("defaultAmbientLight"),t.removeLightById("defaultDirectionalLight"),t.removeLightById("defaultHemisphereLight");const s=this.lightData;null==s||s.forEach((s=>{const o=s.spaceObjectDto;if(o&&o.templateAggregateDto.firstClassify===e.Light){const e=a(o.attribute);if(e.id=s.id,e.position&&(e.position=a(e.position)),e.target&&(e.target=a(e.target)),o.templateAggregateDto.secondClassify===i.AmbientLight){t.getLightById(e.id)?t.setAmbientLight(e):t.createAmbientLight(e)}else if(o.templateAggregateDto.secondClassify===i.DirectionalLight){t.getLightById(e.id)?t.setDirectionalLight(e):t.createDirectionalLight(e)}else if(o.templateAggregateDto.secondClassify===i.HemisphereLight){t.getLightById(e.id)?t.setHemisphereLight(e):t.createHemisphereLight(e)}}}))}async loadScene(e){var i;if(this.spaceData=e||await this.getData(),this.spaceTreeData=this.spaceData2SpaceTreeData(this.spaceData),!(null===(i=this.spaceTreeData)||void 0===i?void 0:i.length))return;const a=this.spaceTreeData,s=async e=>{var i;const{pid:a,sceneType:o}=e,n=this.formatSpaceDataByType(e);if(n)if(o===t.Sbm){this.ssp.getSbmGroupById(a)?await this.ssp.addSbmForGroup(a,[n]):await this.ssp.loadSbmToGroup({id:a},[n])}else if(o===t.Model){this.ssp.getModelGroupById(a)?await this.ssp.addModelForGroup(a,[n]):await this.ssp.loadModelToGroup({id:a},[n])}else if(o===t.Poi){this.ssp.getPoiGroupById(a)?await this.ssp.addPoiForGroup(a,[n]):await this.ssp.createPoiToGroup({id:a},[n])}else if(o===t.Point||o===t.Line||o===t.Polygon){this.ssp.getCanvas3DGroupById(a)?await this.ssp.addCanvas3DForGroup(a,[n]):await this.ssp.createCanvas3DToGroup({id:a},[n])}(null===(i=e.children)||void 0===i?void 0:i.length)&&await Promise.allSettled(e.children.map((t=>s(t))))};await Promise.allSettled(a.map((t=>s(t))))}getData(t="/data/space.json"){return fetch(`${this.baseUrl}${t}`).then((t=>t.json())).then((async t=>t))}spaceData2SpaceTreeData(t=this.spaceData){const e=[],i=[];if(t){const a=[...t];a.forEach((t=>{i.includes(t.id)||i.push(t.id)})),a.forEach((t=>{i.includes(t.pid)||e.push({...t})})),e.forEach((t=>{const e=a.findIndex((e=>e.id===t.id));-1!==e&&a.splice(e,1)}));const s=(t,e)=>{const i=[];t.forEach((t=>{t.pid===e.id&&i.push(t)})),i.length>0&&(e.children=i,i.forEach((e=>s(t,e))))};e.forEach((t=>s(a,t)))}return e}formatSpaceDataByType(e){var i;if(!e.sceneType)return;const{id:s,name:o,sceneType:n,spaceObjectDto:r,position:{coordinates:l}={}}=e,{deg2Euler:h}=this.ssp.utils,{attribute:c,templateAggregateDto:d}=null!=r?r:{},{fileResourceBaseDto:p}=null!=d?d:{},[g=0,u=0,y=0]=null!=l?l:[],{rotation:f={},scale:m={},configAttribute:D={}}=a(c),{x:L=0,y:b=0,z:P=0}=f,{x:v=1,y:G=1,z:x=1}=m,S=null!==(i=null==p?void 0:p.path)&&void 0!==i?i:"";return n===t.Sbm||n===t.Model||n===t.Poi?{id:s,name:o,url:`${this.baseUrl}${S}`,position:{x:g,y:u,z:y},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:G,z:x},userData:{...e}}:n===t.Point?{id:s,name:o,points:[{id:s,position:{x:g,y:u,z:y},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:G,z:x},...D}],userData:{...e}}:n===t.Line?{id:s,name:o,lines:[{id:s,position:{x:g,y:u,z:y},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:G,z:x},...D}],userData:{...e}}:n===t.Polygon?{id:s,name:o,polygons:[{id:s,position:{x:g,y:u,z:y},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:G,z:x},...D}],userData:{...e}}:void t.Circle}}export{s as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-soonmanager2-sync",
|
|
3
3
|
"pluginName": "Soonmanager2SyncPlugin",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.4",
|
|
5
5
|
"description": "Sync soonmanager 2.x data plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "xuek",
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "73b20b95e4b94f6634bfde269b1a983f3f2db6f9"
|
|
17
17
|
}
|