@soonspacejs/plugin-soonmanager2-sync 2.4.2 → 2.4.5

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,15 @@
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{}}};export default class{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}}
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ function t(t,e,i,s){return new(i||(i=Promise))((function(o,a){function n(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,r)}l((s=s.apply(t,e||[])).next())}))}var e,i,s;!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"}(e||(e={})),function(t){t.Model="model",t.MarkPoint="markPoint",t.BaseObject="baseObject",t.Topology="topology",t.Light="light",t.Effect="effect"}(i||(i={})),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"}(s||(s={}));const o=t=>{var e;if(!t)return{};try{return null!==(e=JSON.parse(t))&&void 0!==e?e:{}}catch(t){return{}}};class a{constructor(t){this.ssp=t,this.baseUrl="",this.spaceData=null,this.lightData=null,this.spaceTreeData=null}setBaseUrl(t){this.baseUrl=t}syncLight(){return t(this,void 0,void 0,(function*(){if(this.lightData=yield 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 e=this.lightData;null==e||e.forEach((e=>{const a=e.spaceObjectDto;if(a&&a.templateAggregateDto.firstClassify===i.Light){const i=o(a.attribute);if(i.id=e.id,i.position&&(i.position=o(i.position)),i.target&&(i.target=o(i.target)),a.templateAggregateDto.secondClassify===s.AmbientLight){t.getLightById(i.id)?t.setAmbientLight(i):t.createAmbientLight(i)}else if(a.templateAggregateDto.secondClassify===s.DirectionalLight){t.getLightById(i.id)?t.setDirectionalLight(i):t.createDirectionalLight(i)}else if(a.templateAggregateDto.secondClassify===s.HemisphereLight){t.getLightById(i.id)?t.setHemisphereLight(i):t.createHemisphereLight(i)}}}))}))}loadScene(i){var s;return t(this,void 0,void 0,(function*(){if(this.spaceData=i||(yield this.getData()),this.spaceTreeData=this.spaceData2SpaceTreeData(this.spaceData),!(null===(s=this.spaceTreeData)||void 0===s?void 0:s.length))return;const o=this.spaceTreeData,a=i=>t(this,void 0,void 0,(function*(){var t;const{pid:s,sceneType:o}=i,n=this.formatSpaceDataByType(i);if(n)if(o===e.Sbm){this.ssp.getSbmGroupById(s)?yield this.ssp.addSbmForGroup(s,[n]):yield this.ssp.loadSbmToGroup({id:s},[n])}else if(o===e.Model){this.ssp.getModelGroupById(s)?yield this.ssp.addModelForGroup(s,[n]):yield this.ssp.loadModelToGroup({id:s},[n])}else if(o===e.Poi){this.ssp.getPoiGroupById(s)?yield this.ssp.addPoiForGroup(s,[n]):yield this.ssp.createPoiToGroup({id:s},[n])}else if(o===e.Point||o===e.Line||o===e.Polygon){this.ssp.getCanvas3DGroupById(s)?yield this.ssp.addCanvas3DForGroup(s,[n]):yield this.ssp.createCanvas3DToGroup({id:s},[n])}(null===(t=i.children)||void 0===t?void 0:t.length)&&(yield Promise.allSettled(i.children.map((t=>a(t)))))}));yield Promise.allSettled(o.map((t=>a(t))))}))}getData(e="/data/space.json"){return fetch(`${this.baseUrl}${e}`).then((t=>t.json())).then((e=>t(this,void 0,void 0,(function*(){return e}))))}spaceData2SpaceTreeData(t=this.spaceData){const e=[],i=[];if(t){const s=[...t];s.forEach((t=>{i.includes(t.id)||i.push(t.id)})),s.forEach((t=>{i.includes(t.pid)||e.push(Object.assign({},t))})),e.forEach((t=>{const e=s.findIndex((e=>e.id===t.id));-1!==e&&s.splice(e,1)}));const o=(t,e)=>{const i=[];t.forEach((t=>{t.pid===e.id&&i.push(t)})),i.length>0&&(e.children=i,i.forEach((e=>o(t,e))))};e.forEach((t=>o(s,t)))}return e}formatSpaceDataByType(t){var i;if(!t.sceneType)return;const{id:s,name:a,sceneType:n,spaceObjectDto:r,position:{coordinates:l}={}}=t,{deg2Euler:d}=this.ssp.utils,{attribute:c,templateAggregateDto:h}=null!=r?r:{},{fileResourceBaseDto:p}=null!=h?h:{},[g=0,u=0,y=0]=null!=l?l:[],{rotation:f={},scale:m={},configAttribute:D={}}=o(c),{x:L=0,y:b=0,z:v=0}=f,{x:P=1,y:x=1,z:G=1}=m,S=null!==(i=null==p?void 0:p.path)&&void 0!==i?i:"";return n===e.Sbm||n===e.Model||n===e.Poi?{id:s,name:a,url:`${this.baseUrl}${S}`,position:{x:g,y:u,z:y},rotation:{x:d(L),y:d(b),z:d(v)},scale:{x:P,y:x,z:G},userData:Object.assign({},t)}:n===e.Point?{id:s,name:a,points:[Object.assign({id:s,position:{x:g,y:u,z:y},rotation:{x:d(L),y:d(b),z:d(v)},scale:{x:P,y:x,z:G}},D)],userData:Object.assign({},t)}:n===e.Line?{id:s,name:a,lines:[Object.assign({id:s,position:{x:g,y:u,z:y},rotation:{x:d(L),y:d(b),z:d(v)},scale:{x:P,y:x,z:G}},D)],userData:Object.assign({},t)}:n===e.Polygon?{id:s,name:a,polygons:[Object.assign({id:s,position:{x:g,y:u,z:y},rotation:{x:d(L),y:d(b),z:d(v)},scale:{x:P,y:x,z:G}},D)],userData:Object.assign({},t)}:void e.Circle}}export{a as default};
package/dist/index.js CHANGED
@@ -1 +1,15 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Soonmanager2SyncPlugin=e()}(this,(function(){"use strict";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{}}};return class{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:d,templateAggregateDto:c}=null!=r?r:{},{fileResourceBaseDto:p}=null!=c?c:{},[g=0,u=0,f=0]=null!=l?l:[],{rotation:y={},scale:m={},configAttribute:D={}}=a(d),{x:L=0,y:b=0,z:P=0}=y,{x:v=1,y:S=1,z:T=1}=m,x=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}${x}`,position:{x:g,y:u,z:f},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:S,z:T},userData:{...e}}:n===t.Point?{id:s,name:o,points:[{id:s,position:{x:g,y:u,z:f},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:S,z:T},...D}],userData:{...e}}:n===t.Line?{id:s,name:o,lines:[{id:s,position:{x:g,y:u,z:f},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:S,z:T},...D}],userData:{...e}}:n===t.Polygon?{id:s,name:o,polygons:[{id:s,position:{x:g,y:u,z:f},rotation:{x:h(L),y:h(b),z:h(P)},scale:{x:v,y:S,z:T},...D}],userData:{...e}}:void t.Circle}}}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Soonmanager2SyncPlugin=e()}(this,(function(){"use strict";
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */function t(t,e,i,o){return new(i||(i=Promise))((function(s,a){function n(t){try{l(o.next(t))}catch(t){a(t)}}function r(t){try{l(o.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,r)}l((o=o.apply(t,e||[])).next())}))}var e,i,o;!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"}(e||(e={})),function(t){t.Model="model",t.MarkPoint="markPoint",t.BaseObject="baseObject",t.Topology="topology",t.Light="light",t.Effect="effect"}(i||(i={})),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"}(o||(o={}));const s=t=>{var e;if(!t)return{};try{return null!==(e=JSON.parse(t))&&void 0!==e?e:{}}catch(t){return{}}};return class{constructor(t){this.ssp=t,this.baseUrl="",this.spaceData=null,this.lightData=null,this.spaceTreeData=null}setBaseUrl(t){this.baseUrl=t}syncLight(){return t(this,void 0,void 0,(function*(){if(this.lightData=yield 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 e=this.lightData;null==e||e.forEach((e=>{const a=e.spaceObjectDto;if(a&&a.templateAggregateDto.firstClassify===i.Light){const i=s(a.attribute);if(i.id=e.id,i.position&&(i.position=s(i.position)),i.target&&(i.target=s(i.target)),a.templateAggregateDto.secondClassify===o.AmbientLight){t.getLightById(i.id)?t.setAmbientLight(i):t.createAmbientLight(i)}else if(a.templateAggregateDto.secondClassify===o.DirectionalLight){t.getLightById(i.id)?t.setDirectionalLight(i):t.createDirectionalLight(i)}else if(a.templateAggregateDto.secondClassify===o.HemisphereLight){t.getLightById(i.id)?t.setHemisphereLight(i):t.createHemisphereLight(i)}}}))}))}loadScene(i){var o;return t(this,void 0,void 0,(function*(){if(this.spaceData=i||(yield this.getData()),this.spaceTreeData=this.spaceData2SpaceTreeData(this.spaceData),!(null===(o=this.spaceTreeData)||void 0===o?void 0:o.length))return;const s=this.spaceTreeData,a=i=>t(this,void 0,void 0,(function*(){var t;const{pid:o,sceneType:s}=i,n=this.formatSpaceDataByType(i);if(n)if(s===e.Sbm){this.ssp.getSbmGroupById(o)?yield this.ssp.addSbmForGroup(o,[n]):yield this.ssp.loadSbmToGroup({id:o},[n])}else if(s===e.Model){this.ssp.getModelGroupById(o)?yield this.ssp.addModelForGroup(o,[n]):yield this.ssp.loadModelToGroup({id:o},[n])}else if(s===e.Poi){this.ssp.getPoiGroupById(o)?yield this.ssp.addPoiForGroup(o,[n]):yield this.ssp.createPoiToGroup({id:o},[n])}else if(s===e.Point||s===e.Line||s===e.Polygon){this.ssp.getCanvas3DGroupById(o)?yield this.ssp.addCanvas3DForGroup(o,[n]):yield this.ssp.createCanvas3DToGroup({id:o},[n])}(null===(t=i.children)||void 0===t?void 0:t.length)&&(yield Promise.allSettled(i.children.map((t=>a(t)))))}));yield Promise.allSettled(s.map((t=>a(t))))}))}getData(e="/data/space.json"){return fetch(`${this.baseUrl}${e}`).then((t=>t.json())).then((e=>t(this,void 0,void 0,(function*(){return e}))))}spaceData2SpaceTreeData(t=this.spaceData){const e=[],i=[];if(t){const o=[...t];o.forEach((t=>{i.includes(t.id)||i.push(t.id)})),o.forEach((t=>{i.includes(t.pid)||e.push(Object.assign({},t))})),e.forEach((t=>{const e=o.findIndex((e=>e.id===t.id));-1!==e&&o.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(o,t)))}return e}formatSpaceDataByType(t){var i;if(!t.sceneType)return;const{id:o,name:a,sceneType:n,spaceObjectDto:r,position:{coordinates:l}={}}=t,{deg2Euler:d}=this.ssp.utils,{attribute:c,templateAggregateDto:h}=null!=r?r:{},{fileResourceBaseDto:p}=null!=h?h:{},[g=0,u=0,f=0]=null!=l?l:[],{rotation:y={},scale:m={},configAttribute:D={}}=s(c),{x:b=0,y:L=0,z:v=0}=y,{x:P=1,y:x=1,z:S=1}=m,T=null!==(i=null==p?void 0:p.path)&&void 0!==i?i:"";return n===e.Sbm||n===e.Model||n===e.Poi?{id:o,name:a,url:`${this.baseUrl}${T}`,position:{x:g,y:u,z:f},rotation:{x:d(b),y:d(L),z:d(v)},scale:{x:P,y:x,z:S},userData:Object.assign({},t)}:n===e.Point?{id:o,name:a,points:[Object.assign({id:o,position:{x:g,y:u,z:f},rotation:{x:d(b),y:d(L),z:d(v)},scale:{x:P,y:x,z:S}},D)],userData:Object.assign({},t)}:n===e.Line?{id:o,name:a,lines:[Object.assign({id:o,position:{x:g,y:u,z:f},rotation:{x:d(b),y:d(L),z:d(v)},scale:{x:P,y:x,z:S}},D)],userData:Object.assign({},t)}:n===e.Polygon?{id:o,name:a,polygons:[Object.assign({id:o,position:{x:g,y:u,z:f},rotation:{x:d(b),y:d(L),z:d(v)},scale:{x:P,y:x,z:S}},D)],userData:Object.assign({},t)}:void e.Circle}}}));
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.2",
4
+ "version": "2.4.5",
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": "230b233208bee55f866a7835dc0a3a73a5b398cb"
16
+ "gitHead": "b3d9d2cdea1ab611395f847861d58db5843cd38c"
17
17
  }