@soonspacejs/plugin-soonmanager2-sync 2.5.14 → 2.5.16
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.d.ts +38 -8
- package/dist/index.esm.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,69 @@
|
|
|
1
1
|
import SoonSpace from 'soonspacejs';
|
|
2
2
|
import { TopologyInfo } from 'soonspacejs/types/Library';
|
|
3
|
-
import {
|
|
3
|
+
import { ITreeData, ITopologyPath, ILoadSceneOptions, TPropertiesMap, TAnimationsMap, IPlayAnimationByIdOptions } from './types';
|
|
4
4
|
declare class Soonmanager2SyncPlugin {
|
|
5
5
|
readonly ssp: SoonSpace;
|
|
6
6
|
path: string;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* 模型树
|
|
9
|
+
*/
|
|
10
|
+
treeData: ITreeData[] | null;
|
|
11
|
+
/**
|
|
12
|
+
* 拓扑路径
|
|
13
|
+
*/
|
|
8
14
|
topologyData: TopologyInfo[] | null;
|
|
15
|
+
/**
|
|
16
|
+
* 自定义属性
|
|
17
|
+
*/
|
|
18
|
+
propertiesData: TPropertiesMap | null;
|
|
19
|
+
/**
|
|
20
|
+
* 动画
|
|
21
|
+
*/
|
|
22
|
+
animationsData: TAnimationsMap | null;
|
|
9
23
|
constructor(ssp: SoonSpace);
|
|
10
24
|
private resolvePath;
|
|
11
25
|
private fetchData;
|
|
12
26
|
/**
|
|
13
27
|
* 获取场景树
|
|
14
28
|
*/
|
|
15
|
-
|
|
29
|
+
fetchTreeData(): Promise<ITreeData[]>;
|
|
16
30
|
/**
|
|
17
31
|
* 获取拓扑路径
|
|
18
32
|
* @returns
|
|
19
33
|
*/
|
|
20
|
-
|
|
34
|
+
fetchTopologyData(): Promise<ITopologyPath[]>;
|
|
21
35
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
36
|
+
* 获取自定义属性
|
|
37
|
+
* @returns
|
|
24
38
|
*/
|
|
25
|
-
|
|
39
|
+
fetchPropertiesData(): Promise<TPropertiesMap>;
|
|
40
|
+
/**
|
|
41
|
+
* 获取动画
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
fetchAnimationsData(): Promise<TAnimationsMap>;
|
|
26
45
|
/**
|
|
27
46
|
* 加载场景树中的对象
|
|
28
47
|
*/
|
|
29
48
|
private loadObjects;
|
|
49
|
+
/**
|
|
50
|
+
* 设置 path
|
|
51
|
+
* @param path
|
|
52
|
+
*/
|
|
53
|
+
setPath(path: string): void;
|
|
30
54
|
/**
|
|
31
55
|
* 同步场景树
|
|
32
56
|
*/
|
|
33
|
-
loadScene(): Promise<void>;
|
|
57
|
+
loadScene(options?: ILoadSceneOptions): Promise<void>;
|
|
34
58
|
/**
|
|
35
59
|
* 获取拓扑路径列表
|
|
36
60
|
*/
|
|
37
61
|
getTopologies(): Promise<TopologyInfo[]>;
|
|
62
|
+
/**
|
|
63
|
+
* 播放动画
|
|
64
|
+
*/
|
|
65
|
+
playAnimationById(id: string, animationIndex?: number, options?: IPlayAnimationByIdOptions): Promise<void>;
|
|
38
66
|
}
|
|
67
|
+
export * from './types';
|
|
68
|
+
export * from './constant';
|
|
39
69
|
export default Soonmanager2SyncPlugin;
|
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
|
|
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();this.topologyData=t.map((t=>Object.assign(Object.assign({},t),{type:"network"})))}return this.topologyData}))}playAnimationById(e,o=0,i={}){return t(this,void 0,void 0,(function*(){const{utils:{error:t},animation:a}=this.ssp,{onStart:s,onUpdate:n}=i;this.animationsData||(this.animationsData=yield this.fetchAnimationsData());const r=this.ssp.getObjectById(e);if(!r)return void t(`id: ${e} 场景对象未找到`);const l=this.animationsData.get(e);if(l){const i=l[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 e={x:r.position.x,y:r.position.y,z:r.position.z,rotationX:r.rotation.x,rotationY:r.rotation.y,rotationZ:r.rotation.z,scaleX:r.scale.x,scaleY:r.scale.y,scaleZ:r.scale.z};const o=i.keyframes[t],{delay:l,duration:c,easing:h,repeat:d,yoyo:p}=o,u={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,u,{delay:l,duration:c,mode:h,repeat:-1===d?1/0:d,yoyo:p},((t,e)=>{r.position.set(t.x,t.y,t.z),r.rotation.set(t.rotationX,t.rotationY,t.rotationZ),r.scale.set(t.scaleX,t.scaleY,t.scaleZ),null==n||n(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{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.
|
|
4
|
+
"version": "2.5.16",
|
|
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": "0533bdb68bcfa6342d8b0faad6364f95b90007eb"
|
|
17
17
|
}
|