@soonspacejs/plugin-soonmanager2-sync 2.5.50 → 2.5.51
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/constant.d.ts +32 -0
- package/dist/index.d.ts +28 -3
- package/dist/index.esm.js +1 -1
- package/dist/types.d.ts +147 -0
- package/package.json +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 场景元数据
|
|
3
|
+
*/
|
|
4
|
+
export declare const META_DATA_FILE_PATH = "/SceneMetadata.json";
|
|
5
|
+
/**
|
|
6
|
+
* 签名文件
|
|
7
|
+
*/
|
|
8
|
+
export declare const SIGN_PATH = "/db/sign";
|
|
9
|
+
/**
|
|
10
|
+
* 模型树
|
|
11
|
+
*/
|
|
12
|
+
export declare const TREE_DATA_FILE_PATH = "/db/tree_models.json";
|
|
13
|
+
/**
|
|
14
|
+
* 拓扑路径
|
|
15
|
+
*/
|
|
16
|
+
export declare const TOPOLOGY_DATA_FILE_PATH = "/db/topology_paths.json";
|
|
17
|
+
/**
|
|
18
|
+
* 自定义属性
|
|
19
|
+
*/
|
|
20
|
+
export declare const PROPERTIES_DATA_FLEE_PATH = "/db/properties.json";
|
|
21
|
+
/**
|
|
22
|
+
* 帧动画
|
|
23
|
+
*/
|
|
24
|
+
export declare const ANIMATIONS_DATA_FILE_PATH = "/db/animations.json";
|
|
25
|
+
/**
|
|
26
|
+
* 模型视角
|
|
27
|
+
*/
|
|
28
|
+
export declare const MODEL_VISIONS_DATA_FILE_PATH = "/db/model_visions.json";
|
|
29
|
+
/**
|
|
30
|
+
* 自定义属性 key
|
|
31
|
+
*/
|
|
32
|
+
export declare const PROPERTIES_KEY = "properties";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import SoonSpace from 'soonspacejs';
|
|
2
2
|
import { TopologyInfo } from 'soonspacejs/types/Library';
|
|
3
|
-
import { ITreeData, ITopologyPath, ILoadSceneOptions, TPropertiesMap, TAnimationsMap, IPlayAnimationByIdOptions } from './types';
|
|
3
|
+
import { IMetadata, ITreeData, ITopologyPath, ILoadSceneOptions, TPropertiesMap, TAnimationsMap, IPlayAnimationByIdOptions, IModelVisions, TModelVisionsMap } from './types';
|
|
4
4
|
declare class Soonmanager2SyncPlugin {
|
|
5
5
|
readonly ssp: SoonSpace;
|
|
6
|
-
|
|
6
|
+
_path: string;
|
|
7
|
+
get path(): string;
|
|
8
|
+
set path(val: string);
|
|
9
|
+
private _treeDataMaps;
|
|
10
|
+
/**
|
|
11
|
+
* 场景元数据
|
|
12
|
+
*/
|
|
13
|
+
metaData: IMetadata | null;
|
|
7
14
|
/**
|
|
8
15
|
* 模型树
|
|
9
16
|
*/
|
|
@@ -20,13 +27,30 @@ declare class Soonmanager2SyncPlugin {
|
|
|
20
27
|
* 动画
|
|
21
28
|
*/
|
|
22
29
|
animationsData: TAnimationsMap | null;
|
|
30
|
+
/**
|
|
31
|
+
* 模型视角
|
|
32
|
+
*/
|
|
33
|
+
modelVisionsData: TModelVisionsMap | null;
|
|
23
34
|
constructor(ssp: SoonSpace);
|
|
35
|
+
/**
|
|
36
|
+
* 验证签名
|
|
37
|
+
*/
|
|
38
|
+
private verifySign;
|
|
24
39
|
private resolvePath;
|
|
25
40
|
private fetchData;
|
|
41
|
+
/**
|
|
42
|
+
* 获取场景元数据
|
|
43
|
+
*/
|
|
44
|
+
fetchMetaData(): Promise<IMetadata>;
|
|
45
|
+
/**
|
|
46
|
+
* 获取签名
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
fetchSign(): Promise<Response>;
|
|
26
50
|
/**
|
|
27
51
|
* 获取场景树
|
|
28
52
|
*/
|
|
29
|
-
fetchTreeData(): Promise<
|
|
53
|
+
fetchTreeData(): Promise<Response>;
|
|
30
54
|
/**
|
|
31
55
|
* 获取拓扑路径
|
|
32
56
|
* @returns
|
|
@@ -42,6 +66,7 @@ declare class Soonmanager2SyncPlugin {
|
|
|
42
66
|
* @returns
|
|
43
67
|
*/
|
|
44
68
|
fetchAnimationsData(): Promise<TAnimationsMap>;
|
|
69
|
+
fetchModelVisions(): Promise<Record<string, IModelVisions>>;
|
|
45
70
|
/**
|
|
46
71
|
* 加载场景树中的对象
|
|
47
72
|
*/
|
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,
|
|
15
|
+
function t(t,e,i,s){return new(i||(i=Promise))((function(o,a){function n(t){try{c(s.next(t))}catch(t){a(t)}}function r(t){try{c(s.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,r)}c((s=s.apply(t,e||[])).next())}))}const e="/SceneMetadata.json",i="/db/sign",s="/db/tree_models.json",o="/db/topology_paths.json",a="/db/properties.json",n="/db/animations.json",r="/db/model_visions.json",c="properties";var l;!function(t){t[t.BIDIRECTION=0]="BIDIRECTION",t[t.POSITIVE=1]="POSITIVE",t[t.OPPOSITE=2]="OPPOSITE",t[t.FORBID=3]="FORBID"}(l||(l={}));class h{constructor(t){this.ssp=t,this._path="",this._treeDataMaps=new Map,this.metaData=null,this.treeData=null,this.topologyData=null,this.propertiesData=null,this.animationsData=null,this.modelVisionsData=null}get path(){return this._path}set path(t){const e=this._path;this._path=t,this._path!==e&&this.verifySign()}verifySign(){return t(this,void 0,void 0,(function*(){const{version:t,sceneId:e}=this.metaData=yield this.fetchMetaData();if(t>1){const t=yield this.fetchSign().then((t=>t.text())),[i,s]=t.slice(0,2),o=t.slice(2),a=yield this.fetchTreeData().then((t=>t.clone().text())),{license:n}=this.ssp.viewport,{encryptInfo:{serialNums:r=[]}}=n,c=r.map((t=>t.replace(/\/|=/g,""))).filter((t=>t.charAt(5)===i&&t.charAt(20)===s));for(const t of c){const i=`${e}${a}${t}`;if(n.verify(i,o))break}}}))}resolvePath(t){return`${this._path}${t}`}fetchData(e){return t(this,void 0,void 0,(function*(){const{utils:t}=this.ssp;return t.fetchFile(this.resolvePath(e)).then((t=>t.json()))}))}fetchMetaData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/SceneMetadata.json")}))}fetchSign(){return t(this,void 0,void 0,(function*(){const{utils:t}=this.ssp;return t.fetchFile(this.resolvePath("/db/sign"))}))}fetchTreeData(){return t(this,void 0,void 0,(function*(){const t=this._treeDataMaps.get(this.path);if(t)return t;const{utils:e}=this.ssp,i=e.fetchFile(this.resolvePath("/db/tree_models.json"));return this._treeDataMaps.set(this.path,i),i}))}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=>d(t,"modelId")))}))}fetchAnimationsData(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/animations.json").then((t=>d(t,"modelId")))}))}fetchModelVisions(){return t(this,void 0,void 0,(function*(){return this.fetchData("/db/model_visions.json")}))}loadObjects(e){return t(this,void 0,void 0,(function*(){if(!this.treeData)return void console.error("treeData is null");const{syncProperties:i}=e,s=(e,o)=>t(this,void 0,void 0,(function*(){const{ssp:t}=this,{THREE:{Matrix4:a}}=t,{id:n,name:r,renderType:c,path:l,matrix:h}=e,d=(new a).fromArray(h);let p=null;if("3D"===c)if(l)try{p=yield t.loadModel({id:n,name:r,url:this.resolvePath(l),userData:Object.assign({},e)})}catch(t){console.error(t)}else t.utils.warn(`id: ${n} path 为空`);else"GROUP"===c&&(p=t.createGroup({id:n,name:r,userData:Object.assign({},e)}));if(p&&(d.decompose(p.position,p.quaternion,p.scale),o&&t.addObject(p,o),i&&this.propertiesData)){const t=this.propertiesData.get(n);t&&(p.userData.properties=t)}e.children.length>0&&(yield Promise.allSettled(e.children.map((t=>s(t,p)))))}));yield Promise.allSettled(this.treeData.map((t=>s(t,null))))}))}setPath(t){this.path=t}loadScene(e={}){return t(this,void 0,void 0,(function*(){if((e=Object.assign({syncProperties:!0,syncModelVisions:!0},e)).syncProperties&&(this.propertiesData=yield this.fetchPropertiesData()),e.syncModelVisions){const t=yield this.fetchModelVisions();this.modelVisionsData=new Map(Object.entries(t))}this.treeData=yield this.fetchTreeData().then((t=>t.clone().json())),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,i=0,s={}){return t(this,void 0,void 0,(function*(){const{utils:{error:t},animation:o,THREE:a}=this.ssp,{onStart:n,onUpdate:r}=s;this.animationsData||(this.animationsData=yield this.fetchAnimationsData());const c=this.ssp.getObjectById(e);if(!c)return void t(`playAnimationById: id 为 ${e} 场景对象未找到`);const l=this.animationsData.get(e);if(l){const s=l[i];if(s)for(let t=0,e=s.keyframes.length;t<e;t++){let e;if(s.keyframes[t-1]){const i=s.keyframes[t-1];e={x:i.x,y:i.y,z:i.z,rotationX:i.rotationX,rotationY:i.rotationY,rotationZ:i.rotationZ,scaleX:i.scaleX,scaleY:i.scaleY,scaleZ:i.scaleZ}}else{const t=new a.Object3D,i=(new a.Matrix4).fromArray(c.userData.matrix);t.applyMatrix4(i),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 i=s.keyframes[t],{delay:l,duration:h,easing:d,repeat:p,yoyo:u}=i,f={x:i.x,y:i.y,z:i.z,rotationX:i.rotationX,rotationY:i.rotationY,rotationZ:i.rotationZ,scaleX:i.scaleX,scaleY:i.scaleY,scaleZ:i.scaleZ};yield o(e,f,{delay:l,duration:h,mode:d,repeat:-1===p?1/0:p,yoyo:u},((t,e)=>{c.position.set(t.x,t.y,t.z),c.rotation.set(t.rotationX,t.rotationY,t.rotationZ),c.scale.set(t.scaleX,t.scaleY,t.scaleZ),null==r||r(t,e)}),(t=>{null==n||n(t)}))}else t(`id: ${e} 未找到索引为 ${i} 的动画`)}else t(`id: ${e} 未找到动画`)}))}}function d(t,e){const i=new Map;return t.reduce(((t,i)=>{const s=t.get(i[e]);return s?s.push(i):t.set(i[e],[i]),t}),i),i}export{n as ANIMATIONS_DATA_FILE_PATH,e as META_DATA_FILE_PATH,r as MODEL_VISIONS_DATA_FILE_PATH,a as PROPERTIES_DATA_FLEE_PATH,c as PROPERTIES_KEY,i as SIGN_PATH,o as TOPOLOGY_DATA_FILE_PATH,s as TREE_DATA_FILE_PATH,h as default};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Tween } from '@tweenjs/tween.js';
|
|
2
|
+
import { AnimationModeType, IVector3 } from 'soonspacejs/types/Interface';
|
|
3
|
+
/**
|
|
4
|
+
* 场景元数据
|
|
5
|
+
*/
|
|
6
|
+
export interface IMetadata {
|
|
7
|
+
platformVersion: number;
|
|
8
|
+
version: number;
|
|
9
|
+
name: string;
|
|
10
|
+
projectId: string;
|
|
11
|
+
sceneId: string;
|
|
12
|
+
cover: string | null;
|
|
13
|
+
flatModel: string;
|
|
14
|
+
treeModel: string;
|
|
15
|
+
exportTime: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 场景树
|
|
19
|
+
*/
|
|
20
|
+
export interface ITreeData {
|
|
21
|
+
id: string;
|
|
22
|
+
pid: string | null;
|
|
23
|
+
name: string;
|
|
24
|
+
renderType: 'GROUP' | '3D' | 'ROOM';
|
|
25
|
+
matrix: number[];
|
|
26
|
+
path: string | null;
|
|
27
|
+
children: ITreeData[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* origin path
|
|
31
|
+
*/
|
|
32
|
+
export interface ITopologyPath {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
position: IVector3;
|
|
36
|
+
rotation: IVector3;
|
|
37
|
+
scale: IVector3;
|
|
38
|
+
nodes: ITopologyNode[];
|
|
39
|
+
}
|
|
40
|
+
export interface ITopologyNode {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
position: IVector3;
|
|
44
|
+
graphs: ITopologyNodeGraph[];
|
|
45
|
+
}
|
|
46
|
+
export interface ITopologyNodeGraph {
|
|
47
|
+
linkInfo: ITopologyEdge;
|
|
48
|
+
targetNodeId: string;
|
|
49
|
+
passable: PassableType;
|
|
50
|
+
length: number;
|
|
51
|
+
}
|
|
52
|
+
export interface ITopologyEdge {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
}
|
|
56
|
+
declare enum PassableType {
|
|
57
|
+
BIDIRECTION = 0,
|
|
58
|
+
POSITIVE = 1,
|
|
59
|
+
OPPOSITE = 2,
|
|
60
|
+
FORBID = 3
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 自定义属性
|
|
64
|
+
*/
|
|
65
|
+
export interface IProperties {
|
|
66
|
+
modelId: string;
|
|
67
|
+
group: string;
|
|
68
|
+
key: string;
|
|
69
|
+
value: string | null;
|
|
70
|
+
label: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface IKeyframe {
|
|
73
|
+
id: string;
|
|
74
|
+
uuid: string;
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
z: number;
|
|
78
|
+
scaleX: number;
|
|
79
|
+
scaleY: number;
|
|
80
|
+
scaleZ: number;
|
|
81
|
+
rotationX: number;
|
|
82
|
+
rotationY: number;
|
|
83
|
+
rotationZ: number;
|
|
84
|
+
easing: AnimationModeType;
|
|
85
|
+
mode: string;
|
|
86
|
+
delay: number;
|
|
87
|
+
duration: number;
|
|
88
|
+
repeat: number;
|
|
89
|
+
yoyo: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 动画
|
|
93
|
+
*/
|
|
94
|
+
export interface IAnimations {
|
|
95
|
+
id: string;
|
|
96
|
+
uuid: string;
|
|
97
|
+
modelId: string;
|
|
98
|
+
name: string;
|
|
99
|
+
keyframes: IKeyframe[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 模型视角
|
|
103
|
+
*/
|
|
104
|
+
export interface IModelVisions {
|
|
105
|
+
id: string;
|
|
106
|
+
uuid: string;
|
|
107
|
+
nodeId: string;
|
|
108
|
+
name: string;
|
|
109
|
+
code?: any;
|
|
110
|
+
position: IVector3;
|
|
111
|
+
rotation: IVector3;
|
|
112
|
+
target: IVector3;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* loadScene options
|
|
116
|
+
*/
|
|
117
|
+
export interface ILoadSceneOptions {
|
|
118
|
+
/**
|
|
119
|
+
* 同步自定义属性
|
|
120
|
+
*/
|
|
121
|
+
syncProperties?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* 同步模型视角数据
|
|
124
|
+
*/
|
|
125
|
+
syncModelVisions?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* properties map
|
|
129
|
+
*/
|
|
130
|
+
export declare type TPropertiesMap = Map<IProperties['modelId'], IProperties[]>;
|
|
131
|
+
export declare type TAnimationsTweenProps = Pick<IKeyframe, 'x' | 'y' | 'z' | 'rotationX' | 'rotationY' | 'rotationZ' | 'scaleX' | 'scaleY' | 'scaleZ'>;
|
|
132
|
+
/**
|
|
133
|
+
* playAnimationById options
|
|
134
|
+
*/
|
|
135
|
+
export interface IPlayAnimationByIdOptions {
|
|
136
|
+
onUpdate?: (source: TAnimationsTweenProps, tween: Tween<TAnimationsTweenProps>) => void;
|
|
137
|
+
onStart?: (tween: Tween<TAnimationsTweenProps>) => void;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* animation map
|
|
141
|
+
*/
|
|
142
|
+
export declare type TAnimationsMap = Map<IAnimations['modelId'], IAnimations[]>;
|
|
143
|
+
/**
|
|
144
|
+
* model visions map
|
|
145
|
+
*/
|
|
146
|
+
export declare type TModelVisionsMap = Map<IModelVisions['nodeId'], IModelVisions>;
|
|
147
|
+
export {};
|
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.51",
|
|
5
5
|
"description": "Sync soonmanager 2.x data plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.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": "935d10e09cab915e36057f12b0754296b93a8673"
|
|
17
17
|
}
|