@soonspacejs/plugin-flow 2.13.4 → 2.13.6
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/flows/FlowParser.d.ts +1 -0
- package/dist/flows/edges/index.d.ts +1 -0
- package/dist/flows/index.d.ts +1 -0
- package/dist/flows/nodes/ConditionNode.d.ts +9 -0
- package/dist/flows/nodes/DataExtractionNode.d.ts +8 -0
- package/dist/flows/nodes/DataFilterNode.d.ts +8 -0
- package/dist/flows/nodes/EmissiveNode.d.ts +2 -2
- package/dist/flows/nodes/FlyToNode.d.ts +8 -0
- package/dist/flows/nodes/HideNode.d.ts +2 -2
- package/dist/flows/nodes/HighlightNode.d.ts +2 -2
- package/dist/flows/nodes/Node.d.ts +5 -2
- package/dist/flows/nodes/OpacityNode.d.ts +2 -2
- package/dist/flows/nodes/POINode.d.ts +8 -0
- package/dist/flows/nodes/POISNode.d.ts +8 -0
- package/dist/flows/nodes/PathNode.d.ts +8 -0
- package/dist/flows/nodes/PathsNode.d.ts +8 -0
- package/dist/flows/nodes/RotateNode.d.ts +8 -0
- package/dist/flows/nodes/ScaleNode.d.ts +8 -0
- package/dist/flows/nodes/ShowNode.d.ts +2 -2
- package/dist/flows/nodes/SpaceNode.d.ts +8 -0
- package/dist/flows/nodes/SpacesNode.d.ts +8 -0
- package/dist/flows/nodes/TranslateNode.d.ts +8 -0
- package/dist/flows/nodes/UnEmissiveNode.d.ts +2 -2
- package/dist/flows/nodes/UnHighlightNode.d.ts +2 -2
- package/dist/flows/nodes/UnOpacityNode.d.ts +2 -2
- package/dist/flows/nodes/index.d.ts +13 -0
- package/dist/flows/types.d.ts +16 -2
- package/dist/flows/utils.d.ts +4 -4
- package/dist/index.esm.js +1 -1
- package/dist/triggers/ComponentTrigger.d.ts +5 -9
- package/dist/triggers/Trigger.d.ts +21 -2
- package/dist/triggers/types.d.ts +15 -2
- package/dist/triggers/utils.d.ts +2 -0
- package/package.json +3 -3
- package/test/test.ts +119 -0
package/dist/flows/index.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class ConditionNode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
execFn(fnStr: string): any;
|
|
7
|
+
exec(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export { ConditionNode, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class DataExtractionNode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
exec(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { DataExtractionNode, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class DataFilterNode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
exec(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { DataFilterNode, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import { FlowParser } from '../FlowParser';
|
|
3
|
-
import { NodeType } from '../types';
|
|
3
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
declare class EmissiveNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterEmissiveObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { EmissiveNode, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FlowParser } from '../FlowParser';
|
|
2
|
-
import { NodeType } from '../types';
|
|
2
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
import { Object3D } from 'three';
|
|
5
5
|
declare class HideNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterHideObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { HideNode, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import { FlowParser } from '../FlowParser';
|
|
3
|
-
import { NodeType } from '../types';
|
|
3
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
declare class HighlightNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterHighlightObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { HighlightNode, };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import SoonSpace from 'soonspacejs';
|
|
2
2
|
import { FlowParser } from '../FlowParser';
|
|
3
3
|
import { NodeType, NodeCtxType, NodePropType, NodeGlobalType, NodeTypeEnum } from '../types';
|
|
4
|
+
import { Object3D } from 'three';
|
|
4
5
|
declare class Node {
|
|
5
6
|
parser: FlowParser;
|
|
6
7
|
ssp: SoonSpace;
|
|
@@ -17,15 +18,16 @@ declare class Node {
|
|
|
17
18
|
cleanSets: Set<() => void>;
|
|
18
19
|
onBefore: ((node: Node) => (Promise<void> | void)) | null;
|
|
19
20
|
onAfter: ((node: Node) => (Promise<void> | void)) | null;
|
|
21
|
+
rejected: boolean;
|
|
20
22
|
constructor(parser: FlowParser, node: NodeType);
|
|
21
23
|
init(): void;
|
|
22
24
|
readContext<T = any>(key: string): T | undefined;
|
|
23
25
|
writeContext(key: string, value: any): void;
|
|
24
|
-
findProp(name: string, type: NodePropType['type']):
|
|
26
|
+
findProp(name: string, type: NodePropType['type'] | NodePropType['type'][]): undefined | NodePropType;
|
|
25
27
|
/**
|
|
26
28
|
* 等待前置节点执行完毕
|
|
27
29
|
*/
|
|
28
|
-
waitForPrevNodes(): Promise<void>;
|
|
30
|
+
waitForPrevNodes(): Promise<void[]>;
|
|
29
31
|
/**
|
|
30
32
|
* 合并上下文
|
|
31
33
|
*/
|
|
@@ -41,5 +43,6 @@ declare class Node {
|
|
|
41
43
|
*/
|
|
42
44
|
run(global: NodeGlobalType): Promise<void>;
|
|
43
45
|
cleanup(): void;
|
|
46
|
+
protected getValue(prop: NodePropType, object?: Object3D | null): any;
|
|
44
47
|
}
|
|
45
48
|
export { Node, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import { FlowParser } from '../FlowParser';
|
|
3
|
-
import { NodeType } from '../types';
|
|
3
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
declare class OpacityNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterOpacityObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { OpacityNode, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class POINode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { POINode, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class POIsNode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { POIsNode, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class RotateNode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { RotateNode, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class ScaleNode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { ScaleNode, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FlowParser } from '../FlowParser';
|
|
2
|
-
import { NodeType } from '../types';
|
|
2
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
import { Object3D } from 'three';
|
|
5
5
|
declare class ShowNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterShowObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { ShowNode, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
3
|
+
import { Node } from './Node';
|
|
4
|
+
declare class TranslateNode extends Node {
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { TranslateNode, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import { FlowParser } from '../FlowParser';
|
|
3
|
-
import { NodeType } from '../types';
|
|
3
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
declare class UnEmissiveNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterUnEmissiveObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { UnEmissiveNode, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import { FlowParser } from '../FlowParser';
|
|
3
|
-
import { NodeType } from '../types';
|
|
3
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
declare class UnHighlightNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterUnHighlightObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { UnHighlightNode, };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import { FlowParser } from '../FlowParser';
|
|
3
|
-
import { NodeType } from '../types';
|
|
3
|
+
import { NodeGlobalType, NodeType } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
declare class UnOpacityNode extends Node {
|
|
6
6
|
constructor(parser: FlowParser, node: NodeType);
|
|
7
7
|
filterUnOpacityObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
8
|
-
exec(): Promise<void>;
|
|
8
|
+
exec(global: NodeGlobalType): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export { UnOpacityNode, };
|
|
@@ -13,8 +13,21 @@ export { MeshesNode, } from './MeshesNode';
|
|
|
13
13
|
export { ModelNode, } from './ModelNode';
|
|
14
14
|
export { ModelsNode, } from './ModelsNode';
|
|
15
15
|
export { DelayNode, } from './DelayNode';
|
|
16
|
+
export { ConditionNode, } from './ConditionNode';
|
|
16
17
|
export { ShowNode, } from './ShowNode';
|
|
17
18
|
export { HideNode, } from './HideNode';
|
|
19
|
+
export { TranslateNode, } from './TranslateNode';
|
|
20
|
+
export { ScaleNode, } from './ScaleNode';
|
|
21
|
+
export { RotateNode, } from './RotateNode';
|
|
22
|
+
export { FlyToNode, } from './FlyToNode';
|
|
23
|
+
export { SpaceNode, } from './SpaceNode';
|
|
24
|
+
export { SpacesNode, } from './SpacesNode';
|
|
25
|
+
export { POINode, } from './POINode';
|
|
26
|
+
export { POIsNode, } from './POISNode';
|
|
27
|
+
export { DataExtractionNode, } from './DataExtractionNode';
|
|
28
|
+
export { DataFilterNode, } from './DataFilterNode';
|
|
29
|
+
export { PathNode, } from './PathNode';
|
|
30
|
+
export { PathsNode, } from './PathsNode';
|
|
18
31
|
export { ClipAnimationNode, UnClipAnimationNode, } from './clip-animation';
|
|
19
32
|
export { TweenAnimationNode, UnTweenAnimationNode, } from './tween-animation';
|
|
20
33
|
export { ComponentTweenAnimationNode, UnComponentTweenAnimationNode, } from './component-tween-animation';
|
package/dist/flows/types.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export declare enum NodeTypeEnum {
|
|
|
21
21
|
MESHES = "MESHES",
|
|
22
22
|
MODEL = "MODEL",
|
|
23
23
|
MODELS = "MODELS",
|
|
24
|
-
DELAY = "DELAY",
|
|
25
24
|
SHOW = "SHOW",
|
|
26
25
|
HIDE = "HIDE",
|
|
27
26
|
CLIP_ANIMATION = "CLIP_ANIMATION",
|
|
@@ -29,7 +28,21 @@ export declare enum NodeTypeEnum {
|
|
|
29
28
|
TWEEN_ANIMATION = "TWEEN_ANIMATION",
|
|
30
29
|
UN_TWEEN_ANIMATION = "UN_TWEEN_ANIMATION",
|
|
31
30
|
COMPONENT_TWEEN_ANIMATION = "COMPONENT_TWEEN_ANIMATION",
|
|
32
|
-
UN_COMPONENT_TWEEN_ANIMATION = "UN_COMPONENT_TWEEN_ANIMATION"
|
|
31
|
+
UN_COMPONENT_TWEEN_ANIMATION = "UN_COMPONENT_TWEEN_ANIMATION",
|
|
32
|
+
SPACE = "SPACE",
|
|
33
|
+
SPACES = "SPACES",
|
|
34
|
+
PATH = "PATH",
|
|
35
|
+
PATHS = "PATHS",
|
|
36
|
+
POI = "POI",
|
|
37
|
+
POIS = "POIS",
|
|
38
|
+
FLY_TO = "FLY_TO",
|
|
39
|
+
TRANSLATE = "TRANSLATE",
|
|
40
|
+
ROTATE = "ROTATE",
|
|
41
|
+
SCALE = "SCALE",
|
|
42
|
+
DATA_FILTER = "DATA_FILTER",
|
|
43
|
+
DATA_EXTRACTION = "DATA_EXTRACTION",
|
|
44
|
+
CONDITION_NODE = "CONDITION_NODE",
|
|
45
|
+
DELAY = "DELAY"
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* 节点 props 数据
|
|
@@ -55,6 +68,7 @@ export type EdgeType = {
|
|
|
55
68
|
id: string;
|
|
56
69
|
source: string;
|
|
57
70
|
target: string;
|
|
71
|
+
sourceHandle?: string | null;
|
|
58
72
|
};
|
|
59
73
|
/**
|
|
60
74
|
* 流程数据
|
package/dist/flows/utils.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
|
-
import SoonSpace, {
|
|
2
|
+
import SoonSpace, { BaseObject3D } from 'soonspacejs';
|
|
3
3
|
import { FlowParser } from './FlowParser';
|
|
4
4
|
import { Node } from './nodes';
|
|
5
5
|
import { NodeType } from './types';
|
|
6
6
|
export declare function parseNodeByType(parser: FlowParser, node: NodeType): Node;
|
|
7
7
|
export declare function parseValue<T = any>(value: string): T;
|
|
8
8
|
export declare function waitFor(fn: () => Promise<void>, wait: boolean): Promise<void>;
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function getModelByFamilyId(ssp: SoonSpace, family: string): Model | null;
|
|
9
|
+
export declare function getObjectByIds(ssp: SoonSpace, ids: string[]): BaseObject3D[];
|
|
10
|
+
export declare function getObjectById(ssp: SoonSpace, id: string, object?: Object3D): Object3D | null;
|
|
12
11
|
export declare function getMeshByUserDataUuid(object: Object3D, uuid: string): Object3D | null;
|
|
12
|
+
export declare function filterNodes(prevNode: Node, result: Node[]): Node[];
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventDispatcher as s}from"three";import t from"soonspacejs";import{AnimationPlayer as e}from"umanager-animation-parser";class i{constructor(s){this.id=s.id,this.source=s.source,this.target=s.target}}let n=0;class o{constructor(s,t){this.prevNodes=[],this.postNodes=[],this.execOrder=0,this.cleanSets=new Set,this.onBefore=null,this.onAfter=null,this.parser=s,this.ssp=s.ssp,this.id=t.id,this.type=t.type,this.props=t.props,this.init()}init(){this.ctx={},this.promise=new Promise(((s,t)=>{this.resolve=s,this.reject=t}))}readContext(s){return this.ctx[s]}writeContext(s,t){this.ctx[s]=t}findProp(s,t){return this.props.find((e=>e.name===s&&e.type===t))}async waitForPrevNodes(){await Promise.all(this.prevNodes.map((s=>s.promise)))}mergeContext(){this.prevNodes.forEach((s=>{Object.assign(this.ctx,s.ctx)}))}async exec(s){}async run(s){var t,e,i,o;await this.waitForPrevNodes(),this.mergeContext(),await(null===(e=null!==(t=this.onBefore)&&void 0!==t?t:this.parser.onNodeBefore)||void 0===e?void 0:e(this));try{this.execOrder=++n,await this.exec(s)}catch(s){throw this.reject(s),s}await(null===(o=null!==(i=this.onAfter)&&void 0!==i?i:this.parser.onNodeAfter)||void 0===o?void 0:o(this)),this.resolve()}cleanup(){this.cleanSets.forEach((s=>s())),this.cleanSets.clear()}}class c extends o{constructor(s,t){super(s,t)}}var a,r;!function(s){s.LOCAL="LOCAL",s.READ_CTX="READ_CTX",s.WRITE_CTX="WRITE_CTX"}(a||(a={})),function(s){s.START="START",s.COLOR="COLOR",s.NUMBER="NUMBER",s.HIGHLIGHT="HIGHLIGHT",s.UN_HIGHLIGHT="UN_HIGHLIGHT",s.OPACITY="OPACITY",s.UN_OPACITY="UN_OPACITY",s.EMISSIVE="EMISSIVE",s.UN_EMISSIVE="UN_EMISSIVE",s.MESH="MESH",s.MESHES="MESHES",s.MODEL="MODEL",s.MODELS="MODELS",s.DELAY="DELAY",s.SHOW="SHOW",s.HIDE="HIDE",s.CLIP_ANIMATION="CLIP_ANIMATION",s.UN_CLIP_ANIMATION="UN_CLIP_ANIMATION",s.TWEEN_ANIMATION="TWEEN_ANIMATION",s.UN_TWEEN_ANIMATION="UN_TWEEN_ANIMATION",s.COMPONENT_TWEEN_ANIMATION="COMPONENT_TWEEN_ANIMATION",s.UN_COMPONENT_TWEEN_ANIMATION="UN_COMPONENT_TWEEN_ANIMATION"}(r||(r={}));class h extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("color",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);s&&t&&this.writeContext(Y(t.value),Y(s.value))}}class l extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("number",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);s&&t&&this.writeContext(Y(t.value),Y(s.value))}}const{objectHandle:d}=t.utils;class u extends o{constructor(s,t){super(s,t)}filterHighlightObject(s){const t=[];return d(s,(s=>{this.ssp.viewport.scener.selectedObjects.highlight.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL),t=this.findProp("color",a.LOCAL),e=this.findProp("opacity",a.LOCAL);if(s&&t&&e){const i=K(this.ssp,Y(s.value)),n=Y(t.value),o=Y(e.value);if(i){const s=this.filterHighlightObject(i);this.ssp.highlightShow(s,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unHighlightShow(s)}))}}}}const{objectHandle:p}=t.utils;class f extends o{constructor(s,t){super(s,t)}filterUnHighlightObject(s){const t=[];return p(s,(s=>{this.ssp.viewport.scener.selectedObjects.highlight.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL);if(s){const t=K(this.ssp,Y(s.value));if(t){const s=this.filterUnHighlightObject(t);this.ssp.unHighlightShow(s),this.cleanSets.add((()=>{this.ssp.highlightShow(s)}))}}}}const{objectHandle:E}=t.utils;class O extends o{constructor(s,t){super(s,t)}filterOpacityObject(s){const t=[];return E(s,(s=>{this.ssp.viewport.scener.selectedObjects.opacity.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL),t=this.findProp("color",a.LOCAL),e=this.findProp("opacity",a.LOCAL);if(s&&t&&e){const i=K(this.ssp,Y(s.value)),n=Y(t.value),o=Y(e.value);if(i){const s=this.filterOpacityObject(i);this.ssp.opacityShow(s,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unOpacityShow(s)}))}}}}const{objectHandle:C}=t.utils;class v extends o{constructor(s,t){super(s,t)}filterUnOpacityObject(s){const t=[];return C(s,(s=>{this.ssp.viewport.scener.selectedObjects.opacity.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL);if(s){const t=K(this.ssp,Y(s.value));if(t){const s=this.filterUnOpacityObject(t);this.ssp.unOpacityShow(s),this.cleanSets.add((()=>{this.ssp.opacityShow(s)}))}}}}const{objectHandle:N}=t.utils;class A extends o{constructor(s,t){super(s,t)}filterEmissiveObject(s){const t=[];return N(s,(s=>{this.ssp.viewport.scener.selectedObjects.emissive.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX),t=this.findProp("color",a.READ_CTX),e=this.findProp("baseColor",a.READ_CTX),i=this.findProp("minOpacity",a.READ_CTX),n=this.findProp("maxOpacity",a.READ_CTX),o=this.findProp("duration",a.READ_CTX);if(s&&t&&e&&i&&n&&o){const c=this.readContext(Y(s.value)),a=this.readContext(Y(t.value)),r=this.readContext(Y(e.value)),h=this.readContext(Y(i.value)),l=this.readContext(Y(n.value)),d=this.readContext(Y(o.value));if(c){const s=this.filterEmissiveObject(c);this.ssp.emissiveShow(s,{color:a,baseColor:r,minOpacity:h,maxOpacity:l,duration:d}),this.cleanSets.add((()=>{this.ssp.unEmissiveShow(s)}))}}}}const{objectHandle:I}=t.utils;class T extends o{constructor(s,t){super(s,t)}filterUnEmissiveObject(s){const t=[];return I(s,(s=>{this.ssp.viewport.scener.selectedObjects.emissive.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX);if(s){const t=this.readContext(Y(s.value));if(t){const s=this.filterUnEmissiveObject(t);this.ssp.unEmissiveShow(s),this.cleanSets.add((()=>{this.ssp.emissiveShow(s)}))}}}}const L=Symbol("meshCache");class w extends o{constructor(s,t){super(s,t)}async exec(s){var t;const{viewport:{scene:e}}=this.ssp,i=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this))||e;s[L]||(s[L]={});const n=this.findProp("mesh",a.LOCAL),o=this.findProp("out",a.WRITE_CTX);if(n&&o){let t=null;const e=Y(n.value),c=Y(o.value),a=s[L][e];if(a)return void(t=a);const r=V(i,e);r&&(t=r,s[L][e]=r),this.writeContext(c,t)}}}const g=Symbol("meshesCache");class _ extends o{constructor(s,t){super(s,t)}async exec(s){var t;const{viewport:{scene:e}}=this.ssp,i=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this))||e;s[g]||(s[g]={});const n=this.findProp("meshes",a.LOCAL),o=this.findProp("out",a.WRITE_CTX);if(n&&o){const t=[],e=Y(n.value),c=Y(o.value);e.forEach((e=>{const n=s[g][e];if(n)return void t.push(n);const o=V(i,e);o&&(t.push(o),s[g][e]=o)})),this.writeContext(c,t)}}}class x extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("model",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);if(s&&t){const o=Y(s.value),c=Y(t.value);this.writeContext(c,(e=this.ssp,i=o,null!==(n=e.getAllModel().find((s=>s.userData.id===i||s.userData.uuid===i)))&&void 0!==n?n:null))}var e,i,n}}class M extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("models",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);if(s&&t){const e=Y(s.value),i=Y(t.value);this.writeContext(i,K(this.ssp,e))}}}class m extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("delay",a.LOCAL);if(s){const e=Y(s.value);await t.utils.sleep(e)}}}const{objectHandle:S}=t.utils;class y extends o{constructor(s,t){super(s,t)}filterShowObject(s){const t=[];return S(s,(s=>{!1===s.visible&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX);if(s){const t=this.readContext(Y(s.value));if(t){const s=this.filterShowObject(t),e=t=>{S(s,(s=>{s.visible=t})),this.ssp.render()};e(!0),this.cleanSets.add((()=>e(!1)))}}}}const{objectHandle:P}=t.utils;class b extends o{constructor(s,t){super(s,t)}filterHideObject(s){const t=[];return P(s,(s=>{!0===s.visible&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX);if(s){const t=this.readContext(Y(s.value));if(t){const s=this.filterHideObject(t),e=t=>{P(s,(s=>{s.visible=t})),this.ssp.render()};e(!1),this.cleanSets.add((()=>e(!0)))}}}}class H extends o{constructor(s,t){super(s,t)}async exec(s){var t;let e=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this));if(!e){const s=this.findProp("object",a.READ_CTX);s&&(e=this.readContext(Y(s.value)))}const i=this.findProp("animation",a.LOCAL);if(e&&i){const s=Y(i.value),t=e.animations[s];t&&(this.ssp.playModelAnimation(e,t),this.cleanSets.add((()=>{this.ssp.stopModelAnimation(e,t)})))}}}class D extends o{constructor(s,t){super(s,t)}async exec(s){var t;let e=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this));if(!e){const s=this.findProp("object",a.READ_CTX);s&&(e=this.readContext(Y(s.value)))}const i=this.findProp("animation",a.LOCAL);if(e&&i){const s=Y(i.value),t=e.animations[s];t&&this.ssp.stopModelAnimation(e,t)}}}const j=new Map;function R(s){var t,e;null===(t=j.get(s))||void 0===t||t.forEach((s=>s.stop())),null===(e=j.get(s))||void 0===e||e.clear()}class U extends o{constructor(s,t){super(s,t)}async exec(s){var t;const i=this.findProp("object",a.READ_CTX),n=this.findProp("animation",a.LOCAL),o=this.findProp("wait",a.LOCAL);if(i&&n&&o){const c=this.readContext(Y(i.value)),a=Y(n.value),r=Y(o.value);if(c){const i=await(null===(t=s.getAnimations)||void 0===t?void 0:t.call(s,this,c,a));if(i){const s=i.find((s=>s.id===a));s&&await F((async()=>{const t=c.matrix.clone();await async function(s,t,i){var n;const{id:o,keyframes:c}=i,a=new e(s,t);j.has(o)||j.set(o,new Set),null===(n=j.get(o))||void 0===n||n.add(a),await a.play(c)}(this.ssp,c,s),this.cleanSets.add((()=>{R(s.id),c&&t.decompose(c.position,c.quaternion,c.scale)}))}),r)}}}}}class G extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",a.LOCAL);if(s){R(Y(s.value))}}}const W=new Map;function B(s){var t,e;null===(t=W.get(s))||void 0===t||t.forEach((s=>s.stop())),null===(e=W.get(s))||void 0===e||e.clear()}class X extends o{constructor(s,t){super(s,t)}async exec(s){var t;const i=this.findProp("object",a.READ_CTX),n=this.findProp("animation",a.LOCAL),o=this.findProp("wait",a.LOCAL);if(i&&n&&o){const c=this.readContext(Y(i.value)),a=Y(n.value),r=Y(o.value);if(c){const n=await(null===(t=s.getComponentAnimations)||void 0===t?void 0:t.call(s,this,c,a));if(n){const s=n.find((s=>s.id===a));if(s){let t=null;"Mesh"===i.valueType?t=c:"Model"===i.valueType&&(t=V(c,s.refId)),t&&await F((async()=>{if(t){const i=t.matrix.clone();await async function(s,t,i){var n;const{id:o,keyframes:c}=i,a=new e(s,t);W.has(o)||W.set(o,new Set),null===(n=W.get(o))||void 0===n||n.add(a),await a.play(c)}(this.ssp,t,s),this.cleanSets.add((()=>{B(s.id),t&&i.decompose(t.position,t.quaternion,t.scale)}))}}),r)}}}}}}class k extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",a.LOCAL);if(s){B(Y(s.value))}}}function Y(s){return JSON.parse(s)}async function F(s,t){t?await s():s()}function K(s,t){const e=new Set(t);return s.getAllModel().filter((s=>e.has(s.userData.id)||e.has(s.userData.uuid)))}function V(s,t){if(s.userData.key===t)return s;for(let e=0,i=s.children.length;e<i;e++){const i=V(s.children[e],t);if(null!==i)return i}return null}const{utils:{sleep:q}}=t;class J extends s{constructor(s,t){super(),this.onNodeBefore=null,this.onNodeAfter=null,this.ssp=s,this.flow=t,this.nodes=[],this.nodesMap=new Map,this.edges=[],this.edgesMap=new Map}addNode(s){this.nodes.push(s),this.nodesMap.set(s.id,s)}addEdge(s){this.edges.push(s),this.edgesMap.set(s.id,s)}getNodeById(s){return this.nodesMap.get(s)}getEdgeById(s){return this.edgesMap.get(s)}clear(){this.nodes.length=0,this.nodesMap.clear(),this.edges.length=0,this.edgesMap.clear()}parse(){this.clear();const{nodes:s,edges:t}=this.flow;s.forEach((s=>{const t=function(s,t){switch(t.type){case r.START:return new c(s,t);case r.COLOR:return new h(s,t);case r.NUMBER:return new l(s,t);case r.HIGHLIGHT:return new u(s,t);case r.UN_HIGHLIGHT:return new f(s,t);case r.OPACITY:return new O(s,t);case r.UN_OPACITY:return new v(s,t);case r.EMISSIVE:return new A(s,t);case r.UN_EMISSIVE:return new T(s,t);case r.MESH:return new w(s,t);case r.MESHES:return new _(s,t);case r.MODEL:return new x(s,t);case r.MODELS:return new M(s,t);case r.DELAY:return new m(s,t);case r.SHOW:return new y(s,t);case r.HIDE:return new b(s,t);case r.CLIP_ANIMATION:return new H(s,t);case r.UN_CLIP_ANIMATION:return new D(s,t);case r.TWEEN_ANIMATION:return new U(s,t);case r.UN_TWEEN_ANIMATION:return new G(s,t);case r.COMPONENT_TWEEN_ANIMATION:return new X(s,t);case r.UN_COMPONENT_TWEEN_ANIMATION:return new k(s,t);default:return new o(s,t)}}(this,s);this.addNode(t)})),t.forEach((s=>{const t=new i(s);this.addEdge(t);const e=this.getNodeById(s.source),n=this.getNodeById(s.target);e&&n&&(e.postNodes.push(n),n.prevNodes.push(e))}))}async run(s={}){const t=this.nodes.filter((s=>s.prevNodes.length||s.postNodes.length)).map((t=>t.run(s)));await Promise.all(t)}async debug(s={},t=1500){this.onNodeAfter=async()=>await q(t),await this.run(s)}stop(){this.nodes.forEach((s=>s.reject(new Error("Flow stopped"))))}cleanup(){this.nodes.sort(((s,t)=>t.execOrder-s.execOrder)).forEach((s=>s.cleanup()))}dispose(){this.stop(),this.cleanup()}}class z extends J{constructor(s,t){super(s,t),this.flow=t}}class Q{constructor(s){this.disposables=[],this.ssp=s}dispose(){this.disposables.forEach((s=>s()))}}var Z,$,ss,ts;!function(s){s.GLOBAL="GLOBAL",s.SELF="SELF",s.OTHER="OTHER"}(Z||(Z={})),function(s){s.FLOW="FLOW",s.ANIMATION="ANIMATION",s.DELAY="DELAY"}($||($={})),function(s){s.GLOBAL="GLOBAL",s.INSTANCE="INSTANCE",s.FAMILY="FAMILY"}(ss||(ss={})),function(s){s.MOUSE_CLICK="MOUSE_CLICK",s.MOUSE_DB_CLICK="MOUSE_DB_CLICK",s.MOUSE_RIGHT_CLICK="MOUSE_RIGHT_CLICK",s.THING_PROP_CHANGE="THING_PROP_CHANGE",s.THING_EVENT="THING_EVENT",s.LOADED="LOADED"}(ts||(ts={}));const{groupBy:es}=t.utils;class is extends Q{constructor(s,t,e,i){super(s),this.target=t,this.interaction=e,this.flows=i,this.flowsMap=es(i,"id"),this.init()}init(){switch(this.interaction.type){case ts.MOUSE_CLICK:this.initMouseClick();break;case ts.MOUSE_DB_CLICK:this.initMouseDbClick();break;case ts.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case ts.LOADED:this.initLoaded();break;case ts.THING_PROP_CHANGE:this.initThingPropChange();break;case ts.THING_EVENT:this.initThingEvent()}}modelHandler(s){var t;const{currentTarget:e}=s;null===(t=this.interaction.obsTargets)||void 0===t||t.forEach((s=>{s===e.userData.key&&this.execBehavior()}))}runFlowByIds(s){s.forEach((s=>{const t=this.flowsMap.get(s);if(t){const s=new z(this.ssp,t[0]);s.parse(),s.run({getTarget:async()=>this.target})}}))}async execBehavior(){const{behaviors:s}=this.interaction;null==s||s.forEach((s=>{if(s.action===$.FLOW)s.actionRefs&&this.runFlowByIds(s.actionRefs)}))}initMouseClick(){this.ssp.signals.modelClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelClick.remove(this.modelHandler)))}initMouseDbClick(){this.ssp.signals.modelDblClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelDblClick.remove(this.modelHandler)))}initMouseRightClick(){this.ssp.signals.modelRightClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelRightClick.remove(this.modelHandler)))}initLoaded(){const s=()=>{this.execBehavior()};this.target.addEventListener("load",s),this.disposables.push((()=>this.target.removeEventListener("load",s)))}initThingPropChange(){}initThingEvent(){}}export{z as ComponentFlowParser,is as ComponentTrigger,J as FlowParser,$ as InteractionAction,Z as InteractionActionType,ss as InteractionObsType,ts as InteractionType,a as NodePropTypeEnum,r as NodeTypeEnum,Q as Trigger};
|
|
1
|
+
import{Vector3 as t,Euler as s,EventDispatcher as e,FileLoader as i,ImageLoader as n,TextureLoader as o}from"three";import a from"soonspacejs";import{AnimationPlayer as r}from"umanager-animation-parser";import{FlowParser as c,InteractionAction as l,InteractionType as h,InteractionObsType as d}from"@soonspacejs/plugin-flow";import{RGBELoader as u}from"three/examples/jsm/loaders/RGBELoader.js";import"three/examples/jsm/exporters/GLTFExporter.js";class p{constructor(t){this.id=t.id,this.source=t.source,this.target=t.target,this.sourceHandle=t.sourceHandle}}var f,C;!function(t){t.LOCAL="LOCAL",t.READ_CTX="READ_CTX",t.WRITE_CTX="WRITE_CTX"}(f||(f={})),function(t){t.START="START",t.COLOR="COLOR",t.NUMBER="NUMBER",t.HIGHLIGHT="HIGHLIGHT",t.UN_HIGHLIGHT="UN_HIGHLIGHT",t.OPACITY="OPACITY",t.UN_OPACITY="UN_OPACITY",t.EMISSIVE="EMISSIVE",t.UN_EMISSIVE="UN_EMISSIVE",t.MESH="MESH",t.MESHES="MESHES",t.MODEL="MODEL",t.MODELS="MODELS",t.SHOW="SHOW",t.HIDE="HIDE",t.CLIP_ANIMATION="CLIP_ANIMATION",t.UN_CLIP_ANIMATION="UN_CLIP_ANIMATION",t.TWEEN_ANIMATION="TWEEN_ANIMATION",t.UN_TWEEN_ANIMATION="UN_TWEEN_ANIMATION",t.COMPONENT_TWEEN_ANIMATION="COMPONENT_TWEEN_ANIMATION",t.UN_COMPONENT_TWEEN_ANIMATION="UN_COMPONENT_TWEEN_ANIMATION",t.SPACE="SPACE",t.SPACES="SPACES",t.PATH="PATH",t.PATHS="PATHS",t.POI="POI",t.POIS="POIS",t.FLY_TO="FLY_TO",t.TRANSLATE="TRANSLATE",t.ROTATE="ROTATE",t.SCALE="SCALE",t.DATA_FILTER="DATA_FILTER",t.DATA_EXTRACTION="DATA_EXTRACTION",t.CONDITION_NODE="CONDITION_NODE",t.DELAY="DELAY"}(C||(C={}));let T=0;class E{constructor(t,s){this.prevNodes=[],this.postNodes=[],this.execOrder=0,this.cleanSets=new Set,this.onBefore=null,this.onAfter=null,this.parser=t,this.ssp=t.ssp,this.id=s.id,this.type=s.type,this.props=s.props,this.rejected=!1,this.init()}init(){this.ctx={},this.promise=new Promise(((t,s)=>{this.resolve=t,this.reject=()=>{this.rejected=!0,s()}}))}readContext(t){return this.ctx[t]}writeContext(t,s){this.ctx[t]=s}findProp(t,s){if(!(s instanceof Array))return this.props.find((e=>e.name===t&&e.type===s));for(const e of s){const s=this.findProp(t,e);if(s)return s}}async waitForPrevNodes(){return await Promise.all(this.prevNodes.map((t=>t.promise)))}mergeContext(){this.prevNodes.forEach((t=>{Object.assign(this.ctx,t.ctx)}))}async exec(t){}async run(t){var s,e,i,n;try{if(await this.waitForPrevNodes(),this.rejected)throw new Error;this.mergeContext(),await(null===(e=null!==(s=this.onBefore)&&void 0!==s?s:this.parser.onNodeBefore)||void 0===e?void 0:e(this));try{this.execOrder=++T,await this.exec(t)}catch(t){throw this.reject(t),t}await(null===(n=null!==(i=this.onAfter)&&void 0!==i?i:this.parser.onNodeAfter)||void 0===n?void 0:n(this)),this.resolve()}catch(t){this.reject()}}cleanup(){this.cleanSets.forEach((t=>t())),this.cleanSets.clear()}getValue(t,s){if(t.type===f.READ_CTX)return this.readContext(Tt(t.value));if(t.type===f.LOCAL){const{viewport:{scene:e}}=this.ssp;return"objects"===t.name||"models"===t.name||"meshs"===t.name?Tt(t.value).map((t=>At(this.ssp,t,null!=s?s:e))):"object"===t.name||"model"===t.name||"mesh"===t.name?At(this.ssp,Tt(t.value),null!=s?s:e):Tt(t.value)}}}class A extends E{constructor(t,s){super(t,s)}}class g extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("color",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);t&&s&&this.writeContext(Tt(s.value),Tt(t.value))}}class O extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("number",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);t&&s&&this.writeContext(Tt(s.value),Tt(t.value))}}const{objectHandle:v}=a.utils;class L extends E{constructor(t,s){super(t,s)}filterHighlightObject(t){const s=[];return v(t,(t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)||s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("opacity",[f.READ_CTX,f.LOCAL]),o=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n){const t=this.getValue(e,o),s=this.getValue(i),a=this.getValue(n);if(t){const e=this.filterHighlightObject(t);this.ssp.highlightShow(e,{color:s,opacity:a}),this.cleanSets.add((()=>{this.ssp.unHighlightShow(e)}))}}}}const{objectHandle:w}=a.utils;class I extends E{constructor(t,s){super(t,s)}filterUnHighlightObject(t){const s=[];return w(t,(t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnHighlightObject(t);this.ssp.unHighlightShow(s),this.cleanSets.add((()=>{this.ssp.highlightShow(s)}))}}}}const{objectHandle:y}=a.utils;class N extends E{constructor(t,s){super(t,s)}filterOpacityObject(t){const s=[];return y(t,(t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)||s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("opacity",[f.READ_CTX,f.LOCAL]),o=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n){const t=this.getValue(e,o),s=this.getValue(i),a=this.getValue(n);if(t){const e=this.filterOpacityObject(t);this.ssp.opacityShow(e,{color:s,opacity:a}),this.cleanSets.add((()=>{this.ssp.unOpacityShow(e)}))}}}}const{objectHandle:P}=a.utils;class x extends E{constructor(t,s){super(t,s)}filterUnOpacityObject(t){const s=[];return P(t,(t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnOpacityObject(t);this.ssp.unOpacityShow(s),this.cleanSets.add((()=>{this.ssp.opacityShow(s)}))}}}}const{objectHandle:m}=a.utils;class _ extends E{constructor(t,s){super(t,s)}filterEmissiveObject(t){const s=[];return m(t,(t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)||s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("baseColor",[f.READ_CTX,f.LOCAL]),o=this.findProp("minOpacity",[f.READ_CTX,f.LOCAL]),a=this.findProp("maxOpacity",[f.READ_CTX,f.LOCAL]),r=this.findProp("duration",[f.READ_CTX,f.LOCAL]),c=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n&&o&&a&&r){const t=this.getValue(e,c),s=this.getValue(i),l=this.getValue(n),h=this.getValue(o),d=this.getValue(a),u=this.getValue(r);if(t){const e=this.filterEmissiveObject(t);this.ssp.emissiveShow(e,{color:s,baseColor:l,minOpacity:h,maxOpacity:d,duration:u}),this.cleanSets.add((()=>{this.ssp.unEmissiveShow(e)}))}}}}const{objectHandle:b}=a.utils;class S extends E{constructor(t,s){super(t,s)}filterUnEmissiveObject(t){const s=[];return b(t,(t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnEmissiveObject(t);this.ssp.unEmissiveShow(s),this.cleanSets.add((()=>{this.ssp.emissiveShow(s)}))}}}}const M=Symbol("meshCache");class R extends E{constructor(t,s){super(t,s)}async exec(t){var s;const{viewport:{scene:e}}=this.ssp,i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this))||e;t[M]||(t[M]={});const n=this.findProp("mesh",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){let s=null;const e=Tt(n.value),a=Tt(o.value),r=t[M][e];if(r)return void(s=r);const c=gt(i,e);c&&(s=c,t[M][e]=c),this.writeContext(a,s)}}}const D=Symbol("meshesCache");class H extends E{constructor(t,s){super(t,s)}async exec(t){var s;const{viewport:{scene:e}}=this.ssp,i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this))||e;t[D]||(t[D]={});const n=this.findProp("meshes",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){const s=[],e=Tt(n.value),a=Tt(o.value);e.forEach((e=>{const n=t[D][e];if(n)return void s.push(n);const o=gt(i,e);o&&(s.push(o),t[D][e]=o)})),this.writeContext(a,s)}}}class j extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,At(this.ssp,e))}}}class X extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("models",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const i=Tt(t.value),n=Tt(s.value);this.writeContext(n,(e=this.ssp,i.map((t=>e.getObjectById(t))).filter(Boolean)))}var e}}class B extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("delay",f.LOCAL);if(t){const s=Tt(t.value);await a.utils.sleep(s)}}}class k extends E{constructor(t,s){super(t,s)}execFn(t){return new Function("sourceData",t)(this.ctx)}async exec(){const t=this.findProp("conditaion_node",f.LOCAL);if(t){const s=Tt(t.value),e=this.parser.edges.filter((t=>t.source===this.id));s.forEach((t=>{try{if(!0!==this.execFn(t.value))throw new Error}catch(s){const i=e.find((s=>s.sourceHandle==String(t.id)));if(!i)return;const n=this.postNodes.find((t=>t.id===i.target));null==n||n.reject()}}))}}}const{objectHandle:V}=a.utils;class G extends E{constructor(t,s){super(t,s)}filterShowObject(t){const s=[];return V(t,(t=>{!1===t.visible&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterShowObject(t),e=t=>{V(s,(s=>{s.visible=t})),this.ssp.render()};e(!0),this.cleanSets.add((()=>e(!1)))}}}}const{objectHandle:U}=a.utils;class W extends E{constructor(t,s){super(t,s)}filterHideObject(t){const s=[];return U(t,(t=>{!0===t.visible&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterHideObject(t),e=t=>{U(s,(s=>{s.visible=t})),this.ssp.render()};e(!1),this.cleanSets.add((()=>e(!0)))}}}}const{objectHandle:F}=a.utils;class z extends E{constructor(t,s){super(t,s)}async exec(s){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("translate",[f.READ_CTX,f.LOCAL]),a=await(null===(e=s.getTarget)||void 0===e?void 0:e.call(s,this));if(i&&n&&o){const s=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(s){const i=[],n=800;F(s,(t=>{i.push(t.position.clone())}));const o=(t,s)=>{switch(e){case"x":t.setX(s.x);break;case"y":t.setY(s.y);break;case"z":t.setZ(s.z)}},a=async()=>{const i=F(s,(async s=>{const i=s.position.clone();switch(e){case"x":await this.ssp.animation(i,(new t).set(i.x+r,i.y,i.z),{duration:n},(t=>o(s.position,t)));break;case"y":await this.ssp.animation(i,(new t).set(i.x,i.y+r,i.z),{duration:n},(t=>o(s.position,t)));break;case"z":await this.ssp.animation(i,(new t).set(i.x,i.y,i.z+r),{duration:n},(t=>o(s.position,t)))}}));i instanceof Array?await Promise.all(i):await i,this.ssp.render()};await a(),this.cleanSets.add((()=>{let t=0;F(s,(s=>{s.position.copy(i[t++])}))}))}}}}const{objectHandle:Y}=a.utils;class K extends E{constructor(t,s){super(t,s)}async exec(s){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("scale",[f.READ_CTX,f.LOCAL]),a=await(null===(e=s.getTarget)||void 0===e?void 0:e.call(s,this));if(i&&n&&o){const s=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(s){const i=[],n=800;Y(s,(t=>{i.push(t.scale.clone())}));const o=(t,s)=>{switch(e){case"x":t.setX(s.x);break;case"y":t.setY(s.y);break;case"z":t.setZ(s.z)}},a=async()=>{const i=Y(s,(async s=>{const i=s.scale.clone();switch(e){case"x":await this.ssp.animation(i,(new t).set(i.x*r,i.y,i.z),{duration:n},(t=>o(s.scale,t)));break;case"y":await this.ssp.animation(i,(new t).set(i.x,i.y*r,i.z),{duration:n},(t=>o(s.scale,t)));break;case"z":await this.ssp.animation(i,(new t).set(i.x,i.y,i.z*r),{duration:n},(t=>o(s.scale,t)))}}));i instanceof Array?await Promise.all(i):await i,this.ssp.render()};await a(),this.cleanSets.add((()=>{let t=0;Y(s,(s=>{s.scale.copy(i[t++])}))}))}}}}const{objectHandle:q}=a.utils;class J extends E{constructor(t,s){super(t,s)}async exec(t){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("rotation",[f.READ_CTX,f.LOCAL]),a=await(null===(e=t.getTarget)||void 0===e?void 0:e.call(t,this));if(i&&n&&o){const t=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(t){const i=[],n=800;q(t,(t=>{i.push(t.rotation.clone())}));const o=(t,s)=>{switch(e){case"x":t.x=s.x;break;case"y":t.y=s.y;break;case"z":t.z=s.z}},a=async()=>{const i=r/180*Math.PI,a=q(t,(async t=>{const a=t.rotation.clone();switch(e){case"x":await this.ssp.animation(a,(new s).set(a.x+i,a.y,a.z),{duration:n},(s=>o(t.rotation,s)));break;case"y":await this.ssp.animation(a,(new s).set(a.x,a.y+i,a.z),{duration:n},(s=>o(t.rotation,s)));break;case"z":await this.ssp.animation(a,(new s).set(a.x,a.y,a.z+i),{duration:n},(s=>o(t.rotation,s)))}}));a instanceof Array?await Promise.all(a):await a,this.ssp.render()};await a(),this.cleanSets.add((()=>{let s=0;q(t,(t=>{t.rotation.copy(i[s++])}))}))}}}}class Z extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("viewpoint",[f.READ_CTX,f.LOCAL]);if(t){const s=Tt(this.getValue(t));s&&this.ssp.setCameraViewpoint(s,!0)}}}class Q extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("space",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,At(this.ssp,e))}}}class $ extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("spaces",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value),n=e.map((t=>At(this.ssp,t)));this.writeContext(i,n)}}}class tt extends E{constructor(t,s){super(t,s)}async exec(t){const s=this.findProp("poi",f.LOCAL),e=this.findProp("out",f.WRITE_CTX);if(s&&e){const t=Tt(s.value),i=Tt(e.value);this.writeContext(i,At(this.ssp,t))}}}class st extends E{constructor(t,s){super(t,s)}async exec(t){const s=this.findProp("pois",f.LOCAL),e=this.findProp("out",f.WRITE_CTX);if(s&&e){const t=Tt(s.value),i=Tt(e.value),n=t.map((t=>At(this.ssp,t)));this.writeContext(i,n)}}}class et extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("value",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,e)}}}class it extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",f.LOCAL);if(t){const s=Tt(t.value),e=new Function("sourceData",s);for(const t in this.ctx){const s=e(this.ctx[t]);null!=s&&!1!==s||delete this.ctx[t]}}}}class nt extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("path",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,At(this.ssp,e))}}}class ot extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("paths",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value),n=e.map((t=>At(this.ssp,t)));this.writeContext(i,n)}}}class at extends E{constructor(t,s){super(t,s)}async exec(t){var s;let e=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(!e){const t=this.findProp("model",[f.READ_CTX,f.LOCAL]);t&&(e=this.getValue(t))}const i=this.findProp("animation",[f.READ_CTX,f.LOCAL]);if(e&&i){let t;if(i.type===f.READ_CTX){const s=this.parser.getVariableNameById(Tt(i.value));t=this.readContext(s)}else t=Tt(i.value);const s=e.animations[t];s&&(this.ssp.playModelAnimation(e,s),this.cleanSets.add((()=>{this.ssp.stopModelAnimation(e,s)})))}}}class rt extends E{constructor(t,s){super(t,s)}async exec(t){var s;let e=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(!e){const t=this.findProp("model",[f.READ_CTX,f.LOCAL]);t&&(e=this.getValue(t))}const i=this.findProp("animation",[f.READ_CTX,f.LOCAL]);if(e&&i){let t;if(i.type===f.READ_CTX){const s=this.parser.getVariableNameById(Tt(i.value));t=this.readContext(s)}else t=Tt(i.value);const s=e.animations[t];s&&this.ssp.stopModelAnimation(e,s)}}}const ct=new Map;function lt(t){var s,e;null===(s=ct.get(t))||void 0===s||s.forEach((t=>t.stop())),null===(e=ct.get(t))||void 0===e||e.clear()}class ht extends E{constructor(t,s){super(t,s)}async exec(t){var s;const e=this.findProp("model",[f.READ_CTX,f.LOCAL]),i=this.findProp("animation",f.LOCAL),n=this.findProp("wait",f.LOCAL);if(e&&i&&n){const o=this.getValue(e),a=Tt(i.value),c=Tt(n.value);if(o){const e=await(null===(s=t.getAnimations)||void 0===s?void 0:s.call(t,this,o,a));if(e){const t=e.find((t=>t.id===a));t&&await Et((async()=>{const s=o.matrix.clone();await async function(t,s,e){var i;const{id:n,keyframes:o}=e,a=new r(t,s);ct.has(n)||ct.set(n,new Set),null===(i=ct.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,o,t),this.cleanSets.add((()=>{lt(t.id),o&&s.decompose(o.position,o.quaternion,o.scale)}))}),c)}}}}}class dt extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){lt(Tt(t.value))}}}const ut=new Map;function pt(t){var s,e;null===(s=ut.get(t))||void 0===s||s.forEach((t=>t.stop())),null===(e=ut.get(t))||void 0===e||e.clear()}class ft extends E{constructor(t,s){super(t,s)}async exec(t){var s;const e=this.findProp("mesh",[f.READ_CTX,f.LOCAL]),i=this.findProp("animation",f.LOCAL),n=this.findProp("wait",f.LOCAL);if(e&&i&&n){const o=this.getValue(e),a=Tt(i.value),c=Tt(n.value);if(o){const i=await(null===(s=t.getComponentAnimations)||void 0===s?void 0:s.call(t,this,o,a));if(i){const t=i.find((t=>t.id===a));if(t){let s=null;"Mesh"===e.valueType?s=o:"Model"===e.valueType&&(s=gt(o,t.refId)),s&&await Et((async()=>{if(s){const e=s.matrix.clone();await async function(t,s,e){var i;const{id:n,keyframes:o}=e,a=new r(t,s);ut.has(n)||ut.set(n,new Set),null===(i=ut.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,s,t),this.cleanSets.add((()=>{pt(t.id),s&&e.decompose(s.position,s.quaternion,s.scale)}))}}),c)}}}}}}class Ct extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){pt(Tt(t.value))}}}function Tt(t){return JSON.parse(t)}async function Et(t,s){s?await t():t()}function At(t,s,e){const i=t.getObjectById(s);if(i)return i;{const{viewport:{scene:i}}=t;return gt(null!=e?e:i,s)}}function gt(t,s){if(t.userData.key===s||t.uuid===s)return t;for(let e=0,i=t.children.length;e<i;e++){const i=gt(t.children[e],s);if(null!==i)return i}return null}const{utils:{sleep:Ot}}=a;class vt extends e{constructor(t,s){super(),this.onNodeBefore=null,this.onNodeAfter=null,this.ssp=t,this.flow=s,this.nodes=[],this.nodesMap=new Map,this.edges=[],this.edgesMap=new Map}addNode(t){this.nodes.push(t),this.nodesMap.set(t.id,t)}addEdge(t){this.edges.push(t),this.edgesMap.set(t.id,t)}getNodeById(t){return this.nodesMap.get(t)}getEdgeById(t){return this.edgesMap.get(t)}clear(){this.nodes.length=0,this.nodesMap.clear(),this.edges.length=0,this.edgesMap.clear()}parse(){this.clear();const{nodes:t,edges:s}=this.flow;t.forEach((t=>{const s=function(t,s){switch(s.type){case C.START:return new A(t,s);case C.COLOR:return new g(t,s);case C.NUMBER:return new O(t,s);case C.HIGHLIGHT:return new L(t,s);case C.UN_HIGHLIGHT:return new I(t,s);case C.OPACITY:return new N(t,s);case C.UN_OPACITY:return new x(t,s);case C.EMISSIVE:return new _(t,s);case C.UN_EMISSIVE:return new S(t,s);case C.MESH:return new R(t,s);case C.MESHES:return new H(t,s);case C.MODEL:return new j(t,s);case C.MODELS:return new X(t,s);case C.SPACE:return new Q(t,s);case C.SPACES:return new $(t,s);case C.POIS:return new st(t,s);case C.POI:return new tt(t,s);case C.PATH:return new nt(t,s);case C.PATHS:return new ot(t,s);case C.DELAY:return new B(t,s);case C.CONDITION_NODE:return new k(t,s);case C.SHOW:return new G(t,s);case C.HIDE:return new W(t,s);case C.CLIP_ANIMATION:return new at(t,s);case C.UN_CLIP_ANIMATION:return new rt(t,s);case C.TWEEN_ANIMATION:return new ht(t,s);case C.UN_TWEEN_ANIMATION:return new dt(t,s);case C.COMPONENT_TWEEN_ANIMATION:return new ft(t,s);case C.UN_COMPONENT_TWEEN_ANIMATION:return new Ct(t,s);case C.TRANSLATE:return new z(t,s);case C.ROTATE:return new J(t,s);case C.SCALE:return new K(t,s);case C.FLY_TO:return new Z(t,s);case C.DATA_EXTRACTION:return new et(t,s);case C.DATA_FILTER:return new it(t,s);default:return new E(t,s)}}(this,t);this.addNode(s)})),s.forEach((t=>{const s=new p(t);this.addEdge(s);const e=this.getNodeById(t.source),i=this.getNodeById(t.target);e&&i&&(e.postNodes.push(i),i.prevNodes.push(e))}))}async run(t={}){const s=this.nodes.filter((t=>t.prevNodes.length||t.postNodes.length)).map((s=>s.run(t)));await Promise.allSettled(s)}async debug(t={},s=1500){const e=this.onNodeAfter;this.onNodeAfter=async t=>{await Ot(s),null==e||e(t)},await this.run(t)}stop(){this.nodes.forEach((t=>t.reject(new Error("Flow stopped"))))}cleanup(){this.nodes.sort(((t,s)=>s.execOrder-t.execOrder)).forEach((t=>t.cleanup()))}getVariableNameById(t){const s=this.nodes.find((s=>s.id===t));if(s){const t=s.props.find((t=>"out"===t.name));return t?Tt(t.value):null}return null}dispose(){this.stop(),this.cleanup()}}class Lt extends vt{constructor(t,s){super(t,s),this.flow=s}}function wt(t,s,e,i){if("a"===e&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof s?t!==s||!i:!s.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?i:"a"===e?i.call(t):i?i.value:s.get(t)}var It,yt;"function"==typeof SuppressedError&&SuppressedError,function(t){t.Group="Group",t.Light="Light",t.Model="Model",t.Poi="Poi",t.PoiNode="PoiNode",t.Canvas3D="Canvas3D",t.Topology="Topology",t.Helper="Helper",t.Decal="Decal",t.PluginObject="PluginObject"}(It||(It={})),function(t){t.sbm="SBM",t.sbmx="SBMX",t.glb="GLB",t.gltf="GLTF",t.fbx="FBX",t.obj="OBJ",t.stl="STL"}(yt||(yt={})),new t,new t,new t;const Nt={},Pt=new i;Pt.setRequestHeader(Nt);(new n).load=(t,s,e,i)=>{const n=new Image;return Pt.setResponseType("blob"),Pt.load(t,(function(t){n.src=URL.createObjectURL(t),n.onload=()=>{URL.revokeObjectURL(n.src),null==s||s(n)}}),e,i),n};(new o).setRequestHeader(Nt);async function xt(t){return async function(t,s){return await s()}(0,t)}(new u).setRequestHeader(Nt),new t,new t,new t;const mt=(t,s)=>t.userData.key===s||!!t.parent&&mt(t.parent,s);var _t,bt,St;const{groupBy:Mt}=a.utils;class Rt{constructor(t,s,e,i){_t.add(this),this.disposables=[],this.status="ready",this.ssp=t,this.interaction=s,this.flows=e,this.flowsMap=Mt(e,"id"),this.options=i||{},wt(this,_t,"m",bt).call(this)}modelHandler(t){var s;const{target:e,currentTarget:i}=t,n=this.interaction.editionId;n?e.sid!==n&&e.userData.familyId!==n||!mt(i,this.interaction.modelId)||(this.target=e,this.execBehavior()):null===(s=this.interaction.obsTargets)||void 0===s||s.forEach((t=>{t!==e.userData.id&&t!==e.userData.sid||(this.target=e,this.execBehavior())}))}runFlowByIds(t){const s=this.target?async()=>this.target:wt(this,_t,"m",St).bind(this);t.forEach((t=>{const e=this.flowsMap.get(t);if(e){const t=new c(this.ssp,e[0]);t.parse(),xt((()=>t.run({getTarget:s,getAnimations:this.options.getAnimations,getComponentAnimations:this.options.getComponentAnimations})))}}))}async execBehavior(){var t,s,e,i,n;if(null===(t=this.interaction.active)||void 0===t||t)try{this.status="running";const{behaviors:t}=this.interaction;null==t||t.forEach((t=>{if(t.action===l.FLOW)t.actionRefs&&this.runFlowByIds(t.actionRefs)})),(null===(s=this.options)||void 0===s?void 0:s.onTrigger)&&(null===(e=this.options)||void 0===e||e.onTrigger(this.interaction))}catch(t){this.status="error",(null===(i=this.options)||void 0===i?void 0:i.onError)&&(null===(n=this.options)||void 0===n||n.onError(t))}}initMouseClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelClick.add(t),this.disposables.push((()=>this.ssp.signals.modelClick.remove(t)))}initMouseDbClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelDblClick.add(t),this.disposables.push((()=>this.ssp.signals.modelDblClick.remove(t)))}initMouseRightClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelRightClick.add(t),this.disposables.push((()=>this.ssp.signals.modelRightClick.remove(t)))}initLoaded(){(()=>{this.execBehavior()})()}modelPropChangeHandler(t){var s,e;(null===(s=null==t?void 0:t.target)||void 0===s?void 0:s.refId)&&"code"!==this.ssp.utils.propertiesCtx.source&&(null===(e=t.target)||void 0===e||e.refId,this.interaction.editionId&&(this.target=this.ssp.getObjectByUserDataProperty("familyId",this.interaction.editionId)[0]),this.execBehavior())}initModelPropChange(){const t=this.modelPropChangeHandler.bind(this);this.ssp.signals.propertiesChanged.add(t),this.disposables.push((()=>this.ssp.signals.propertiesChanged.remove(t)))}initThingPropChange(){}initThingEvent(){}dispose(){this.disposables.forEach((t=>t()))}}var Dt,Ht,jt,Xt,Bt,kt,Vt,Gt;_t=new WeakSet,bt=function(){switch(this.interaction.type){case h.MOUSE_CLICK:this.initMouseClick();break;case h.MOUSE_DB_CLICK:this.initMouseDbClick();break;case h.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case h.LOADED:this.initLoaded();break;case h.THING_PROP_CHANGE:this.initThingPropChange();break;case h.THING_EVENT:this.initThingEvent();break;case h.MODEL_PROP_CHANGE:this.initModelPropChange()}},St=async function(t){const{obsType:s,obsTargets:e,editionId:i}=this.interaction;if(s===d.GLOBAL)return null;if(s===d.INSTANCE){let t;i?(t=this.ssp.getModelById(i),t||console.warn("Target not found:",i)):t=null==e?void 0:e.map((t=>{const s=this.ssp.getModelById(t);return s||console.warn("Target not found:",e[0]),s}))[0]}return null},function(t){t.GLOBAL="GLOBAL",t.SELF="SELF",t.OTHER="OTHER"}(Dt||(Dt={})),function(t){t.FLOW="FLOW",t.ANIMATION="ANIMATION",t.DELAY="DELAY"}(Ht||(Ht={})),function(t){t.GLOBAL="GLOBAL",t.INSTANCE="INSTANCE",t.FAMILY="FAMILY"}(jt||(jt={})),function(t){t.MOUSE_CLICK="MOUSE_CLICK",t.MOUSE_DB_CLICK="MOUSE_DB_CLICK",t.MOUSE_RIGHT_CLICK="MOUSE_RIGHT_CLICK",t.THING_PROP_CHANGE="THING_PROP_CHANGE",t.THING_EVENT="THING_EVENT",t.LOADED="LOADED",t.MODEL_PROP_CHANGE="MODEL_PROP_CHANGE"}(Xt||(Xt={}));const{groupBy:Ut}=a.utils;class Wt extends Rt{constructor(t,s,e,i){super(t,s,e,i),Bt.add(this),this.flows=e,this.flowsMap=Ut(e,"id"),wt(this,Bt,"m",kt).call(this)}modelHandler(t){var s;const{currentTarget:e}=t;null===(s=this.interaction.obsTargets)||void 0===s||s.forEach((t=>{t===e.userData.key&&this.execBehavior()}))}runFlowByIds(t){const s=wt(this,Bt,"m",Vt).bind(this);t.forEach((t=>{const e=this.flowsMap.get(t);if(e){const t=new Lt(this.ssp,e[0]);t.parse(),xt((()=>t.run({getTarget:s})))}}))}async execBehavior(){var t,s,e,i;try{const{behaviors:e}=this.interaction;null==e||e.forEach((t=>{if(t.action===Ht.FLOW)t.actionRefs&&this.runFlowByIds(t.actionRefs)})),(null===(t=this.options)||void 0===t?void 0:t.onTrigger)&&(null===(s=this.options)||void 0===s||s.onTrigger(this.interaction))}catch(t){(null===(e=this.options)||void 0===e?void 0:e.onError)&&(null===(i=this.options)||void 0===i||i.onError(t))}}initLoaded(){const t=()=>{this.execBehavior()};wt(this,Bt,"m",Vt).call(this).then((s=>{s&&(s.addEventListener("load",t),this.disposables.push((()=>s.removeEventListener("load",t))))}))}initThingPropChange(){const t=wt(this,Bt,"m",Gt).bind(this);this.ssp.signals.thingModelPropsChange.add(t),this.disposables.push((()=>this.ssp.signals.thingModelPropsChange.remove(t)))}initThingEvent(){}onThingPropChange(t){this.ssp.signals.thingModelPropsChange.dispatch({propKey:t})}}Bt=new WeakSet,kt=function(){switch(this.interaction.type){case Xt.MOUSE_CLICK:this.initMouseClick();break;case Xt.MOUSE_DB_CLICK:this.initMouseDbClick();break;case Xt.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case Xt.LOADED:this.initLoaded();break;case Xt.THING_PROP_CHANGE:this.initThingPropChange();break;case Xt.THING_EVENT:this.initThingEvent();break;case Xt.MODEL_PROP_CHANGE:this.initModelPropChange()}},Vt=async function(t){console.log("currentNode",t);const{obsType:s,obsTargets:e}=this.interaction;if(s===jt.GLOBAL)return null;if(s===jt.INSTANCE){const t=null==e?void 0:e.map((t=>{const s=this.ssp.getModelById(t);return s||console.warn("Target not found:",t),s}));return t?t[0]:null}return null},Gt=function(t){var s;const{propKey:e}=t;null===(s=this.interaction.obsProps)||void 0===s||s.forEach((t=>{t===e&&this.execBehavior()}))};export{Lt as ComponentFlowParser,Wt as ComponentTrigger,vt as FlowParser,Ht as InteractionAction,Dt as InteractionActionType,jt as InteractionObsType,Xt as InteractionType,E as Node,f as NodePropTypeEnum,C as NodeTypeEnum,Rt as Trigger};
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import SoonSpace, {
|
|
1
|
+
import SoonSpace, { ModelEventParams } from 'soonspacejs';
|
|
2
2
|
import { Trigger } from './Trigger';
|
|
3
|
-
import { Interaction } from './types';
|
|
3
|
+
import { Interaction, TriggerOptions } from './types';
|
|
4
4
|
import { ComponentFlowType } from '../flows/types';
|
|
5
5
|
declare class ComponentTrigger extends Trigger {
|
|
6
|
-
|
|
7
|
-
interaction: Interaction;
|
|
6
|
+
#private;
|
|
8
7
|
flows: ComponentFlowType[];
|
|
9
8
|
flowsMap: Map<string, ComponentFlowType[]>;
|
|
10
|
-
constructor(ssp: SoonSpace,
|
|
11
|
-
init(): void;
|
|
9
|
+
constructor(ssp: SoonSpace, interaction: Interaction, flows: ComponentFlowType[], options: TriggerOptions);
|
|
12
10
|
modelHandler(params: ModelEventParams): void;
|
|
13
11
|
runFlowByIds(flowIds: string[]): void;
|
|
14
12
|
execBehavior(): Promise<void>;
|
|
15
|
-
initMouseClick(): void;
|
|
16
|
-
initMouseDbClick(): void;
|
|
17
|
-
initMouseRightClick(): void;
|
|
18
13
|
initLoaded(): void;
|
|
19
14
|
initThingPropChange(): void;
|
|
20
15
|
initThingEvent(): void;
|
|
16
|
+
onThingPropChange(newProps: string): void;
|
|
21
17
|
}
|
|
22
18
|
export { ComponentTrigger, };
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import SoonSpace from 'soonspacejs';
|
|
1
|
+
import SoonSpace, { Model, ModelEventParams } from 'soonspacejs';
|
|
2
|
+
import { FlowType, Interaction, TriggerOptions } from '@soonspacejs/plugin-flow';
|
|
2
3
|
declare class Trigger {
|
|
4
|
+
#private;
|
|
3
5
|
ssp: SoonSpace;
|
|
6
|
+
interaction: Interaction;
|
|
7
|
+
flows: FlowType[];
|
|
8
|
+
flowsMap: Map<string, FlowType[]>;
|
|
9
|
+
options: TriggerOptions;
|
|
4
10
|
disposables: (() => void)[];
|
|
5
|
-
|
|
11
|
+
status: 'ready' | 'running' | 'error';
|
|
12
|
+
target?: Model;
|
|
13
|
+
constructor(ssp: SoonSpace, interaction: Interaction, flows: FlowType[], options: TriggerOptions);
|
|
14
|
+
modelHandler(params: ModelEventParams): void;
|
|
15
|
+
runFlowByIds(flowIds: string[]): void;
|
|
16
|
+
execBehavior(): Promise<void>;
|
|
17
|
+
initMouseClick(): void;
|
|
18
|
+
initMouseDbClick(): void;
|
|
19
|
+
initMouseRightClick(): void;
|
|
20
|
+
initLoaded(): void;
|
|
21
|
+
modelPropChangeHandler(properties: any): void;
|
|
22
|
+
initModelPropChange(): void;
|
|
23
|
+
initThingPropChange(): void;
|
|
24
|
+
initThingEvent(): void;
|
|
6
25
|
dispose(): void;
|
|
7
26
|
}
|
|
8
27
|
export { Trigger, };
|
package/dist/triggers/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { IAnimation, IComponentAnimation } from '../types';
|
|
3
|
+
import { Node } from '../flows';
|
|
1
4
|
export declare enum InteractionActionType {
|
|
2
5
|
GLOBAL = "GLOBAL",
|
|
3
6
|
SELF = "SELF",
|
|
@@ -19,7 +22,8 @@ export declare enum InteractionType {
|
|
|
19
22
|
MOUSE_RIGHT_CLICK = "MOUSE_RIGHT_CLICK",
|
|
20
23
|
THING_PROP_CHANGE = "THING_PROP_CHANGE",
|
|
21
24
|
THING_EVENT = "THING_EVENT",
|
|
22
|
-
LOADED = "LOADED"
|
|
25
|
+
LOADED = "LOADED",
|
|
26
|
+
MODEL_PROP_CHANGE = "MODEL_PROP_CHANGE"
|
|
23
27
|
}
|
|
24
28
|
export type InteractionBehavior = {
|
|
25
29
|
id: string;
|
|
@@ -31,11 +35,20 @@ export type InteractionBehavior = {
|
|
|
31
35
|
};
|
|
32
36
|
export type Interaction = {
|
|
33
37
|
id: string;
|
|
34
|
-
|
|
38
|
+
sid: string;
|
|
35
39
|
name: string;
|
|
40
|
+
modelId: string;
|
|
36
41
|
type: InteractionType;
|
|
37
42
|
obsType: InteractionObsType;
|
|
38
43
|
obsTargets: string[] | null;
|
|
39
44
|
obsProps: string[] | null;
|
|
40
45
|
behaviors: InteractionBehavior[] | null;
|
|
46
|
+
active: boolean;
|
|
47
|
+
editionId?: string;
|
|
48
|
+
};
|
|
49
|
+
export type TriggerOptions = {
|
|
50
|
+
onError?: (e: Error) => void;
|
|
51
|
+
onTrigger?: (interaction: Interaction) => void;
|
|
52
|
+
getAnimations?: (currentNode: Node, object: Object3D, animationId: string) => Promise<IAnimation[] | null>;
|
|
53
|
+
getComponentAnimations?: (currentNode: Node, object: Object3D, animationId: string) => Promise<IComponentAnimation[] | null>;
|
|
41
54
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-flow",
|
|
3
3
|
"pluginName": "FlowPlugin",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.6",
|
|
5
5
|
"description": "FlowPlugin plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "xunwei",
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "6c1113b3e61e448be7ce9463ed22a75f507d9f67",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.13.
|
|
18
|
+
"soonspacejs": "2.13.6",
|
|
19
19
|
"umanager-animation-parser": "^0.0.6"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/test/test.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import componentThingJson from '../example/scene-test/db/component_thing.json'
|
|
2
|
+
|
|
3
|
+
function generateMockData ( schema: any ): any {
|
|
4
|
+
|
|
5
|
+
const result: Record<string, any> = {}
|
|
6
|
+
|
|
7
|
+
// 遍历schema的properties属性
|
|
8
|
+
for ( const prop of schema.thing.properties ) {
|
|
9
|
+
|
|
10
|
+
const identifier = prop.identifier
|
|
11
|
+
const defineType = prop.define.type
|
|
12
|
+
|
|
13
|
+
switch ( defineType ) {
|
|
14
|
+
|
|
15
|
+
case 'string':
|
|
16
|
+
result[ identifier ] = `模拟${prop.name}`
|
|
17
|
+
break
|
|
18
|
+
case 'int':
|
|
19
|
+
result[ identifier ] = Math.floor( Math.random() * 10000 )
|
|
20
|
+
break
|
|
21
|
+
case 'enum':
|
|
22
|
+
const keys = Object.keys( prop.define.mapping )
|
|
23
|
+
|
|
24
|
+
result[ identifier ] = keys[ Math.floor( Math.random() * keys.length ) ]
|
|
25
|
+
break
|
|
26
|
+
case 'struct':
|
|
27
|
+
result[ identifier ] = generateMockData( { thing: { properties: prop.define.properties, }, } )
|
|
28
|
+
break
|
|
29
|
+
default:
|
|
30
|
+
result[ identifier ] = null
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface SchemaMapping {
|
|
41
|
+
sourceField: string;
|
|
42
|
+
targetField: string;
|
|
43
|
+
transform?: ( value: any ) => any;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function transformData (
|
|
47
|
+
sourceData: any,
|
|
48
|
+
mappings: SchemaMapping[],
|
|
49
|
+
defaultValues: Record<string, any> = {}
|
|
50
|
+
): any {
|
|
51
|
+
|
|
52
|
+
const result: Record<string, any> = { ...defaultValues, }
|
|
53
|
+
|
|
54
|
+
for ( const mapping of mappings ) {
|
|
55
|
+
|
|
56
|
+
const { sourceField, targetField, transform, } = mapping
|
|
57
|
+
|
|
58
|
+
// 获取源数据的值
|
|
59
|
+
const value = sourceField.split( '.' ).reduce( ( obj, key ) =>
|
|
60
|
+
obj && obj[ key ] !== undefined ? obj[ key ] : undefined, sourceData )
|
|
61
|
+
|
|
62
|
+
// 如果存在值并且有transform函数,则应用transform
|
|
63
|
+
if ( value !== undefined ) {
|
|
64
|
+
|
|
65
|
+
const transformedValue = transform ? transform( value ) : value
|
|
66
|
+
|
|
67
|
+
// 将转换后的值设置到目标字段
|
|
68
|
+
const fieldParts = targetField.split( '.' )
|
|
69
|
+
let current = result
|
|
70
|
+
|
|
71
|
+
for ( let i = 0; i < fieldParts.length - 1; i++ ) {
|
|
72
|
+
|
|
73
|
+
const part = fieldParts[ i ]
|
|
74
|
+
|
|
75
|
+
if ( !current[ part ] ) {
|
|
76
|
+
|
|
77
|
+
current[ part ] = {}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
current = current[ part ]
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
current[ fieldParts[ fieldParts.length - 1 ] ] = transformedValue
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return result
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
// 1. 生成模拟数据
|
|
96
|
+
const schema = componentThingJson[ 0 ] // 你的JSON文件中的第一个元素
|
|
97
|
+
const mockData = generateMockData( schema )
|
|
98
|
+
|
|
99
|
+
console.log( '生成的模拟数据:', mockData )
|
|
100
|
+
|
|
101
|
+
// 2. 定义映射(从一种模式到另一种模式)
|
|
102
|
+
const mappings: SchemaMapping[] = [
|
|
103
|
+
{ sourceField: 'name', targetField: 'user.basicInfo.fullName', },
|
|
104
|
+
{ sourceField: 'id', targetField: 'user.basicInfo.idNumber', },
|
|
105
|
+
{ sourceField: 'gender', targetField: 'user.basicInfo.gender',
|
|
106
|
+
transform: ( value ) => value === 'male' ? '男' : ( value === 'female' ? '女' : '未知' ), },
|
|
107
|
+
{ sourceField: 'phoneNumber', targetField: 'user.contact.mobile', },
|
|
108
|
+
{ sourceField: 'address', targetField: 'user.contact.address', },
|
|
109
|
+
{ sourceField: 'image.data', targetField: 'user.avatar',
|
|
110
|
+
transform: ( value ) => ( { url: value, } ), }
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
// 3. 转换数据
|
|
114
|
+
const transformedData = transformData( mockData, mappings, {
|
|
115
|
+
version: '1.0',
|
|
116
|
+
createdAt: new Date().toISOString(),
|
|
117
|
+
} )
|
|
118
|
+
|
|
119
|
+
console.log( '转换后的数据:', transformedData )
|