@soonspacejs/plugin-soonmanager2-sync 2.5.33 → 2.5.36

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
@@ -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,o,i){return new(o||(o=Promise))((function(a,s){function n(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(n,r)}l((i=i.apply(t,e||[])).next())}))}const e="/SceneMetadata.json",o="/db/tree_models.json",i="/db/topology_paths.json",a="/db/properties.json",s="/db/animations.json",n="properties";var r;!function(t){t[t.BIDIRECTION=0]="BIDIRECTION",t[t.POSITIVE=1]="POSITIVE",t[t.OPPOSITE=2]="OPPOSITE",t[t.FORBID=3]="FORBID"}(r||(r={}));class l{constructor(t){this.ssp=t,this.path="",this.treeData=null,this.topologyData=null,this.propertiesData=null,this.animationsData=null}resolvePath(t){return`${this.path}${t}`}fetchData(e){return t(this,void 0,void 0,(function*(){const{utils:t}=this.ssp;return yield t.fetchFile(this.resolvePath(e)).then((t=>t.json()))}))}fetchTreeData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/tree_models.json")}))}fetchTopologyData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/topology_paths.json")}))}fetchPropertiesData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/properties.json").then((t=>c(t,"modelId")))}))}fetchAnimationsData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/animations.json").then((t=>c(t,"modelId")))}))}loadObjects(e){return t(this,void 0,void 0,(function*(){if(!this.treeData)return void console.error("treeData is null");const{syncProperties:o}=e,i=(e,a)=>t(this,void 0,void 0,(function*(){const{ssp:t}=this,{THREE:{Matrix4:s}}=t,{id:n,name:r,renderType:l,path:c,matrix:h,pid:d}=e,p=(new s).fromArray(h);let u=null;if("3D"===l)if(c)try{u=yield t.loadModel({id:n,name:r,url:this.resolvePath(c),userData:Object.assign({},e)})}catch(t){console.error(t)}else t.utils.warn(`id: ${n} path 为空`);else"GROUP"===l&&(u=t.createGroup({id:n,name:r,userData:Object.assign({},e)}));if(u&&(u.applyMatrix4(p),a&&t.addObject(u,a),o&&this.propertiesData)){const t=this.propertiesData.get(n);t&&(u.userData.properties=t)}e.children.length>0&&(yield Promise.allSettled(e.children.map((t=>i(t,u)))))}));yield Promise.allSettled(this.treeData.map((t=>i(t,null))))}))}setPath(t){this.path=t}loadScene(e={}){return t(this,void 0,void 0,(function*(){const{syncProperties:t=!0}=e;t&&!this.propertiesData&&(this.propertiesData=yield this.fetchPropertiesData()),this.treeData||(this.treeData=yield this.fetchTreeData()),yield this.loadObjects(e)}))}getTopologies(){return t(this,void 0,void 0,(function*(){if(!this.topologyData){const t=yield this.fetchTopologyData(),e={linkWidth:.1,linkColor:["#00ff00"],nodeRadius:.05,nodeColor:"#0000ff"};this.topologyData=t.map((t=>Object.assign(Object.assign(Object.assign({},t),{type:"network"}),e)))}return this.topologyData}))}playAnimationById(e,o=0,i={}){return t(this,void 0,void 0,(function*(){const{utils:{error:t},animation:a,THREE:s}=this.ssp,{onStart:n,onUpdate:r}=i;this.animationsData||(this.animationsData=yield this.fetchAnimationsData());const l=this.ssp.getObjectById(e);if(!l)return void t(`id: ${e} 场景对象未找到`);const c=this.animationsData.get(e);if(c){const i=c[o];if(i)for(let t=0,e=i.keyframes.length;t<e;t++){let e;if(i.keyframes[t-1]){const o=i.keyframes[t-1];e={x:o.x,y:o.y,z:o.z,rotationX:o.rotationX,rotationY:o.rotationY,rotationZ:o.rotationZ,scaleX:o.scaleX,scaleY:o.scaleY,scaleZ:o.scaleZ}}else{const t=new s.Object3D,o=(new s.Matrix4).fromArray(l.userData.matrix);t.applyMatrix4(o),e={x:t.position.x,y:t.position.y,z:t.position.z,rotationX:t.rotation.x,rotationY:t.rotation.y,rotationZ:t.rotation.z,scaleX:t.scale.x,scaleY:t.scale.y,scaleZ:t.scale.z}}const o=i.keyframes[t],{delay:c,duration:h,easing:d,repeat:p,yoyo:u}=o,f={x:o.x,y:o.y,z:o.z,rotationX:o.rotationX,rotationY:o.rotationY,rotationZ:o.rotationZ,scaleX:o.scaleX,scaleY:o.scaleY,scaleZ:o.scaleZ};yield a(e,f,{delay:c,duration:h,mode:d,repeat:-1===p?1/0:p,yoyo:u},((t,e)=>{l.position.set(t.x,t.y,t.z),l.rotation.set(t.rotationX,t.rotationY,t.rotationZ),l.scale.set(t.scaleX,t.scaleY,t.scaleZ),null==r||r(t,e)}),(t=>{null==n||n(t)}))}else t(`id: ${e} 未找到索引为 ${o} 的动画`)}else t(`id: ${e} 未找到动画`)}))}}function c(t,e){const o=new Map;return t.reduce(((t,o)=>{const i=t.get(o[e]);return i?i.push(o):t.set(o[e],[o]),t}),o),o}export{s as ANIMATIONS_DATA_FILE_PATH,e as META_DATA_FILE_PATH,a as PROPERTIES_DATA_FLEE_PATH,n as PROPERTIES_KEY,i as TOPOLOGY_DATA_FILE_PATH,o as TREE_DATA_FILE_PATH,l as default};
15
+ function t(t,e,o,i){return new(o||(o=Promise))((function(a,s){function n(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(n,r)}l((i=i.apply(t,e||[])).next())}))}const e="/SceneMetadata.json",o="/db/tree_models.json",i="/db/topology_paths.json",a="/db/properties.json",s="/db/animations.json",n="properties";var r;!function(t){t[t.BIDIRECTION=0]="BIDIRECTION",t[t.POSITIVE=1]="POSITIVE",t[t.OPPOSITE=2]="OPPOSITE",t[t.FORBID=3]="FORBID"}(r||(r={}));class l{constructor(t){this.ssp=t,this.path="",this.treeData=null,this.topologyData=null,this.propertiesData=null,this.animationsData=null}resolvePath(t){return`${this.path}${t}`}fetchData(e){return t(this,void 0,void 0,(function*(){const{utils:t}=this.ssp;return yield t.fetchFile(this.resolvePath(e)).then((t=>t.json()))}))}fetchTreeData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/tree_models.json")}))}fetchTopologyData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/topology_paths.json")}))}fetchPropertiesData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/properties.json").then((t=>c(t,"modelId")))}))}fetchAnimationsData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/animations.json").then((t=>c(t,"modelId")))}))}loadObjects(e){return t(this,void 0,void 0,(function*(){if(!this.treeData)return void console.error("treeData is null");const{syncProperties:o}=e,i=(e,a)=>t(this,void 0,void 0,(function*(){const{ssp:t}=this,{THREE:{Matrix4:s}}=t,{id:n,name:r,renderType:l,path:c,matrix:h,pid:d}=e,p=(new s).fromArray(h);let u=null;if("3D"===l)if(c)try{u=yield t.loadModel({id:n,name:r,url:this.resolvePath(c),userData:Object.assign({},e)})}catch(t){console.error(t)}else t.utils.warn(`id: ${n} path 为空`);else"GROUP"===l&&(u=t.createGroup({id:n,name:r,userData:Object.assign({},e)}));if(u&&(p.decompose(u.position,u.quaternion,u.scale),a&&t.addObject(u,a),o&&this.propertiesData)){const t=this.propertiesData.get(n);t&&(u.userData.properties=t)}e.children.length>0&&(yield Promise.allSettled(e.children.map((t=>i(t,u)))))}));yield Promise.allSettled(this.treeData.map((t=>i(t,null))))}))}setPath(t){this.path=t}loadScene(e={}){return t(this,void 0,void 0,(function*(){const{syncProperties:t=!0}=e;t&&!this.propertiesData&&(this.propertiesData=yield this.fetchPropertiesData()),this.treeData||(this.treeData=yield this.fetchTreeData()),yield this.loadObjects(e)}))}getTopologies(){return t(this,void 0,void 0,(function*(){if(!this.topologyData){const t=yield this.fetchTopologyData(),e={linkWidth:.1,linkColor:["#00ff00"],nodeRadius:.05,nodeColor:"#0000ff"};this.topologyData=t.map((t=>Object.assign(Object.assign(Object.assign({},t),{type:"network"}),e)))}return this.topologyData}))}playAnimationById(e,o=0,i={}){return t(this,void 0,void 0,(function*(){const{utils:{error:t},animation:a,THREE:s}=this.ssp,{onStart:n,onUpdate:r}=i;this.animationsData||(this.animationsData=yield this.fetchAnimationsData());const l=this.ssp.getObjectById(e);if(!l)return void t(`id: ${e} 场景对象未找到`);const c=this.animationsData.get(e);if(c){const i=c[o];if(i)for(let t=0,e=i.keyframes.length;t<e;t++){let e;if(i.keyframes[t-1]){const o=i.keyframes[t-1];e={x:o.x,y:o.y,z:o.z,rotationX:o.rotationX,rotationY:o.rotationY,rotationZ:o.rotationZ,scaleX:o.scaleX,scaleY:o.scaleY,scaleZ:o.scaleZ}}else{const t=new s.Object3D,o=(new s.Matrix4).fromArray(l.userData.matrix);t.applyMatrix4(o),e={x:t.position.x,y:t.position.y,z:t.position.z,rotationX:t.rotation.x,rotationY:t.rotation.y,rotationZ:t.rotation.z,scaleX:t.scale.x,scaleY:t.scale.y,scaleZ:t.scale.z}}const o=i.keyframes[t],{delay:c,duration:h,easing:d,repeat:p,yoyo:u}=o,f={x:o.x,y:o.y,z:o.z,rotationX:o.rotationX,rotationY:o.rotationY,rotationZ:o.rotationZ,scaleX:o.scaleX,scaleY:o.scaleY,scaleZ:o.scaleZ};yield a(e,f,{delay:c,duration:h,mode:d,repeat:-1===p?1/0:p,yoyo:u},((t,e)=>{l.position.set(t.x,t.y,t.z),l.rotation.set(t.rotationX,t.rotationY,t.rotationZ),l.scale.set(t.scaleX,t.scaleY,t.scaleZ),null==r||r(t,e)}),(t=>{null==n||n(t)}))}else t(`id: ${e} 未找到索引为 ${o} 的动画`)}else t(`id: ${e} 未找到动画`)}))}}function c(t,e){const o=new Map;return t.reduce(((t,o)=>{const i=t.get(o[e]);return i?i.push(o):t.set(o[e],[o]),t}),o),o}export{s as ANIMATIONS_DATA_FILE_PATH,e as META_DATA_FILE_PATH,a as PROPERTIES_DATA_FLEE_PATH,n as PROPERTIES_KEY,i as TOPOLOGY_DATA_FILE_PATH,o as TREE_DATA_FILE_PATH,l 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.5.33",
4
+ "version": "2.5.36",
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": "63c35fe80f9c32f2925d9933e66b13c0a2a33fdc"
16
+ "gitHead": "33821c3eadbc24f0d138169c4caac601b6dae52a"
17
17
  }