@soonspacejs/plugin-soonmanager2-sync 2.5.39 → 2.5.41
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
|
@@ -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,
|
|
15
|
+
function t(t,e,o,i){return new(o||(o=Promise))((function(a,n){function s(t){try{l(i.next(t))}catch(t){n(t)}}function r(t){try{l(i.throw(t))}catch(t){n(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(s,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",n="/db/animations.json",s="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:n}}=t,{id:s,name:r,renderType:l,path:c,matrix:d,pid:h}=e,u=(new n).fromArray(d);let p=null;if("3D"===l)if(c)try{p=yield t.loadModel({id:s,name:r,url:this.resolvePath(c),userData:Object.assign({},e)})}catch(t){console.error(t)}else t.utils.warn(`id: ${s} path 为空`);else"GROUP"===l&&(p=t.createGroup({id:s,name:r,userData:Object.assign({},e)}));if(p&&(u.decompose(p.position,p.quaternion,p.scale),a&&t.addObject(p,a),o&&this.propertiesData)){const t=this.propertiesData.get(s);t&&(p.userData.properties=t)}e.children.length>0&&(yield Promise.allSettled(e.children.map((t=>i(t,p)))))}));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=yield this.fetchPropertiesData()),this.treeData=yield this.fetchTreeData(),yield this.loadObjects(e)}))}getTopologies(){return t(this,void 0,void 0,(function*(){const t=yield this.fetchTopologyData(),e={linkWidth:.1,linkColor:["#00ff00"],nodeRadius:.05,nodeColor:"#0000ff"};return this.topologyData=t.map((t=>Object.assign(Object.assign(Object.assign({},t),{type:"network"}),e))),this.topologyData}))}playAnimationById(e,o=0,i={}){return t(this,void 0,void 0,(function*(){const{utils:{error:t},animation:a,THREE:n}=this.ssp,{onStart:s,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 n.Object3D,o=(new n.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:d,easing:h,repeat:u,yoyo:p}=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:d,mode:h,repeat:-1===u?1/0:u,yoyo:p},((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==s||s(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{n as ANIMATIONS_DATA_FILE_PATH,e as META_DATA_FILE_PATH,a as PROPERTIES_DATA_FLEE_PATH,s 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.
|
|
4
|
+
"version": "2.5.41",
|
|
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": "e6e9fdbc1cefdcabde37159e7a0dda25dc11e130"
|
|
17
17
|
}
|