@soonspacejs/plugin-flow 2.16.8 → 3.0.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.d.ts CHANGED
@@ -1,3 +1,402 @@
1
- export * from './flows';
2
- export * from './triggers';
3
- export * from './types';
1
+ import { AnimationModeType } from 'soonspacejs';
2
+ import { default as default_2 } from 'soonspacejs';
3
+ import { EventDispatcher } from 'three';
4
+ import { FlowType as FlowType_2 } from '@soonspacejs/plugin-flow';
5
+ import { Interaction as Interaction_2 } from '@soonspacejs/plugin-flow';
6
+ import { IVector3 } from 'soonspacejs';
7
+ import { Model } from 'soonspacejs';
8
+ import { ModelEventParams } from 'soonspacejs';
9
+ import { Node as Node_3 } from '@soonspacejs/plugin-flow';
10
+ import { Object3D } from 'three';
11
+ import SoonSpace from 'soonspacejs';
12
+ import { TriggerOptions as TriggerOptions_2 } from '@soonspacejs/plugin-flow';
13
+ import { Tween } from 'three/examples/jsm/libs/tween.module.js';
14
+
15
+ export declare class AnimationPlayer extends EventDispatcher<TEventMap> {
16
+ readonly ssp: SoonSpace;
17
+ readonly target: Object3D;
18
+ tweenSet: Set<TTweenType>;
19
+ constructor(ssp: SoonSpace, target: Object3D);
20
+ initTransform(defaultTransform?: TTransformObject): TTransformObject;
21
+ getInitialTransform(): TTransformObject | undefined;
22
+ play(frames: TAnimationFrame[]): Promise<void>;
23
+ stop(): void;
24
+ reset(): void;
25
+ dispose(): void;
26
+ }
27
+
28
+ export declare class ComponentFlowParser extends FlowParser {
29
+ flow: ComponentFlowType;
30
+ constructor(ssp: default_2, flow: ComponentFlowType);
31
+ }
32
+
33
+ /**
34
+ * 组件流程数据
35
+ */
36
+ export declare type ComponentFlowType = FlowType & {
37
+ editionId: string;
38
+ };
39
+
40
+ export declare class ComponentTrigger extends Trigger {
41
+ flows: ComponentFlowType[];
42
+ flowsMap: Map<string, ComponentFlowType[]>;
43
+ constructor(ssp: default_2, interaction: Interaction, flows: ComponentFlowType[], options: TriggerOptions);
44
+ protected init(): void;
45
+ getComponentObsTarget(currentNode?: Node_2): Promise<Model | null>;
46
+ modelHandler(params: ModelEventParams): void;
47
+ componentThingModelHandler(params: {
48
+ propKey: string;
49
+ }): void;
50
+ runFlowByIds(flowIds: string[]): void;
51
+ execBehavior(): Promise<void>;
52
+ initLoaded(): void;
53
+ initThingPropChange(): void;
54
+ initThingEvent(): void;
55
+ onThingPropChange(newProps: string): void;
56
+ }
57
+
58
+ declare class Edge {
59
+ id: string;
60
+ source: string;
61
+ target: string;
62
+ sourceHandle?: string | null;
63
+ constructor(edge: EdgeType);
64
+ }
65
+
66
+ /**
67
+ * 连接数据
68
+ */
69
+ export declare type EdgeType = {
70
+ id: string;
71
+ source: string;
72
+ target: string;
73
+ sourceHandle?: string | null;
74
+ };
75
+
76
+ export declare class FlowParser extends EventDispatcher<FlowParserEventMap> {
77
+ ssp: default_2;
78
+ flow: FlowType;
79
+ nodes: Node_2[];
80
+ nodesMap: Map<Node_2['id'], Node_2>;
81
+ edges: Edge[];
82
+ edgesMap: Map<Edge['id'], Edge>;
83
+ onNodeBefore: Node_2['onBefore'];
84
+ onNodeAfter: Node_2['onAfter'];
85
+ constructor(ssp: default_2, flow: FlowType);
86
+ addNode(node: Node_2): void;
87
+ addEdge(edge: Edge): void;
88
+ getNodeById(id: string): Node_2 | undefined;
89
+ getEdgeById(id: string): Edge | undefined;
90
+ clear(): void;
91
+ /**
92
+ * 解析流程
93
+ */
94
+ parse(): void;
95
+ /**
96
+ * 执行流程
97
+ * @param startNode
98
+ * @param ctx
99
+ */
100
+ run(global?: NodeGlobalType, options?: {
101
+ preload: boolean;
102
+ }): Promise<void>;
103
+ /**
104
+ * 调试流程
105
+ */
106
+ debug(global?: NodeGlobalType, time?: number): Promise<void>;
107
+ /**
108
+ * 停止流程
109
+ */
110
+ stop(): void;
111
+ /**
112
+ * 清理流程
113
+ */
114
+ cleanup(): void;
115
+ getVariableNameById(id: string): any;
116
+ dispose(): void;
117
+ }
118
+
119
+ export declare type FlowParserEventMap = {};
120
+
121
+ /**
122
+ * 流程数据
123
+ */
124
+ export declare type FlowType = {
125
+ id: string;
126
+ sid: string;
127
+ name: string;
128
+ portal: string;
129
+ nodes: NodeType[];
130
+ edges: EdgeType[];
131
+ };
132
+
133
+ export declare interface IAnimation {
134
+ id: string;
135
+ sid: string;
136
+ modelId: string;
137
+ name: string;
138
+ keyframes: TAnimationFrame[];
139
+ }
140
+
141
+ export declare interface IComponentAnimation {
142
+ id: string;
143
+ sid: string;
144
+ name: string;
145
+ refId: string;
146
+ editionId: string;
147
+ keyframes: TAnimationFrame[];
148
+ }
149
+
150
+ export declare type Interaction = {
151
+ id: string;
152
+ sid: string;
153
+ name: string;
154
+ modelId: string;
155
+ type: InteractionType;
156
+ obsType: InteractionObsType;
157
+ obsTargets: string[] | null;
158
+ obsProps: string[] | null;
159
+ behaviors: InteractionBehavior[] | null;
160
+ active: boolean;
161
+ editionId?: string;
162
+ };
163
+
164
+ export declare enum InteractionAction {
165
+ FLOW = "FLOW",
166
+ ANIMATION = "ANIMATION",
167
+ DELAY = "DELAY"
168
+ }
169
+
170
+ export declare enum InteractionActionType {
171
+ GLOBAL = "GLOBAL",
172
+ SELF = "SELF",
173
+ OTHER = "OTHER"
174
+ }
175
+
176
+ export declare type InteractionBehavior = {
177
+ id: string;
178
+ uuid: string;
179
+ actionType: InteractionActionType;
180
+ action: InteractionAction;
181
+ actionTargets: string[] | null;
182
+ actionRefs: string[] | null;
183
+ };
184
+
185
+ export declare enum InteractionObsType {
186
+ GLOBAL = "GLOBAL",
187
+ INSTANCE = "INSTANCE",
188
+ FAMILY = "FAMILY"
189
+ }
190
+
191
+ export declare enum InteractionType {
192
+ MOUSE_CLICK = "MOUSE_CLICK",
193
+ MOUSE_DB_CLICK = "MOUSE_DB_CLICK",
194
+ MOUSE_RIGHT_CLICK = "MOUSE_RIGHT_CLICK",
195
+ THING_PROP_CHANGE = "THING_PROP_CHANGE",
196
+ THING_EVENT = "THING_EVENT",
197
+ LOADED = "LOADED",
198
+ MODEL_PROP_CHANGE = "MODEL_PROP_CHANGE"
199
+ }
200
+
201
+ declare class Node_2 {
202
+ parser: FlowParser;
203
+ ssp: default_2;
204
+ id: string;
205
+ type: NodeTypeEnum;
206
+ props: NodeType['props'];
207
+ prevNodes: Node_2[];
208
+ postNodes: Node_2[];
209
+ execOrder: number;
210
+ ctx: NodeCtxType;
211
+ promise: Promise<void>;
212
+ resolve: () => void;
213
+ reject: (reason?: any) => void;
214
+ cleanSets: Set<() => void>;
215
+ onBefore: ((node: Node_2) => (Promise<void> | void)) | null;
216
+ onAfter: ((node: Node_2) => (Promise<void> | void)) | null;
217
+ rejected: boolean;
218
+ constructor(parser: FlowParser, node: NodeType);
219
+ init(): void;
220
+ readContext<T = any>(key: string): T | undefined;
221
+ writeContext(key: string, value: any): void;
222
+ findProp(name: string, type: NodePropType['type'] | NodePropType['type'][]): undefined | NodePropType;
223
+ /**
224
+ * 等待前置节点执行完毕
225
+ */
226
+ waitForPrevNodes(): Promise<void[]>;
227
+ /**
228
+ * 合并上下文
229
+ */
230
+ mergeContext(): void;
231
+ /**
232
+ * 执行节点逻辑
233
+ * @param global
234
+ */
235
+ exec(_global: NodeGlobalType): Promise<void>;
236
+ /**
237
+ * 运行节点
238
+ * @param global
239
+ * @param options
240
+ */
241
+ run(global: NodeGlobalType, options?: {
242
+ preload: boolean;
243
+ }): Promise<void>;
244
+ cleanup(): void;
245
+ protected getValue(prop: NodePropType, object?: Object3D | null): any;
246
+ private _mergeUserDataMap;
247
+ }
248
+ export { Node_2 as Node }
249
+
250
+ /**
251
+ * 节点上下文对象
252
+ */
253
+ export declare type NodeCtxType = {
254
+ [x: string]: any;
255
+ };
256
+
257
+ /**
258
+ * 节点全局对象
259
+ * 由运行时动态定义接口
260
+ */
261
+ export declare type NodeGlobalType = {
262
+ getTarget?: (currentNode: Node_2) => Promise<Model | null>;
263
+ getAnimations?: (currentNode: Node_2, object: Object3D, animationId: string) => Promise<IAnimation[] | null>;
264
+ getComponentAnimations?: (currentNode: Node_2, object: Object3D, animationId: string) => Promise<IComponentAnimation[] | null>;
265
+ [s: symbol]: any;
266
+ };
267
+
268
+ /**
269
+ * 节点 props 数据
270
+ */
271
+ export declare type NodePropType = {
272
+ name: string;
273
+ type: NodePropTypeEnum;
274
+ value: string;
275
+ valueType: string;
276
+ };
277
+
278
+ export declare enum NodePropTypeEnum {
279
+ LOCAL = "LOCAL",
280
+ READ_CTX = "READ_CTX",
281
+ WRITE_CTX = "WRITE_CTX"
282
+ }
283
+
284
+ /**
285
+ * 节点数据
286
+ */
287
+ export declare type NodeType = {
288
+ id: string;
289
+ type: NodeTypeEnum;
290
+ props: NodePropType[];
291
+ };
292
+
293
+ export declare enum NodeTypeEnum {
294
+ START = "START",
295
+ COLOR = "COLOR",
296
+ NUMBER = "NUMBER",
297
+ HIGHLIGHT = "HIGHLIGHT",
298
+ UN_HIGHLIGHT = "UN_HIGHLIGHT",
299
+ OPACITY = "OPACITY",
300
+ UN_OPACITY = "UN_OPACITY",
301
+ EMISSIVE = "EMISSIVE",
302
+ UN_EMISSIVE = "UN_EMISSIVE",
303
+ MESH = "MESH",
304
+ MESHES = "MESHES",
305
+ MODEL = "MODEL",
306
+ MODELS = "MODELS",
307
+ SHOW = "SHOW",
308
+ HIDE = "HIDE",
309
+ CLIP_ANIMATION = "CLIP_ANIMATION",
310
+ UN_CLIP_ANIMATION = "UN_CLIP_ANIMATION",
311
+ TWEEN_ANIMATION = "TWEEN_ANIMATION",
312
+ UN_TWEEN_ANIMATION = "UN_TWEEN_ANIMATION",
313
+ COMPONENT_TWEEN_ANIMATION = "COMPONENT_TWEEN_ANIMATION",
314
+ UN_COMPONENT_TWEEN_ANIMATION = "UN_COMPONENT_TWEEN_ANIMATION",
315
+ SPACE = "SPACE",
316
+ SPACES = "SPACES",
317
+ PATH = "PATH",
318
+ PATHS = "PATHS",
319
+ POI = "POI",
320
+ POIS = "POIS",
321
+ FLY_TO = "FLY_TO",
322
+ TRANSLATE = "TRANSLATE",
323
+ ROTATE = "ROTATE",
324
+ SCALE = "SCALE",
325
+ DATA_FILTER = "DATA_FILTER",
326
+ DATA_EXTRACTION = "DATA_EXTRACTION",
327
+ CONDITION_NODE = "CONDITION_NODE",
328
+ DELAY = "DELAY",
329
+ USER_DATA_NODE = "USER_DATA_NODE"
330
+ }
331
+
332
+ export declare type TAnimationFrame = {
333
+ position: IVector3;
334
+ rotation: IVector3;
335
+ scale: IVector3;
336
+ duration: number;
337
+ delay: number;
338
+ repeat: number;
339
+ yoyo: boolean;
340
+ easing: AnimationModeType;
341
+ };
342
+
343
+ export declare type TEventMap = {
344
+ update: {
345
+ source: TTweenSource;
346
+ tween: TTweenType;
347
+ };
348
+ start: {
349
+ tween: TTweenType;
350
+ };
351
+ };
352
+
353
+ export declare class Trigger {
354
+ ssp: default_2;
355
+ interaction: Interaction_2;
356
+ flows: FlowType_2[];
357
+ flowsMap: Map<string, FlowType_2[]>;
358
+ options: TriggerOptions_2;
359
+ disposables: (() => void)[];
360
+ status: 'ready' | 'running' | 'error';
361
+ target?: Model;
362
+ constructor(ssp: default_2, interaction: Interaction_2, flows: FlowType_2[], options: TriggerOptions_2);
363
+ protected init(): void;
364
+ getObsTarget(currentNode: Node_3): Promise<null>;
365
+ modelHandler(params: ModelEventParams): void;
366
+ runFlowByIds(flowIds: string[]): void;
367
+ execBehavior(): Promise<void>;
368
+ initMouseClick(): void;
369
+ initMouseDbClick(): void;
370
+ initMouseRightClick(): void;
371
+ initLoaded(): void;
372
+ modelPropChangeHandler(properties: any): void;
373
+ initModelPropChange(): void;
374
+ initThingPropChange(): void;
375
+ initThingEvent(): void;
376
+ dispose(): void;
377
+ }
378
+
379
+ export declare type TriggerOptions = {
380
+ onError?: (e: Error) => void;
381
+ onTrigger?: (interaction: Interaction) => void;
382
+ getAnimations?: (currentNode: Node_2, object: Object3D, animationId: string) => Promise<IAnimation[] | null>;
383
+ getComponentAnimations?: (currentNode: Node_2, object: Object3D, animationId: string) => Promise<IComponentAnimation[] | null>;
384
+ };
385
+
386
+ export declare type TTransformObject = Pick<TAnimationFrame, 'position' | 'rotation' | 'scale'>;
387
+
388
+ export declare type TTweenSource = {
389
+ x: number;
390
+ y: number;
391
+ z: number;
392
+ rotationX: number;
393
+ rotationY: number;
394
+ rotationZ: number;
395
+ scaleX: number;
396
+ scaleY: number;
397
+ scaleZ: number;
398
+ };
399
+
400
+ export declare type TTweenType = Tween<TTweenSource>;
401
+
402
+ export { }