@soonspacejs/plugin-flow 2.13.1 → 2.13.2
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 +10 -0
- package/dist/flows/nodes/ColorNode.d.ts +2 -2
- package/dist/flows/nodes/DelayNode.d.ts +2 -2
- package/dist/flows/nodes/EmissiveNode.d.ts +4 -2
- package/dist/flows/nodes/HideNode.d.ts +4 -2
- package/dist/flows/nodes/HighlightNode.d.ts +4 -2
- package/dist/flows/nodes/MeshNode.d.ts +2 -2
- package/dist/flows/nodes/MeshesNode.d.ts +2 -2
- package/dist/flows/nodes/ModelNode.d.ts +2 -2
- package/dist/flows/nodes/ModelsNode.d.ts +2 -2
- package/dist/flows/nodes/Node.d.ts +9 -2
- package/dist/flows/nodes/NumberNode.d.ts +2 -2
- package/dist/flows/nodes/OpacityNode.d.ts +4 -2
- package/dist/flows/nodes/ShowNode.d.ts +4 -2
- package/dist/flows/nodes/StartNode.d.ts +2 -2
- package/dist/flows/nodes/UnEmissiveNode.d.ts +4 -2
- package/dist/flows/nodes/UnHighlightNode.d.ts +4 -2
- package/dist/flows/nodes/UnOpacityNode.d.ts +4 -2
- package/dist/flows/nodes/clip-animation/ClipAnimationNode.d.ts +2 -2
- package/dist/flows/nodes/clip-animation/UnClipAnimationNode.d.ts +2 -2
- package/dist/flows/nodes/component-tween-animation/ComponentTweenAnimationNode.d.ts +2 -2
- package/dist/flows/nodes/component-tween-animation/UnComponentTweenAnimationNode.d.ts +2 -2
- package/dist/flows/nodes/tween-animation/TweenAnimationNode.d.ts +2 -2
- package/dist/flows/nodes/tween-animation/UnTweenAnimationNode.d.ts +2 -2
- package/dist/flows/utils.d.ts +2 -1
- package/dist/index.esm.js +1 -1
- package/package.json +3 -3
|
@@ -9,6 +9,8 @@ declare class FlowParser {
|
|
|
9
9
|
nodesMap: Map<Node['id'], Node>;
|
|
10
10
|
edges: Edge[];
|
|
11
11
|
edgesMap: Map<Edge['id'], Edge>;
|
|
12
|
+
onNodeBefore: Node['onBefore'];
|
|
13
|
+
onNodeAfter: Node['onAfter'];
|
|
12
14
|
constructor(ssp: SoonSpace, flow: FlowType);
|
|
13
15
|
addNode(node: Node): void;
|
|
14
16
|
addEdge(edge: Edge): void;
|
|
@@ -25,5 +27,13 @@ declare class FlowParser {
|
|
|
25
27
|
* @param ctx
|
|
26
28
|
*/
|
|
27
29
|
run(global?: NodeGlobalType): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* 停止流程
|
|
32
|
+
*/
|
|
33
|
+
stop(): void;
|
|
34
|
+
/**
|
|
35
|
+
* 清理流程
|
|
36
|
+
*/
|
|
37
|
+
cleanup(): void;
|
|
28
38
|
}
|
|
29
39
|
export { FlowParser, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class ColorNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { ColorNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class DelayNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { DelayNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { FlowParser } from '../FlowParser';
|
|
2
3
|
import { NodeType } from '../types';
|
|
3
4
|
import { Node } from './Node';
|
|
4
5
|
declare class EmissiveNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterEmissiveObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { EmissiveNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
|
+
import { Object3D } from 'three';
|
|
4
5
|
declare class HideNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterHideObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { HideNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { FlowParser } from '../FlowParser';
|
|
2
3
|
import { NodeType } from '../types';
|
|
3
4
|
import { Node } from './Node';
|
|
4
5
|
declare class HighlightNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterHighlightObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { HighlightNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeGlobalType, NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class MeshNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(global: NodeGlobalType): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { MeshNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeGlobalType, NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class MeshesNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(global: NodeGlobalType): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { MeshesNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class ModelNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { ModelNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class ModelsNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { ModelsNode, };
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import SoonSpace from 'soonspacejs';
|
|
2
|
+
import { FlowParser } from '../FlowParser';
|
|
2
3
|
import { NodeType, NodeCtxType, NodePropType, NodeGlobalType, NodeTypeEnum } from '../types';
|
|
3
4
|
declare class Node {
|
|
5
|
+
parser: FlowParser;
|
|
4
6
|
ssp: SoonSpace;
|
|
5
7
|
id: string;
|
|
6
8
|
type: NodeTypeEnum;
|
|
7
9
|
props: NodeType['props'];
|
|
8
10
|
prevNodes: Node[];
|
|
9
11
|
postNodes: Node[];
|
|
12
|
+
execOrder: number;
|
|
10
13
|
ctx: NodeCtxType;
|
|
11
14
|
promise: Promise<void>;
|
|
12
15
|
resolve: () => void;
|
|
13
16
|
reject: (reason?: any) => void;
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
cleanSets: Set<() => void>;
|
|
18
|
+
onBefore: ((node: Node) => (Promise<void> | void)) | null;
|
|
19
|
+
onAfter: ((node: Node) => (Promise<void> | void)) | null;
|
|
20
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
21
|
+
init(): void;
|
|
16
22
|
readContext<T = any>(key: string): T | undefined;
|
|
17
23
|
writeContext(key: string, value: any): void;
|
|
18
24
|
findProp(name: string, type: NodePropType['type']): NodePropType | undefined;
|
|
@@ -34,5 +40,6 @@ declare class Node {
|
|
|
34
40
|
* @param global
|
|
35
41
|
*/
|
|
36
42
|
run(global: NodeGlobalType): Promise<void>;
|
|
43
|
+
cleanup(): void;
|
|
37
44
|
}
|
|
38
45
|
export { Node, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class NumberNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { NumberNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { FlowParser } from '../FlowParser';
|
|
2
3
|
import { NodeType } from '../types';
|
|
3
4
|
import { Node } from './Node';
|
|
4
5
|
declare class OpacityNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterOpacityObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { OpacityNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
|
+
import { Object3D } from 'three';
|
|
4
5
|
declare class ShowNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterShowObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { ShowNode, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../FlowParser';
|
|
2
2
|
import { NodeType } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
4
|
declare class StartNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
}
|
|
7
7
|
export { StartNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { FlowParser } from '../FlowParser';
|
|
2
3
|
import { NodeType } from '../types';
|
|
3
4
|
import { Node } from './Node';
|
|
4
5
|
declare class UnEmissiveNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterUnEmissiveObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { UnEmissiveNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { FlowParser } from '../FlowParser';
|
|
2
3
|
import { NodeType } from '../types';
|
|
3
4
|
import { Node } from './Node';
|
|
4
5
|
declare class UnHighlightNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterUnHighlightObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { UnHighlightNode, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { FlowParser } from '../FlowParser';
|
|
2
3
|
import { NodeType } from '../types';
|
|
3
4
|
import { Node } from './Node';
|
|
4
5
|
declare class UnOpacityNode extends Node {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
7
|
+
filterUnOpacityObject(objectsValue: Object3D[] | Object3D): Object3D<import("three").Object3DEventMap>[];
|
|
6
8
|
exec(): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export { UnOpacityNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../../FlowParser';
|
|
2
2
|
import { NodeGlobalType, NodeType } from '../../types';
|
|
3
3
|
import { Node } from '../Node';
|
|
4
4
|
declare class ClipAnimationNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(global: NodeGlobalType): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { ClipAnimationNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../../FlowParser';
|
|
2
2
|
import { NodeGlobalType, NodeType } from '../../types';
|
|
3
3
|
import { Node } from '../Node';
|
|
4
4
|
declare class UnClipAnimationNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(global: NodeGlobalType): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { UnClipAnimationNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../../FlowParser';
|
|
2
2
|
import { NodeType, NodeGlobalType } from '../../types';
|
|
3
3
|
import { Node } from '../Node';
|
|
4
4
|
declare class ComponentTweenAnimationNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(global: NodeGlobalType): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { ComponentTweenAnimationNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../../FlowParser';
|
|
2
2
|
import { NodeType } from '../../types';
|
|
3
3
|
import { Node } from '../Node';
|
|
4
4
|
declare class UnComponentTweenAnimationNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { UnComponentTweenAnimationNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../../FlowParser';
|
|
2
2
|
import { NodeType, NodeGlobalType } from '../../types';
|
|
3
3
|
import { Node } from '../Node';
|
|
4
4
|
declare class TweenAnimationNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(global: NodeGlobalType): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { TweenAnimationNode, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowParser } from '../../FlowParser';
|
|
2
2
|
import { NodeType } from '../../types';
|
|
3
3
|
import { Node } from '../Node';
|
|
4
4
|
declare class UnTweenAnimationNode extends Node {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(parser: FlowParser, node: NodeType);
|
|
6
6
|
exec(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export { UnTweenAnimationNode, };
|
package/dist/flows/utils.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import SoonSpace, { Model } from 'soonspacejs';
|
|
3
|
+
import { FlowParser } from './FlowParser';
|
|
3
4
|
import { Node } from './nodes';
|
|
4
5
|
import { NodeType } from './types';
|
|
5
|
-
export declare function parseNodeByType(
|
|
6
|
+
export declare function parseNodeByType(parser: FlowParser, node: NodeType): Node;
|
|
6
7
|
export declare function parseValue<T = any>(value: string): T;
|
|
7
8
|
export declare function waitFor(fn: () => Promise<void>, wait: boolean): Promise<void>;
|
|
8
9
|
export declare function getModelByUuid(ssp: SoonSpace, uuid: string): Model | null;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import s from"soonspacejs";import{AnimationPlayer as t}from"umanager-animation-parser";class e{constructor(s){this.id=s.id,this.source=s.source,this.target=s.target}}class i{constructor(s,t){this.prevNodes=[],this.postNodes=[],this.ssp=s,this.id=t.id,this.type=t.type,this.props=t.props,this.reset()}reset(){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){await this.waitForPrevNodes(),this.mergeContext(),await this.exec(s).then(this.resolve)}}class n extends i{constructor(s,t){super(s,t)}}var o,a;!function(s){s.LOCAL="LOCAL",s.READ_CTX="READ_CTX",s.WRITE_CTX="WRITE_CTX"}(o||(o={})),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"}(a||(a={}));class r extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("color",o.LOCAL),t=this.findProp("out",o.WRITE_CTX);s&&t&&this.writeContext(H(t.value),H(s.value))}}class c extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("number",o.LOCAL),t=this.findProp("out",o.WRITE_CTX);s&&t&&this.writeContext(H(t.value),H(s.value))}}class h extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX),t=this.findProp("color",o.READ_CTX),e=this.findProp("opacity",o.READ_CTX);if(s&&t&&e){const i=this.readContext(H(s.value)),n=this.readContext(H(t.value)),o=this.readContext(H(e.value));i&&this.ssp.highlightShow(i,{color:n,opacity:o})}}}class l extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX);if(s){const t=this.readContext(H(s.value));t&&this.ssp.unHighlightShow(t)}}}class d extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX),t=this.findProp("color",o.READ_CTX),e=this.findProp("opacity",o.READ_CTX);if(s&&t&&e){const i=this.readContext(H(s.value)),n=this.readContext(H(t.value)),o=this.readContext(H(e.value));i&&this.ssp.opacityShow(i,{color:n,opacity:o})}}}class u extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX);if(s){const t=this.readContext(H(s.value));t&&this.ssp.unOpacityShow(t)}}}class p extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX),t=this.findProp("color",o.READ_CTX),e=this.findProp("baseColor",o.READ_CTX),i=this.findProp("minOpacity",o.READ_CTX),n=this.findProp("maxOpacity",o.READ_CTX),a=this.findProp("duration",o.READ_CTX);if(s&&t&&e&&i&&n&&a){const o=this.readContext(H(s.value)),r=this.readContext(H(t.value)),c=this.readContext(H(e.value)),h=this.readContext(H(i.value)),l=this.readContext(H(n.value)),d=this.readContext(H(a.value));o&&this.ssp.emissiveShow(o,{color:r,baseColor:c,minOpacity:h,maxOpacity:l,duration:d})}}}class E extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX);if(s){const t=this.readContext(H(s.value));t&&this.ssp.unEmissiveShow(t)}}}const C=Symbol("meshCache");class T extends i{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[C]||(s[C]={});const n=this.findProp("mesh",o.LOCAL),a=this.findProp("out",o.WRITE_CTX);if(n&&a){let t=null;const e=H(n.value),o=H(a.value),r=s[C][e];if(r)return void(t=r);const c=b(i,e);c&&(t=c,s[C][e]=c),this.writeContext(o,t)}}}const f=Symbol("meshesCache");class I extends i{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[f]||(s[f]={});const n=this.findProp("meshes",o.LOCAL),a=this.findProp("out",o.WRITE_CTX);if(n&&a){const t=[],e=H(n.value),o=H(a.value);e.forEach((e=>{const n=s[f][e];if(n)return void t.push(n);const o=b(i,e);o&&(t.push(o),s[f][e]=o)})),this.writeContext(o,t)}}}class N extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("model",o.LOCAL),t=this.findProp("out",o.WRITE_CTX);if(s&&t){const o=H(s.value),a=H(t.value);this.writeContext(a,(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 A extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("models",o.LOCAL),t=this.findProp("out",o.WRITE_CTX);if(s&&t){const e=H(s.value),i=H(t.value);this.writeContext(i,function(s,t){const e=new Set(t);return s.getAllModel().filter((s=>e.has(s.userData.id)||e.has(s.userData.uuid)))}(this.ssp,e))}}}class v extends i{constructor(s,t){super(s,t)}async exec(){const t=this.findProp("delay",o.LOCAL);if(t){const e=H(t.value);await s.utils.sleep(e)}}}const{objectHandle:O}=s.utils;class _ extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX);if(s){const t=this.readContext(H(s.value));t&&(O(t,(s=>{s.visible=!0})),this.ssp.render())}}}const{objectHandle:L}=s.utils;class x extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("objects",o.READ_CTX);if(s){const t=this.readContext(H(s.value));t&&(L(t,(s=>{s.visible=!1})),this.ssp.render())}}}class M extends i{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",o.READ_CTX);s&&(e=this.readContext(H(s.value)))}const i=this.findProp("animation",o.LOCAL);if(e&&i){const s=H(i.value),t=e.animations[s];t&&this.ssp.playModelAnimation(e,t)}}}class w extends i{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",o.READ_CTX);s&&(e=this.readContext(H(s.value)))}const i=this.findProp("animation",o.LOCAL);if(e&&i){const s=H(i.value),t=e.animations[s];t&&this.ssp.stopModelAnimation(e,t)}}}const g=new Map;class P extends i{constructor(s,t){super(s,t)}async exec(s){var e;const i=this.findProp("object",o.READ_CTX),n=this.findProp("animation",o.LOCAL),a=this.findProp("wait",o.LOCAL);if(i&&n&&a){const o=this.readContext(H(i.value)),r=H(n.value),c=H(a.value);if(o){const i=await(null===(e=s.getAnimations)||void 0===e?void 0:e.call(s,this,o,r));if(i){const s=i.find((s=>s.id===r));s&&await R((async()=>{await async function(s,e,i){var n;const{id:o,keyframes:a}=i,r=new t(s,e);g.has(o)||g.set(o,new Set),null===(n=g.get(o))||void 0===n||n.add(r),await r.play(a)}(this.ssp,o,s)}),c)}}}}}class y extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",o.LOCAL);if(s){const n=H(s.value);t=n,null===(e=g.get(t))||void 0===e||e.forEach((s=>s.stop())),null===(i=g.get(t))||void 0===i||i.clear()}var t,e,i}}const m=new Map;class D extends i{constructor(s,t){super(s,t)}async exec(s){var e;const i=this.findProp("object",o.READ_CTX),n=this.findProp("animation",o.LOCAL),a=this.findProp("wait",o.LOCAL);if(i&&n&&a){const o=this.readContext(H(i.value)),r=H(n.value),c=H(a.value);if(o){const n=await(null===(e=s.getComponentAnimations)||void 0===e?void 0:e.call(s,this,o,r));if(n){const s=n.find((s=>s.id===r));if(s){let e=null;"Mesh"===i.valueType?e=o:"Model"===i.valueType&&(e=b(o,s.refId)),e&&await R((async()=>{e&&await async function(s,e,i){var n;const{id:o,keyframes:a}=i,r=new t(s,e);m.has(o)||m.set(o,new Set),null===(n=m.get(o))||void 0===n||n.add(r),await r.play(a)}(this.ssp,e,s)}),c)}}}}}}class S extends i{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",o.LOCAL);if(s){const n=H(s.value);t=n,null===(e=m.get(t))||void 0===e||e.forEach((s=>s.stop())),null===(i=m.get(t))||void 0===i||i.clear()}var t,e,i}}function H(s){return JSON.parse(s)}async function R(s,t){t?await s():s()}function b(s,t){if(s.userData.key===t)return s;for(let e=0,i=s.children.length;e<i;e++){const i=b(s.children[e],t);if(null!==i)return i}return null}class X{constructor(s,t){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 a.START:return new n(s,t);case a.COLOR:return new r(s,t);case a.NUMBER:return new c(s,t);case a.HIGHLIGHT:return new h(s,t);case a.UN_HIGHLIGHT:return new l(s,t);case a.OPACITY:return new d(s,t);case a.UN_OPACITY:return new u(s,t);case a.EMISSIVE:return new p(s,t);case a.UN_EMISSIVE:return new E(s,t);case a.MESH:return new T(s,t);case a.MESHES:return new I(s,t);case a.MODEL:return new N(s,t);case a.MODELS:return new A(s,t);case a.DELAY:return new v(s,t);case a.SHOW:return new _(s,t);case a.HIDE:return new x(s,t);case a.CLIP_ANIMATION:return new M(s,t);case a.UN_CLIP_ANIMATION:return new w(s,t);case a.TWEEN_ANIMATION:return new P(s,t);case a.UN_TWEEN_ANIMATION:return new y(s,t);case a.COMPONENT_TWEEN_ANIMATION:return new D(s,t);case a.UN_COMPONENT_TWEEN_ANIMATION:return new S(s,t);default:return new i(s,t)}}(this.ssp,s);this.addNode(t)})),t.forEach((s=>{const t=new e(s);this.addEdge(t);const i=this.getNodeById(s.source),n=this.getNodeById(s.target);i&&n&&(i.postNodes.push(n),n.prevNodes.push(i))}))}async run(s={}){const t=this.nodes.map((t=>t.run(s)));await Promise.all(t)}}class U extends X{constructor(s,t){super(s,t),this.flow=t}}class G{constructor(s){this.disposables=[],this.ssp=s}dispose(){this.disposables.forEach((s=>s()))}}var W,k,B,j;!function(s){s.GLOBAL="GLOBAL",s.SELF="SELF",s.OTHER="OTHER"}(W||(W={})),function(s){s.FLOW="FLOW",s.ANIMATION="ANIMATION",s.DELAY="DELAY"}(k||(k={})),function(s){s.GLOBAL="GLOBAL",s.INSTANCE="INSTANCE",s.FAMILY="FAMILY"}(B||(B={})),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"}(j||(j={}));const{groupBy:Y}=s.utils;class F extends G{constructor(s,t,e,i){super(s),this.target=t,this.interaction=e,this.flows=i,this.flowsMap=Y(i,"id"),this.init()}init(){switch(this.interaction.type){case j.MOUSE_CLICK:this.initMouseClick();break;case j.MOUSE_DB_CLICK:this.initMouseDbClick();break;case j.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case j.LOADED:this.initLoaded();break;case j.THING_PROP_CHANGE:this.initThingPropChange();break;case j.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 U(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===k.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{U as ComponentFlowParser,F as ComponentTrigger,X as FlowParser,k as InteractionAction,W as InteractionActionType,B as InteractionObsType,j as InteractionType,o as NodePropTypeEnum,a as NodeTypeEnum,G as Trigger};
|
|
1
|
+
import t from"soonspacejs";import{AnimationPlayer as s}from"umanager-animation-parser";class e{constructor(t){this.id=t.id,this.source=t.source,this.target=t.target}}let i=0;class n{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.init()}init(){this.ctx={},this.promise=new Promise(((t,s)=>{this.resolve=t,this.reject=s}))}readContext(t){return this.ctx[t]}writeContext(t,s){this.ctx[t]=s}findProp(t,s){return this.props.find((e=>e.name===t&&e.type===s))}async waitForPrevNodes(){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,n,o;await(null===(e=null!==(s=this.onBefore)&&void 0!==s?s:this.parser.onNodeBefore)||void 0===e?void 0:e(this)),await this.waitForPrevNodes(),this.mergeContext();try{this.execOrder=++i,await this.exec(t).then(this.resolve)}catch(t){throw this.reject(t),t}await(null===(o=null!==(n=this.onAfter)&&void 0!==n?n:this.parser.onNodeAfter)||void 0===o?void 0:o(this))}cleanup(){this.cleanSets.forEach((t=>t())),this.cleanSets.clear()}}class o extends n{constructor(t,s){super(t,s)}}var a,c;!function(t){t.LOCAL="LOCAL",t.READ_CTX="READ_CTX",t.WRITE_CTX="WRITE_CTX"}(a||(a={})),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.DELAY="DELAY",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"}(c||(c={}));class r extends n{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("color",a.LOCAL),s=this.findProp("out",a.WRITE_CTX);t&&s&&this.writeContext(k(s.value),k(t.value))}}class h extends n{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("number",a.LOCAL),s=this.findProp("out",a.WRITE_CTX);t&&s&&this.writeContext(k(s.value),k(t.value))}}const{objectHandle:l}=t.utils;class d extends n{constructor(t,s){super(t,s)}filterHighlightObject(t){const s=[];return l(t,(t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)||s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX),s=this.findProp("color",a.READ_CTX),e=this.findProp("opacity",a.READ_CTX);if(t&&s&&e){const i=this.readContext(k(t.value)),n=this.readContext(k(s.value)),o=this.readContext(k(e.value));if(i){const t=this.filterHighlightObject(i);this.ssp.highlightShow(t,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unHighlightShow(t)}))}}}}const{objectHandle:u}=t.utils;class p extends n{constructor(t,s){super(t,s)}filterUnHighlightObject(t){const s=[];return u(t,(t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)&&s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX);if(t){const s=this.readContext(k(t.value));if(s){const t=this.filterUnHighlightObject(s);this.ssp.unHighlightShow(t),this.cleanSets.add((()=>{this.ssp.highlightShow(t)}))}}}}const{objectHandle:f}=t.utils;class E extends n{constructor(t,s){super(t,s)}filterOpacityObject(t){const s=[];return f(t,(t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)||s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX),s=this.findProp("color",a.READ_CTX),e=this.findProp("opacity",a.READ_CTX);if(t&&s&&e){const i=this.readContext(k(t.value)),n=this.readContext(k(s.value)),o=this.readContext(k(e.value));if(i){const t=this.filterOpacityObject(i);this.ssp.opacityShow(t,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unOpacityShow(t)}))}}}}const{objectHandle:C}=t.utils;class O extends n{constructor(t,s){super(t,s)}filterUnOpacityObject(t){const s=[];return C(t,(t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)&&s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX);if(t){const s=this.readContext(k(t.value));if(s){const t=this.filterUnOpacityObject(s);this.ssp.unOpacityShow(t),this.cleanSets.add((()=>{this.ssp.opacityShow(t)}))}}}}const{objectHandle:v}=t.utils;class T extends n{constructor(t,s){super(t,s)}filterEmissiveObject(t){const s=[];return v(t,(t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)||s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX),s=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(t&&s&&e&&i&&n&&o){const a=this.readContext(k(t.value)),c=this.readContext(k(s.value)),r=this.readContext(k(e.value)),h=this.readContext(k(i.value)),l=this.readContext(k(n.value)),d=this.readContext(k(o.value));if(a){const t=this.filterEmissiveObject(a);this.ssp.emissiveShow(t,{color:c,baseColor:r,minOpacity:h,maxOpacity:l,duration:d}),this.cleanSets.add((()=>{this.ssp.unEmissiveShow(t)}))}}}}const{objectHandle:A}=t.utils;class N extends n{constructor(t,s){super(t,s)}filterUnEmissiveObject(t){const s=[];return A(t,(t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)&&s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX);if(t){const s=this.readContext(k(t.value));if(s){const t=this.filterUnEmissiveObject(s);this.ssp.unEmissiveShow(t),this.cleanSets.add((()=>{this.ssp.emissiveShow(t)}))}}}}const I=Symbol("meshCache");class w extends n{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[I]||(t[I]={});const n=this.findProp("mesh",a.LOCAL),o=this.findProp("out",a.WRITE_CTX);if(n&&o){let s=null;const e=k(n.value),a=k(o.value),c=t[I][e];if(c)return void(s=c);const r=F(i,e);r&&(s=r,t[I][e]=r),this.writeContext(a,s)}}}const _=Symbol("meshesCache");class x extends n{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[_]||(t[_]={});const n=this.findProp("meshes",a.LOCAL),o=this.findProp("out",a.WRITE_CTX);if(n&&o){const s=[],e=k(n.value),a=k(o.value);e.forEach((e=>{const n=t[_][e];if(n)return void s.push(n);const o=F(i,e);o&&(s.push(o),t[_][e]=o)})),this.writeContext(a,s)}}}class g extends n{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",a.LOCAL),s=this.findProp("out",a.WRITE_CTX);if(t&&s){const o=k(t.value),a=k(s.value);this.writeContext(a,(e=this.ssp,i=o,null!==(n=e.getAllModel().find((t=>t.userData.id===i||t.userData.uuid===i)))&&void 0!==n?n:null))}var e,i,n}}class L extends n{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("models",a.LOCAL),s=this.findProp("out",a.WRITE_CTX);if(t&&s){const e=k(t.value),i=k(s.value);this.writeContext(i,function(t,s){const e=new Set(s);return t.getAllModel().filter((t=>e.has(t.userData.id)||e.has(t.userData.uuid)))}(this.ssp,e))}}}class M extends n{constructor(t,s){super(t,s)}async exec(){const s=this.findProp("delay",a.LOCAL);if(s){const e=k(s.value);await t.utils.sleep(e)}}}const{objectHandle:S}=t.utils;class m extends n{constructor(t,s){super(t,s)}filterShowObject(t){const s=[];return S(t,(t=>{!1===t.visible&&s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX);if(t){const s=this.readContext(k(t.value));if(s){const t=this.filterShowObject(s),e=s=>{S(t,(t=>{t.visible=s})),this.ssp.render()};e(!0),this.cleanSets.add((()=>e(!1)))}}}}const{objectHandle:y}=t.utils;class P extends n{constructor(t,s){super(t,s)}filterHideObject(t){const s=[];return y(t,(t=>{!0===t.visible&&s.push(t)})),s}async exec(){const t=this.findProp("objects",a.READ_CTX);if(t){const s=this.readContext(k(t.value));if(s){const t=this.filterHideObject(s),e=s=>{y(t,(t=>{t.visible=s})),this.ssp.render()};e(!1),this.cleanSets.add((()=>e(!0)))}}}}class b extends n{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("object",a.READ_CTX);t&&(e=this.readContext(k(t.value)))}const i=this.findProp("animation",a.LOCAL);if(e&&i){const t=k(i.value),s=e.animations[t];s&&(this.ssp.playModelAnimation(e,s),this.cleanSets.add((()=>{this.ssp.stopModelAnimation(e,s)})))}}}class H extends n{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("object",a.READ_CTX);t&&(e=this.readContext(k(t.value)))}const i=this.findProp("animation",a.LOCAL);if(e&&i){const t=k(i.value),s=e.animations[t];s&&this.ssp.stopModelAnimation(e,s)}}}const D=new Map;function R(t){var s,e;null===(s=D.get(t))||void 0===s||s.forEach((t=>t.stop())),null===(e=D.get(t))||void 0===e||e.clear()}class j extends n{constructor(t,s){super(t,s)}async exec(t){var e;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 a=this.readContext(k(i.value)),c=k(n.value),r=k(o.value);if(a){const i=await(null===(e=t.getAnimations)||void 0===e?void 0:e.call(t,this,a,c));if(i){const t=i.find((t=>t.id===c));t&&await Y((async()=>{const e=a.matrix.clone();await async function(t,e,i){var n;const{id:o,keyframes:a}=i,c=new s(t,e);D.has(o)||D.set(o,new Set),null===(n=D.get(o))||void 0===n||n.add(c),await c.play(a)}(this.ssp,a,t),this.cleanSets.add((()=>{R(t.id),a&&e.decompose(a.position,a.quaternion,a.scale)}))}),r)}}}}}class U extends n{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",a.LOCAL);if(t){R(k(t.value))}}}const X=new Map;function G(t){var s,e;null===(s=X.get(t))||void 0===s||s.forEach((t=>t.stop())),null===(e=X.get(t))||void 0===e||e.clear()}class W extends n{constructor(t,s){super(t,s)}async exec(t){var e;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 a=this.readContext(k(i.value)),c=k(n.value),r=k(o.value);if(a){const n=await(null===(e=t.getComponentAnimations)||void 0===e?void 0:e.call(t,this,a,c));if(n){const t=n.find((t=>t.id===c));if(t){let e=null;"Mesh"===i.valueType?e=a:"Model"===i.valueType&&(e=F(a,t.refId)),e&&await Y((async()=>{if(e){const i=e.matrix.clone();await async function(t,e,i){var n;const{id:o,keyframes:a}=i,c=new s(t,e);X.has(o)||X.set(o,new Set),null===(n=X.get(o))||void 0===n||n.add(c),await c.play(a)}(this.ssp,e,t),this.cleanSets.add((()=>{G(t.id),e&&i.decompose(e.position,e.quaternion,e.scale)}))}}),r)}}}}}}class B extends n{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",a.LOCAL);if(t){G(k(t.value))}}}function k(t){return JSON.parse(t)}async function Y(t,s){s?await t():t()}function F(t,s){if(t.userData.key===s)return t;for(let e=0,i=t.children.length;e<i;e++){const i=F(t.children[e],s);if(null!==i)return i}return null}class K{constructor(t,s){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 o(t,s);case c.COLOR:return new r(t,s);case c.NUMBER:return new h(t,s);case c.HIGHLIGHT:return new d(t,s);case c.UN_HIGHLIGHT:return new p(t,s);case c.OPACITY:return new E(t,s);case c.UN_OPACITY:return new O(t,s);case c.EMISSIVE:return new T(t,s);case c.UN_EMISSIVE:return new N(t,s);case c.MESH:return new w(t,s);case c.MESHES:return new x(t,s);case c.MODEL:return new g(t,s);case c.MODELS:return new L(t,s);case c.DELAY:return new M(t,s);case c.SHOW:return new m(t,s);case c.HIDE:return new P(t,s);case c.CLIP_ANIMATION:return new b(t,s);case c.UN_CLIP_ANIMATION:return new H(t,s);case c.TWEEN_ANIMATION:return new j(t,s);case c.UN_TWEEN_ANIMATION:return new U(t,s);case c.COMPONENT_TWEEN_ANIMATION:return new W(t,s);case c.UN_COMPONENT_TWEEN_ANIMATION:return new B(t,s);default:return new n(t,s)}}(this,t);this.addNode(s)})),s.forEach((t=>{const s=new e(t);this.addEdge(s);const i=this.getNodeById(t.source),n=this.getNodeById(t.target);i&&n&&(i.postNodes.push(n),n.prevNodes.push(i))}))}async run(t={}){const s=this.nodes.map((s=>s.run(t)));await Promise.all(s)}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()))}}class V extends K{constructor(t,s){super(t,s),this.flow=s}}class q{constructor(t){this.disposables=[],this.ssp=t}dispose(){this.disposables.forEach((t=>t()))}}var J,z,Q,Z;!function(t){t.GLOBAL="GLOBAL",t.SELF="SELF",t.OTHER="OTHER"}(J||(J={})),function(t){t.FLOW="FLOW",t.ANIMATION="ANIMATION",t.DELAY="DELAY"}(z||(z={})),function(t){t.GLOBAL="GLOBAL",t.INSTANCE="INSTANCE",t.FAMILY="FAMILY"}(Q||(Q={})),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"}(Z||(Z={}));const{groupBy:$}=t.utils;class tt extends q{constructor(t,s,e,i){super(t),this.target=s,this.interaction=e,this.flows=i,this.flowsMap=$(i,"id"),this.init()}init(){switch(this.interaction.type){case Z.MOUSE_CLICK:this.initMouseClick();break;case Z.MOUSE_DB_CLICK:this.initMouseDbClick();break;case Z.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case Z.LOADED:this.initLoaded();break;case Z.THING_PROP_CHANGE:this.initThingPropChange();break;case Z.THING_EVENT:this.initThingEvent()}}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){t.forEach((t=>{const s=this.flowsMap.get(t);if(s){const t=new V(this.ssp,s[0]);t.parse(),t.run({getTarget:async()=>this.target})}}))}async execBehavior(){const{behaviors:t}=this.interaction;null==t||t.forEach((t=>{if(t.action===z.FLOW)t.actionRefs&&this.runFlowByIds(t.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 t=()=>{this.execBehavior()};this.target.addEventListener("load",t),this.disposables.push((()=>this.target.removeEventListener("load",t)))}initThingPropChange(){}initThingEvent(){}}export{V as ComponentFlowParser,tt as ComponentTrigger,K as FlowParser,z as InteractionAction,J as InteractionActionType,Q as InteractionObsType,Z as InteractionType,a as NodePropTypeEnum,c as NodeTypeEnum,q as Trigger};
|
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.2",
|
|
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": "31d61cfb34a7879b1cff3a955663415672ef2ef7",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.13.
|
|
18
|
+
"soonspacejs": "2.13.2",
|
|
19
19
|
"umanager-animation-parser": "^0.0.6"
|
|
20
20
|
}
|
|
21
21
|
}
|