@soonspacejs/plugin-soonmanager2-sync 2.4.15 → 2.5.0-alpha.0
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/dist/index.js +2 -2
- package/package.json +2 -2
- package/dist/index.d.ts +0 -36
package/dist/index.esm.js
CHANGED
|
@@ -12,4 +12,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
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
|
|
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{}}};export default 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=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){let 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}}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
var Soonmanager2SyncPlugin=function(){"use strict";
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function t(t,e,i,
|
|
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{}}};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=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){let 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:c}=this.ssp.utils,{attribute:d,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(d),{x:L=0,y:b=0,z:v=0}=f,{x:P=1,y:S=1,z:x=1}=m,G=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}${G}`,position:{x:g,y:u,z:y},rotation:{x:c(L),y:c(b),z:c(v)},scale:{x:P,y:S,z:x},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:c(L),y:c(b),z:c(v)},scale:{x:P,y:S,z:x}},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:c(L),y:c(b),z:c(v)},scale:{x:P,y:S,z:x}},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:c(L),y:c(b),z:c(v)},scale:{x:P,y:S,z:x}},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
|
+
"version": "2.5.0-alpha.0",
|
|
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": "b8187989f9105b6b235cc22a8e093b4ecab698fb"
|
|
17
17
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import SoonSpace from 'soonspacejs';
|
|
2
|
-
import { Space, SpaceTree } from './types';
|
|
3
|
-
export default class Soonmanager2SyncPlugin {
|
|
4
|
-
readonly ssp: SoonSpace;
|
|
5
|
-
baseUrl: string;
|
|
6
|
-
spaceData: Space[] | null;
|
|
7
|
-
lightData: Space[] | null;
|
|
8
|
-
spaceTreeData: SpaceTree[] | null;
|
|
9
|
-
constructor(ssp: SoonSpace);
|
|
10
|
-
/**
|
|
11
|
-
* 设置公共资源路径
|
|
12
|
-
*/
|
|
13
|
-
setBaseUrl(url: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* 同步灯光
|
|
16
|
-
*/
|
|
17
|
-
syncLight(): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* 加载场景
|
|
20
|
-
*/
|
|
21
|
-
loadScene(spaceData?: Space[]): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* 获取空间数据、灯光
|
|
24
|
-
*/
|
|
25
|
-
private getData;
|
|
26
|
-
/**
|
|
27
|
-
* 将空间数据转换为树结构数据
|
|
28
|
-
*/
|
|
29
|
-
private spaceData2SpaceTreeData;
|
|
30
|
-
/**
|
|
31
|
-
* 根据类型格式化数据
|
|
32
|
-
* @param baseUrl
|
|
33
|
-
* @param spaceTree
|
|
34
|
-
*/
|
|
35
|
-
private formatSpaceDataByType;
|
|
36
|
-
}
|